From db0ac33c3d04c27aa456d1b03b7fce0c7776bad8 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Fri, 11 Nov 2022 12:44:46 -0800 Subject: [PATCH 001/210] bug fix --- Sources/Core/EthereumABI/ABIElements.swift | 2 +- Sources/web3swift/Operations/ReadTransaction.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Core/EthereumABI/ABIElements.swift b/Sources/Core/EthereumABI/ABIElements.swift index 2e6b5d94f..be9bfa685 100755 --- a/Sources/Core/EthereumABI/ABIElements.swift +++ b/Sources/Core/EthereumABI/ABIElements.swift @@ -325,7 +325,7 @@ extension ABI.Element.Function { // set a flag to detect the request succeeded } - if returnArray.isEmpty { + if returnArray.isEmpty && !outputs.isEmpty && data.isEmpty{ return nil } diff --git a/Sources/web3swift/Operations/ReadTransaction.swift b/Sources/web3swift/Operations/ReadTransaction.swift index 5c721db19..a5b38f436 100755 --- a/Sources/web3swift/Operations/ReadTransaction.swift +++ b/Sources/web3swift/Operations/ReadTransaction.swift @@ -34,7 +34,7 @@ public class ReadOperation { // TODO: Remove type erasing here, some broad wide protocol should be added instead public func callContractMethod() async throws -> [String: Any] { - await transaction.resolve(provider: web3.provider) + try await transaction.resolve(provider: web3.provider) // MARK: Read data from ABI flow // FIXME: This should be dropped, and after `execute()` call, just to decode raw data. let data: Data = try await self.web3.eth.callTransaction(transaction) From d9fd03c95c405ef4b398600603556149930ae8d2 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Fri, 11 Nov 2022 12:46:45 -0800 Subject: [PATCH 002/210] cleanup --- .../APIRequest+ComputedProperties.swift | 6 ++-- .../KeystoreManager/KeystoreManager.swift | 8 +++-- .../Core/Utility/Encodable+Extensions.swift | 2 ++ .../Ethereum/Eth+GetBlockByHash.swift | 1 - Sources/web3swift/Utils/ENS/ENSResolver.swift | 31 +++++-------------- Sources/web3swift/Web3/Web3+Contract.swift | 2 +- Sources/web3swift/Web3/Web3.swift | 4 +-- 7 files changed, 19 insertions(+), 35 deletions(-) diff --git a/Sources/Core/EthereumNetwork/Request/APIRequest+ComputedProperties.swift b/Sources/Core/EthereumNetwork/Request/APIRequest+ComputedProperties.swift index 9b6fabf23..1b53a2b8e 100644 --- a/Sources/Core/EthereumNetwork/Request/APIRequest+ComputedProperties.swift +++ b/Sources/Core/EthereumNetwork/Request/APIRequest+ComputedProperties.swift @@ -9,13 +9,11 @@ import Foundation extension APIRequest { var method: REST { - switch self { - default: return .POST - } + .POST } public var encodedBody: Data { - let request = RequestBody(method: self.call, params: self.parameters) + let request = RequestBody(method: call, params: parameters) // this is safe to force try this here // Because request must failed to compile if it not conformable with `Encodable` protocol return try! JSONEncoder().encode(request) diff --git a/Sources/Core/KeystoreManager/KeystoreManager.swift b/Sources/Core/KeystoreManager/KeystoreManager.swift index 8d6a09fc5..78ec4a608 100755 --- a/Sources/Core/KeystoreManager/KeystoreManager.swift +++ b/Sources/Core/KeystoreManager/KeystoreManager.swift @@ -42,9 +42,11 @@ public class KeystoreManager: AbstractKeystore { } public func UNSAFE_getPrivateKeyData(password: String, account: EthereumAddress) throws -> Data { - guard let keystore = self.walletForAddress(account) else {throw AbstractKeystoreError.invalidAccountError} - return try keystore.UNSAFE_getPrivateKeyData(password: password, account: account) - } + guard let keystore = walletForAddress(account) else { + throw AbstractKeystoreError.invalidAccountError + } + return try keystore.UNSAFE_getPrivateKeyData(password: password, account: account) + } public static var allManagers = [KeystoreManager]() public static var defaultManager: KeystoreManager? { diff --git a/Sources/Core/Utility/Encodable+Extensions.swift b/Sources/Core/Utility/Encodable+Extensions.swift index 96167e516..e4eb88eb5 100644 --- a/Sources/Core/Utility/Encodable+Extensions.swift +++ b/Sources/Core/Utility/Encodable+Extensions.swift @@ -64,3 +64,5 @@ public extension EncodableToHex where Self: BinaryInteger { extension BigUInt: EncodableToHex { } extension UInt: EncodableToHex { } + +extension Int: EncodableToHex { } diff --git a/Sources/web3swift/EthereumAPICalls/Ethereum/Eth+GetBlockByHash.swift b/Sources/web3swift/EthereumAPICalls/Ethereum/Eth+GetBlockByHash.swift index ac1453ef7..00fb0edb8 100755 --- a/Sources/web3swift/EthereumAPICalls/Ethereum/Eth+GetBlockByHash.swift +++ b/Sources/web3swift/EthereumAPICalls/Ethereum/Eth+GetBlockByHash.swift @@ -10,7 +10,6 @@ import Core extension Web3.Eth { public func block(by hash: Data, fullTransactions: Bool = false) async throws -> Block { - guard let hexString = String(data: hash, encoding: .utf8)?.addHexPrefix() else { throw Web3Error.dataError } let requestCall: APIRequest = .getBlockByHash(hash.toHexString().addHexPrefix(), fullTransactions) return try await APIRequest.sendRequest(with: self.provider, for: requestCall).result } diff --git a/Sources/web3swift/Utils/ENS/ENSResolver.swift b/Sources/web3swift/Utils/ENS/ENSResolver.swift index 0830d0bcf..4fb34eb0a 100755 --- a/Sources/web3swift/Utils/ENS/ENSResolver.swift +++ b/Sources/web3swift/Utils/ENS/ENSResolver.swift @@ -19,30 +19,13 @@ public extension ENS { case URI = 8 } - public enum InterfaceName { - case addr - case name - case content - case ABI - case pubkey - case text - - func hash() -> String { - switch self { - case .addr: - return "0x3b3b57de" - case .name: - return "0x691f3431" - case .content: - return "0xbc1c58d1" - case .ABI: - return "0x2203ab56" - case .pubkey: - return "0xc8690233" - case .text: - return "0x59d1d43c" - } - } + public enum InterfaceName: String { + case addr = "0x3b3b57de" + case name = "0x691f3431" + case content = "0xbc1c58d1" + case ABI = "0x2203ab56" + case pubkey = "0xc8690233" + case text = "0x59d1d43c" } lazy var resolverContract: Web3.Contract = { diff --git a/Sources/web3swift/Web3/Web3+Contract.swift b/Sources/web3swift/Web3/Web3+Contract.swift index dc2d135f0..abefbea29 100755 --- a/Sources/web3swift/Web3/Web3+Contract.swift +++ b/Sources/web3swift/Web3/Web3+Contract.swift @@ -105,7 +105,7 @@ extension Web3 { /// /// Returns a "Transaction intermediate" object. public func createWriteOperation(_ method: String = "fallback", parameters: [AnyObject] = [AnyObject](), extraData: Data = Data()) -> WriteOperation? { - guard var data = self.contract.method(method, parameters: parameters, extraData: extraData) else {return nil} + guard let data = self.contract.method(method, parameters: parameters, extraData: extraData) else {return nil} transaction.data = data if let network = self.web3.provider.network { transaction.chainID = network.chainID diff --git a/Sources/web3swift/Web3/Web3.swift b/Sources/web3swift/Web3/Web3.swift index ab2731a6e..cd09e2a37 100755 --- a/Sources/web3swift/Web3/Web3.swift +++ b/Sources/web3swift/Web3/Web3.swift @@ -12,9 +12,9 @@ extension Web3 { /// Initialized provider-bound Web3 instance using a provider's URL. Under the hood it performs a synchronous call to get /// the Network ID for EIP155 purposes - public static func new(_ providerURL: URL) async throws -> Web3 { + public static func new(_ providerURL: URL, network net: Networks = .Mainnet) async throws -> Web3 { // FIXME: Change this hardcoded value to dynamicly fethed from a Node - guard let provider = await Web3HttpProvider(providerURL, network: .Mainnet) else { + guard let provider = await Web3HttpProvider(providerURL, network: net) else { throw Web3Error.inputError(desc: "Wrong provider - should be Web3HttpProvider with endpoint scheme http or https") } return Web3(provider: provider) From bcebcb05c05ff9c61f82e66d83667c9e5ea62909 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Fri, 11 Nov 2022 12:55:01 -0800 Subject: [PATCH 003/210] cleanup --- .../Core/Transaction/CodableTransaction.swift | 18 ++++++------------ .../Transaction/Envelope/EIP1559Envelope.swift | 6 ++++-- .../Transaction/Envelope/EIP2930Envelope.swift | 6 ++++-- .../Transaction/Envelope/LegacyEnvelope.swift | 3 ++- Sources/Core/Utility/Utilities.swift | 17 ++++++++--------- 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/Sources/Core/Transaction/CodableTransaction.swift b/Sources/Core/Transaction/CodableTransaction.swift index 288a82d5d..448cfcaeb 100644 --- a/Sources/Core/Transaction/CodableTransaction.swift +++ b/Sources/Core/Transaction/CodableTransaction.swift @@ -188,18 +188,18 @@ public struct CodableTransaction { return self.envelope.encode(for: type) } - public mutating func resolve(provider: Web3Provider) async { + public mutating func resolve(provider: Web3Provider) async throws { // FIXME: Delete force try - self.gasLimit = try! await self.gasLimitPolicy.resolve(provider: provider, transaction: self) + self.gasLimit = try await self.gasLimitPolicy.resolve(provider: provider, transaction: self) if from != nil || sender != nil { - self.nonce = try! await self.resolveNonce(provider: provider) + self.nonce = try await self.resolveNonce(provider: provider) } if case .eip1559 = type { - self.maxFeePerGas = try! await self.maxFeePerGasPolicy.resolve(provider: provider) - self.maxPriorityFeePerGas = try! await self.maxPriorityFeePerGasPolicy.resolve(provider: provider) + self.maxFeePerGas = try await self.maxFeePerGasPolicy.resolve(provider: provider) + self.maxPriorityFeePerGas = try await self.maxPriorityFeePerGasPolicy.resolve(provider: provider) } else { - self.gasPrice = try! await self.gasPricePolicy.resolve(provider: provider) + self.gasPrice = try await self.gasPricePolicy.resolve(provider: provider) } } @@ -380,12 +380,6 @@ extension CodableTransaction { return value } } - - - - - - } diff --git a/Sources/Core/Transaction/Envelope/EIP1559Envelope.swift b/Sources/Core/Transaction/Envelope/EIP1559Envelope.swift index 2da61bf59..705d27492 100644 --- a/Sources/Core/Transaction/Envelope/EIP1559Envelope.swift +++ b/Sources/Core/Transaction/Envelope/EIP1559Envelope.swift @@ -249,8 +249,10 @@ extension EIP1559Envelope { let list = accessList.map { $0.encodeAsList() as AnyObject } switch type { - case .transaction: fields = [chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to.addressData, value, data, list, v, r, s] as [AnyObject] - case .signature: fields = [chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to.addressData, value, data, list] as [AnyObject] + case .transaction: + fields = [chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to.addressData, value, data, list, v, r, s] as [AnyObject] + case .signature: + fields = [chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to.addressData, value, data, list] as [AnyObject] } guard var result = RLP.encode(fields) else { return nil } result.insert(UInt8(self.type.rawValue), at: 0) diff --git a/Sources/Core/Transaction/Envelope/EIP2930Envelope.swift b/Sources/Core/Transaction/Envelope/EIP2930Envelope.swift index e58d3d176..191c4498d 100644 --- a/Sources/Core/Transaction/Envelope/EIP2930Envelope.swift +++ b/Sources/Core/Transaction/Envelope/EIP2930Envelope.swift @@ -210,8 +210,10 @@ extension EIP2930Envelope { let list = accessList.map { $0.encodeAsList() as AnyObject } switch type { - case .transaction: fields = [chainID, nonce, gasPrice, gasLimit, to.addressData, value, data, list, v, r, s] as [AnyObject] - case .signature: fields = [chainID, nonce, gasPrice, gasLimit, to.addressData, value, data, list] as [AnyObject] + case .transaction: + fields = [chainID, nonce, gasPrice, gasLimit, to.addressData, value, data, list, v, r, s] as [AnyObject] + case .signature: + fields = [chainID, nonce, gasPrice, gasLimit, to.addressData, value, data, list] as [AnyObject] } guard var result = RLP.encode(fields) else { return nil } result.insert(UInt8(self.type.rawValue), at: 0) diff --git a/Sources/Core/Transaction/Envelope/LegacyEnvelope.swift b/Sources/Core/Transaction/Envelope/LegacyEnvelope.swift index 40c133ada..6ef5351b5 100644 --- a/Sources/Core/Transaction/Envelope/LegacyEnvelope.swift +++ b/Sources/Core/Transaction/Envelope/LegacyEnvelope.swift @@ -194,7 +194,8 @@ extension LegacyEnvelope { public func encode(for type: EncodeType = .transaction) -> Data? { let fields: [AnyObject] switch type { - case .transaction: fields = [self.nonce, self.gasPrice, self.gasLimit, self.to.addressData, self.value, self.data, v, r, s] as [AnyObject] + case .transaction: + fields = [self.nonce, self.gasPrice, self.gasLimit, self.to.addressData, self.value, self.data, v, r, s] as [AnyObject] case .signature: if let chainID = self.chainID, chainID != 0 { fields = [self.nonce, self.gasPrice, self.gasLimit, self.to.addressData, self.value, self.data, chainID, BigUInt(0), BigUInt(0)] as [AnyObject] diff --git a/Sources/Core/Utility/Utilities.swift b/Sources/Core/Utility/Utilities.swift index 218db9027..8525baef6 100644 --- a/Sources/Core/Utility/Utilities.swift +++ b/Sources/Core/Utility/Utilities.swift @@ -162,19 +162,18 @@ public struct Utilities { if bigNumber == 0 { return "0" } - let unitDecimals = numberDecimals var toDecimals = formattingDecimals - if unitDecimals < toDecimals { - toDecimals = unitDecimals + if numberDecimals < toDecimals { + toDecimals = numberDecimals } - let divisor = BigUInt(10).power(unitDecimals) + let divisor = BigUInt(10).power(numberDecimals) let (quotient, remainder) = bigNumber.quotientAndRemainder(dividingBy: divisor) - var fullRemainder = String(remainder) - let fullPaddedRemainder = fullRemainder.leftPadding(toLength: unitDecimals, withPad: "0") + var fullRemainder = "\(remainder)" + let fullPaddedRemainder = fullRemainder.leftPadding(toLength: numberDecimals, withPad: "0") let remainderPadded = fullPaddedRemainder[0.. Date: Sun, 13 Nov 2022 13:24:10 -0800 Subject: [PATCH 004/210] fix bug --- .../EthereumAPICalls/Ethereum/Eth+SendRawTransaction.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/web3swift/EthereumAPICalls/Ethereum/Eth+SendRawTransaction.swift b/Sources/web3swift/EthereumAPICalls/Ethereum/Eth+SendRawTransaction.swift index 250d4be9e..29011c66f 100755 --- a/Sources/web3swift/EthereumAPICalls/Ethereum/Eth+SendRawTransaction.swift +++ b/Sources/web3swift/EthereumAPICalls/Ethereum/Eth+SendRawTransaction.swift @@ -9,7 +9,8 @@ import Core extension Web3.Eth { public func send(raw data: Data) async throws -> TransactionSendingResult { - guard let hexString = String(data: data, encoding: .utf8)?.addHexPrefix() else { throw Web3Error.dataError } + let hexString = data.toHexString().addHexPrefix() + let request: APIRequest = .sendRawTransaction(hexString) let response: APIResponse = try await APIRequest.sendRequest(with: self.provider, for: request) return try TransactionSendingResult(data: data, hash: response.result) From 915bcd91e1046ebe6ecbbe74caef0de1acf84dda Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Tue, 15 Nov 2022 17:57:32 -0800 Subject: [PATCH 005/210] Mnemonic Wallet Creation Cleanup --- .../Core/KeystoreManager/BIP32HDNode.swift | 228 +++++++++--------- .../Core/KeystoreManager/BIP32Keystore.swift | 78 +++--- Sources/Core/KeystoreManager/BIP39.swift | 99 +++++--- .../KeystoreManager/EthereumKeystoreV3.swift | 15 +- .../Core/KeystoreManager/KeystoreParams.swift | 33 ++- Sources/Core/Utility/Data+Extension.swift | 31 +-- Sources/Core/Utility/String+Extension.swift | 22 +- .../web3swift/Operations/WriteOperation.swift | 30 ++- Sources/web3swift/Utils/ENS/ENS.swift | 34 +-- 9 files changed, 346 insertions(+), 224 deletions(-) diff --git a/Sources/Core/KeystoreManager/BIP32HDNode.swift b/Sources/Core/KeystoreManager/BIP32HDNode.swift index e442e90f9..1eba04a85 100755 --- a/Sources/Core/KeystoreManager/BIP32HDNode.swift +++ b/Sources/Core/KeystoreManager/BIP32HDNode.swift @@ -1,3 +1,4 @@ +// web3swift // // Created by Alex Vlasov. // Copyright © 2018 Alex Vlasov. All rights reserved. @@ -23,12 +24,11 @@ extension UInt32 { } public class HDNode { - public struct HDversion{ - public var privatePrefix: Data = Data.fromHex("0x0488ADE4")! - public var publicPrefix: Data = Data.fromHex("0x0488B21E")! - public init() { - } + private struct HDversion{ + public static var privatePrefix: Data? = Data.fromHex("0x0488ADE4") + public static var publicPrefix: Data? = Data.fromHex("0x0488B21E") + } public var path: String? = "m" public var privateKey: Data? = nil @@ -51,11 +51,6 @@ public class HDNode { } } } - public var hasPrivate: Bool { - get { - return privateKey != nil - } - } init() { publicKey = Data() @@ -72,7 +67,7 @@ public class HDNode { guard data.count == 82 else {return nil} let header = data[0..<4] var serializePrivate = false - if header == HDNode.HDversion().privatePrefix { + if header == HDversion.privatePrefix { serializePrivate = true } depth = data[4..<5].bytes[0] @@ -94,8 +89,10 @@ public class HDNode { public init?(seed: Data) { guard seed.count >= 16 else {return nil} - let hmacKey = "Bitcoin seed".data(using: .ascii)! - let hmac: Authenticator = HMAC(key: hmacKey.bytes, variant: HMAC.Variant.sha2(.sha512)) + + guard let hmacKey = "Bitcoin seed".data(using: .ascii) else {return nil} + let hmac:Authenticator = HMAC(key: hmacKey.bytes, variant: HMAC.Variant.sha2(.sha512)) + guard let entropy = try? hmac.authenticate(seed.bytes) else {return nil} guard entropy.count == 64 else { return nil} let I_L = entropy[0..<32] @@ -104,7 +101,7 @@ public class HDNode { let privKeyCandidate = Data(I_L) guard SECP256K1.verifyPrivateKey(privateKey: privKeyCandidate) else {return nil} guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: privKeyCandidate, compressed: true) else {return nil} - guard pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03 else {return nil} + guard pubKeyCandidate.bytes.first == 0x02 || pubKeyCandidate.bytes.first == 0x03 else {return nil} publicKey = pubKeyCandidate privateKey = privKeyCandidate depth = 0x00 @@ -120,91 +117,99 @@ public class HDNode { } extension HDNode { - public func derive (index: UInt32, derivePrivateKey: Bool, hardened: Bool = false) -> HDNode? { - if derivePrivateKey { - if self.hasPrivate { // derive private key when is itself extended private key - var entropy: Array - var trueIndex: UInt32 - if index >= (UInt32(1) << 31) || hardened { - trueIndex = index - if trueIndex < (UInt32(1) << 31) { - trueIndex = trueIndex + (UInt32(1) << 31) - } - let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) - var inputForHMAC = Data() - inputForHMAC.append(Data([UInt8(0x00)])) - inputForHMAC.append(self.privateKey!) - inputForHMAC.append(trueIndex.serialize32()) - guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else {return nil } - guard ent.count == 64 else { return nil } - entropy = ent - } else { - trueIndex = index - let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) - var inputForHMAC = Data() - inputForHMAC.append(self.publicKey) - inputForHMAC.append(trueIndex.serialize32()) - guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else {return nil } - guard ent.count == 64 else { return nil } - entropy = ent - } - let I_L = entropy[0..<32] - let I_R = entropy[32..<64] - let cc = Data(I_R) - let bn = BigUInt(Data(I_L)) - if bn > HDNode.curveOrder { - if trueIndex < UInt32.max { - return self.derive(index: index+1, derivePrivateKey: derivePrivateKey, hardened: hardened) - } - return nil - } - let newPK = (bn + BigUInt(self.privateKey!)) % HDNode.curveOrder - if newPK == BigUInt(0) { - if trueIndex < UInt32.max { - return self.derive(index: index+1, derivePrivateKey: derivePrivateKey, hardened: hardened) - } - return nil - } - guard let privKeyCandidate = newPK.serialize().setLengthLeft(32) else {return nil} - guard SECP256K1.verifyPrivateKey(privateKey: privKeyCandidate) else {return nil } - guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: privKeyCandidate, compressed: true) else {return nil} - guard pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03 else {return nil} - guard self.depth < UInt8.max else {return nil} - let newNode = HDNode() - newNode.chaincode = cc - newNode.depth = self.depth + 1 - newNode.publicKey = pubKeyCandidate - newNode.privateKey = privKeyCandidate - newNode.childNumber = trueIndex - guard let fprint = try? RIPEMD160.hash(message: self.publicKey.sha256())[0..<4] else { - return nil - } - newNode.parentFingerprint = fprint - var newPath = String() - if newNode.isHardened { - newPath = self.path! + "/" - newPath += String(newNode.index % HDNode.hardenedIndexPrefix) + "'" - } else { - newPath = self.path! + "/" + String(newNode.index) - } - newNode.path = newPath - return newNode - } else { - return nil // derive private key when is itself extended public key (impossible) + public func derive(index: UInt32, derivePrivateKey:Bool, hardened: Bool = false) -> HDNode? { + derivePrivateKey ? + deriveAlongPrivateKey(index: index, derivePrivateKey: derivePrivateKey, hardened: hardened) + : + deriveWithoutPrivateKey(index: index, derivePrivateKey: derivePrivateKey, hardened: hardened) + } + public func deriveAlongPrivateKey(index: UInt32, derivePrivateKey:Bool, hardened: Bool = false) -> HDNode? { + guard let privateKey = self.privateKey else { + return nil + }// derive private key when is itself extended private key + var entropy:Array + var trueIndex: UInt32 + if index >= (UInt32(1) << 31) || hardened { + trueIndex = index + if trueIndex < (UInt32(1) << 31) { + trueIndex = trueIndex + (UInt32(1) << 31) } - } else { // deriving only the public key - var entropy: Array // derive public key when is itself public key - if index >= (UInt32(1) << 31) || hardened { - return nil // no derivation of hardened public key from extended public key - } else { - let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) - var inputForHMAC = Data() - inputForHMAC.append(self.publicKey) - inputForHMAC.append(index.serialize32()) - guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else {return nil } - guard ent.count == 64 else { return nil } - entropy = ent + let hmac:Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) + var inputForHMAC = Data() + inputForHMAC.append(Data([UInt8(0x00)])) + inputForHMAC.append(privateKey) + inputForHMAC.append(trueIndex.serialize32()) + guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else {return nil } + guard ent.count == 64 else { return nil } + entropy = ent + } else { + trueIndex = index + let hmac:Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) + var inputForHMAC = Data() + inputForHMAC.append(self.publicKey) + inputForHMAC.append(trueIndex.serialize32()) + guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else {return nil } + guard ent.count == 64 else { return nil } + entropy = ent + } + let I_L = entropy[0..<32] + let I_R = entropy[32..<64] + let cc = Data(I_R) + let bn = BigUInt(Data(I_L)) + if bn > HDNode.curveOrder { + if trueIndex < UInt32.max { + return self.derive(index:index+1, derivePrivateKey: derivePrivateKey, hardened:hardened) } + return nil + } + let newPK = (bn + BigUInt(privateKey)) % HDNode.curveOrder + if newPK == BigUInt(0) { + if trueIndex < UInt32.max { + return self.derive(index:index+1, derivePrivateKey: derivePrivateKey, hardened:hardened) + } + return nil + } + guard let privKeyCandidate = newPK.serialize().setLengthLeft(32) else {return nil} + guard SECP256K1.verifyPrivateKey(privateKey: privKeyCandidate) else {return nil } + guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: privKeyCandidate, compressed: true) else {return nil} + guard pubKeyCandidate.bytes.first == 0x02 || pubKeyCandidate.bytes.first == 0x03 else {return nil} + guard self.depth < UInt8.max else {return nil} + let newNode = HDNode() + newNode.chaincode = cc + newNode.depth = self.depth + 1 + newNode.publicKey = pubKeyCandidate + newNode.privateKey = privKeyCandidate + newNode.childNumber = trueIndex + guard let fprint = try? RIPEMD160.hash(message: self.publicKey.sha256())[0..<4] else { + return nil + } + newNode.parentFingerprint = fprint + var newPath = String() + if newNode.isHardened { + newPath = (self.path ?? "") + "/" + newPath += String(newNode.index % HDNode.hardenedIndexPrefix) + "'" + } else { + newPath = (self.path ?? "") + "/" + String(newNode.index) + } + newNode.path = newPath + return newNode + } + + public func deriveWithoutPrivateKey(index: UInt32, derivePrivateKey:Bool, hardened: Bool = false) -> HDNode? { + // deriving only the public key + var entropy:Array // derive public key when is itself public key + guard !hardened && index < (UInt32(1) << 31) else { + return nil // no derivation of hardened public key from extended public key + } + + let hmac:Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) + var inputForHMAC = Data() + inputForHMAC.append(self.publicKey) + inputForHMAC.append(index.serialize32()) + guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else {return nil } + guard ent.count == 64 else { return nil } + entropy = ent + let I_L = entropy[0..<32] let I_R = entropy[32..<64] let cc = Data(I_R) @@ -218,9 +223,9 @@ extension HDNode { guard let tempKey = bn.serialize().setLengthLeft(32) else {return nil} guard SECP256K1.verifyPrivateKey(privateKey: tempKey) else {return nil } guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: tempKey, compressed: true) else {return nil} - guard pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03 else {return nil} + guard pubKeyCandidate.bytes.first == 0x02 || pubKeyCandidate.bytes.first == 0x03 else {return nil} guard let newPublicKey = SECP256K1.combineSerializedPublicKeys(keys: [self.publicKey, pubKeyCandidate], outputCompressed: true) else {return nil} - guard newPublicKey.bytes[0] == 0x02 || newPublicKey.bytes[0] == 0x03 else {return nil} + guard newPublicKey.bytes.first == 0x02 || newPublicKey.bytes.first == 0x03 else {return nil} guard self.depth < UInt8.max else {return nil} let newNode = HDNode() newNode.chaincode = cc @@ -233,17 +238,17 @@ extension HDNode { newNode.parentFingerprint = fprint var newPath = String() if newNode.isHardened { - newPath = self.path! + "/" + newPath = (self.path ?? "") + "/" newPath += String(newNode.index % HDNode.hardenedIndexPrefix) + "'" } else { - newPath = self.path! + "/" + String(newNode.index) + newPath = (self.path ?? "") + "/" + String(newNode.index) } newNode.path = newPath return newNode - } } - public func derive (path: String, derivePrivateKey: Bool = true) -> HDNode? { + public func derive(path: String, derivePrivateKey: Bool = true) -> HDNode? { + let components = path.components(separatedBy: "/") var currentNode: HDNode = self var firstComponent = 0 @@ -262,19 +267,24 @@ extension HDNode { return currentNode } - public func serializeToString(serializePublic: Bool = true, version: HDversion = HDversion()) -> String? { - guard let data = self.serialize(serializePublic: serializePublic, version: version) else {return nil} + public func serializeToString(serializePublic: Bool = true) -> String? { + guard let data = self.serialize(serializePublic: serializePublic) else {return nil} let encoded = Base58.base58FromBytes(data.bytes) return encoded } - public func serialize(serializePublic: Bool = true, version: HDversion = HDversion()) -> Data? { + public func serialize(serializePublic: Bool = true) -> Data? { + var data = Data() - if (!serializePublic && !self.hasPrivate) {return nil} + + guard serializePublic || privateKey != nil else { + return nil + } + if serializePublic { - data.append(version.publicPrefix) + data.append(HDversion.publicPrefix!) } else { - data.append(version.privatePrefix) + data.append(HDversion.privatePrefix!) } data.append(contentsOf: [self.depth]) data.append(self.parentFingerprint) diff --git a/Sources/Core/KeystoreManager/BIP32Keystore.swift b/Sources/Core/KeystoreManager/BIP32Keystore.swift index 0059bed91..bf256c8ba 100755 --- a/Sources/Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Core/KeystoreManager/BIP32Keystore.swift @@ -1,3 +1,4 @@ +// web3swift // // Created by Alex Vlasov. // Copyright © 2018 Alex Vlasov. All rights reserved. @@ -44,7 +45,6 @@ public class BIP32Keystore: AbstractKeystore { guard let decryptedRootNode = try? self.getPrefixNodeData(password) else {throw AbstractKeystoreError.encryptionError("Failed to decrypt a keystore")} guard let rootNode = HDNode(decryptedRootNode) else {throw AbstractKeystoreError.encryptionError("Failed to deserialize a root node")} guard rootNode.depth == (self.rootPrefix.components(separatedBy: "/").count - 1) else {throw AbstractKeystoreError.encryptionError("Derivation depth mismatch")} -// guard rootNode.depth == HDNode.defaultPathPrefix.components(separatedBy: "/").count - 1 else {throw AbstractKeystoreError.encryptionError("Derivation depth mismatch")} guard let index = UInt32(key.components(separatedBy: "/").last!) else { throw AbstractKeystoreError.encryptionError("Derivation depth mismatch") } @@ -63,7 +63,7 @@ public class BIP32Keystore: AbstractKeystore { private static let KeystoreParamsBIP32Version = 4 - public private (set) var addressStorage: PathAddressStorage + private (set) var addressStorage: PathAddressStorage public convenience init?(_ jsonString: String) { let lowercaseJSON = jsonString.lowercased() @@ -88,8 +88,15 @@ public class BIP32Keystore: AbstractKeystore { rootPrefix = keystoreParams!.rootPath! } - public convenience init?(mnemonics: String, password: String, mnemonicsPassword: String = "", language: BIP39Language = BIP39Language.english, prefixPath: String = HDNode.defaultPathMetamaskPrefix, aesMode: String = "aes-128-cbc") throws { - guard var seed = BIP39.seedFromMmemonics(mnemonics, password: mnemonicsPassword, language: language) else { + public convenience init?(mnemonics: String, password: String = "web3swift", mnemonicsPassword: String = "", language: BIP39Language = .english, prefixPath: String = HDNode.defaultPathMetamaskPrefix, aesMode: String = "aes-128-cbc") throws { + do { + try self.init(mnemonicsPhrase: mnemonics.components(separatedBy: language.separator)) + } catch { + return nil + } + } + public convenience init(mnemonicsPhrase: [String], password: String = "web3swift", mnemonicsPassword: String = "", language: BIP39Language = .english, prefixPath: String = HDNode.defaultPathMetamaskPrefix, aesMode: String = "aes-128-cbc") throws { + guard var seed = BIP39.seedFromMmemonics(mnemonicsPhrase, password: mnemonicsPassword, language: language) else { throw AbstractKeystoreError.noEntropyError } defer{ @@ -98,9 +105,12 @@ public class BIP32Keystore: AbstractKeystore { try self.init(seed: seed, password: password, prefixPath: prefixPath, aesMode: aesMode) } - public init? (seed: Data, password: String, prefixPath: String = HDNode.defaultPathMetamaskPrefix, aesMode: String = "aes-128-cbc") throws { + public init(seed: Data, password: String = "web3swift", prefixPath: String = HDNode.defaultPathMetamaskPrefix, aesMode: String = "aes-128-cbc") throws { + addressStorage = PathAddressStorage() - guard let rootNode = HDNode(seed: seed)?.derive(path: prefixPath, derivePrivateKey: true) else {return nil} + guard let rootNode = HDNode(seed: seed)?.derive(path: prefixPath, derivePrivateKey: true) else { + throw AbstractKeystoreError.keyDerivationError + } self.rootPrefix = prefixPath try createNewAccount(parentNode: rootNode, password: password) guard let serializedRootNode = rootNode.serialize(serializePublic: false) else { @@ -109,7 +119,7 @@ public class BIP32Keystore: AbstractKeystore { try encryptDataToStorage(password, data: serializedRootNode, aesMode: aesMode) } - public func createNewChildAccount(password: String) throws { + public func createNewChildAccount(password: String = "web3swift") throws { guard let decryptedRootNode = try? self.getPrefixNodeData(password) else { throw AbstractKeystoreError.encryptionError("Failed to decrypt a keystore") } @@ -127,14 +137,21 @@ public class BIP32Keystore: AbstractKeystore { try encryptDataToStorage(password, data: serializedRootNode, aesMode: self.keystoreParams!.crypto.cipher) } - func createNewAccount(parentNode: HDNode, password: String ) throws { - var newIndex = UInt32(0) - for p in addressStorage.paths { - guard let idx = UInt32(p.components(separatedBy: "/").last!) else {continue} - if idx >= newIndex { - newIndex = idx + 1 - } + func createNewAccount(parentNode: HDNode, password: String = "web3swift") throws { + + let maxIndex = addressStorage.paths + .compactMap { $0.components(separatedBy: "/").last } + .compactMap { UInt32($0) } + .max() + + let newIndex: UInt32 + + if let idx = maxIndex { + newIndex = idx + 1 + } else { + newIndex = UInt32.zero } + guard let newNode = parentNode.derive(index: newIndex, derivePrivateKey: true, hardened: false) else { throw AbstractKeystoreError.keyDerivationError } @@ -151,7 +168,7 @@ public class BIP32Keystore: AbstractKeystore { addressStorage.add(address: newAddress, for: newPath) } - public func createNewCustomChildAccount(password: String, path: String) throws {guard let decryptedRootNode = try? self.getPrefixNodeData(password) else { + public func createNewCustomChildAccount(password: String = "web3swift", path: String) throws {guard let decryptedRootNode = try? self.getPrefixNodeData(password) else { throw AbstractKeystoreError.encryptionError("Failed to decrypt a keystore") } guard let rootNode = HDNode(decryptedRootNode) else { @@ -203,38 +220,31 @@ public class BIP32Keystore: AbstractKeystore { try encryptDataToStorage(password, data: serializedRootNode, aesMode: self.keystoreParams!.crypto.cipher) } - fileprivate func encryptDataToStorage(_ password: String, data: Data?, dkLen: Int = 32, N: Int = 4096, R: Int = 6, P: Int = 1, aesMode: String = "aes-128-cbc") throws { - if (data == nil) { - throw AbstractKeystoreError.encryptionError("Encryption without key data") - } - if (data!.count != 82) { + fileprivate func encryptDataToStorage(_ password: String, data: Data, dkLen: Int = 32, N: Int = 4096, R: Int = 6, P: Int = 1, aesMode: String = "aes-128-cbc") throws { + guard data.count == 82 else { throw AbstractKeystoreError.encryptionError("Invalid expected data length") } - let saltLen = 32 - guard let saltData = Data.randomBytes(length: saltLen) else { - throw AbstractKeystoreError.noEntropyError - } - guard let derivedKey = scrypt(password: password, salt: saltData, length: dkLen, N: N, R: R, P: P) else { + let saltData = Data.randomBytes(length: 32) + + guard let derivedKey = scrypt(password: password, salt: saltData!, length: dkLen, N: N, R: R, P: P) else { throw AbstractKeystoreError.keyDerivationError } let last16bytes = derivedKey[(derivedKey.count - 16)...(derivedKey.count - 1)] let encryptionKey = derivedKey[0...15] - guard let IV = Data.randomBytes(length: 16) else { - throw AbstractKeystoreError.noEntropyError - } + let IV = Data.randomBytes(length: 16) var aesCipher: AES? switch aesMode { case "aes-128-cbc": - aesCipher = try? AES(key: encryptionKey.bytes, blockMode: CBC(iv: IV.bytes), padding: .pkcs7) + aesCipher = try? AES(key: encryptionKey.bytes, blockMode: CBC(iv: IV!.bytes), padding: .pkcs7) case "aes-128-ctr": - aesCipher = try? AES(key: encryptionKey.bytes, blockMode: CTR(iv: IV.bytes), padding: .pkcs7) + aesCipher = try? AES(key: encryptionKey.bytes, blockMode: CTR(iv: IV!.bytes), padding: .pkcs7) default: aesCipher = nil } if aesCipher == nil { throw AbstractKeystoreError.aesError } - guard let encryptedKey = try aesCipher?.encrypt(data!.bytes) else { + guard let encryptedKey = try aesCipher?.encrypt(data.bytes) else { throw AbstractKeystoreError.aesError } let encryptedKeyData = Data(encryptedKey) @@ -242,8 +252,8 @@ public class BIP32Keystore: AbstractKeystore { dataForMAC.append(last16bytes) dataForMAC.append(encryptedKeyData) let mac = dataForMAC.sha3(.keccak256) - let kdfparams = KdfParamsV3(salt: saltData.toHexString(), dklen: dkLen, n: N, p: P, r: R, c: nil, prf: nil) - let cipherparams = CipherParamsV3(iv: IV.toHexString()) + let kdfparams = KdfParamsV3(salt: saltData!.toHexString(), dklen: dkLen, n: N, p: P, r: R, c: nil, prf: nil) + let cipherparams = CipherParamsV3(iv: IV!.toHexString()) let crypto = CryptoParamsV3(ciphertext: encryptedKeyData.toHexString(), cipher: aesMode, cipherparams: cipherparams, kdf: "scrypt", kdfparams: kdfparams, mac: mac.toHexString(), version: nil) var keystorePars = KeystoreParamsBIP32(crypto: crypto, id: UUID().uuidString.lowercased(), version: Self.KeystoreParamsBIP32Version) @@ -369,7 +379,7 @@ public class BIP32Keystore: AbstractKeystore { return data } - public func serializeRootNodeToString(password: String ) throws -> String { + public func serializeRootNodeToString(password: String = "web3swift") throws -> String { guard let decryptedRootNode = try? self.getPrefixNodeData(password) else { throw AbstractKeystoreError.encryptionError("Failed to decrypt a keystore") } diff --git a/Sources/Core/KeystoreManager/BIP39.swift b/Sources/Core/KeystoreManager/BIP39.swift index 80271616a..2b025b4c7 100755 --- a/Sources/Core/KeystoreManager/BIP39.swift +++ b/Sources/Core/KeystoreManager/BIP39.swift @@ -1,3 +1,4 @@ +// web3swift // // Created by Alex Vlasov. // Copyright © 2018 Alex Vlasov. All rights reserved. @@ -71,48 +72,77 @@ public enum BIP39Language { public class BIP39 { static public func generateMnemonicsFromEntropy(entropy: Data, language: BIP39Language = BIP39Language.english) -> String? { - guard entropy.count >= 16, entropy.count & 4 == 0 else {return nil} - let checksum = entropy.sha256() - let checksumBits = entropy.count*8/32 - var fullEntropy = Data() - fullEntropy.append(entropy) - fullEntropy.append(checksum[0 ..< (checksumBits+7)/8 ]) - var wordList = [String]() - for i in 0 ..< fullEntropy.count*8/11 { - guard let bits = fullEntropy.bitsInRange(i*11, 11) else {return nil} - let index = Int(bits) - guard language.words.count > index else {return nil} - let word = language.words[index] - wordList.append(word) - } + let wordList = generateMnemonicsFrom(entropy: entropy) let separator = language.separator return wordList.joined(separator: separator) } + static public func generateMnemonicsFrom(entropy: Data, language: BIP39Language = BIP39Language.english) -> [String] { + let entropy_bit_size = entropy.count * 8 + let checksum_length = entropy_bit_size / 32 + + var entropy_bits = bitarray(from: entropy) + print("array: \(entropy_bits)") + guard let checksumTest = generateChecksum(entropyBytes: entropy, checksumLength: checksum_length) else { + return [] + } + entropy_bits += checksumTest + return entropy_bits + .split(every: 11) + .compactMap { binary in + Int(binary, radix: 2) + } + .map { index in + language.words[index] + } + } + + static func bitarray(from data: Data) -> String { + data.map { + let binary = String($0, radix: 2) + let padding = String(repeating: "0", count: 8 - binary.count) + return padding + binary + }.joined() + } + static func generateChecksum(entropyBytes inputData: Data, checksumLength: Int) -> String? { + guard let checksumData = inputData.sha256().bitsInRange(0, checksumLength) else { + return nil + } + let checksum = String(checksumData, radix: 2).leftPadding(toLength: checksumLength, withPad: "0") + return checksum + } + + /** + Initializes a new mnemonics set with the provided bitsOfEntropy. + **/ + /// Initializes a new mnemonics set with the provided bitsOfEntropy. /// - Parameters: /// - bitsOfEntropy: 128 - 12 words, 192 - 18 words , 256 - 24 words in output. /// - language: words language, default english - /// - Returns: random 12-24 words, that represent new Mnemonic phrase. - static public func generateMnemonics(bitsOfEntropy: Int, language: BIP39Language = BIP39Language.english) throws -> String? { + static public func generateMnemonics(bitsOfEntropy: Int, language: BIP39Language = BIP39Language.english) -> String? { guard bitsOfEntropy >= 128 && bitsOfEntropy <= 256 && bitsOfEntropy.isMultiple(of: 32) else {return nil} - guard let entropy = Data.randomBytes(length: bitsOfEntropy/8) else {throw AbstractKeystoreError.noEntropyError} - return BIP39.generateMnemonicsFromEntropy(entropy: entropy, language: - language) + let entropy = Data.randomBytes(length: bitsOfEntropy/8)! + return generateMnemonicsFromEntropy(entropy: entropy, language: language) + } + static public func generateMnemonics(entropy: Int, language: BIP39Language = BIP39Language.english) -> [String]? { + guard entropy >= 128 && entropy <= 256 && entropy.isMultiple(of: 32) else {return nil} + let entropy = Data.randomBytes(length: entropy/8)! + return generateMnemonicsFrom(entropy: entropy, language: language) } static public func mnemonicsToEntropy(_ mnemonics: String, language: BIP39Language = BIP39Language.english) -> Data? { - let wordList = mnemonics.components(separatedBy: " ") - guard wordList.count >= 12 && wordList.count.isMultiple(of: 3) && wordList.count <= 24 else {return nil} + mnemonicsToEntropy(mnemonics.components(separatedBy: language.separator)) + } + static public func mnemonicsToEntropy(_ mnemonics: [String], language: BIP39Language = BIP39Language.english) -> Data? { + guard mnemonics.count >= 12 && mnemonics.count.isMultiple(of: 3) && mnemonics.count <= 24 else {return nil} var bitString = "" - for word in wordList { - let idx = language.words.firstIndex(of: word) - if (idx == nil) { + for word in mnemonics { + guard let idx = language.words.firstIndex(of: word) else { return nil } - let idxAsInt = language.words.startIndex.distance(to: idx!) - let stringForm = String(UInt16(idxAsInt), radix: 2).leftPadding(toLength: 11, withPad: "0") + let stringForm = String(UInt16(idx), radix: 2).leftPadding(toLength: 11, withPad: "0") bitString.append(stringForm) } let stringCount = bitString.count @@ -132,22 +162,21 @@ public class BIP39 { } static public func seedFromMmemonics(_ mnemonics: String, password: String = "", language: BIP39Language = BIP39Language.english) -> Data? { - let valid = BIP39.mnemonicsToEntropy(mnemonics, language: language) != nil - if (!valid) { + seedFromMmemonics(mnemonics.components(separatedBy: language.separator)) + } + static public func seedFromMmemonics(_ mnemonics: [String], password: String = "", language: BIP39Language = BIP39Language.english) -> Data? { + if mnemonicsToEntropy(mnemonics, language: language) == nil { return nil } - guard let mnemData = mnemonics.decomposedStringWithCompatibilityMapping.data(using: .utf8) else {return nil} + guard let mnemData = mnemonics.joined(separator: language.separator).decomposedStringWithCompatibilityMapping.data(using: .utf8) else {return nil} let salt = "mnemonic" + password guard let saltData = salt.decomposedStringWithCompatibilityMapping.data(using: .utf8) else {return nil} guard let seedArray = try? PKCS5.PBKDF2(password: mnemData.bytes, salt: saltData.bytes, iterations: 2048, keyLength: 64, variant: HMAC.Variant.sha2(.sha512)).calculate() else {return nil} - let seed = Data(seedArray) - return seed + return Data(seedArray) } static public func seedFromEntropy(_ entropy: Data, password: String = "", language: BIP39Language = BIP39Language.english) -> Data? { - guard let mnemonics = BIP39.generateMnemonicsFromEntropy(entropy: entropy, language: language) else { - return nil - } - return BIP39.seedFromMmemonics(mnemonics, password: password, language: language) + let mnemonics = generateMnemonicsFrom(entropy: entropy, language: language) + return seedFromMmemonics(mnemonics, password: password, language: language) } } diff --git a/Sources/Core/KeystoreManager/EthereumKeystoreV3.swift b/Sources/Core/KeystoreManager/EthereumKeystoreV3.swift index 5c0373593..a9510c520 100755 --- a/Sources/Core/KeystoreManager/EthereumKeystoreV3.swift +++ b/Sources/Core/KeystoreManager/EthereumKeystoreV3.swift @@ -1,3 +1,4 @@ +// web3swift // // Created by Alex Vlasov. // Copyright © 2018 Alex Vlasov. All rights reserved. @@ -69,7 +70,7 @@ public class EthereumKeystoreV3: AbstractKeystore { } } - public init?(password: String, aesMode: String = "aes-128-cbc") throws { + public init?(password: String = "web3swift", aesMode: String = "aes-128-cbc") throws { guard var newPrivateKey = SECP256K1.generatePrivateKey() else { return nil } @@ -79,7 +80,7 @@ public class EthereumKeystoreV3: AbstractKeystore { try encryptDataToStorage(password, keyData: newPrivateKey, aesMode: aesMode) } - public init?(privateKey: Data, password: String, aesMode: String = "aes-128-cbc") throws { + public init?(privateKey: Data, password: String = "web3swift", aesMode: String = "aes-128-cbc") throws { guard privateKey.count == 32 else { return nil } @@ -93,18 +94,14 @@ public class EthereumKeystoreV3: AbstractKeystore { if (keyData == nil) { throw AbstractKeystoreError.encryptionError("Encryption without key data") } - let saltLen = 32 - guard let saltData = Data.randomBytes(length: saltLen) else { - throw AbstractKeystoreError.noEntropyError - } + let saltLen = 32; + let saltData = Data.randomBytes(length: saltLen)! guard let derivedKey = scrypt(password: password, salt: saltData, length: dkLen, N: N, R: R, P: P) else { throw AbstractKeystoreError.keyDerivationError } let last16bytes = Data(derivedKey[(derivedKey.count - 16)...(derivedKey.count - 1)]) let encryptionKey = Data(derivedKey[0...15]) - guard let IV = Data.randomBytes(length: 16) else { - throw AbstractKeystoreError.noEntropyError - } + let IV = Data.randomBytes(length: 16)! var aesCipher: AES? switch aesMode { case "aes-128-cbc": diff --git a/Sources/Core/KeystoreManager/KeystoreParams.swift b/Sources/Core/KeystoreManager/KeystoreParams.swift index a0329aa88..07dfb9d2a 100644 --- a/Sources/Core/KeystoreManager/KeystoreParams.swift +++ b/Sources/Core/KeystoreManager/KeystoreParams.swift @@ -12,10 +12,22 @@ public struct KdfParamsV3: Decodable, Encodable { var r: Int? var c: Int? var prf: String? + public init(salt: String, dklen: Int, n: Int? = nil, p: Int? = nil, r: Int? = nil, c: Int? = nil, prf: String? = nil) { + self.salt = salt + self.dklen = dklen + self.n = n + self.p = p + self.r = r + self.c = c + self.prf = prf + } } public struct CipherParamsV3: Decodable, Encodable { var iv: String + public init(iv: String) { + self.iv = iv + } } public struct CryptoParamsV3: Decodable, Encodable { @@ -26,6 +38,15 @@ public struct CryptoParamsV3: Decodable, Encodable { var kdfparams: KdfParamsV3 var mac: String var version: String? + public init(ciphertext: String, cipher: String, cipherparams: CipherParamsV3, kdf: String, kdfparams: KdfParamsV3, mac: String, version: String? = nil) { + self.ciphertext = ciphertext + self.cipher = cipher + self.cipherparams = cipherparams + self.kdf = kdf + self.kdfparams = kdfparams + self.mac = mac + self.version = version + } } public protocol AbstractKeystoreParams: Codable { @@ -37,8 +58,12 @@ public protocol AbstractKeystoreParams: Codable { } public struct PathAddressPair: Codable { - let path: String - let address: String + public let path: String + public let address: String + public init(path: String, address: String) { + self.path = path + self.address = address + } } public struct KeystoreParamsBIP32: AbstractKeystoreParams { @@ -61,7 +86,7 @@ public struct KeystoreParamsBIP32: AbstractKeystoreParams { } } - var pathAddressPairs: [PathAddressPair] + public var pathAddressPairs: [PathAddressPair] var rootPath: String? public init(crypto cr: CryptoParamsV3, id i: String, version ver: Int = 32, rootPath: String? = nil) { @@ -81,7 +106,7 @@ public struct KeystoreParamsV3: AbstractKeystoreParams { public var version: Int public var isHDWallet: Bool - var address: String? + public var address: String? public init(address ad: String?, crypto cr: CryptoParamsV3, id i: String, version ver: Int) { address = ad diff --git a/Sources/Core/Utility/Data+Extension.swift b/Sources/Core/Utility/Data+Extension.swift index 4bc94645d..482c0fa90 100755 --- a/Sources/Core/Utility/Data+Extension.swift +++ b/Sources/Core/Utility/Data+Extension.swift @@ -4,6 +4,7 @@ // import Foundation +import Metal extension Data { init(fromArray values: [T]) { @@ -41,21 +42,23 @@ extension Data { } public static func randomBytes(length: Int) -> Data? { - for _ in 0...1024 { - var data = Data(repeating: 0, count: length) - let result = data.withUnsafeMutableBytes { (body: UnsafeMutableRawBufferPointer) -> Int32? in - if let bodyAddress = body.baseAddress, body.count > 0 { - let pointer = bodyAddress.assumingMemoryBound(to: UInt8.self) - return SecRandomCopyBytes(kSecRandomDefault, length, pointer) - } else { - return nil - } - } - if let notNilResult = result, notNilResult == errSecSuccess { - return data - } + let entropy_bit_size = length//128 + //# valid_entropy_bit_sizes = [128, 160, 192, 224, 256], count: [12, 15, 18, 21, 24] + var entropy_bytes = [UInt8](repeating: 0, count: entropy_bit_size)// / 8) + let status = SecRandomCopyBytes(kSecRandomDefault, entropy_bytes.count, &entropy_bytes) + + if status != errSecSuccess { // Always test the status. + } else { + entropy_bytes = [UInt8](repeating: 0, count: entropy_bit_size)// / 8) + arc4random_buf(&entropy_bytes, entropy_bytes.count) + } + + let source1 = MTLCreateSystemDefaultDevice()?.makeBuffer(length: length)?.hash.description.data(using: .utf8) + + let entropyData = entropy_bytes.shuffled().map{ bit in + return bit ^ (source1?.randomElement() ?? 0) } - return nil + return Data(entropyData) } public func bitsInRange(_ startingBit: Int, _ length: Int) -> UInt64? { // return max of 8 bytes for simplicity, non-public diff --git a/Sources/Core/Utility/String+Extension.swift b/Sources/Core/Utility/String+Extension.swift index 45a7ecbf3..cd0511dce 100755 --- a/Sources/Core/Utility/String+Extension.swift +++ b/Sources/Core/Utility/String+Extension.swift @@ -32,6 +32,26 @@ extension String { return output } + /// Splits a string into groups of `every` n characters, grouping from left-to-right by default. If `backwards` is true, right-to-left. + public func split(every: Int, backwards: Bool = false) -> [String] { + var result = [String]() + + for i in stride(from: 0, to: self.count, by: every) { + switch backwards { + case true: + let endIndex = self.index(self.endIndex, offsetBy: -i) + let startIndex = self.index(endIndex, offsetBy: -every, limitedBy: self.startIndex) ?? self.startIndex + result.insert(String(self[startIndex..) -> String { let start = index(self.startIndex, offsetBy: bounds.lowerBound) let end = index(self.startIndex, offsetBy: bounds.upperBound) @@ -50,7 +70,7 @@ extension String { return String(self[start.. String { + public func leftPadding(toLength: Int, withPad character: Character) -> String { let stringLength = self.count if stringLength < toLength { return String(repeatElement(character, count: toLength - stringLength)) + self diff --git a/Sources/web3swift/Operations/WriteOperation.swift b/Sources/web3swift/Operations/WriteOperation.swift index 89f7f3a72..401298918 100755 --- a/Sources/web3swift/Operations/WriteOperation.swift +++ b/Sources/web3swift/Operations/WriteOperation.swift @@ -12,7 +12,7 @@ public class WriteOperation: ReadOperation { // FIXME: Rewrite this to CodableTransaction public func writeToChain(password: String) async throws -> TransactionSendingResult { - await transaction.resolve(provider: web3.provider) + try await transaction.resolve(provider: web3.provider) if let attachedKeystoreManager = self.web3.provider.attachedKeystoreManager { do { try Web3Signer.signTX(transaction: &transaction, @@ -28,6 +28,34 @@ public class WriteOperation: ReadOperation { // MARK: Sending Data flow return try await web3.eth.send(transaction) } + + public func depploy(password: String) async throws -> TransactionSendingResult { + //TODO: optimize/cleanup + try await transaction.resolve(provider: web3.provider) + + guard let attachedKeystoreManager = self.web3.provider.attachedKeystoreManager else { + throw Web3Error.inputError(desc: "Failed to locally sign a transaction") + } + + do { + //TODO: optimize/cleanup +// transaction.unsign() + let account = transaction.from ?? transaction.sender ?? EthereumAddress.contractDeploymentAddress() + var privateKey = try attachedKeystoreManager.UNSAFE_getPrivateKeyData(password: password, account: account) + defer { Data.zero(&privateKey) } + try transaction.sign(privateKey: privateKey, useExtraEntropy: false) + } catch { + throw Web3Error.inputError(desc: "Failed to locally sign a transaction") + } + + //TODO: optimize/cleanup + guard let transactionData = transaction.encode(for: .transaction) else { throw Web3Error.dataError } +// let vectorHash = transaction.hash!.toHexString().addHexPrefix() +// print(vectorHash) + + //TODO: optimize/cleanup + return try await web3.eth.send(raw: transactionData) + } // FIXME: Rewrite this to CodableTransaction func nonce(for policy: CodableTransaction.NoncePolicy, from: EthereumAddress) async throws -> BigUInt { diff --git a/Sources/web3swift/Utils/ENS/ENS.swift b/Sources/web3swift/Utils/ENS/ENS.swift index d598d57e6..c4b2a3408 100755 --- a/Sources/web3swift/Utils/ENS/ENS.swift +++ b/Sources/web3swift/Utils/ENS/ENS.swift @@ -84,7 +84,7 @@ public class ENS { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } - guard let isAddrSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.addr.hash()) else { + guard let isAddrSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.addr.rawValue) else { throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") } guard isAddrSupports else { @@ -101,7 +101,7 @@ public class ENS { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } - guard let isAddrSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.addr.hash()) else { + guard let isAddrSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.addr.rawValue) else { throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") } guard isAddrSupports else { @@ -119,12 +119,12 @@ public class ENS { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } - guard let isNameSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.name.hash()) else { - throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") - } - guard isNameSupports else { - throw Web3Error.processingError(desc: "Name isn't supported") - } +// guard let isNameSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.name.rawValue) else { +// throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") +// } +// guard isNameSupports else { +// throw Web3Error.processingError(desc: "Name isn't supported") +// } guard let name = try? await resolver.getCanonicalName(forNode: node) else { throw Web3Error.processingError(desc: "Can't get name") } @@ -136,7 +136,7 @@ public class ENS { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } - guard let isNameSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.name.hash()) else { + guard let isNameSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.name.rawValue) else { throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") } guard isNameSupports else { @@ -155,7 +155,7 @@ public class ENS { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } - guard let isContentSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.content.hash()) else { + guard let isContentSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.content.rawValue) else { throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") } guard isContentSupports else { @@ -172,7 +172,7 @@ public class ENS { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } - guard let isContentSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.content.hash()) else { + guard let isContentSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.content.rawValue) else { throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") } guard isContentSupports else { @@ -190,7 +190,7 @@ public class ENS { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } - guard let isABISupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.ABI.hash()) else { + guard let isABISupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.ABI.rawValue) else { throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") } guard isABISupports else { @@ -207,7 +207,7 @@ public class ENS { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } - guard let isABISupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.ABI.hash()) else { + guard let isABISupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.ABI.rawValue) else { throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") } guard isABISupports else { @@ -225,7 +225,7 @@ public class ENS { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } - guard let isPKSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.pubkey.hash()) else { + guard let isPKSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.pubkey.rawValue) else { throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") } guard isPKSupports else { @@ -242,7 +242,7 @@ public class ENS { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } - guard let isPKSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.pubkey.hash()) else { + guard let isPKSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.pubkey.rawValue) else { throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") } guard isPKSupports else { @@ -260,7 +260,7 @@ public class ENS { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } - guard let isTextSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.text.hash()) else { + guard let isTextSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.text.rawValue) else { throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") } guard isTextSupports else { @@ -277,7 +277,7 @@ public class ENS { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } - guard let isTextSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.text.hash()) else { + guard let isTextSupports = try? await resolver.supportsInterface(interfaceID: Resolver.InterfaceName.text.rawValue) else { throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") } guard isTextSupports else { From f6f86b39c4f8605256da5b787a873a66a2f5dab4 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Tue, 15 Nov 2022 18:25:40 -0800 Subject: [PATCH 006/210] cleanup post merge --- .../Core/KeystoreManager/BIP32Keystore.swift | 2 +- .../Core/Transaction/CodableTransaction.swift | 110 ------------------ .../web3swift/Operations/WriteOperation.swift | 24 ++-- .../web3swiftTests/remoteTests/ENSTests.swift | 10 +- 4 files changed, 18 insertions(+), 128 deletions(-) diff --git a/Sources/Core/KeystoreManager/BIP32Keystore.swift b/Sources/Core/KeystoreManager/BIP32Keystore.swift index 040bb3cdf..756d40ced 100755 --- a/Sources/Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Core/KeystoreManager/BIP32Keystore.swift @@ -63,7 +63,7 @@ public class BIP32Keystore: AbstractKeystore { private static let KeystoreParamsBIP32Version = 4 - private (set) var addressStorage: PathAddressStorage + public private(set) var addressStorage: PathAddressStorage public convenience init?(_ jsonString: String) { let lowercaseJSON = jsonString.lowercased() diff --git a/Sources/Core/Transaction/CodableTransaction.swift b/Sources/Core/Transaction/CodableTransaction.swift index 896625a11..19f5773fe 100644 --- a/Sources/Core/Transaction/CodableTransaction.swift +++ b/Sources/Core/Transaction/CodableTransaction.swift @@ -188,27 +188,6 @@ public struct CodableTransaction { return self.envelope.encode(for: type) } - public mutating func resolve(provider: Web3Provider) async throws { - // FIXME: Delete force try - self.gasLimit = try await self.gasLimitPolicy.resolve(provider: provider, transaction: self) - - if from != nil || sender != nil { - self.nonce = try await self.resolveNonce(provider: provider) - } - if case .eip1559 = type { - self.maxFeePerGas = try await self.maxFeePerGasPolicy.resolve(provider: provider) - self.maxPriorityFeePerGas = try await self.maxPriorityFeePerGasPolicy.resolve(provider: provider) - } else { - self.gasPrice = try await self.gasPricePolicy.resolve(provider: provider) - } - } - - public var noncePolicy: NoncePolicy - public var maxFeePerGasPolicy: FeePerGasPolicy - public var maxPriorityFeePerGasPolicy: PriorityFeePerGasPolicy - public var gasPricePolicy: GasPricePolicy - public var gasLimitPolicy: GasLimitPolicy - public static var emptyTransaction = CodableTransaction(to: EthereumAddress.contractDeploymentAddress()) } @@ -285,95 +264,6 @@ extension CodableTransaction: Codable { } -public protocol Policyable { - func resolve(provider: Web3Provider, transaction: CodableTransaction?) async throws -> BigUInt -} - -extension CodableTransaction { - public enum GasLimitPolicy { - case automatic - case manual(BigUInt) - case limited(BigUInt) - case withMargin(Double) - - func resolve(provider: Web3Provider, transaction: CodableTransaction?) async throws -> BigUInt { - guard let transaction = transaction else { throw Web3Error.valueError } - let request: APIRequest = .estimateGas(transaction, transaction.callOnBlock ?? .latest) - let response: APIResponse = try await APIRequest.sendRequest(with: provider, for: request) - switch self { - case .automatic, .withMargin: - return response.result - case .manual(let value): - return value - case .limited(let limit): - if limit <= response.result { - return response.result - } else { - return limit - } - } - } - } - - public enum GasPricePolicy { - case automatic - case manual(BigUInt) - case withMargin(Double) - - func resolve(provider: Web3Provider, transaction: CodableTransaction? = nil) async throws -> BigUInt { - let oracle = Oracle(provider) - switch self { - case .automatic, .withMargin: - return await oracle.gasPriceLegacyPercentiles().max() ?? 0 - case .manual(let value): - return value - } - } - } - - public enum PriorityFeePerGasPolicy: Policyable { - case automatic - case manual(BigUInt) - - public func resolve(provider: Web3Provider, transaction: CodableTransaction? = nil) async throws -> BigUInt { - let oracle = Oracle(provider) - switch self { - case .automatic: - return await oracle.tipFeePercentiles().max() ?? 0 - case .manual(let value): - return value - } - } - } - - public enum FeePerGasPolicy: Policyable { - case automatic - case manual(BigUInt) - - public func resolve(provider: Web3Provider, transaction: CodableTransaction? = nil) async throws -> BigUInt { - let oracle = Oracle(provider) - switch self { - case .automatic: - return await oracle.baseFeePercentiles().max() ?? 0 - case .manual(let value): - return value - } - } - } - - func resolveNonce(provider: Web3Provider) async throws -> BigUInt { - switch noncePolicy { - case .pending, .latest, .earliest: - guard let address = from ?? sender else { throw Web3Error.valueError } - let request: APIRequest = .getTransactionCount(address.address, callOnBlock ?? .latest) - let response: APIResponse = try await APIRequest.sendRequest(with: provider, for: request) - return response.result - case .exact(let value): - return value - } - } -} - extension CodableTransaction: CustomStringConvertible { /// required by CustomString convertable /// returns a string description for the transaction and its data diff --git a/Sources/web3swift/Operations/WriteOperation.swift b/Sources/web3swift/Operations/WriteOperation.swift index b055611dd..6aebe8683 100755 --- a/Sources/web3swift/Operations/WriteOperation.swift +++ b/Sources/web3swift/Operations/WriteOperation.swift @@ -63,16 +63,16 @@ public class WriteOperation: ReadOperation { } // FIXME: Rewrite this to CodableTransaction - func nonce(for policy: CodableTransaction.NoncePolicy, from: EthereumAddress) async throws -> BigUInt { - switch policy { - case .latest: - return try await self.web3.eth.getTransactionCount(for: from, onBlock: .latest) - case .pending: - return try await self.web3.eth.getTransactionCount(for: from, onBlock: .pending) - case .earliest: - return try await self.web3.eth.getTransactionCount(for: from, onBlock: .earliest) - case .exact(let nonce): - return nonce - } - } +// func nonce(for policy: CodableTransaction.NoncePolicy, from: EthereumAddress) async throws -> BigUInt { +// switch policy { +// case .latest: +// return try await self.web3.eth.getTransactionCount(for: from, onBlock: .latest) +// case .pending: +// return try await self.web3.eth.getTransactionCount(for: from, onBlock: .pending) +// case .earliest: +// return try await self.web3.eth.getTransactionCount(for: from, onBlock: .earliest) +// case .exact(let nonce): +// return nonce +// } +// } } diff --git a/Tests/web3swiftTests/remoteTests/ENSTests.swift b/Tests/web3swiftTests/remoteTests/ENSTests.swift index 598948504..3097cb4b0 100755 --- a/Tests/web3swiftTests/remoteTests/ENSTests.swift +++ b/Tests/web3swiftTests/remoteTests/ENSTests.swift @@ -44,10 +44,10 @@ class ENSTests: XCTestCase { let ens = ENS(web3: web3) let domain = "somename.eth" let resolver = try await ens?.registry.getResolver(forDomain: domain) - let isAddrSupports = try await resolver?.supportsInterface(interfaceID: ENS.Resolver.InterfaceName.addr.hash()) - let isNameSupports = try await resolver?.supportsInterface(interfaceID: ENS.Resolver.InterfaceName.name.hash()) - let isABIsupports = try await resolver?.supportsInterface(interfaceID: ENS.Resolver.InterfaceName.ABI.hash()) - let isPubkeySupports = try await resolver?.supportsInterface(interfaceID: ENS.Resolver.InterfaceName.pubkey.hash()) + let isAddrSupports = try await resolver?.supportsInterface(interfaceID: ENS.Resolver.InterfaceName.addr.rawValue) + let isNameSupports = try await resolver?.supportsInterface(interfaceID: ENS.Resolver.InterfaceName.name.rawValue) + let isABIsupports = try await resolver?.supportsInterface(interfaceID: ENS.Resolver.InterfaceName.ABI.rawValue) + let isPubkeySupports = try await resolver?.supportsInterface(interfaceID: ENS.Resolver.InterfaceName.pubkey.rawValue) XCTAssertEqual(isAddrSupports, true) XCTAssertEqual(isNameSupports, true) XCTAssertEqual(isABIsupports, true) @@ -59,7 +59,7 @@ class ENSTests: XCTestCase { let ens = ENS(web3: web3) let domain = "somename.eth" let resolver = try await ens?.registry.getResolver(forDomain: domain) - if let isABIsupported = try await resolver?.supportsInterface(interfaceID: ENS.Resolver.InterfaceName.ABI.hash()), + if let isABIsupported = try await resolver?.supportsInterface(interfaceID: ENS.Resolver.InterfaceName.ABI.rawValue), isABIsupported { let res = try await resolver?.getContractABI(forNode: domain, contentType: .zlibCompressedJSON) XCTAssert(res?.0 == 0) From e968d2f68d0b095386742d72b9792a311b0dc5a8 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Wed, 16 Nov 2022 07:08:47 -0800 Subject: [PATCH 007/210] fix bug --- Tests/web3swiftTests/localTests/LocalTestCase.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tests/web3swiftTests/localTests/LocalTestCase.swift b/Tests/web3swiftTests/localTests/LocalTestCase.swift index 20640fd3b..e56048d82 100644 --- a/Tests/web3swiftTests/localTests/LocalTestCase.swift +++ b/Tests/web3swiftTests/localTests/LocalTestCase.swift @@ -15,8 +15,10 @@ class LocalTestCase: XCTestCase { override func setUp() async throws { let web3 = try! await Web3.new(LocalTestCase.url) - let block = try! await web3.eth.blockNumber() - if block >= 25 { return } + guard let block = try? await web3.eth.blockNumber() else { + return + } + guard block < 25 else { return } print("\n ****** Preloading Ganache (\(25 - block) blocks) *****\n") From 1fff2c678de2787c3657615ad6999e9f5ea9d8af Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Wed, 16 Nov 2022 10:49:35 -0800 Subject: [PATCH 008/210] improve test code actually handle force unwrap fix crashes --- .../localTests/KeystoresTests.swift | 230 +++++++++++++----- 1 file changed, 169 insertions(+), 61 deletions(-) diff --git a/Tests/web3swiftTests/localTests/KeystoresTests.swift b/Tests/web3swiftTests/localTests/KeystoresTests.swift index 4911c6c39..82032dcd6 100755 --- a/Tests/web3swiftTests/localTests/KeystoresTests.swift +++ b/Tests/web3swiftTests/localTests/KeystoresTests.swift @@ -73,126 +73,225 @@ class KeystoresTests: LocalTestCase { func testHMAC() throws { let seed = Data.fromHex("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b")! let data = Data.fromHex("4869205468657265")! - let hmac = try! HMAC.init(key: seed.bytes, variant: HMAC.Variant.sha2(.sha512)).authenticate(data.bytes) + guard let hmac = try? HMAC.init(key: seed.bytes, variant: HMAC.Variant.sha2(.sha512)).authenticate(data.bytes) else { + XCTFail() + return + } XCTAssert(Data(hmac).toHexString() == "87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854") } func testV3keystoreExportPrivateKey() throws { - let keystore = try! EthereumKeystoreV3(password: "") + guard let keystore = try? EthereumKeystoreV3(password: "") else { + XCTFail() + return + } XCTAssertNotNil(keystore) - let account = keystore!.addresses![0] + let account = keystore.addresses![0] print(account) - let data = try! keystore!.serialize() - print(try! JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions(rawValue: 0))) - let key = try! keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + guard let data = try? keystore.serialize() else { + XCTFail() + return + } + print(try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions(rawValue: 0))) + guard let key = try? keystore.UNSAFE_getPrivateKeyData(password: "", account: account) else { + XCTFail() + return + } XCTAssertNotNil(key) } func testV3keystoreSerialization() throws { - let keystore = try! EthereumKeystoreV3(password: "") + guard let keystore = try? EthereumKeystoreV3(password: "") else { + XCTFail() + return + } XCTAssertNotNil(keystore) - let account = keystore!.addresses![0] - let data = try! keystore!.serialize() - let key = try! keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + let account = keystore.addresses![0] + guard let data = try? keystore.serialize() else { + XCTFail() + return + } + guard let key = try? keystore.UNSAFE_getPrivateKeyData(password: "", account: account) else { + XCTFail() + return + } XCTAssertNotNil(key) - let restored = EthereumKeystoreV3(data!) + let restored = EthereumKeystoreV3(data) XCTAssertNotNil(restored) - XCTAssertEqual(keystore!.addresses!.first!, restored!.addresses!.first!) - let restoredKey = try! restored!.UNSAFE_getPrivateKeyData(password: "", account: account) + XCTAssertEqual(keystore.addresses!.first!, restored!.addresses!.first!) + guard let restoredKey = try? restored!.UNSAFE_getPrivateKeyData(password: "", account: account) else { + XCTFail() + return + } XCTAssertNotNil(restoredKey) XCTAssertEqual(key, restoredKey) } func testNewBIP32keystore() throws { - let mnemonic = try! BIP39.generateMnemonics(bitsOfEntropy: 256)! - let keystore = try! BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") + guard let mnemonic = BIP39.generateMnemonics(bitsOfEntropy: 256) else { + XCTFail() + return + } + let keystore = try? BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") XCTAssert(keystore != nil) } func testSameAddressesFromTheSameMnemonics() throws { - let mnemonic = try! BIP39.generateMnemonics(bitsOfEntropy: 256)! - let keystore1 = try! BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") - let keystore2 = try! BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") - XCTAssert(keystore1?.addresses?.first == keystore2?.addresses?.first) + guard let mnemonic = BIP39.generateMnemonics(bitsOfEntropy: 256) else { + XCTFail() + return + } + guard let keystore1 = try? BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") else { + XCTFail() + return + } + guard let keystore2 = try? BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") else { + XCTFail() + return + } + XCTAssert(keystore1.addresses?.first == keystore2.addresses?.first) } func testBIP32keystoreExportPrivateKey() throws { let mnemonic = "normal dune pole key case cradle unfold require tornado mercy hospital buyer" - let keystore = try! BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") + guard let keystore = try? BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") else { + XCTFail() + return + } XCTAssertNotNil(keystore) - let account = keystore!.addresses![0] - let key = try! keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + let account = keystore.addresses![0] + guard let key = try? keystore.UNSAFE_getPrivateKeyData(password: "", account: account) else { + XCTFail() + return + } XCTAssertNotNil(key) } func testBIP32keystoreMatching() throws { - let keystore = try! BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "banana") + guard let keystore = try? BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "banana") else { + XCTFail() + return + } XCTAssertNotNil(keystore) - let account = keystore!.addresses![0] - let key = try! keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + let account = keystore.addresses![0] + guard let key = try? keystore.UNSAFE_getPrivateKeyData(password: "", account: account) else { + XCTFail() + return + } let pubKey = Utilities.privateToPublic(key, compressed: true) XCTAssert(pubKey?.toHexString() == "027160bd3a4d938cac609ff3a11fe9233de7b76c22a80d2b575e202cbf26631659") } func testBIP32keystoreMatchingRootNode() throws { - let keystore = try! BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "banana") + guard let keystore = try? BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "banana") else { + XCTFail() + return + } XCTAssertNotNil(keystore) - let rootNode = try! keystore!.serializeRootNodeToString(password: "") + guard let rootNode = try? keystore.serializeRootNodeToString(password: "") else { + XCTFail() + return + } XCTAssert(rootNode == "xprvA2KM71v838kPwE8Lfr12m9DL939TZmPStMnhoFcZkr1nBwDXSG7c3pjYbMM9SaqcofK154zNSCp7W7b4boEVstZu1J3pniLQJJq7uvodfCV") } func testBIP32keystoreCustomPathMatching() throws { - let keystore = try! BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "banana", prefixPath: "m/44'/60'/0'/0") + guard let keystore = try? BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "banana", prefixPath: "m/44'/60'/0'/0") else { + XCTFail() + return + } XCTAssertNotNil(keystore) - let account = keystore!.addresses![0] - let key = try! keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + let account = keystore.addresses![0] + guard let key = try? keystore.UNSAFE_getPrivateKeyData(password: "", account: account) else { + XCTFail() + return + } let pubKey = Utilities.privateToPublic(key, compressed: true) XCTAssert(pubKey?.toHexString() == "027160bd3a4d938cac609ff3a11fe9233de7b76c22a80d2b575e202cbf26631659") } func testByBIP32keystoreCreateChildAccount() throws { let mnemonic = "normal dune pole key case cradle unfold require tornado mercy hospital buyer" - let keystore = try! BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") + guard let keystore = try? BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") else { + XCTFail() + return + } XCTAssertNotNil(keystore) - XCTAssertEqual(keystore!.addresses?.count, 1) - try! keystore?.createNewChildAccount(password: "") - XCTAssertEqual(keystore?.addresses?.count, 2) - let account = keystore!.addresses![0] - let key = try! keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + XCTAssertEqual(keystore.addresses?.count, 1) + try? keystore.createNewChildAccount(password: "") + XCTAssertEqual(keystore.addresses?.count, 2) + let account = keystore.addresses![0] + guard let key = try? keystore.UNSAFE_getPrivateKeyData(password: "", account: account) else { + XCTFail() + return + } XCTAssertNotNil(key) } func testByBIP32keystoreCreateCustomChildAccount() throws { let mnemonic = "normal dune pole key case cradle unfold require tornado mercy hospital buyer" - let keystore = try! BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") + guard let keystore = try? BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") else { + XCTFail() + return + } XCTAssertNotNil(keystore) - XCTAssertEqual(keystore!.addresses?.count, 1) - try! keystore?.createNewCustomChildAccount(password: "", path: "/42/1") - XCTAssertEqual(keystore?.addresses?.count, 2) - let account = keystore!.addresses![1] - let key = try! keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + XCTAssertEqual(keystore.addresses?.count, 1) + try? keystore.createNewCustomChildAccount(password: "", path: "/42/1") + XCTAssertEqual(keystore.addresses?.count, 2) + guard keystore.addresses?.count ?? 0 > 1 else { + XCTFail() + return + } + guard let account = keystore.addresses?[1] else { + XCTFail() + return + } + guard let key = try? keystore.UNSAFE_getPrivateKeyData(password: "", account: account) else { + XCTFail() + return + } XCTAssertNotNil(key) - print(keystore!.addressStorage.paths) + print(keystore.addressStorage.paths) } func testByBIP32keystoreSaveAndDeriva() throws { let mnemonic = "normal dune pole key case cradle unfold require tornado mercy hospital buyer" - let keystore = try! BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "", prefixPath: "m/44'/60'/0'") + guard let keystore = try? BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "", prefixPath: "m/44'/60'/0'") else { + XCTFail() + return + } XCTAssertNotNil(keystore) - XCTAssertEqual(keystore!.addresses?.count, 1) - try! keystore?.createNewCustomChildAccount(password: "", path: "/0/1") - XCTAssertEqual(keystore?.addresses?.count, 2) - let data = try! keystore?.serialize() - let recreatedStore = BIP32Keystore.init(data!) - XCTAssert(keystore?.addresses?.count == recreatedStore?.addresses?.count) - XCTAssert(keystore?.rootPrefix == recreatedStore?.rootPrefix) - print(keystore!.addresses![0].address) - print(keystore!.addresses![1].address) - print(recreatedStore!.addresses![0].address) + XCTAssertEqual(keystore.addresses?.count, 1) + try? keystore.createNewCustomChildAccount(password: "", path: "/0/1") + XCTAssertEqual(keystore.addresses?.count, 2) + guard let data = try? keystore.serialize() else { + XCTFail() + return + } + let recreatedStore = BIP32Keystore.init(data) + XCTAssert(keystore.addresses?.count == recreatedStore?.addresses?.count) + XCTAssert(keystore.rootPrefix == recreatedStore?.rootPrefix) + guard let firstAddress = keystore.addresses?.first else { + XCTFail() + return + } + guard let recreatedFirstAddress = recreatedStore?.addresses?.first else { + XCTFail() + return + } + print(firstAddress.address) + print(recreatedFirstAddress.address) + XCTAssert(firstAddress == recreatedFirstAddress) + + guard keystore.addresses?.count ?? 0 > 1 && recreatedStore?.addresses?.count ?? 0 > 1 else { + XCTFail() + return + } + + print(keystore.addresses![1].address) print(recreatedStore!.addresses![1].address) - XCTAssert(keystore?.addresses![0] == recreatedStore?.addresses![0]) - XCTAssert(keystore?.addresses![1] == recreatedStore?.addresses![1]) + XCTAssert(keystore.addresses![1] == recreatedStore?.addresses![1]) } // FIXME: Failed on async with 10_000 iterations @@ -207,7 +306,10 @@ class KeystoresTests: LocalTestCase { func testRIPEMD() throws { let data = "message digest".data(using: .ascii) - let hash = try! RIPEMD160.hash(message: data!) + guard let hash = try? RIPEMD160.hash(message: data!) else { + XCTFail() + return + } XCTAssert(hash.toHexString() == "5d0689ef49d2fae572b881b123a85ffa21595f36") } @@ -269,15 +371,21 @@ class KeystoresTests: LocalTestCase { func testKeystoreDerivationTime() throws { let privateKey = Data.randomBytes(length: 32)! measure { - let ks = try! EthereumKeystoreV3(privateKey: privateKey, password: "TEST")! + guard let ks = try? EthereumKeystoreV3(privateKey: privateKey, password: "TEST") else { + XCTFail() + return + } let account = ks.addresses!.first! - _ = try! ks.UNSAFE_getPrivateKeyData(password: "TEST", account: account) + _ = try? ks.UNSAFE_getPrivateKeyData(password: "TEST", account: account) } } func testSingleScryptDerivation() throws { - let privateKey = Data.randomBytes(length: 32)! - _ = try! EthereumKeystoreV3(privateKey: privateKey, password: "TEST")! + guard let privateKey = Data.randomBytes(length: 32) else { + XCTFail() + return + } + _ = try? EthereumKeystoreV3(privateKey: privateKey, password: "TEST") } } From d5df8e22c36b839c4596af0a2a62645768392c8b Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 13 Jan 2023 17:30:32 +0200 Subject: [PATCH 009/210] fix: removed the use of AnyObject in all places possible - replaced with Any --- .../WalletViewController.swift | 12 +- README.md | 2 +- Sources/Core/EthereumABI/ABIElements.swift | 6 +- .../Web3Core/Contract/ContractProtocol.swift | 16 +- .../Web3Core/EthereumABI/ABIDecoding.swift | 48 +++--- .../Web3Core/EthereumABI/ABIElements.swift | 6 +- .../Web3Core/EthereumABI/ABIEncoding.swift | 46 +++--- Sources/Web3Core/RLP/RLP.swift | 8 +- .../Envelope/EIP1559Envelope.swift | 8 +- .../Envelope/EIP2930Envelope.swift | 12 +- .../Transaction/Envelope/LegacyEnvelope.swift | 8 +- Sources/web3swift/Browser/browser.js | 14 +- .../web3swift/Operations/ReadOperation.swift | 2 +- .../Tokens/ERC1155/Web3+ERC1155.swift | 16 +- .../Tokens/ERC1376/Web3+ERC1376.swift | 44 +++--- .../Tokens/ERC1400/Web3+ERC1400.swift | 100 ++++++------- .../Tokens/ERC1410/Web3+ERC1410.swift | 74 +++++----- .../Tokens/ERC1594/Web3+ERC1594.swift | 30 ++-- .../Tokens/ERC1633/Web3+ERC1633.swift | 20 +-- .../Tokens/ERC1643/Web3+ERC1643.swift | 22 +-- .../Tokens/ERC1644/Web3+ERC1644.swift | 20 +-- .../Tokens/ERC20/ERC20BaseProperties.swift | 2 +- .../web3swift/Tokens/ERC20/Web3+ERC20.swift | 14 +- .../web3swift/Tokens/ERC721/Web3+ERC721.swift | 36 ++--- .../Tokens/ERC721x/Web3+ERC721x.swift | 52 +++---- .../web3swift/Tokens/ERC777/Web3+ERC777.swift | 46 +++--- .../web3swift/Tokens/ERC888/Web3+ERC888.swift | 4 +- Sources/web3swift/Tokens/ST20/Web3+ST20.swift | 22 +-- .../Tokens/ST20/Web3+SecurityToken.swift | 36 ++--- Sources/web3swift/Utils/EIP/EIP67Code.swift | 2 +- Sources/web3swift/Utils/EIP/EIP681.swift | 42 +++--- Sources/web3swift/Utils/EIP/EIP712.swift | 8 +- .../Utils/ENS/ENSBaseRegistrar.swift | 12 +- Sources/web3swift/Utils/ENS/ENSRegistry.swift | 14 +- Sources/web3swift/Utils/ENS/ENSResolver.swift | 28 ++-- .../Utils/ENS/ENSReverseRegistrar.swift | 10 +- .../Utils/ENS/ETHRegistrarController.swift | 16 +- Sources/web3swift/Web3/Web3+Contract.swift | 6 +- Sources/web3swift/Web3/Web3+Utils.swift | 2 +- .../localTests/ABIEncoderTest.swift | 138 +++++++++--------- .../localTests/AdvancedABIv2Tests.swift | 8 +- .../localTests/BasicLocalNodeTests.swift | 4 +- .../localTests/EIP681Tests.swift | 28 ++-- .../localTests/EIP712Tests.swift | 8 +- .../localTests/ERC20Tests.swift | 4 +- .../localTests/EthereumContractTest.swift | 6 +- .../localTests/PersonalSignatureTests.swift | 4 +- .../localTests/PromisesTests.swift | 8 +- .../ST20AndSecurityTokenTests.swift | 14 +- .../localTests/TestHelpers.swift | 4 +- .../localTests/UncategorizedTests.swift | 4 +- .../web3swiftTests/localTests/UserCases.swift | 4 +- 52 files changed, 555 insertions(+), 545 deletions(-) diff --git a/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift b/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift index 1326f3e7a..c766c5758 100644 --- a/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift +++ b/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift @@ -89,13 +89,13 @@ class WalletViewController: UIViewController { let manager = KeystoreManager([myWeb3KeyStore]) let address = keystore?.addresses?.first #if DEBUG - print("Address :::>>>>> ", address as Any) - print("Address :::>>>>> ", manager.addresses as Any) + print("Address :::>>>>> ", address) + print("Address :::>>>>> ", manager.addresses) #endif let walletAddress = manager.addresses?.first?.address self.walletAddressLabel.text = walletAddress ?? "0x" - print(walletAddress as Any) + print(walletAddress) } else { print("error") } @@ -115,7 +115,7 @@ class WalletViewController: UIViewController { } func importWalletWith(mnemonics: String) { let walletAddress = try? BIP32Keystore(mnemonics: mnemonics , prefixPath: "m/44'/77777'/0'/0") - print(walletAddress?.addresses as Any) + print(walletAddress?.addresses) self.walletAddressLabel.text = "\(walletAddress?.addresses?.first?.address ?? "0x")" } @@ -137,7 +137,7 @@ extension WalletViewController { self._mnemonics = tMnemonics print(_mnemonics) let tempWalletAddress = try? BIP32Keystore(mnemonics: self._mnemonics , prefixPath: "m/44'/77777'/0'/0") - print(tempWalletAddress?.addresses?.first?.address as Any) + print(tempWalletAddress?.addresses?.first?.address) guard let walletAddress = tempWalletAddress?.addresses?.first else { self.showAlertMessage(title: "", message: "We are unable to create wallet", actionName: "Ok") return @@ -145,7 +145,7 @@ extension WalletViewController { self._walletAddress = walletAddress.address let privateKey = try tempWalletAddress?.UNSAFE_getPrivateKeyData(password: "", account: walletAddress) #if DEBUG - print(privateKey as Any, "Is the private key") + print(privateKey, "Is the private key") #endif let keyData = try? JSONEncoder().encode(tempWalletAddress?.keystoreParams) FileManager.default.createFile(atPath: userDir + "/keystore"+"/key.json", contents: keyData, attributes: nil) diff --git a/README.md b/README.md index 92c686767..9ed1c18c5 100755 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ let response = try await readTX.callContractMethod() let abiString = "[]" // some ABI string let bytecode = Data.fromHex("") // some ABI bite sequence let contract = web3.contract(abiString, at: nil, abiVersion: 2)! -let parameters = [...] as [AnyObject] +let parameters: [Any] = [...] let deployOp = contract.prepareDeploy(bytecode: bytecode, constructor: contract.contract.constructor, parameters: parameters)! deployOp.transaction.from = "" // your address deployOp.transaction.gasLimitPolicy = .manual(3000000) diff --git a/Sources/Core/EthereumABI/ABIElements.swift b/Sources/Core/EthereumABI/ABIElements.swift index c947f6159..2e18b9dcb 100755 --- a/Sources/Core/EthereumABI/ABIElements.swift +++ b/Sources/Core/EthereumABI/ABIElements.swift @@ -173,7 +173,7 @@ public extension ABI { // MARK: - Function parameters encoding extension ABI.Element { - public func encodeParameters(_ parameters: [AnyObject]) -> Data? { + public func encodeParameters(_ parameters: [Any]) -> Data? { switch self { case .constructor(let constructor): return constructor.encodeParameters(parameters) @@ -192,7 +192,7 @@ extension ABI.Element { } extension ABI.Element.Constructor { - public func encodeParameters(_ parameters: [AnyObject]) -> Data? { + public func encodeParameters(_ parameters: [Any]) -> Data? { guard parameters.count == inputs.count else { return nil } return ABIEncoder.encode(types: inputs, values: parameters) } @@ -203,7 +203,7 @@ extension ABI.Element.Function { /// Encode parameters of a given contract method /// - Parameter parameters: Parameters to pass to Ethereum contract /// - Returns: Encoded data - public func encodeParameters(_ parameters: [AnyObject]) -> Data? { + public func encodeParameters(_ parameters: [Any]) -> Data? { guard parameters.count == inputs.count, let data = ABIEncoder.encode(types: inputs, values: parameters) else { return nil } return methodEncoding + data diff --git a/Sources/Web3Core/Contract/ContractProtocol.swift b/Sources/Web3Core/Contract/ContractProtocol.swift index 9302cbc8e..33e25884d 100755 --- a/Sources/Web3Core/Contract/ContractProtocol.swift +++ b/Sources/Web3Core/Contract/ContractProtocol.swift @@ -35,7 +35,7 @@ import BigInt /// let inputArgsTypes: [ABI.Element.InOut] = [.init(name: "firstArgument", type: ABI.Element.ParameterType.string), /// .init(name: "secondArgument", type: ABI.Element.ParameterType.uint(bits: 256))] /// let constructor = ABI.Element.Constructor(inputs: inputArgsTypes, constant: false, payable: payable) -/// let constructorArguments = ["This is the array of constructor arguments", 10_000] as [AnyObject] +/// let constructorArguments = ["This is the array of constructor arguments", 10_000] /// /// contract.deploy(bytecode: smartContractBytecode, /// constructor: constructor, @@ -48,7 +48,7 @@ import BigInt /// /// ```swift /// let contract = EthereumContract(abiString) -/// let constructorArguments = ["This is the array of constructor arguments", 10_000] as [AnyObject] +/// let constructorArguments = ["This is the array of constructor arguments", 10_000] /// /// contract.deploy(bytecode: smartContractBytecode, /// constructor: contract.constructor, @@ -121,7 +121,7 @@ public protocol ContractProtocol { /// - Returns: Encoded data for a given parameters, which is should be assigned to ``CodableTransaction.data`` property func deploy(bytecode: Data, constructor: ABI.Element.Constructor?, - parameters: [AnyObject]?, + parameters: [Any]?, extraData: Data?) -> Data? /// Creates function call transaction with data set as `method` encoded with given `parameters`. @@ -134,7 +134,7 @@ public protocol ContractProtocol { /// - parameters: method input arguments; /// - extraData: additional data to append at the end of `transaction.data` field; /// - Returns: transaction object if `method` was found and `parameters` were successfully encoded. - func method(_ method: String, parameters: [AnyObject], extraData: Data?) -> Data? + func method(_ method: String, parameters: [Any], extraData: Data?) -> Data? /// Decode output data of a function. /// - Parameters: @@ -190,7 +190,7 @@ extension ContractProtocol { /// See ``ContractProtocol/deploy(bytecode:constructor:parameters:extraData:)`` for details. func deploy(_ bytecode: Data, constructor: ABI.Element.Constructor? = nil, - parameters: [AnyObject]? = nil, + parameters: [Any]? = nil, extraData: Data? = nil) -> Data? { deploy(bytecode: bytecode, constructor: constructor, @@ -203,7 +203,7 @@ extension ContractProtocol { /// /// See ``ContractProtocol/method(_:parameters:extraData:)`` for details. func method(_ method: String = "fallback", - parameters: [AnyObject]? = nil, + parameters: [Any]? = nil, extraData: Data? = nil) -> Data? { self.method(method, parameters: parameters ?? [], extraData: extraData) } @@ -222,7 +222,7 @@ extension DefaultContractProtocol { // MARK: Writing Data flow public func deploy(bytecode: Data, constructor: ABI.Element.Constructor?, - parameters: [AnyObject]?, + parameters: [Any]?, extraData: Data?) -> Data? { var fullData = bytecode @@ -258,7 +258,7 @@ extension DefaultContractProtocol { /// - data: parameters + extraData /// - params: EthereumParameters with no contract method call encoded data. public func method(_ method: String, - parameters: [AnyObject], + parameters: [Any], extraData: Data?) -> Data? { // MARK: - Encoding ABI Data flow if method == "fallback" { diff --git a/Sources/Web3Core/EthereumABI/ABIDecoding.swift b/Sources/Web3Core/EthereumABI/ABIDecoding.swift index 7dad9179f..adcb77b09 100755 --- a/Sources/Web3Core/EthereumABI/ABIDecoding.swift +++ b/Sources/Web3Core/EthereumABI/ABIDecoding.swift @@ -9,15 +9,15 @@ import BigInt public struct ABIDecoder { } extension ABIDecoder { - public static func decode(types: [ABI.Element.InOut], data: Data) -> [AnyObject]? { + public static func decode(types: [ABI.Element.InOut], data: Data) -> [Any]? { let params = types.compactMap { el -> ABI.Element.ParameterType in return el.type } return decode(types: params, data: data) } - public static func decode(types: [ABI.Element.ParameterType], data: Data) -> [AnyObject]? { - var toReturn = [AnyObject]() + public static func decode(types: [ABI.Element.ParameterType], data: Data) -> [Any]? { + var toReturn = [Any]() var consumed: UInt64 = 0 for i in 0 ..< types.count { let (v, c) = decodeSingleType(type: types[i], data: data, pointer: consumed) @@ -29,7 +29,7 @@ extension ABIDecoder { return toReturn } - public static func decodeSingleType(type: ABI.Element.ParameterType, data: Data, pointer: UInt64 = 0) -> (value: AnyObject?, bytesConsumed: UInt64?) { + public static func decodeSingleType(type: ABI.Element.ParameterType, data: Data, pointer: UInt64 = 0) -> (value: Any?, bytesConsumed: UInt64?) { let (elData, nextPtr) = followTheData(type: type, data: data, pointer: pointer) guard let elementItself = elData, let nextElementPointer = nextPtr else { return (nil, nil) @@ -40,18 +40,18 @@ extension ABIDecoder { let mod = BigUInt(1) << bits let dataSlice = elementItself[0 ..< 32] let v = BigUInt(dataSlice) % mod - return (v as AnyObject, type.memoryUsage) + return (v, type.memoryUsage) case .int(let bits): guard elementItself.count >= 32 else {break} let mod = BigInt(1) << bits let dataSlice = elementItself[0 ..< 32] let v = BigInt.fromTwosComplement(data: dataSlice) % mod - return (v as AnyObject, type.memoryUsage) + return (v, type.memoryUsage) case .address: guard elementItself.count >= 32 else {break} let dataSlice = elementItself[12 ..< 32] let address = EthereumAddress(dataSlice) - return (address as AnyObject, type.memoryUsage) + return (address, type.memoryUsage) case .bool: guard elementItself.count >= 32 else {break} let dataSlice = elementItself[0 ..< 32] @@ -60,17 +60,17 @@ extension ABIDecoder { v == BigUInt(32) || v == BigUInt(28) || v == BigUInt(1) { - return (true as AnyObject, type.memoryUsage) + return (true, type.memoryUsage) } else if v == BigUInt(35) || v == BigUInt(31) || v == BigUInt(27) || v == BigUInt(0) { - return (false as AnyObject, type.memoryUsage) + return (false, type.memoryUsage) } case .bytes(let length): guard elementItself.count >= 32 else {break} let dataSlice = elementItself[0 ..< length] - return (dataSlice as AnyObject, type.memoryUsage) + return (dataSlice, type.memoryUsage) case .string: guard elementItself.count >= 32 else {break} var dataSlice = elementItself[0 ..< 32] @@ -78,14 +78,14 @@ extension ABIDecoder { guard elementItself.count >= 32+length else {break} dataSlice = elementItself[32 ..< 32 + length] guard let string = String(data: dataSlice, encoding: .utf8) else {break} - return (string as AnyObject, type.memoryUsage) + return (string, type.memoryUsage) case .dynamicBytes: guard elementItself.count >= 32 else {break} var dataSlice = elementItself[0 ..< 32] let length = UInt64(BigUInt(dataSlice)) guard elementItself.count >= 32+length else {break} dataSlice = elementItself[32 ..< 32 + length] - return (dataSlice as AnyObject, nextElementPointer) + return (dataSlice, nextElementPointer) case .array(type: let subType, length: let length): switch type.arraySize { case .dynamicSize: @@ -97,14 +97,14 @@ extension ABIDecoder { guard elementItself.count >= 32 + subType.memoryUsage*length else {break} dataSlice = elementItself[32 ..< 32 + subType.memoryUsage*length] var subpointer: UInt64 = 32 - var toReturn = [AnyObject]() + var toReturn = [Any]() for _ in 0 ..< length { let (v, c) = decodeSingleType(type: subType, data: elementItself, pointer: subpointer) guard let valueUnwrapped = v, let consumedUnwrapped = c else {break} toReturn.append(valueUnwrapped) subpointer = subpointer + consumedUnwrapped } - return (toReturn as AnyObject, type.memoryUsage) + return (toReturn, type.memoryUsage) } else { // in principle is true for tuple[], so will work for string[] too guard elementItself.count >= 32 else {break} @@ -113,7 +113,7 @@ extension ABIDecoder { guard elementItself.count >= 32 else {break} dataSlice = Data(elementItself[32 ..< elementItself.count]) var subpointer: UInt64 = 0 - var toReturn = [AnyObject]() + var toReturn = [Any]() for _ in 0 ..< length { let (v, c) = decodeSingleType(type: subType, data: dataSlice, pointer: subpointer) guard let valueUnwrapped = v, let consumedUnwrapped = c else {break} @@ -124,11 +124,11 @@ extension ABIDecoder { subpointer = consumedUnwrapped // need to go by nextElementPointer } } - return (toReturn as AnyObject, nextElementPointer) + return (toReturn, nextElementPointer) } case .staticSize(let staticLength): guard length == staticLength else {break} - var toReturn = [AnyObject]() + var toReturn = [Any]() var consumed: UInt64 = 0 for _ in 0 ..< length { let (v, c) = decodeSingleType(type: subType, data: elementItself, pointer: consumed) @@ -137,15 +137,15 @@ extension ABIDecoder { consumed = consumed + consumedUnwrapped } if subType.isStatic { - return (toReturn as AnyObject, consumed) + return (toReturn, consumed) } else { - return (toReturn as AnyObject, nextElementPointer) + return (toReturn, nextElementPointer) } case .notArray: break } case .tuple(types: let subTypes): - var toReturn = [AnyObject]() + var toReturn = [Any]() var consumed: UInt64 = 0 for i in 0 ..< subTypes.count { let (v, c) = decodeSingleType(type: subTypes[i], data: elementItself, pointer: consumed) @@ -173,14 +173,14 @@ extension ABIDecoder { } } if type.isStatic { - return (toReturn as AnyObject, consumed) + return (toReturn, consumed) } else { - return (toReturn as AnyObject, nextElementPointer) + return (toReturn, nextElementPointer) } case .function: guard elementItself.count >= 32 else {break} let dataSlice = elementItself[8 ..< 32] - return (dataSlice as AnyObject, type.memoryUsage) + return (dataSlice, type.memoryUsage) } return (nil, nil) } @@ -236,7 +236,7 @@ extension ABIDecoder { return inp.type } guard logs.count == indexedInputs.count + 1 else {return nil} - var indexedValues = [AnyObject]() + var indexedValues = [Any]() for i in 0 ..< indexedInputs.count { let data = logs[i+1] let input = indexedInputs[i] diff --git a/Sources/Web3Core/EthereumABI/ABIElements.swift b/Sources/Web3Core/EthereumABI/ABIElements.swift index aadf61b9a..6a1e80716 100755 --- a/Sources/Web3Core/EthereumABI/ABIElements.swift +++ b/Sources/Web3Core/EthereumABI/ABIElements.swift @@ -174,7 +174,7 @@ public extension ABI { // MARK: - Function parameters encoding extension ABI.Element { - public func encodeParameters(_ parameters: [AnyObject]) -> Data? { + public func encodeParameters(_ parameters: [Any]) -> Data? { switch self { case .constructor(let constructor): return constructor.encodeParameters(parameters) @@ -193,7 +193,7 @@ extension ABI.Element { } extension ABI.Element.Constructor { - public func encodeParameters(_ parameters: [AnyObject]) -> Data? { + public func encodeParameters(_ parameters: [Any]) -> Data? { guard parameters.count == inputs.count else { return nil } return ABIEncoder.encode(types: inputs, values: parameters) } @@ -204,7 +204,7 @@ extension ABI.Element.Function { /// Encode parameters of a given contract method /// - Parameter parameters: Parameters to pass to Ethereum contract /// - Returns: Encoded data - public func encodeParameters(_ parameters: [AnyObject]) -> Data? { + public func encodeParameters(_ parameters: [Any]) -> Data? { guard parameters.count == inputs.count, let data = ABIEncoder.encode(types: inputs, values: parameters) else { return nil } return methodEncoding + data diff --git a/Sources/Web3Core/EthereumABI/ABIEncoding.swift b/Sources/Web3Core/EthereumABI/ABIEncoding.swift index f62177ec8..7a73c2477 100755 --- a/Sources/Web3Core/EthereumABI/ABIEncoding.swift +++ b/Sources/Web3Core/EthereumABI/ABIEncoding.swift @@ -12,7 +12,7 @@ public struct ABIEncoder { /// All negative values will return `nil`. /// - Parameter value: an arbitrary object. /// - Returns: converted value or `nil` if types is not support or initialization failed. - public static func convertToBigUInt(_ value: AnyObject) -> BigUInt? { + public static func convertToBigUInt(_ value: Any) -> BigUInt? { switch value { case let v as BigUInt: return v @@ -60,7 +60,7 @@ public struct ABIEncoder { /// Supported types are `BigUInt`, `BigInt`, `String` as hex and decimal, `UInt[8-64]`, `Int[8-64]` and `Data`. /// - Parameter value: an arbitrary object. /// - Returns: converted value or `nil` if types is not support or initialization failed. - public static func convertToBigInt(_ value: AnyObject) -> BigInt? { + public static func convertToBigInt(_ value: Any) -> BigInt? { switch value { case let v as BigUInt: return BigInt(v) @@ -102,7 +102,7 @@ public struct ABIEncoder { /// Note: if `String` has `0x` prefix an attempt to interpret it as a hexadecimal number will take place. Otherwise, UTF-8 bytes are returned. /// - Parameter value: any object. /// - Returns: `Data` representation of an object ready for ABI encoding. - public static func convertToData(_ value: AnyObject) -> Data? { + public static func convertToData(_ value: Any) -> Data? { switch value { case let d as Data: return d @@ -137,7 +137,7 @@ public struct ABIEncoder { /// - Returns: ABI encoded data, e.g. function call parameters. Returns `nil` if: /// - `types.count != values.count`; /// - encoding of at least one value has failed (e.g. type mismatch). - public static func encode(types: [ABI.Element.InOut], values: [AnyObject]) -> Data? { + public static func encode(types: [ABI.Element.InOut], values: [Any]) -> Data? { guard types.count == values.count else {return nil} let params = types.compactMap { el -> ABI.Element.ParameterType in return el.type @@ -153,7 +153,7 @@ public struct ABIEncoder { /// - Returns: ABI encoded data, e.g. function call parameters. Returns `nil` if: /// - `types.count != values.count`; /// - encoding of at least one value has failed (e.g. type mismatch). - public static func encode(types: [ABI.Element.ParameterType], values: [AnyObject]) -> Data? { + public static func encode(types: [ABI.Element.ParameterType], values: [Any]) -> Data? { guard types.count == values.count else {return nil} var tails = [Data]() var heads = [Data]() @@ -195,7 +195,7 @@ public struct ABIEncoder { /// /// **It does not add the data offset for dynamic types!!** To return single value **with data offset** use the following instead: /// ```swift - /// ABIEncoder.encode(types: [type], values: [value] as [AnyObject]) + /// ABIEncoder.encode(types: [type], values: [value]) /// ``` /// Almost identical to use of `web3.eth.abi.encodeParameter` in web3.js. /// Calling `web3.eth.abi.encodeParameter('string','test')` in web3.js will return the following: @@ -204,7 +204,7 @@ public struct ABIEncoder { /// 0000000000000000000000000000000000000000000000000000000000000004 /// 7465737400000000000000000000000000000000000000000000000000000000 /// ``` - /// but calling `ABIEncoder.encodeSingleType(type: .string, value: "test" as AnyObject)` will return: + /// but calling `ABIEncoder.encodeSingleType(type: .string, value: "test")` will return: /// ``` /// 0x0000000000000000000000000000000000000000000000000000000000000004 /// 7465737400000000000000000000000000000000000000000000000000000000 @@ -215,7 +215,7 @@ public struct ABIEncoder { /// - Returns: ABI encoded data, e.g. function call parameters. Returns `nil` if: /// - `types.count != values.count`; /// - encoding has failed (e.g. type mismatch). - public static func encodeSingleType(type: ABI.Element.ParameterType, value: AnyObject) -> Data? { + public static func encodeSingleType(type: ABI.Element.ParameterType, value: Any) -> Data? { switch type { case .uint: if let biguint = convertToBigUInt(value) { @@ -283,7 +283,7 @@ public struct ABIEncoder { switch type.arraySize { case .dynamicSize: guard length == 0 else {break} - guard let val = value as? [AnyObject] else {break} + guard let val = value as? [Any] else {break} guard let lengthEncoding = BigUInt(val.count).abiEncode(bits: 256) else {break} if subType.isStatic { // work in a previous context @@ -330,7 +330,7 @@ public struct ABIEncoder { } case .staticSize(let staticLength): guard staticLength != 0 else {break} - guard let val = value as? [AnyObject] else {break} + guard let val = value as? [Any] else {break} guard staticLength == val.count else {break} if subType.isStatic { // work in a previous context @@ -375,7 +375,7 @@ public struct ABIEncoder { case .tuple(types: let subTypes): var tails = [Data]() var heads = [Data]() - guard let val = value as? [AnyObject] else {break} + guard let val = value as? [Any] else {break} for i in 0 ..< subTypes.count { let enc = encodeSingleType(type: subTypes[i], value: val[i]) guard let encoding = enc else {return nil} @@ -444,7 +444,7 @@ public extension ABIEncoder { } } - /// Using AnyObject any number can be represented as Bool and Bool can be represented as number. + /// Using Any any number can be represented as Bool and Bool can be represented as number. /// That will lead to invalid hash output. DO NOT USE THIS FUNCTION. /// This function will exist to intentionally throw an error that will raise awareness that the hash output can be potentially, /// and most likely will be, wrong. @@ -471,26 +471,26 @@ public extension ABIEncoder { if let v = value as? Bool { return Data(v ? [0b1] : [0b0]) } else if let v = value as? Int { - return ABIEncoder.convertToData(BigInt(exactly: v)?.abiEncode(bits: 256)! as AnyObject)! + return ABIEncoder.convertToData(BigInt(exactly: v)?.abiEncode(bits: 256)!)! } else if let v = value as? Int8 { - return ABIEncoder.convertToData(BigInt(exactly: v)?.abiEncode(bits: 8) as AnyObject)! + return ABIEncoder.convertToData(BigInt(exactly: v)?.abiEncode(bits: 8))! } else if let v = value as? Int16 { - return ABIEncoder.convertToData(BigInt(exactly: v)?.abiEncode(bits: 16)! as AnyObject)! + return ABIEncoder.convertToData(BigInt(exactly: v)?.abiEncode(bits: 16)!)! } else if let v = value as? Int32 { - return ABIEncoder.convertToData(BigInt(exactly: v)?.abiEncode(bits: 32)! as AnyObject)! + return ABIEncoder.convertToData(BigInt(exactly: v)?.abiEncode(bits: 32)!)! } else if let v = value as? Int64 { - return ABIEncoder.convertToData(BigInt(exactly: v)?.abiEncode(bits: 64)! as AnyObject)! + return ABIEncoder.convertToData(BigInt(exactly: v)?.abiEncode(bits: 64)!)! } else if let v = value as? UInt { - return ABIEncoder.convertToData(BigUInt(exactly: v)?.abiEncode(bits: 256)! as AnyObject)! + return ABIEncoder.convertToData(BigUInt(exactly: v)?.abiEncode(bits: 256)!)! } else if let v = value as? UInt8 { - return ABIEncoder.convertToData(BigUInt(exactly: v)?.abiEncode(bits: 8)! as AnyObject)! + return ABIEncoder.convertToData(BigUInt(exactly: v)?.abiEncode(bits: 8)!)! } else if let v = value as? UInt16 { - return ABIEncoder.convertToData(BigUInt(exactly: v)?.abiEncode(bits: 16)! as AnyObject)! + return ABIEncoder.convertToData(BigUInt(exactly: v)?.abiEncode(bits: 16)!)! } else if let v = value as? UInt32 { - return ABIEncoder.convertToData(BigUInt(exactly: v)?.abiEncode(bits: 32)! as AnyObject)! + return ABIEncoder.convertToData(BigUInt(exactly: v)?.abiEncode(bits: 32)!)! } else if let v = value as? UInt64 { - return ABIEncoder.convertToData(BigUInt(exactly: v)?.abiEncode(bits: 64)! as AnyObject)! - } else if let data = ABIEncoder.convertToData(value as AnyObject) { + return ABIEncoder.convertToData(BigUInt(exactly: v)?.abiEncode(bits: 64)!)! + } else if let data = ABIEncoder.convertToData(value) { return data } throw Web3Error.inputError(desc: "SoliditySha3: `abiEncode` accepts an Int/UInt (any of 8, 16, 32, 64 bits long), decimal or hexadecimal string, Bool, Data, [UInt8], EthereumAddress, [IntegerLiteralType], BigInt or BigUInt instance. Given value is of type \(type(of: value)).") diff --git a/Sources/Web3Core/RLP/RLP.swift b/Sources/Web3Core/RLP/RLP.swift index 588432db7..8200401c2 100755 --- a/Sources/Web3Core/RLP/RLP.swift +++ b/Sources/Web3Core/RLP/RLP.swift @@ -18,7 +18,7 @@ public struct RLP { static var length56 = BigUInt(UInt(56)) static var lengthMax = (BigUInt(UInt(1)) << 256) - internal static func encode(_ element: AnyObject) -> Data? { + internal static func encode(_ element: Any) -> Data? { if let string = element as? String { return encode(string) @@ -112,14 +112,14 @@ public struct RLP { return encoded.bytes[0] } - // FIXME: Make encode generic to avoid casting it's argument to [AnyObject] - internal static func encode(_ elements: [AnyObject]) -> Data? { + // FIXME: Make encode generic to avoid casting it's argument to [Any] + internal static func encode(_ elements: [Any]) -> Data? { var encodedData = Data() for e in elements { if let encoded = encode(e) { encodedData.append(encoded) } else { - guard let asArray = e as? [AnyObject] else {return nil} + guard let asArray = e as? [Any] else {return nil} guard let encoded = encode(asArray) else {return nil} encodedData.append(encoded) } diff --git a/Sources/Web3Core/Transaction/Envelope/EIP1559Envelope.swift b/Sources/Web3Core/Transaction/Envelope/EIP1559Envelope.swift index 673af57ce..18eb2cf26 100644 --- a/Sources/Web3Core/Transaction/Envelope/EIP1559Envelope.swift +++ b/Sources/Web3Core/Transaction/Envelope/EIP1559Envelope.swift @@ -245,14 +245,14 @@ extension EIP1559Envelope { // } public func encode(for type: EncodeType = .transaction) -> Data? { - let fields: [AnyObject] - let list = accessList.map { $0.encodeAsList() as AnyObject } + let fields: [Any] + let list = accessList.map { $0.encodeAsList() } switch type { case .transaction: - fields = [chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to.addressData, value, data, list, v, r, s] as [AnyObject] + fields = [chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to.addressData, value, data, list, v, r, s] case .signature: - fields = [chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to.addressData, value, data, list] as [AnyObject] + fields = [chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to.addressData, value, data, list] } guard var result = RLP.encode(fields) else { return nil } result.insert(UInt8(self.type.rawValue), at: 0) diff --git a/Sources/Web3Core/Transaction/Envelope/EIP2930Envelope.swift b/Sources/Web3Core/Transaction/Envelope/EIP2930Envelope.swift index fe4bcfb46..d0f3a2c58 100644 --- a/Sources/Web3Core/Transaction/Envelope/EIP2930Envelope.swift +++ b/Sources/Web3Core/Transaction/Envelope/EIP2930Envelope.swift @@ -206,14 +206,14 @@ extension EIP2930Envelope { } public func encode(for type: EncodeType = .transaction) -> Data? { - let fields: [AnyObject] - let list = accessList.map { $0.encodeAsList() as AnyObject } + let fields: [Any] + let list = accessList.map { $0.encodeAsList() } switch type { case .transaction: - fields = [chainID, nonce, gasPrice, gasLimit, to.addressData, value, data, list, v, r, s] as [AnyObject] + fields = [chainID, nonce, gasPrice, gasLimit, to.addressData, value, data, list, v, r, s] case .signature: - fields = [chainID, nonce, gasPrice, gasLimit, to.addressData, value, data, list] as [AnyObject] + fields = [chainID, nonce, gasPrice, gasLimit, to.addressData, value, data, list] } guard var result = RLP.encode(fields) else { return nil } result.insert(UInt8(self.type.rawValue), at: 0) @@ -310,7 +310,7 @@ public struct AccessListEntry: CustomStringConvertible, Codable { } } - public func encodeAsList() -> [AnyObject]? { + public func encodeAsList() -> [Any]? { var storage: [Data] = [] for key in storageKeys { @@ -318,7 +318,7 @@ public struct AccessListEntry: CustomStringConvertible, Codable { storage.append(keyData) } - return [address.address as AnyObject, storage as AnyObject] + return [address.address, storage] } // FIXME: THIS NOT WORKING!!! diff --git a/Sources/Web3Core/Transaction/Envelope/LegacyEnvelope.swift b/Sources/Web3Core/Transaction/Envelope/LegacyEnvelope.swift index b1c2c7e4c..f38a69ecc 100644 --- a/Sources/Web3Core/Transaction/Envelope/LegacyEnvelope.swift +++ b/Sources/Web3Core/Transaction/Envelope/LegacyEnvelope.swift @@ -192,15 +192,15 @@ extension LegacyEnvelope { // } public func encode(for type: EncodeType = .transaction) -> Data? { - let fields: [AnyObject] + let fields: [Any] switch type { case .transaction: - fields = [nonce, gasPrice, gasLimit, to.addressData, value, data, v, r, s] as [AnyObject] + fields = [nonce, gasPrice, gasLimit, to.addressData, value, data, v, r, s] case .signature: if let chainID = chainID, chainID != 0 { - fields = [nonce, gasPrice, gasLimit, to.addressData, value, data, chainID, BigUInt(0), BigUInt(0)] as [AnyObject] + fields = [nonce, gasPrice, gasLimit, to.addressData, value, data, chainID, BigUInt(0), BigUInt(0)] } else { - fields = [nonce, gasPrice, gasLimit, to.addressData, value, data] as [AnyObject] + fields = [nonce, gasPrice, gasLimit, to.addressData, value, data] } } return RLP.encode(fields) diff --git a/Sources/web3swift/Browser/browser.js b/Sources/web3swift/Browser/browser.js index 6f7d8ea26..88b5c8e4a 100644 --- a/Sources/web3swift/Browser/browser.js +++ b/Sources/web3swift/Browser/browser.js @@ -5379,7 +5379,7 @@ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. * The iteratee must complete with a boolean value as its result. * Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called as soon as any + * @param {Function} [callback] - A callback which is called as soon * iteratee returns `true`, or after all the `iteratee` functions have finished. * Result will be the first item in the array that passes the truth test * (iteratee) or the value `undefined` if none passed. Invoked with @@ -5412,7 +5412,7 @@ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. * The iteratee must complete with a boolean value as its result. * Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called as soon as any + * @param {Function} [callback] - A callback which is called as soon * iteratee returns `true`, or after all the `iteratee` functions have finished. * Result will be the first item in the array that passes the truth test * (iteratee) or the value `undefined` if none passed. Invoked with @@ -5434,7 +5434,7 @@ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. * The iteratee must complete with a boolean value as its result. * Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called as soon as any + * @param {Function} [callback] - A callback which is called as soon * iteratee returns `true`, or after all the `iteratee` functions have finished. * Result will be the first item in the array that passes the truth test * (iteratee) or the value `undefined` if none passed. Invoked with @@ -7297,7 +7297,7 @@ * in the collections in parallel. * The iteratee should complete with a boolean `result` value. * Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called as soon as any + * @param {Function} [callback] - A callback which is called as soon * iteratee returns `true`, or after all the iteratee functions have finished. * Result will be either `true` or `false` depending on the values of the async * tests. Invoked with (err, result). @@ -7329,7 +7329,7 @@ * in the collections in parallel. * The iteratee should complete with a boolean `result` value. * Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called as soon as any + * @param {Function} [callback] - A callback which is called as soon * iteratee returns `true`, or after all the iteratee functions have finished. * Result will be either `true` or `false` depending on the values of the async * tests. Invoked with (err, result). @@ -7351,7 +7351,7 @@ * in the collections in series. * The iteratee should complete with a boolean `result` value. * Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called as soon as any + * @param {Function} [callback] - A callback which is called as soon * iteratee returns `true`, or after all the iteratee functions have finished. * Result will be either `true` or `false` depending on the values of the async * tests. Invoked with (err, result). @@ -68348,4 +68348,4 @@ //# sourceURL=/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy/wk.bridge.js },{}]},{},[1]); - \ No newline at end of file + diff --git a/Sources/web3swift/Operations/ReadOperation.swift b/Sources/web3swift/Operations/ReadOperation.swift index 937ab2b14..04eb275bb 100755 --- a/Sources/web3swift/Operations/ReadOperation.swift +++ b/Sources/web3swift/Operations/ReadOperation.swift @@ -42,7 +42,7 @@ public class ReadOperation { let data: Data = try await self.web3.eth.callTransaction(transaction) if self.method == "fallback" { let resultHex = data.toHexString().addHexPrefix() - return ["result": resultHex as Any] + return ["result": resultHex] } guard let decodedData = self.contract.decodeReturnData(self.method, data: data) else { throw Web3Error.processingError(desc: "Can not decode returned parameters") diff --git a/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift b/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift index 2ddb502a3..c03245a53 100644 --- a/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift +++ b/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift @@ -71,7 +71,7 @@ public class ERC1155: IERC1155 { guard contract.contract.address != nil else {return} self.transaction.callOnBlock = .latest - guard let tokenIdPromise = try await contract.createReadOperation("id", parameters: [] as [AnyObject], extraData: Data())?.callContractMethod() else {return} + guard let tokenIdPromise = try await contract.createReadOperation("id", parameters: [], extraData: Data())?.callContractMethod() else {return} guard let tokenId = tokenIdPromise["0"] as? BigUInt else {return} self._tokenId = tokenId @@ -84,7 +84,7 @@ public class ERC1155: IERC1155 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, id, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, id, value, data] )! return tx } @@ -94,7 +94,7 @@ public class ERC1155: IERC1155 { self.transaction.to = self.address let tx = contract - .createWriteOperation("safeBatchTransferFrom", parameters: [originalOwner, to, ids, values, data] as [AnyObject] )! + .createWriteOperation("safeBatchTransferFrom", parameters: [originalOwner, to, ids, values, data] )! return tx } @@ -102,12 +102,12 @@ public class ERC1155: IERC1155 { let contract = self.contract self.transaction.callOnBlock = .latest let result = try await contract - .createReadOperation("balanceOf", parameters: [account, id] as [AnyObject], extraData: Data() )! + .createReadOperation("balanceOf", parameters: [account, id], extraData: Data() )! .callContractMethod() /* let result = try await contract - .prepareToRead("balanceOf", parameters: [account, id] as [AnyObject], extraData: Data() )! + .prepareToRead("balanceOf", parameters: [account, id], extraData: Data() )! .execute() .decodeData() @@ -121,14 +121,14 @@ public class ERC1155: IERC1155 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setApprovalForAll", parameters: [user, approved, scope] as [AnyObject] )! + let tx = contract.createWriteOperation("setApprovalForAll", parameters: [user, approved, scope] )! return tx } public func isApprovedForAll(owner: EthereumAddress, operator user: EthereumAddress, scope: Data) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("isApprovedForAll", parameters: [owner, user, scope] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("isApprovedForAll", parameters: [owner, user, scope], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -136,7 +136,7 @@ public class ERC1155: IERC1155 { public func supportsInterface(interfaceID: String) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } diff --git a/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift b/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift index f3570578b..766a08c76 100644 --- a/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift +++ b/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift @@ -91,7 +91,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { public func getBalance(account: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOf", parameters: [account] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("balanceOf", parameters: [account], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -99,7 +99,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -121,7 +121,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! return tx } @@ -143,7 +143,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! return tx } @@ -165,7 +165,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! return tx } @@ -187,14 +187,14 @@ public class ERC1376: IERC1376, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] as [AnyObject] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! return tx } public func totalSupply() async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("totalSupply", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("totalSupply", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -220,7 +220,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, eValue, nValue] as [AnyObject] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, eValue, nValue] )! return tx } @@ -242,7 +242,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("increaseAllowance", parameters: [spender, amount] as [AnyObject] )! + let tx = contract.createWriteOperation("increaseAllowance", parameters: [spender, amount] )! return tx } @@ -264,7 +264,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("decreaseAllowance", parameters: [spender, amount, strict] as [AnyObject] )! + let tx = contract.createWriteOperation("decreaseAllowance", parameters: [spender, amount, strict] )! return tx } @@ -273,14 +273,14 @@ public class ERC1376: IERC1376, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setERC20ApproveChecking", parameters: [approveChecking] as [AnyObject] )! + let tx = contract.createWriteOperation("setERC20ApproveChecking", parameters: [approveChecking] )! return tx } func spendableAllowance(owner: EthereumAddress, spender: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("spendableAllowance", parameters: [owner, spender] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("spendableAllowance", parameters: [owner, spender], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -302,7 +302,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(data, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [value] as [AnyObject] )! + let tx = contract.createWriteOperation("transfer", parameters: [value] )! return tx } @@ -323,14 +323,14 @@ public class ERC1376: IERC1376, ERC20BaseProperties { guard let amount = Utilities.parseToBigUInt(value, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferAndCall", parameters: [to, amount, data] as [AnyObject] )! + let tx = contract.createWriteOperation("transferAndCall", parameters: [to, amount, data] )! return tx } func nonceOf(owner: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("nonceOf", parameters: [owner] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("nonceOf", parameters: [owner], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -341,7 +341,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { self.transaction.to = self.address self.transaction.callOnBlock = .latest - let tx = contract.createWriteOperation("increaseNonce", parameters: [] as [AnyObject] )! + let tx = contract.createWriteOperation("increaseNonce", parameters: [] )! return tx } @@ -365,14 +365,14 @@ public class ERC1376: IERC1376, ERC20BaseProperties { let modeValue = mode.rawValue - let tx = contract.createWriteOperation("delegateTransferAndCall", parameters: [nonce, fee, gasAmount, to, amount, data, modeValue, v, r, s] as [AnyObject] )! + let tx = contract.createWriteOperation("delegateTransferAndCall", parameters: [nonce, fee, gasAmount, to, amount, data, modeValue, v, r, s] )! return tx } func directDebit(debtor: EthereumAddress, receiver: EthereumAddress) async throws -> DirectDebit { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("directDebit", parameters: [debtor, receiver] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("directDebit", parameters: [debtor, receiver], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? DirectDebit else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -382,7 +382,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setupDirectDebit", parameters: [receiver, info] as [AnyObject] )! + let tx = contract.createWriteOperation("setupDirectDebit", parameters: [receiver, info] )! return tx } @@ -391,7 +391,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("terminateDirectDebit", parameters: [receiver] as [AnyObject] )! + let tx = contract.createWriteOperation("terminateDirectDebit", parameters: [receiver] )! return tx } @@ -400,7 +400,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("withdrawDirectDebit", parameters: [debtor] as [AnyObject] )! + let tx = contract.createWriteOperation("withdrawDirectDebit", parameters: [debtor] )! return tx } @@ -409,7 +409,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("withdrawDirectDebit", parameters: [debtors, strict] as [AnyObject] )! + let tx = contract.createWriteOperation("withdrawDirectDebit", parameters: [debtors, strict] )! return tx } } diff --git a/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift b/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift index 98d98360f..a700d0fbf 100644 --- a/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift +++ b/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift @@ -88,7 +88,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { public func getBalance(account: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOf", parameters: [account] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("balanceOf", parameters: [account], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -96,7 +96,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -118,7 +118,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! return tx } @@ -140,7 +140,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! return tx } @@ -162,14 +162,14 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! return tx } public func totalSupply() async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("totalSupply", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("totalSupply", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -191,7 +191,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] as [AnyObject] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! return tx } @@ -199,7 +199,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { public func getDocument(name: Data) async throws -> (String, Data) { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("getDocument", parameters: [name] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("getDocument", parameters: [name], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? (String, Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -209,14 +209,14 @@ public class ERC1400: IERC1400, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setDocument", parameters: [name, uri, documentHash] as [AnyObject] )! + let tx = contract.createWriteOperation("setDocument", parameters: [name, uri, documentHash] )! return tx } public func balanceOfByPartition(partition: Data, tokenHolder: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOfByPartition", parameters: [partition, tokenHolder] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("balanceOfByPartition", parameters: [partition, tokenHolder], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -224,7 +224,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { public func partitionsOf(tokenHolder: EthereumAddress) async throws -> [Data] { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("partitionsOf", parameters: [tokenHolder] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("partitionsOf", parameters: [tokenHolder], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? [Data] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -247,7 +247,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferWithData", parameters: [to, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("transferWithData", parameters: [to, value, data] )! return tx } @@ -269,7 +269,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFromWithData", parameters: [originalOwner, to, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("transferFromWithData", parameters: [originalOwner, to, value, data] )! return tx } @@ -291,7 +291,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferByPartition", parameters: [partition, to, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("transferByPartition", parameters: [partition, to, value, data] )! return tx } @@ -313,14 +313,14 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("operatorTransferByPartition", parameters: [partition, originalOwner, to, value, data, operatorData] as [AnyObject] )! + let tx = contract.createWriteOperation("operatorTransferByPartition", parameters: [partition, originalOwner, to, value, data, operatorData] )! return tx } public func isControllable() async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("isControllable", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("isControllable", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -343,7 +343,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("controllerTransfer", parameters: [originalOwner, to, value, data, operatorData] as [AnyObject] )! + let tx = contract.createWriteOperation("controllerTransfer", parameters: [originalOwner, to, value, data, operatorData] )! return tx } @@ -365,7 +365,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("controllerRedeem", parameters: [tokenHolder, value, data, operatorData] as [AnyObject] )! + let tx = contract.createWriteOperation("controllerRedeem", parameters: [tokenHolder, value, data, operatorData] )! return tx } @@ -374,7 +374,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("authorizeOperator", parameters: [user] as [AnyObject] )! + let tx = contract.createWriteOperation("authorizeOperator", parameters: [user] )! return tx } @@ -383,7 +383,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("revokeOperator", parameters: [user] as [AnyObject] )! + let tx = contract.createWriteOperation("revokeOperator", parameters: [user] )! return tx } @@ -392,7 +392,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("authorizeOperatorByPartition", parameters: [partition, user] as [AnyObject] )! + let tx = contract.createWriteOperation("authorizeOperatorByPartition", parameters: [partition, user] )! return tx } @@ -401,14 +401,14 @@ public class ERC1400: IERC1400, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("revokeOperatorByPartition", parameters: [partition, user] as [AnyObject] )! + let tx = contract.createWriteOperation("revokeOperatorByPartition", parameters: [partition, user] )! return tx } public func isOperator(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("isOperator", parameters: [user, tokenHolder] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("isOperator", parameters: [user, tokenHolder], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -416,7 +416,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { public func isOperatorForPartition(partition: Data, operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("isOperatorForPartition", parameters: [partition, user, tokenHolder] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("isOperatorForPartition", parameters: [partition, user, tokenHolder], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -424,7 +424,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { public func isIssuable() async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("isIssuable", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("isIssuable", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -447,7 +447,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("issue", parameters: [tokenHolder, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("issue", parameters: [tokenHolder, value, data] )! return tx } @@ -469,7 +469,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("issueByPartition", parameters: [partition, tokenHolder, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("issueByPartition", parameters: [partition, tokenHolder, value, data] )! return tx } @@ -491,7 +491,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("redeem", parameters: [value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("redeem", parameters: [value, data] )! return tx } @@ -513,7 +513,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("redeemFrom", parameters: [tokenHolder, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("redeemFrom", parameters: [tokenHolder, value, data] )! return tx } @@ -535,7 +535,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("redeemByPartition", parameters: [partition, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("redeemByPartition", parameters: [partition, value, data] )! return tx } @@ -557,7 +557,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("operatorRedeemByPartition", parameters: [partition, tokenHolder, value, operatorData] as [AnyObject] )! + let tx = contract.createWriteOperation("operatorRedeemByPartition", parameters: [partition, tokenHolder, value, operatorData] )! return tx } @@ -577,7 +577,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let result = try await contract.createReadOperation("canTransfer", parameters: [to, value, data] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("canTransfer", parameters: [to, value, data], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? ([UInt8], Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -598,7 +598,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, value, data] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, value, data], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? ([UInt8], Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -619,7 +619,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, partition, value, data] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, partition, value, data], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? ([UInt8], Data, Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -629,7 +629,7 @@ extension ERC1400: IERC777 { public func canImplementInterfaceForAddress(interfaceHash: Data, addr: EthereumAddress) async throws -> Data { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("canImplementInterfaceForAddress", parameters: [interfaceHash, addr] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("canImplementInterfaceForAddress", parameters: [interfaceHash, addr], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Data else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -637,7 +637,7 @@ extension ERC1400: IERC777 { public func getInterfaceImplementer(addr: EthereumAddress, interfaceHash: Data) async throws -> EthereumAddress { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("getInterfaceImplementer", parameters: [addr, interfaceHash] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("getInterfaceImplementer", parameters: [addr, interfaceHash], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -647,7 +647,7 @@ extension ERC1400: IERC777 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer] as [AnyObject] )! + let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer] )! return tx } @@ -656,14 +656,14 @@ extension ERC1400: IERC777 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager] as [AnyObject] )! + let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager] )! return tx } public func interfaceHash(interfaceName: String) async throws -> Data { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("interfaceHash", parameters: [interfaceName] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("interfaceHash", parameters: [interfaceName], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Data else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -673,14 +673,14 @@ extension ERC1400: IERC777 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId] as [AnyObject] )! + let tx = contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId] )! return tx } public func supportsInterface(interfaceID: String) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -688,7 +688,7 @@ extension ERC1400: IERC777 { public func getGranularity() async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("granularity", parameters: [] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("granularity", parameters: [], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -696,7 +696,7 @@ extension ERC1400: IERC777 { public func getDefaultOperators() async throws -> [EthereumAddress] { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("defaultOperators", parameters: [] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("defaultOperators", parameters: [], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? [EthereumAddress] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -707,7 +707,7 @@ extension ERC1400: IERC777 { self.transaction.to = self.address self.transaction.callOnBlock = .latest - let tx = contract.createWriteOperation("authorizeOperator", parameters: [user] as [AnyObject] )! + let tx = contract.createWriteOperation("authorizeOperator", parameters: [user] )! return tx } @@ -717,14 +717,14 @@ extension ERC1400: IERC777 { self.transaction.to = self.address self.transaction.callOnBlock = .latest - let tx = contract.createWriteOperation("revokeOperator", parameters: [user] as [AnyObject] )! + let tx = contract.createWriteOperation("revokeOperator", parameters: [user] )! return tx } public func isOperatorFor(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("isOperatorFor", parameters: [user, tokenHolder] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("isOperatorFor", parameters: [user, tokenHolder], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -746,7 +746,7 @@ extension ERC1400: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("send", parameters: [to, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("send", parameters: [to, value, data] )! return tx } @@ -767,7 +767,7 @@ extension ERC1400: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData] as [AnyObject] )! + let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData] )! return tx } @@ -788,7 +788,7 @@ extension ERC1400: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("burn", parameters: [value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("burn", parameters: [value, data] )! return tx } @@ -809,7 +809,7 @@ extension ERC1400: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData] as [AnyObject] )! + let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData] )! return tx } } diff --git a/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift b/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift index 4551cd793..f77011da9 100644 --- a/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift +++ b/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift @@ -66,7 +66,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { public func getBalance(account: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOf", parameters: [account] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("balanceOf", parameters: [account], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -74,7 +74,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -97,7 +97,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! return tx } @@ -120,7 +120,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! return tx } @@ -143,7 +143,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! return tx } @@ -151,7 +151,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("totalSupply", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("totalSupply", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -175,7 +175,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] as [AnyObject] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! return tx } @@ -184,7 +184,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOfByPartition", parameters: [partition, tokenHolder] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("balanceOfByPartition", parameters: [partition, tokenHolder], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -192,7 +192,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { public func partitionsOf(tokenHolder: EthereumAddress) async throws -> [Data] { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("partitionsOf", parameters: [tokenHolder] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("partitionsOf", parameters: [tokenHolder], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? [Data] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -216,7 +216,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferByPartition", parameters: [partition, to, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("transferByPartition", parameters: [partition, to, value, data] )! return tx } @@ -239,7 +239,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("operatorTransferByPartition", parameters: [partition, originalOwner, to, value, data, operatorData] as [AnyObject] )! + let tx = contract.createWriteOperation("operatorTransferByPartition", parameters: [partition, originalOwner, to, value, data, operatorData] )! return tx } @@ -259,7 +259,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, partition, value, data] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, partition, value, data], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? ([UInt8], Data, Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -267,7 +267,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { public func isOperator(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("isOperator", parameters: [user, tokenHolder] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("isOperator", parameters: [user, tokenHolder], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -275,7 +275,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { public func isOperatorForPartition(partition: Data, operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("isOperatorForPartition", parameters: [partition, user, tokenHolder] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("isOperatorForPartition", parameters: [partition, user, tokenHolder], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -286,7 +286,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("authorizeOperator", parameters: [user] as [AnyObject] )! + let tx = contract.createWriteOperation("authorizeOperator", parameters: [user] )! return tx } @@ -296,7 +296,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("revokeOperator", parameters: [user] as [AnyObject] )! + let tx = contract.createWriteOperation("revokeOperator", parameters: [user] )! return tx } @@ -306,7 +306,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("authorizeOperatorByPartition", parameters: [partition, user] as [AnyObject] )! + let tx = contract.createWriteOperation("authorizeOperatorByPartition", parameters: [partition, user] )! return tx } @@ -316,7 +316,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("revokeOperatorByPartition", parameters: [partition, user] as [AnyObject] )! + let tx = contract.createWriteOperation("revokeOperatorByPartition", parameters: [partition, user] )! return tx } @@ -339,7 +339,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("issueByPartition", parameters: [partition, tokenHolder, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("issueByPartition", parameters: [partition, tokenHolder, value, data] )! return tx } @@ -362,7 +362,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("redeemByPartition", parameters: [partition, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("redeemByPartition", parameters: [partition, value, data] )! return tx } @@ -385,7 +385,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("operatorRedeemByPartition", parameters: [partition, tokenHolder, value, operatorData] as [AnyObject] )! + let tx = contract.createWriteOperation("operatorRedeemByPartition", parameters: [partition, tokenHolder, value, operatorData] )! return tx } } @@ -394,7 +394,7 @@ extension ERC1410: IERC777 { public func canImplementInterfaceForAddress(interfaceHash: Data, addr: EthereumAddress) async throws -> Data { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("canImplementInterfaceForAddress", parameters: [interfaceHash, addr] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("canImplementInterfaceForAddress", parameters: [interfaceHash, addr], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Data else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -402,7 +402,7 @@ extension ERC1410: IERC777 { public func getInterfaceImplementer(addr: EthereumAddress, interfaceHash: Data) async throws -> EthereumAddress { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("getInterfaceImplementer", parameters: [addr, interfaceHash] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("getInterfaceImplementer", parameters: [addr, interfaceHash], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -412,7 +412,7 @@ extension ERC1410: IERC777 { self.transaction.from = from - let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer] as [AnyObject] )! + let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer] )! return tx } @@ -421,14 +421,14 @@ extension ERC1410: IERC777 { self.transaction.from = from - let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager] as [AnyObject] )! + let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager] )! return tx } public func interfaceHash(interfaceName: String) async throws -> Data { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("interfaceHash", parameters: [interfaceName] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("interfaceHash", parameters: [interfaceName], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Data else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -438,14 +438,14 @@ extension ERC1410: IERC777 { self.transaction.from = from - let tx = contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId] as [AnyObject] )! + let tx = contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId] )! return tx } public func supportsInterface(interfaceID: String) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -456,7 +456,7 @@ extension ERC1410: IERC777 { self.transaction.from = from self.transaction.callOnBlock = .latest - let tx = contract.createWriteOperation("authorizeOperator", parameters: [user] as [AnyObject] )! + let tx = contract.createWriteOperation("authorizeOperator", parameters: [user] )! return tx } @@ -466,14 +466,14 @@ extension ERC1410: IERC777 { self.transaction.from = from self.transaction.callOnBlock = .latest - let tx = contract.createWriteOperation("revokeOperator", parameters: [user] as [AnyObject] )! + let tx = contract.createWriteOperation("revokeOperator", parameters: [user] )! return tx } public func isOperatorFor(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("isOperatorFor", parameters: [user, tokenHolder] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("isOperatorFor", parameters: [user, tokenHolder], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -496,7 +496,7 @@ extension ERC1410: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("send", parameters: [to, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("send", parameters: [to, value, data] )! return tx } @@ -518,7 +518,7 @@ extension ERC1410: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData] as [AnyObject] )! + let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData] )! return tx } @@ -540,7 +540,7 @@ extension ERC1410: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("burn", parameters: [value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("burn", parameters: [value, data] )! return tx } @@ -562,14 +562,14 @@ extension ERC1410: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData] as [AnyObject] )! + let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData] )! return tx } public func getGranularity() async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("granularity", parameters: [] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("granularity", parameters: [], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -577,7 +577,7 @@ extension ERC1410: IERC777 { public func getDefaultOperators() async throws -> [EthereumAddress] { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("defaultOperators", parameters: [] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("defaultOperators", parameters: [], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? [EthereumAddress] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } diff --git a/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift b/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift index de3bb5b41..e02bd6b18 100644 --- a/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift +++ b/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift @@ -56,7 +56,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { public func getBalance(account: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOf", parameters: [account] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("balanceOf", parameters: [account], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -64,7 +64,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -87,7 +87,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! return tx } @@ -110,7 +110,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! return tx } @@ -133,7 +133,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! return tx } @@ -141,7 +141,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("totalSupply", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("totalSupply", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -165,7 +165,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] as [AnyObject] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! return tx } @@ -189,7 +189,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferWithData", parameters: [to, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("transferWithData", parameters: [to, value, data] )! return tx } @@ -212,14 +212,14 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFromWithData", parameters: [originalOwner, to, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("transferFromWithData", parameters: [originalOwner, to, value, data] )! return tx } public func isIssuable() async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("isIssuable", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("isIssuable", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -243,7 +243,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("issue", parameters: [tokenHolder, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("issue", parameters: [tokenHolder, value, data] )! return tx } @@ -266,7 +266,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("redeem", parameters: [value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("redeem", parameters: [value, data] )! return tx } @@ -289,7 +289,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("redeemFrom", parameters: [tokenHolder, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("redeemFrom", parameters: [tokenHolder, value, data] )! return tx } @@ -309,7 +309,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let result = try await contract.createReadOperation("canTransfer", parameters: [to, value, data] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("canTransfer", parameters: [to, value, data], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? ([UInt8], Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -330,7 +330,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, value, data] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, value, data], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? ([UInt8], Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } diff --git a/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift b/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift index 7aae7e727..40480c564 100644 --- a/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift +++ b/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift @@ -43,7 +43,7 @@ public class ERC1633: IERC1633, ERC20BaseProperties { public func getBalance(account: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOf", parameters: [account] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("balanceOf", parameters: [account], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -51,7 +51,7 @@ public class ERC1633: IERC1633, ERC20BaseProperties { public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -74,7 +74,7 @@ public class ERC1633: IERC1633, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! return tx } @@ -97,7 +97,7 @@ public class ERC1633: IERC1633, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! return tx } @@ -120,14 +120,14 @@ public class ERC1633: IERC1633, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! return tx } public func totalSupply() async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("totalSupply", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("totalSupply", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -151,14 +151,14 @@ public class ERC1633: IERC1633, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] as [AnyObject] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! return tx } func parentToken() async throws -> EthereumAddress { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("parentToken", parameters: [] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("parentToken", parameters: [], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -166,7 +166,7 @@ public class ERC1633: IERC1633, ERC20BaseProperties { func parentTokenId() async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("parentTokenId", parameters: [] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("parentTokenId", parameters: [], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -174,7 +174,7 @@ public class ERC1633: IERC1633, ERC20BaseProperties { public func supportsInterface(interfaceID: String) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } diff --git a/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift b/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift index be5cce528..6227c19c7 100644 --- a/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift +++ b/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift @@ -46,7 +46,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { public func getBalance(account: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOf", parameters: [account] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("balanceOf", parameters: [account], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -54,7 +54,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -77,7 +77,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! return tx } @@ -100,7 +100,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! return tx } @@ -123,14 +123,14 @@ public class ERC1643: IERC1643, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! return tx } public func totalSupply() async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("totalSupply", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("totalSupply", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -154,7 +154,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] as [AnyObject] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! return tx } @@ -162,7 +162,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { public func getDocument(name: Data) async throws -> (String, Data) { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("getDocument", parameters: [name] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("getDocument", parameters: [name], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? (String, Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -173,7 +173,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setDocument", parameters: [name, uri, documentHash] as [AnyObject] )! + let tx = contract.createWriteOperation("setDocument", parameters: [name, uri, documentHash] )! return tx } @@ -183,14 +183,14 @@ public class ERC1643: IERC1643, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("removeDocument", parameters: [name] as [AnyObject] )! + let tx = contract.createWriteOperation("removeDocument", parameters: [name] )! return tx } public func getAllDocuments() async throws -> [Data] { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("getAllDocuments", parameters: [] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("getAllDocuments", parameters: [], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? [Data] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } diff --git a/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift b/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift index 98d3f60f4..7e4cdf580 100644 --- a/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift +++ b/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift @@ -45,7 +45,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { public func getBalance(account: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOf", parameters: [account] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("balanceOf", parameters: [account], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -53,7 +53,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -76,7 +76,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! return tx } @@ -99,7 +99,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! return tx } @@ -122,14 +122,14 @@ public class ERC1644: IERC1644, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! return tx } public func totalSupply() async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("totalSupply", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("totalSupply", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -153,7 +153,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] as [AnyObject] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! return tx } @@ -161,7 +161,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { public func isControllable() async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("isControllable", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("isControllable", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -185,7 +185,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("controllerTransfer", parameters: [originalOwner, to, value, data, operatorData] as [AnyObject] )! + let tx = contract.createWriteOperation("controllerTransfer", parameters: [originalOwner, to, value, data, operatorData] )! return tx } @@ -208,7 +208,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("controllerRedeem", parameters: [tokenHolder, value, data, operatorData] as [AnyObject] )! + let tx = contract.createWriteOperation("controllerRedeem", parameters: [tokenHolder, value, data, operatorData] )! return tx } } diff --git a/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift b/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift index e0d861fe7..6146d467e 100644 --- a/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift +++ b/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift @@ -9,7 +9,7 @@ import Foundation /// Declares common properties of an [ERC-20](https://eips.ethereum.org/EIPS/eip-20) complient smart contract. /// Default implementation of access to these properties is declared in the extension of this protocol. -public protocol ERC20BaseProperties: AnyObject { +public protocol ERC20BaseProperties: Any { var basePropertiesProvider: ERC20BasePropertiesProvider { get } var contract: Web3.Contract { get } var name: String? { get } diff --git a/Sources/web3swift/Tokens/ERC20/Web3+ERC20.swift b/Sources/web3swift/Tokens/ERC20/Web3+ERC20.swift index d1aeba7ea..aa20848cb 100644 --- a/Sources/web3swift/Tokens/ERC20/Web3+ERC20.swift +++ b/Sources/web3swift/Tokens/ERC20/Web3+ERC20.swift @@ -45,7 +45,7 @@ public class ERC20: IERC20, ERC20BaseProperties { let contract = self.contract self.transaction.callOnBlock = .latest let result = try await contract - .createReadOperation("balanceOf", parameters: [account] as [AnyObject], extraData: Data() )! + .createReadOperation("balanceOf", parameters: [account], extraData: Data() )! .callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res @@ -55,7 +55,7 @@ public class ERC20: IERC20, ERC20BaseProperties { let contract = self.contract self.transaction.callOnBlock = .latest let result = try await contract - .createReadOperation("allowance", parameters: [originalOwner, delegate] as [AnyObject], extraData: Data() )! + .createReadOperation("allowance", parameters: [originalOwner, delegate], extraData: Data() )! .callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res @@ -80,7 +80,7 @@ public class ERC20: IERC20, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! return tx } @@ -104,7 +104,7 @@ public class ERC20: IERC20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! return tx } @@ -128,7 +128,7 @@ public class ERC20: IERC20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! return tx } @@ -152,7 +152,7 @@ public class ERC20: IERC20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] as [AnyObject] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! return tx } @@ -160,7 +160,7 @@ public class ERC20: IERC20, ERC20BaseProperties { let contract = self.contract self.transaction.callOnBlock = .latest let result = try await contract - .createReadOperation("totalSupply", parameters: [AnyObject](), extraData: Data() )! + .createReadOperation("totalSupply", parameters: [Any](), extraData: Data() )! .callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res diff --git a/Sources/web3swift/Tokens/ERC721/Web3+ERC721.swift b/Sources/web3swift/Tokens/ERC721/Web3+ERC721.swift index 9a5887eab..2892ac4f0 100644 --- a/Sources/web3swift/Tokens/ERC721/Web3+ERC721.swift +++ b/Sources/web3swift/Tokens/ERC721/Web3+ERC721.swift @@ -93,7 +93,7 @@ public class ERC721: IERC721 { guard contract.contract.address != nil else {return} self.transaction.callOnBlock = .latest - async let tokenIdPromise = contract.createReadOperation("tokenId", parameters: [AnyObject](), extraData: Data())?.callContractMethod() + async let tokenIdPromise = contract.createReadOperation("tokenId", parameters: [Any](), extraData: Data())?.callContractMethod() guard let tokenIdResult = try await tokenIdPromise else {return} guard let tokenId = tokenIdResult["0"] as? BigUInt else {return} @@ -106,7 +106,7 @@ public class ERC721: IERC721 { public func getBalance(account: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOf", parameters: [account] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("balanceOf", parameters: [account], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -114,7 +114,7 @@ public class ERC721: IERC721 { public func getOwner(tokenId: BigUInt) async throws -> EthereumAddress { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("ownerOf", parameters: [tokenId] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("ownerOf", parameters: [tokenId], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -122,7 +122,7 @@ public class ERC721: IERC721 { public func getApproved(tokenId: BigUInt) async throws -> EthereumAddress { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("getApproved", parameters: [tokenId] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("getApproved", parameters: [tokenId], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -132,7 +132,7 @@ public class ERC721: IERC721 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("transfer", parameters: [to, tokenId] as [AnyObject] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, tokenId] )! return tx } @@ -141,7 +141,7 @@ public class ERC721: IERC721 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, tokenId] as [AnyObject] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, tokenId] )! return tx } @@ -150,7 +150,7 @@ public class ERC721: IERC721 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId] as [AnyObject] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId] )! return tx } @@ -159,7 +159,7 @@ public class ERC721: IERC721 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, data] as [AnyObject] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, data] )! return tx } @@ -168,7 +168,7 @@ public class ERC721: IERC721 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("approve", parameters: [approved, tokenId] as [AnyObject] )! + let tx = contract.createWriteOperation("approve", parameters: [approved, tokenId] )! return tx } @@ -177,14 +177,14 @@ public class ERC721: IERC721 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setApprovalForAll", parameters: [user, approved] as [AnyObject] )! + let tx = contract.createWriteOperation("setApprovalForAll", parameters: [user, approved] )! return tx } public func isApprovedForAll(owner: EthereumAddress, operator user: EthereumAddress) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("isApprovedForAll", parameters: [owner, user] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("isApprovedForAll", parameters: [owner, user], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -192,7 +192,7 @@ public class ERC721: IERC721 { public func supportsInterface(interfaceID: String) async throws -> Bool { let contract = self.contract transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -204,7 +204,7 @@ extension ERC721: IERC721Enumerable { public func totalSupply() async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("totalSupply", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("totalSupply", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -212,7 +212,7 @@ extension ERC721: IERC721Enumerable { public func tokenByIndex(index: BigUInt) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("tokenByIndex", parameters: [index] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("tokenByIndex", parameters: [index], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -220,7 +220,7 @@ extension ERC721: IERC721Enumerable { public func tokenOfOwnerByIndex(owner: EthereumAddress, index: BigUInt) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("tokenOfOwnerByIndex", parameters: [owner, index] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("tokenOfOwnerByIndex", parameters: [owner, index], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -233,7 +233,7 @@ extension ERC721: IERC721Metadata { public func name() async throws -> String { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("name", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("name", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? String else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -241,7 +241,7 @@ extension ERC721: IERC721Metadata { public func symbol() async throws -> String { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("symbol", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("symbol", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? String else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -249,7 +249,7 @@ extension ERC721: IERC721Metadata { public func tokenURI(tokenId: BigUInt) async throws -> String { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("tokenURI", parameters: [tokenId] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("tokenURI", parameters: [tokenId], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? String else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } diff --git a/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift b/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift index 7285b48c9..941e68824 100644 --- a/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift +++ b/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift @@ -77,7 +77,7 @@ public class ERC721x: IERC721x { guard contract.contract.address != nil else {return} self.transaction.callOnBlock = .latest - guard let tokenIdPromise = try await contract.createReadOperation("tokenId", parameters: [] as [AnyObject], extraData: Data())?.callContractMethod() else {return} + guard let tokenIdPromise = try await contract.createReadOperation("tokenId", parameters: [], extraData: Data())?.callContractMethod() else {return} guard let tokenId = tokenIdPromise["0"] as? BigUInt else {return} self._tokenId = tokenId @@ -88,7 +88,7 @@ public class ERC721x: IERC721x { public func getBalance(account: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOf", parameters: [account] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("balanceOf", parameters: [account], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -96,7 +96,7 @@ public class ERC721x: IERC721x { public func getOwner(tokenId: BigUInt) async throws -> EthereumAddress { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("ownerOf", parameters: [tokenId] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("ownerOf", parameters: [tokenId], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -104,7 +104,7 @@ public class ERC721x: IERC721x { public func getApproved(tokenId: BigUInt) async throws -> EthereumAddress { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("getApproved", parameters: [tokenId] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("getApproved", parameters: [tokenId], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -114,7 +114,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("transfer", parameters: [to, tokenId] as [AnyObject] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, tokenId] )! return tx } @@ -123,7 +123,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, tokenId] as [AnyObject] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, tokenId] )! return tx } @@ -132,7 +132,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId] as [AnyObject] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId] )! return tx } @@ -141,7 +141,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, data] as [AnyObject] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, data] )! return tx } @@ -150,7 +150,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("approve", parameters: [approved, tokenId] as [AnyObject] )! + let tx = contract.createWriteOperation("approve", parameters: [approved, tokenId] )! return tx } @@ -159,14 +159,14 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setApprovalForAll", parameters: [user, approved] as [AnyObject] )! + let tx = contract.createWriteOperation("setApprovalForAll", parameters: [user, approved] )! return tx } public func isApprovedForAll(owner: EthereumAddress, operator user: EthereumAddress) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("isApprovedForAll", parameters: [owner, user] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("isApprovedForAll", parameters: [owner, user], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -174,7 +174,7 @@ public class ERC721x: IERC721x { public func supportsInterface(interfaceID: String) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -182,7 +182,7 @@ public class ERC721x: IERC721x { public func totalSupply() async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("totalSupply", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("totalSupply", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -190,7 +190,7 @@ public class ERC721x: IERC721x { public func tokenByIndex(index: BigUInt) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("tokenByIndex", parameters: [index] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("tokenByIndex", parameters: [index], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -198,7 +198,7 @@ public class ERC721x: IERC721x { public func tokenOfOwnerByIndex(owner: EthereumAddress, index: BigUInt) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("tokenOfOwnerByIndex", parameters: [owner, index] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("tokenOfOwnerByIndex", parameters: [owner, index], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -206,7 +206,7 @@ public class ERC721x: IERC721x { public func name() async throws -> String { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("name", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("name", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? String else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -214,7 +214,7 @@ public class ERC721x: IERC721x { public func symbol() async throws -> String { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("symbol", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("symbol", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? String else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -222,7 +222,7 @@ public class ERC721x: IERC721x { public func tokenURI(tokenId: BigUInt) async throws -> String { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("tokenURI", parameters: [tokenId] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("tokenURI", parameters: [tokenId], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? String else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -230,7 +230,7 @@ public class ERC721x: IERC721x { func implementsERC721X() async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("implementsERC721X", parameters: [] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("implementsERC721X", parameters: [], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -238,7 +238,7 @@ public class ERC721x: IERC721x { func getBalance(account: EthereumAddress, tokenId: BigUInt) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOf", parameters: [account, tokenId] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("balanceOf", parameters: [account, tokenId], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -246,7 +246,7 @@ public class ERC721x: IERC721x { func tokensOwned(account: EthereumAddress) async throws -> ([BigUInt], [BigUInt]) { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("tokensOwned", parameters: [account] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("tokensOwned", parameters: [account], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? ([BigUInt], [BigUInt]) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -256,7 +256,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("transfer", parameters: [to, tokenId, quantity] as [AnyObject] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, tokenId, quantity] )! return tx } @@ -265,7 +265,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, tokenId, quantity] as [AnyObject] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, tokenId, quantity] )! return tx } @@ -274,7 +274,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, amount] as [AnyObject] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, amount] )! return tx } @@ -283,7 +283,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, amount, data] as [AnyObject] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, amount, data] )! return tx } @@ -292,7 +292,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenIds, amounts, data] as [AnyObject] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenIds, amounts, data] )! return tx } } diff --git a/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift b/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift index 4ef3be52f..5e297f367 100644 --- a/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift +++ b/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift @@ -59,7 +59,7 @@ public class ERC777: IERC777, ERC20BaseProperties { public func getGranularity() async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("granularity", parameters: [] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("granularity", parameters: [], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -67,7 +67,7 @@ public class ERC777: IERC777, ERC20BaseProperties { public func getDefaultOperators() async throws -> [EthereumAddress] { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("defaultOperators", parameters: [] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("defaultOperators", parameters: [], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? [EthereumAddress] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -75,7 +75,7 @@ public class ERC777: IERC777, ERC20BaseProperties { public func getBalance(account: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOf", parameters: [account] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("balanceOf", parameters: [account], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -83,7 +83,7 @@ public class ERC777: IERC777, ERC20BaseProperties { public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -105,7 +105,7 @@ public class ERC777: IERC777, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! return tx } @@ -127,7 +127,7 @@ public class ERC777: IERC777, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! return tx } @@ -149,14 +149,14 @@ public class ERC777: IERC777, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! return tx } public func totalSupply() async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("totalSupply", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("totalSupply", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -168,7 +168,7 @@ public class ERC777: IERC777, ERC20BaseProperties { self.transaction.to = self.address self.transaction.callOnBlock = .latest - let tx = contract.createWriteOperation("authorizeOperator", parameters: [user] as [AnyObject] )! + let tx = contract.createWriteOperation("authorizeOperator", parameters: [user] )! return tx } @@ -178,14 +178,14 @@ public class ERC777: IERC777, ERC20BaseProperties { self.transaction.to = self.address self.transaction.callOnBlock = .latest - let tx = contract.createWriteOperation("revokeOperator", parameters: [user] as [AnyObject] )! + let tx = contract.createWriteOperation("revokeOperator", parameters: [user] )! return tx } public func isOperatorFor(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("isOperatorFor", parameters: [user, tokenHolder] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("isOperatorFor", parameters: [user, tokenHolder], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -207,7 +207,7 @@ public class ERC777: IERC777, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("send", parameters: [to, value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("send", parameters: [to, value, data] )! return tx } @@ -228,7 +228,7 @@ public class ERC777: IERC777, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData] as [AnyObject] )! + let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData] )! return tx } @@ -249,7 +249,7 @@ public class ERC777: IERC777, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("burn", parameters: [value, data] as [AnyObject] )! + let tx = contract.createWriteOperation("burn", parameters: [value, data] )! return tx } @@ -270,14 +270,14 @@ public class ERC777: IERC777, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData] as [AnyObject] )! + let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData] )! return tx } public func canImplementInterfaceForAddress(interfaceHash: Data, addr: EthereumAddress) async throws -> Data { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("canImplementInterfaceForAddress", parameters: [interfaceHash, addr] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("canImplementInterfaceForAddress", parameters: [interfaceHash, addr], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Data else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -285,7 +285,7 @@ public class ERC777: IERC777, ERC20BaseProperties { public func getInterfaceImplementer(addr: EthereumAddress, interfaceHash: Data) async throws -> EthereumAddress { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("getInterfaceImplementer", parameters: [addr, interfaceHash] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("getInterfaceImplementer", parameters: [addr, interfaceHash], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -295,7 +295,7 @@ public class ERC777: IERC777, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer] as [AnyObject] )! + let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer] )! return tx } @@ -304,14 +304,14 @@ public class ERC777: IERC777, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager] as [AnyObject] )! + let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager] )! return tx } public func interfaceHash(interfaceName: String) async throws -> Data { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("interfaceHash", parameters: [interfaceName] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("interfaceHash", parameters: [interfaceName], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Data else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -321,7 +321,7 @@ public class ERC777: IERC777, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId] as [AnyObject] )! + let tx = contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId] )! return tx } @@ -343,14 +343,14 @@ public class ERC777: IERC777, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] as [AnyObject] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! return tx } public func supportsInterface(interfaceID: String) async throws -> Bool { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } diff --git a/Sources/web3swift/Tokens/ERC888/Web3+ERC888.swift b/Sources/web3swift/Tokens/ERC888/Web3+ERC888.swift index 46a0dc8f0..4ff2e9c5f 100644 --- a/Sources/web3swift/Tokens/ERC888/Web3+ERC888.swift +++ b/Sources/web3swift/Tokens/ERC888/Web3+ERC888.swift @@ -41,7 +41,7 @@ public class ERC888: IERC888, ERC20BaseProperties { public func getBalance(account: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOf", parameters: [account] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("balanceOf", parameters: [account], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -63,7 +63,7 @@ public class ERC888: IERC888, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! return tx } diff --git a/Sources/web3swift/Tokens/ST20/Web3+ST20.swift b/Sources/web3swift/Tokens/ST20/Web3+ST20.swift index 71097eb27..66cfc8dd6 100644 --- a/Sources/web3swift/Tokens/ST20/Web3+ST20.swift +++ b/Sources/web3swift/Tokens/ST20/Web3+ST20.swift @@ -52,7 +52,7 @@ public class ST20: IST20, ERC20BaseProperties { func tokenDetails() async throws -> [UInt32] { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("tokenDetails", parameters: [] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("tokenDetails", parameters: [], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? [UInt32] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -76,7 +76,7 @@ public class ST20: IST20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("verifyTransfer", parameters: [originalOwner, to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("verifyTransfer", parameters: [originalOwner, to, value] )! return tx } @@ -99,7 +99,7 @@ public class ST20: IST20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("mint", parameters: [investor, value] as [AnyObject] )! + let tx = contract.createWriteOperation("mint", parameters: [investor, value] )! return tx } @@ -121,14 +121,14 @@ public class ST20: IST20, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("burn", parameters: [value] as [AnyObject] )! + let tx = contract.createWriteOperation("burn", parameters: [value] )! return tx } public func getBalance(account: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOf", parameters: [account] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("balanceOf", parameters: [account], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -136,7 +136,7 @@ public class ST20: IST20, ERC20BaseProperties { public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate] as [AnyObject], extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate], extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -159,7 +159,7 @@ public class ST20: IST20, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! return tx } @@ -182,7 +182,7 @@ public class ST20: IST20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! return tx } @@ -205,7 +205,7 @@ public class ST20: IST20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] as [AnyObject] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! return tx } @@ -228,14 +228,14 @@ public class ST20: IST20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] as [AnyObject] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! return tx } public func totalSupply() async throws -> BigUInt { let contract = self.contract self.transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("totalSupply", parameters: [AnyObject](), extraData: Data() )!.callContractMethod() + let result = try await contract.createReadOperation("totalSupply", parameters: [Any](), extraData: Data() )!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } diff --git a/Sources/web3swift/Tokens/ST20/Web3+SecurityToken.swift b/Sources/web3swift/Tokens/ST20/Web3+SecurityToken.swift index a7670f124..772dc0da8 100644 --- a/Sources/web3swift/Tokens/ST20/Web3+SecurityToken.swift +++ b/Sources/web3swift/Tokens/ST20/Web3+SecurityToken.swift @@ -112,7 +112,7 @@ public class SecurityToken: ISecurityToken, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - return contract.createWriteOperation("verifyTransfer", parameters: [originalOwner, to, value] as [AnyObject])! + return contract.createWriteOperation("verifyTransfer", parameters: [originalOwner, to, value])! } func mint(from: EthereumAddress, investor: EthereumAddress, amount: String) async throws -> WriteOperation { @@ -131,7 +131,7 @@ public class SecurityToken: ISecurityToken, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - return contract.createWriteOperation("mint", parameters: [investor, value] as [AnyObject])! + return contract.createWriteOperation("mint", parameters: [investor, value])! } public func burn(from: EthereumAddress, amount: String) async throws -> WriteOperation { @@ -150,19 +150,19 @@ public class SecurityToken: ISecurityToken, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - return contract.createWriteOperation("burn", parameters: [value] as [AnyObject])! + return contract.createWriteOperation("burn", parameters: [value])! } public func getBalance(account: EthereumAddress) async throws -> BigUInt { transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOf", parameters: [account] as [AnyObject])!.callContractMethod() + let result = try await contract.createReadOperation("balanceOf", parameters: [account])!.callContractMethod() guard let res = result["0"] as? BigUInt else { throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node") } return res } public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate] as [AnyObject])!.callContractMethod() + let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate])!.callContractMethod() guard let res = result["0"] as? BigUInt else { throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node") } return res } @@ -183,7 +183,7 @@ public class SecurityToken: ISecurityToken, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - return contract.createWriteOperation("transfer", parameters: [to, value] as [AnyObject])! + return contract.createWriteOperation("transfer", parameters: [to, value])! } public func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) async throws -> WriteOperation { @@ -202,7 +202,7 @@ public class SecurityToken: ISecurityToken, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - return contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] as [AnyObject])! + return contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! } public func setAllowance(from: EthereumAddress, to: EthereumAddress, newAmount: String) async throws -> WriteOperation { @@ -221,7 +221,7 @@ public class SecurityToken: ISecurityToken, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(newAmount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - return contract.createWriteOperation("setAllowance", parameters: [to, value] as [AnyObject])! + return contract.createWriteOperation("setAllowance", parameters: [to, value])! } public func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) async throws -> WriteOperation { @@ -240,7 +240,7 @@ public class SecurityToken: ISecurityToken, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - return contract.createWriteOperation("approve", parameters: [spender, value] as [AnyObject])! + return contract.createWriteOperation("approve", parameters: [spender, value])! } public func totalSupply() async throws -> BigUInt { @@ -254,14 +254,14 @@ public class SecurityToken: ISecurityToken, ERC20BaseProperties { transaction.from = from transaction.to = self.address transaction.callOnBlock = .latest - return contract.createWriteOperation("renounceOwnership", parameters: [AnyObject]() )! + return contract.createWriteOperation("renounceOwnership", parameters: [Any]() )! } public func transferOwnership(from: EthereumAddress, newOwner: EthereumAddress) throws -> WriteOperation { transaction.from = from transaction.to = self.address transaction.callOnBlock = .latest - return contract.createWriteOperation("transferOwnership", parameters: [newOwner] as [AnyObject])! + return contract.createWriteOperation("transferOwnership", parameters: [newOwner])! } public func currentCheckpointId() async throws -> BigUInt { @@ -287,21 +287,21 @@ public class SecurityToken: ISecurityToken, ERC20BaseProperties { public func investors(index: UInt) async throws -> [EthereumAddress] { transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("investors", parameters: [index] as [AnyObject])!.callContractMethod() + let result = try await contract.createReadOperation("investors", parameters: [index])!.callContractMethod() guard let res = result["0"] as? [EthereumAddress] else { throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node") } return res } public func checkPermission(delegate: EthereumAddress, module: EthereumAddress, perm: [UInt32]) async throws -> Bool { transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("checkPermission", parameters: [delegate, module, perm] as [AnyObject])!.callContractMethod() + let result = try await contract.createReadOperation("checkPermission", parameters: [delegate, module, perm])!.callContractMethod() guard let res = result["0"] as? Bool else { throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node") } return res } public func getModule(moduleType: UInt8, moduleIndex: UInt8) async throws -> ([UInt32], EthereumAddress) { transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("getModule", parameters: [moduleType, moduleIndex] as [AnyObject])!.callContractMethod() + let result = try await contract.createReadOperation("getModule", parameters: [moduleType, moduleIndex])!.callContractMethod() guard let moduleList = result["0"] as? [UInt32] else { throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node") } guard let moduleAddress = result["1"] as? EthereumAddress else { throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node") } return (moduleList, moduleAddress) @@ -309,7 +309,7 @@ public class SecurityToken: ISecurityToken, ERC20BaseProperties { public func getModuleByName(moduleType: UInt8, name: [UInt32]) async throws -> ([UInt32], EthereumAddress) { transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("getModuleByName", parameters: [moduleType, name] as [AnyObject])!.callContractMethod() + let result = try await contract.createReadOperation("getModuleByName", parameters: [moduleType, name])!.callContractMethod() guard let moduleList = result["0"] as? [UInt32] else { throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node") } guard let moduleAddress = result["1"] as? EthereumAddress else { throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node") } return (moduleList, moduleAddress) @@ -317,14 +317,14 @@ public class SecurityToken: ISecurityToken, ERC20BaseProperties { public func totalSupplyAt(checkpointId: BigUInt) async throws -> BigUInt { transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("totalSupplyAt", parameters: [checkpointId] as [AnyObject])!.callContractMethod() + let result = try await contract.createReadOperation("totalSupplyAt", parameters: [checkpointId])!.callContractMethod() guard let res = result["0"] as? BigUInt else { throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node") } return res } public func balanceOfAt(investor: EthereumAddress, checkpointId: BigUInt) async throws -> BigUInt { transaction.callOnBlock = .latest - let result = try await contract.createReadOperation("balanceOfAt", parameters: [investor, checkpointId] as [AnyObject])!.callContractMethod() + let result = try await contract.createReadOperation("balanceOfAt", parameters: [investor, checkpointId])!.callContractMethod() guard let res = result["0"] as? BigUInt else { throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node") } return res } @@ -333,7 +333,7 @@ public class SecurityToken: ISecurityToken, ERC20BaseProperties { transaction.from = from transaction.to = self.address transaction.callOnBlock = .latest - return contract.createWriteOperation("createCheckpoint", parameters: [AnyObject]() )! + return contract.createWriteOperation("createCheckpoint", parameters: [Any]() )! } public func getInvestorsLength() async throws -> BigUInt { diff --git a/Sources/web3swift/Utils/EIP/EIP67Code.swift b/Sources/web3swift/Utils/EIP/EIP67Code.swift index 49f4e887c..38e95b112 100755 --- a/Sources/web3swift/Utils/EIP/EIP67Code.swift +++ b/Sources/web3swift/Utils/EIP/EIP67Code.swift @@ -22,7 +22,7 @@ extension Web3 { } public struct Function { public var method: String - public var parameters: [(ABI.Element.ParameterType, AnyObject)] + public var parameters: [(ABI.Element.ParameterType, Any)] public func toString() -> String? { let encoding = method + "(" + parameters.map({ el -> String in diff --git a/Sources/web3swift/Utils/EIP/EIP681.swift b/Sources/web3swift/Utils/EIP/EIP681.swift index 62a05a509..c15ffd41f 100755 --- a/Sources/web3swift/Utils/EIP/EIP681.swift +++ b/Sources/web3swift/Utils/EIP/EIP681.swift @@ -23,9 +23,9 @@ extension Web3 { public struct EIP681Code { public struct EIP681Parameter { public var type: ABI.Element.ParameterType - public var value: AnyObject + public var value: Any - public init(type: ABI.Element.ParameterType, value: AnyObject) { + public init(type: ABI.Element.ParameterType, value: Any) { self.type = type self.value = value } @@ -90,7 +90,7 @@ extension Web3 { public struct EIP681CodeEncoder { public static func encodeFunctionArgument(_ inputType: ABI.Element.ParameterType, - _ rawValue: AnyObject) -> String? { + _ rawValue: Any) -> String? { switch inputType { case .address: if let ethAddress = rawValue as? EthereumAddress { @@ -209,7 +209,7 @@ extension Web3 { } return nil case let .array(type, length): - if let array = rawValue as? [AnyObject] { + if let array = rawValue as? [Any] { let mappedArray = array.compactMap { object in encodeFunctionArgument(type, object) } @@ -350,58 +350,58 @@ extension Web3 { _ rawValue: String, chainID: BigUInt, inputNumber: Int) async -> FunctionArgument? { - var nativeValue: AnyObject? + var nativeValue: Any? switch inputType { case .address: let val = EIP681Code.TargetAddress(rawValue) switch val { case .ethereumAddress(let ethereumAddress): - nativeValue = ethereumAddress as AnyObject + nativeValue = ethereumAddress case .ensAddress(let ens): do { let web = await Web3(provider: InfuraProvider(Networks.fromInt(UInt(chainID)) ?? Networks.Mainnet)!) let ensModel = ENS(web3: web) try await ensModel?.setENSResolver(withDomain: ens) let address = try await ensModel?.getAddress(forNode: ens) - nativeValue = address as AnyObject + nativeValue = address } catch { return nil } } case .uint(bits: _): if let val = BigUInt(rawValue, radix: 10) { - nativeValue = val as AnyObject + nativeValue = val } else if let val = BigUInt(rawValue.stripHexPrefix(), radix: 16) { - nativeValue = val as AnyObject + nativeValue = val } case .int(bits: _): if let val = BigInt(rawValue, radix: 10) { - nativeValue = val as AnyObject + nativeValue = val } else if let val = BigInt(rawValue.stripHexPrefix(), radix: 16) { - nativeValue = val as AnyObject + nativeValue = val } case .string: - nativeValue = rawValue as AnyObject + nativeValue = rawValue case .dynamicBytes: if let val = Data.fromHex(rawValue) { - nativeValue = val as AnyObject + nativeValue = val } else if let val = rawValue.data(using: .utf8) { - nativeValue = val as AnyObject + nativeValue = val } case .bytes(length: _): if let val = Data.fromHex(rawValue) { - nativeValue = val as AnyObject + nativeValue = val } else if let val = rawValue.data(using: .utf8) { - nativeValue = val as AnyObject + nativeValue = val } case .bool: switch rawValue { case "true", "True", "TRUE", "1": - nativeValue = true as AnyObject + nativeValue = true case "false", "False", "FALSE", "0": - nativeValue = false as AnyObject + nativeValue = false default: - nativeValue = true as AnyObject + nativeValue = true } case let .array(type, length): var rawValues: [String] = [] @@ -420,7 +420,7 @@ extension Web3 { rawValues = rawValue.split(separator: ",").map { String($0) } } - var nativeValueArray: [AnyObject] = [] + var nativeValueArray: [Any] = [] for value in rawValues { let intermidiateValue = await parseFunctionArgument(type, @@ -433,7 +433,7 @@ extension Web3 { nativeValueArray.append(intermidiateValue) } } - nativeValue = nativeValueArray as AnyObject + nativeValue = nativeValueArray guard nativeValueArray.count == rawValues.count && (length == 0 || UInt64(rawValues.count) == length) else { return nil } diff --git a/Sources/web3swift/Utils/EIP/EIP712.swift b/Sources/web3swift/Utils/EIP/EIP712.swift index 4cb913ffd..a10b20864 100644 --- a/Sources/web3swift/Utils/EIP/EIP712.swift +++ b/Sources/web3swift/Utils/EIP/EIP712.swift @@ -38,7 +38,6 @@ public extension EIP712Hashable { } func hash() throws -> Data { - typealias SolidityValue = (value: Any, type: ABI.Element.ParameterType) var parameters: [Data] = [typehash] for case let (_, field) in Mirror(reflecting: self).children { let result: Data @@ -48,14 +47,15 @@ public extension EIP712Hashable { case let data as EIP712.Bytes: result = data.sha3(.keccak256) case is EIP712.UInt8: - result = ABIEncoder.encodeSingleType(type: .uint(bits: 8), value: field as AnyObject)! + result = ABIEncoder.encodeSingleType(type: .uint(bits: 8), value: field)! case is EIP712.UInt256: - result = ABIEncoder.encodeSingleType(type: .uint(bits: 256), value: field as AnyObject)! + result = ABIEncoder.encodeSingleType(type: .uint(bits: 256), value: field)! case is EIP712.Address: - result = ABIEncoder.encodeSingleType(type: .address, value: field as AnyObject)! + result = ABIEncoder.encodeSingleType(type: .address, value: field)! case let hashable as EIP712Hashable: result = try hashable.hash() default: + /// Cast to `AnyObject` is required. Otherwise, `nil` value will fail this condition. if (field as AnyObject) is NSNull { continue } else { diff --git a/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift b/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift index 744ffa61b..b5bee7973 100644 --- a/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift +++ b/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift @@ -36,7 +36,7 @@ public extension ENS { public func addController(from: EthereumAddress, controllerAddress: EthereumAddress) throws -> WriteOperation { defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("addController", parameters: [controllerAddress as AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("addController", parameters: [controllerAddress], extraData: Data() ) else {throw Web3Error.transactionSerializationError} return transaction } @@ -44,7 +44,7 @@ public extension ENS { public func removeController(from: EthereumAddress, controllerAddress: EthereumAddress) throws -> WriteOperation { defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("removeController", parameters: [controllerAddress as AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("removeController", parameters: [controllerAddress], extraData: Data() ) else {throw Web3Error.transactionSerializationError} return transaction } @@ -52,12 +52,12 @@ public extension ENS { public func setResolver(from: EthereumAddress, resolverAddress: EthereumAddress) throws -> WriteOperation { defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("setResolver", parameters: [resolverAddress as AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("setResolver", parameters: [resolverAddress], extraData: Data() ) else {throw Web3Error.transactionSerializationError} return transaction } public func getNameExpirity(name: BigUInt) async throws -> BigUInt { - guard let transaction = self.contract.createReadOperation("nameExpires", parameters: [name as AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createReadOperation("nameExpires", parameters: [name], extraData: Data() ) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let expirity = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Can't get answer")} return expirity @@ -65,7 +65,7 @@ public extension ENS { @available(*, message: "This function should not be used to check if a name can be registered by a user. To check if a name can be registered by a user, check name availablility via the controller") public func isNameAvailable(name: BigUInt) async throws -> Bool { - guard let transaction = self.contract.createReadOperation("available", parameters: [name as AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createReadOperation("available", parameters: [name], extraData: Data() ) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let available = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Can't get answer")} return available @@ -74,7 +74,7 @@ public extension ENS { public func reclaim(from: EthereumAddress, record: BigUInt) throws -> WriteOperation { defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("reclaim", parameters: [record as AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("reclaim", parameters: [record], extraData: Data() ) else {throw Web3Error.transactionSerializationError} return transaction } diff --git a/Sources/web3swift/Utils/ENS/ENSRegistry.swift b/Sources/web3swift/Utils/ENS/ENSRegistry.swift index 587684eb8..725de6ef9 100644 --- a/Sources/web3swift/Utils/ENS/ENSRegistry.swift +++ b/Sources/web3swift/Utils/ENS/ENSRegistry.swift @@ -48,7 +48,7 @@ public extension ENS { public func getOwner(node: String) async throws -> EthereumAddress { guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.registryContract.createReadOperation("owner", parameters: [nameHash as AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.registryContract.createReadOperation("owner", parameters: [nameHash], extraData: Data() ) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let address = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "No address in result")} return address @@ -56,7 +56,7 @@ public extension ENS { public func getResolver(forDomain domain: String) async throws -> Resolver { guard let nameHash = NameHash.nameHash(domain) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.registryContract.createReadOperation("resolver", parameters: [nameHash as AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.registryContract.createReadOperation("resolver", parameters: [nameHash], extraData: Data() ) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let resolverAddress = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "No address in result")} return Resolver(web3: self.web3, resolverContractAddress: resolverAddress) @@ -64,7 +64,7 @@ public extension ENS { public func getTTL(node: String) async throws -> BigUInt { guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.registryContract.createReadOperation("ttl", parameters: [nameHash as AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.registryContract.createReadOperation("ttl", parameters: [nameHash], extraData: Data() ) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let ans = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "No answer in result")} return ans @@ -77,7 +77,7 @@ public extension ENS { options.to = contractAddress } guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.registryContract.createWriteOperation("setOwner", parameters: [nameHash, owner] as [AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.registryContract.createWriteOperation("setOwner", parameters: [nameHash, owner], extraData: Data() ) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.writeToChain(password: password) else {throw Web3Error.processingError(desc: "Can't send transaction")} return result } @@ -90,7 +90,7 @@ public extension ENS { } guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} guard let labelHash = NameHash.nameHash(label) else {throw Web3Error.processingError(desc: "Failed to get label hash")} - guard let transaction = self.registryContract.createWriteOperation("setSubnodeOwner", parameters: [nameHash, labelHash, owner] as [AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.registryContract.createWriteOperation("setSubnodeOwner", parameters: [nameHash, labelHash, owner], extraData: Data() ) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.writeToChain(password: password) else {throw Web3Error.processingError(desc: "Can't send transaction")} return result } @@ -102,7 +102,7 @@ public extension ENS { options.to = contractAddress } guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.registryContract.createWriteOperation("setResolver", parameters: [nameHash, resolver] as [AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.registryContract.createWriteOperation("setResolver", parameters: [nameHash, resolver], extraData: Data() ) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.writeToChain(password: password) else {throw Web3Error.processingError(desc: "Can't send transaction")} return result } @@ -114,7 +114,7 @@ public extension ENS { options.to = contractAddress } guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.registryContract.createWriteOperation("setTTL", parameters: [nameHash, ttl] as [AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.registryContract.createWriteOperation("setTTL", parameters: [nameHash, ttl], extraData: Data() ) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.writeToChain(password: password) else {throw Web3Error.processingError(desc: "Can't send transaction")} return result } diff --git a/Sources/web3swift/Utils/ENS/ENSResolver.swift b/Sources/web3swift/Utils/ENS/ENSResolver.swift index 5147ab4e4..620d4acbc 100755 --- a/Sources/web3swift/Utils/ENS/ENSResolver.swift +++ b/Sources/web3swift/Utils/ENS/ENSResolver.swift @@ -76,7 +76,7 @@ public extension ENS { } public func supportsInterface(interfaceID: String) async throws -> Bool { - guard let transaction = self.resolverContract.createReadOperation("supportsInterface", parameters: [interfaceID as AnyObject]) else { + guard let transaction = self.resolverContract.createReadOperation("supportsInterface", parameters: [interfaceID]) else { throw Web3Error.transactionSerializationError } guard let result = try? await transaction.callContractMethod() else { @@ -90,7 +90,7 @@ public extension ENS { public func interfaceImplementer(forNode node: String, interfaceID: String) async throws -> EthereumAddress { guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.createReadOperation("interfaceImplementer", parameters: [nameHash, interfaceID] as [AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.resolverContract.createReadOperation("interfaceImplementer", parameters: [nameHash, interfaceID]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let address = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Can't get address")} return address @@ -98,7 +98,7 @@ public extension ENS { public func getAddress(forNode node: String) async throws -> EthereumAddress { guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.createReadOperation("addr", parameters: [nameHash as AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.resolverContract.createReadOperation("addr", parameters: [nameHash]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let address = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Can't get address")} return address @@ -110,14 +110,14 @@ public extension ENS { var options = options ?? defaultOptions options.to = self.resolverContractAddress guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.createWriteOperation("setAddr", parameters: [nameHash, address] as [AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.resolverContract.createWriteOperation("setAddr", parameters: [nameHash, address]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.writeToChain(password: password) else {throw Web3Error.processingError(desc: "Can't send transaction")} return result } public func getCanonicalName(forNode node: String) async throws -> String { guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.createReadOperation("name", parameters: [nameHash as AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.resolverContract.createReadOperation("name", parameters: [nameHash]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let name = result["0"] as? String else {throw Web3Error.processingError(desc: "Can't get name")} return name @@ -129,14 +129,14 @@ public extension ENS { var options = options ?? defaultOptions options.to = self.resolverContractAddress guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.createWriteOperation("setName", parameters: [nameHash, name] as [AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.resolverContract.createWriteOperation("setName", parameters: [nameHash, name]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.writeToChain(password: password) else {throw Web3Error.processingError(desc: "Can't send transaction")} return result } func getContentHash(forNode node: String) async throws -> Data { guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.createReadOperation("contenthash", parameters: [nameHash] as [AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.resolverContract.createReadOperation("contenthash", parameters: [nameHash]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let content = result["0"] as? Data else {throw Web3Error.processingError(desc: "Can't get content")} return content @@ -148,7 +148,7 @@ public extension ENS { var options = options ?? defaultOptions options.to = self.resolverContractAddress guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.createWriteOperation("setContenthash", parameters: [nameHash, hash] as [AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.resolverContract.createWriteOperation("setContenthash", parameters: [nameHash, hash]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.writeToChain(password: password) else {throw Web3Error.processingError(desc: "Can't send transaction")} return result @@ -156,7 +156,7 @@ public extension ENS { public func getContractABI(forNode node: String, contentType: ENS.Resolver.ContentType) async throws -> (BigUInt, Data) { guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.createReadOperation("ABI", parameters: [nameHash, contentType.rawValue] as [AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.resolverContract.createReadOperation("ABI", parameters: [nameHash, contentType.rawValue]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let encoding = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Can't get encoding")} guard let data = result["1"] as? Data else {throw Web3Error.processingError(desc: "Can't get data")} @@ -169,14 +169,14 @@ public extension ENS { var options = options ?? defaultOptions options.to = self.resolverContractAddress guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.createWriteOperation("setABI", parameters: [nameHash, contentType.rawValue, data] as [AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.resolverContract.createWriteOperation("setABI", parameters: [nameHash, contentType.rawValue, data]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.writeToChain(password: password) else {throw Web3Error.processingError(desc: "Can't send transaction")} return result } public func getPublicKey(forNode node: String) async throws -> PublicKey { guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.createReadOperation("pubkey", parameters: [nameHash as AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.resolverContract.createReadOperation("pubkey", parameters: [nameHash]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let x = result["x"] as? Data else {throw Web3Error.processingError(desc: "Can't get x")} guard let y = result["y"] as? Data else {throw Web3Error.processingError(desc: "Can't get y")} @@ -191,14 +191,14 @@ public extension ENS { options.to = self.resolverContractAddress let pubkeyWithoutPrefix = publicKey.getComponentsWithoutPrefix() guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.createWriteOperation("setPubkey", parameters: [nameHash, pubkeyWithoutPrefix.x, pubkeyWithoutPrefix.y] as [AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.resolverContract.createWriteOperation("setPubkey", parameters: [nameHash, pubkeyWithoutPrefix.x, pubkeyWithoutPrefix.y]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.writeToChain(password: password) else {throw Web3Error.processingError(desc: "Can't send transaction")} return result } public func getTextData(forNode node: String, key: String) async throws -> String { guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.createReadOperation("text", parameters: [nameHash, key] as [AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.resolverContract.createReadOperation("text", parameters: [nameHash, key]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let text = result["0"] as? String else {throw Web3Error.processingError(desc: "Can't get text")} return text @@ -210,7 +210,7 @@ public extension ENS { var options = options ?? defaultOptions options.to = self.resolverContractAddress guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.createWriteOperation("setText", parameters: [nameHash, key, value] as [AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.resolverContract.createWriteOperation("setText", parameters: [nameHash, key, value]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.writeToChain(password: password) else {throw Web3Error.processingError(desc: "Can't send transaction")} return result } diff --git a/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift b/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift index 1ba0baa24..8d9a39194 100644 --- a/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift +++ b/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift @@ -33,33 +33,33 @@ public extension ENS { public func claimAddress(from: EthereumAddress, owner: EthereumAddress) throws -> WriteOperation { defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("claim", parameters: [owner as AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("claim", parameters: [owner], extraData: Data() ) else {throw Web3Error.transactionSerializationError} return transaction } public func claimAddressWithResolver(from: EthereumAddress, owner: EthereumAddress, resolver: EthereumAddress) throws -> WriteOperation { defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("claimWithResolver", parameters: [owner, resolver] as [AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("claimWithResolver", parameters: [owner, resolver], extraData: Data() ) else {throw Web3Error.transactionSerializationError} return transaction } public func setName(from: EthereumAddress, name: String) throws -> WriteOperation { defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("setName", parameters: [name] as [AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("setName", parameters: [name], extraData: Data() ) else {throw Web3Error.transactionSerializationError} return transaction } public func getReverseRecordName(address: EthereumAddress) async throws -> Data { - guard let transaction = self.contract.createReadOperation("node", parameters: [address] as [AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createReadOperation("node", parameters: [address], extraData: Data() ) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let name = result["0"] as? Data else {throw Web3Error.processingError(desc: "Can't get answer")} return name } public func getDefaultResolver() async throws -> EthereumAddress { - guard let transaction = self.contract.createReadOperation("defaultResolver", parameters: [] as [AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createReadOperation("defaultResolver", parameters: [], extraData: Data() ) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let address = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Can't get answer")} return address diff --git a/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift b/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift index f684e3692..c64dd03da 100644 --- a/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift +++ b/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift @@ -31,28 +31,28 @@ public extension ENS { } public func getRentPrice(name: String, duration: UInt) async throws -> BigUInt { - guard let transaction = self.contract.createReadOperation("rentPrice", parameters: [name, duration] as [AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createReadOperation("rentPrice", parameters: [name, duration], extraData: Data() ) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let price = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Can't get answer")} return price } public func checkNameValidity(name: String) async throws -> Bool { - guard let transaction = self.contract.createReadOperation("valid", parameters: [name] as [AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createReadOperation("valid", parameters: [name], extraData: Data() ) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let valid = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Can't get answer")} return valid } public func isNameAvailable(name: String) async throws -> Bool { - guard let transaction = self.contract.createReadOperation("available", parameters: [name as AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createReadOperation("available", parameters: [name], extraData: Data() ) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let available = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Can't get answer")} return available } public func calculateCommitmentHash(name: String, owner: EthereumAddress, secret: String) async throws -> Data { - guard let transaction = self.contract.createReadOperation("makeCommitment", parameters: [name, owner.address, secret] as [AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createReadOperation("makeCommitment", parameters: [name, owner.address, secret], extraData: Data() ) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let hash = result["0"] as? Data else {throw Web3Error.processingError(desc: "Can't get answer")} return hash @@ -61,7 +61,7 @@ public extension ENS { public func sumbitCommitment(from: EthereumAddress, commitment: Data) throws -> WriteOperation { defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("commit", parameters: [commitment as AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("commit", parameters: [commitment], extraData: Data() ) else {throw Web3Error.transactionSerializationError} return transaction } @@ -70,7 +70,7 @@ public extension ENS { defaultOptions.value = amount defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("register", parameters: [name, owner.address, duration, secret] as [AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("register", parameters: [name, owner.address, duration, secret], extraData: Data() ) else {throw Web3Error.transactionSerializationError} return transaction } @@ -79,7 +79,7 @@ public extension ENS { defaultOptions.value = amount defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("renew", parameters: [name, duration] as [AnyObject], extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("renew", parameters: [name, duration], extraData: Data() ) else {throw Web3Error.transactionSerializationError} return transaction } @@ -87,7 +87,7 @@ public extension ENS { public func withdraw(from: EthereumAddress) throws -> WriteOperation { defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("withdraw", parameters: [AnyObject](), extraData: Data() ) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("withdraw", parameters: [Any](), extraData: Data() ) else {throw Web3Error.transactionSerializationError} return transaction } } diff --git a/Sources/web3swift/Web3/Web3+Contract.swift b/Sources/web3swift/Web3/Web3+Contract.swift index ebb9bc41a..da59285ed 100755 --- a/Sources/web3swift/Web3/Web3+Contract.swift +++ b/Sources/web3swift/Web3/Web3+Contract.swift @@ -53,7 +53,7 @@ extension Web3 { /// Returns a "Transaction intermediate" object. public func prepareDeploy(bytecode: Data, constructor: ABI.Element.Constructor? = nil, - parameters: [AnyObject]? = nil, + parameters: [Any]? = nil, extraData: Data? = nil) -> WriteOperation? { // MARK: Writing Data flow guard let data = self.contract.deploy(bytecode: bytecode, @@ -83,7 +83,7 @@ extension Web3 { /// Elements of "parameters" can be other arrays or instances of String, Data, BigInt, BigUInt, Int or EthereumAddress. /// /// Returns a "Transaction intermediate" object. - public func createReadOperation(_ method: String = "fallback", parameters: [AnyObject] = [AnyObject](), extraData: Data = Data()) -> ReadOperation? { + public func createReadOperation(_ method: String = "fallback", parameters: [Any] = [Any](), extraData: Data = Data()) -> ReadOperation? { // MARK: - Encoding ABI Data flow guard let data = contract.method(method, parameters: parameters, extraData: extraData) else { return nil } @@ -104,7 +104,7 @@ extension Web3 { /// Elements of "parameters" can be other arrays or instances of String, Data, BigInt, BigUInt, Int or EthereumAddress. /// /// Returns a "Transaction intermediate" object. - public func createWriteOperation(_ method: String = "fallback", parameters: [AnyObject] = [AnyObject](), extraData: Data = Data()) -> WriteOperation? { + public func createWriteOperation(_ method: String = "fallback", parameters: [Any] = [Any](), extraData: Data = Data()) -> WriteOperation? { guard let data = contract.method(method, parameters: parameters, extraData: extraData) else { return nil } transaction.data = data if let network = web3.provider.network { diff --git a/Sources/web3swift/Web3/Web3+Utils.swift b/Sources/web3swift/Web3/Web3+Utils.swift index e58005fd1..a5a3310b9 100755 --- a/Sources/web3swift/Web3/Web3+Utils.swift +++ b/Sources/web3swift/Web3/Web3+Utils.swift @@ -23,7 +23,7 @@ extension Web3.Utils { // /// and the nonce of this address // public static func calculateContractAddress(from: EthereumAddress, nonce: BigUInt) -> EthereumAddress? { // guard let normalizedAddress = from.addressData.setLengthLeft(32) else {return nil} - // guard let data = RLP.encode([normalizedAddress, nonce] as [AnyObject]) else {return nil} + // guard let data = RLP.encode([normalizedAddress, nonce]) else {return nil} // guard let contractAddressData = Utilities.sha3(data)?[12..<32] else {return nil} // guard let contractAddress = EthereumAddress(Data(contractAddressData)) else {return nil} // return contractAddress diff --git a/Tests/web3swiftTests/localTests/ABIEncoderTest.swift b/Tests/web3swiftTests/localTests/ABIEncoderTest.swift index 4b50fdecd..efe0348a5 100644 --- a/Tests/web3swiftTests/localTests/ABIEncoderTest.swift +++ b/Tests/web3swiftTests/localTests/ABIEncoderTest.swift @@ -103,7 +103,7 @@ class ABIEncoderTest: XCTestCase { } func testAbiEncodingEmptyValues() { - let zeroBytes = ABIEncoder.encode(types: [ABI.Element.InOut](), values: [AnyObject]())! + let zeroBytes = ABIEncoder.encode(types: [ABI.Element.InOut](), values: [Any]())! XCTAssert(zeroBytes.count == 0) let functionWithNoInput = ABI.Element.Function(name: "testFunction", @@ -117,69 +117,69 @@ class ABIEncoderTest: XCTestCase { } func testConvertToBigInt() { - XCTAssertEqual(ABIEncoder.convertToBigInt(BigInt(-29390909).serialize() as AnyObject), -29390909) - XCTAssertEqual(ABIEncoder.convertToBigInt(Data.fromHex("00FF")! as AnyObject), 255) - XCTAssertEqual(ABIEncoder.convertToBigInt(BigInt(-29390909) as AnyObject), -29390909) - XCTAssertEqual(ABIEncoder.convertToBigInt(BigUInt(29390909) as AnyObject), 29390909) - XCTAssertEqual(ABIEncoder.convertToBigInt(UInt(123) as AnyObject), 123) - XCTAssertEqual(ABIEncoder.convertToBigInt(UInt8(254) as AnyObject), 254) - XCTAssertEqual(ABIEncoder.convertToBigInt(UInt16(9090) as AnyObject), 9090) - XCTAssertEqual(ABIEncoder.convertToBigInt(UInt32(747474) as AnyObject), 747474) - XCTAssertEqual(ABIEncoder.convertToBigInt(UInt64(45222) as AnyObject), 45222) - XCTAssertEqual(ABIEncoder.convertToBigInt(Int(123) as AnyObject), 123) - XCTAssertEqual(ABIEncoder.convertToBigInt(Int8(127) as AnyObject), 127) - XCTAssertEqual(ABIEncoder.convertToBigInt(Int16(9090) as AnyObject), 9090) - XCTAssertEqual(ABIEncoder.convertToBigInt(Int32(83888) as AnyObject), 83888) - XCTAssertEqual(ABIEncoder.convertToBigInt(Int64(45222) as AnyObject), 45222) - XCTAssertEqual(ABIEncoder.convertToBigInt(Int(-32213) as AnyObject), -32213) - XCTAssertEqual(ABIEncoder.convertToBigInt(Int8(-10) as AnyObject), -10) - XCTAssertEqual(ABIEncoder.convertToBigInt(Int16(-32000) as AnyObject), -32000) - XCTAssertEqual(ABIEncoder.convertToBigInt(Int32(-50050500) as AnyObject), -50050500) - XCTAssertEqual(ABIEncoder.convertToBigInt(Int64(-2) as AnyObject), -2) - XCTAssertEqual(ABIEncoder.convertToBigInt("10" as AnyObject), 10) - XCTAssertEqual(ABIEncoder.convertToBigInt("-10" as AnyObject), -10) - XCTAssertEqual(ABIEncoder.convertToBigInt("FF" as AnyObject), 255) - XCTAssertEqual(ABIEncoder.convertToBigInt("-FF" as AnyObject), -255) - XCTAssertEqual(ABIEncoder.convertToBigInt("0xFF" as AnyObject), 255) - XCTAssertEqual(ABIEncoder.convertToBigInt(" 10 " as AnyObject), 10) - XCTAssertEqual(ABIEncoder.convertToBigInt(" -10 " as AnyObject), -10) - XCTAssertEqual(ABIEncoder.convertToBigInt(" FF " as AnyObject), 255) - XCTAssertEqual(ABIEncoder.convertToBigInt(" -FF " as AnyObject), -255) - XCTAssertEqual(ABIEncoder.convertToBigInt(" 0xFF " as AnyObject), 255) + XCTAssertEqual(ABIEncoder.convertToBigInt(BigInt(-29390909).serialize()), -29390909) + XCTAssertEqual(ABIEncoder.convertToBigInt(Data.fromHex("00FF")!), 255) + XCTAssertEqual(ABIEncoder.convertToBigInt(BigInt(-29390909)), -29390909) + XCTAssertEqual(ABIEncoder.convertToBigInt(BigUInt(29390909)), 29390909) + XCTAssertEqual(ABIEncoder.convertToBigInt(UInt(123)), 123) + XCTAssertEqual(ABIEncoder.convertToBigInt(UInt8(254)), 254) + XCTAssertEqual(ABIEncoder.convertToBigInt(UInt16(9090)), 9090) + XCTAssertEqual(ABIEncoder.convertToBigInt(UInt32(747474)), 747474) + XCTAssertEqual(ABIEncoder.convertToBigInt(UInt64(45222)), 45222) + XCTAssertEqual(ABIEncoder.convertToBigInt(Int(123)), 123) + XCTAssertEqual(ABIEncoder.convertToBigInt(Int8(127)), 127) + XCTAssertEqual(ABIEncoder.convertToBigInt(Int16(9090)), 9090) + XCTAssertEqual(ABIEncoder.convertToBigInt(Int32(83888)), 83888) + XCTAssertEqual(ABIEncoder.convertToBigInt(Int64(45222)), 45222) + XCTAssertEqual(ABIEncoder.convertToBigInt(Int(-32213)), -32213) + XCTAssertEqual(ABIEncoder.convertToBigInt(Int8(-10)), -10) + XCTAssertEqual(ABIEncoder.convertToBigInt(Int16(-32000)), -32000) + XCTAssertEqual(ABIEncoder.convertToBigInt(Int32(-50050500)), -50050500) + XCTAssertEqual(ABIEncoder.convertToBigInt(Int64(-2)), -2) + XCTAssertEqual(ABIEncoder.convertToBigInt("10"), 10) + XCTAssertEqual(ABIEncoder.convertToBigInt("-10"), -10) + XCTAssertEqual(ABIEncoder.convertToBigInt("FF"), 255) + XCTAssertEqual(ABIEncoder.convertToBigInt("-FF"), -255) + XCTAssertEqual(ABIEncoder.convertToBigInt("0xFF"), 255) + XCTAssertEqual(ABIEncoder.convertToBigInt(" 10 "), 10) + XCTAssertEqual(ABIEncoder.convertToBigInt(" -10 "), -10) + XCTAssertEqual(ABIEncoder.convertToBigInt(" FF "), 255) + XCTAssertEqual(ABIEncoder.convertToBigInt(" -FF "), -255) + XCTAssertEqual(ABIEncoder.convertToBigInt(" 0xFF "), 255) } func testConvertToBigUInt() { /// When negative value is serialized the first byte represents sign when decoding as a signed number. /// Unsigned numbers treat the first byte as just another byte of a number, not a sign. - XCTAssertEqual(ABIEncoder.convertToBigUInt(BigInt(-29390909).serialize() as AnyObject), 4324358205) - XCTAssertEqual(ABIEncoder.convertToBigUInt(Data.fromHex("00FF")! as AnyObject), 255) - XCTAssertEqual(ABIEncoder.convertToBigUInt(BigInt(-29390909) as AnyObject), nil) - XCTAssertEqual(ABIEncoder.convertToBigUInt(BigUInt(29390909) as AnyObject), 29390909) - XCTAssertEqual(ABIEncoder.convertToBigUInt(UInt(123) as AnyObject), 123) - XCTAssertEqual(ABIEncoder.convertToBigUInt(UInt8(254) as AnyObject), 254) - XCTAssertEqual(ABIEncoder.convertToBigUInt(UInt16(9090) as AnyObject), 9090) - XCTAssertEqual(ABIEncoder.convertToBigUInt(UInt32(747474) as AnyObject), 747474) - XCTAssertEqual(ABIEncoder.convertToBigUInt(UInt64(45222) as AnyObject), 45222) - XCTAssertEqual(ABIEncoder.convertToBigUInt(Int(123) as AnyObject), 123) - XCTAssertEqual(ABIEncoder.convertToBigUInt(Int8(127) as AnyObject), 127) - XCTAssertEqual(ABIEncoder.convertToBigUInt(Int16(9090) as AnyObject), 9090) - XCTAssertEqual(ABIEncoder.convertToBigUInt(Int32(83888) as AnyObject), 83888) - XCTAssertEqual(ABIEncoder.convertToBigUInt(Int64(45222) as AnyObject), 45222) - XCTAssertEqual(ABIEncoder.convertToBigUInt(Int(-32213) as AnyObject), nil) - XCTAssertEqual(ABIEncoder.convertToBigUInt(Int8(-10) as AnyObject), nil) - XCTAssertEqual(ABIEncoder.convertToBigUInt(Int16(-32000) as AnyObject), nil) - XCTAssertEqual(ABIEncoder.convertToBigUInt(Int32(-50050500) as AnyObject), nil) - XCTAssertEqual(ABIEncoder.convertToBigUInt(Int64(-2) as AnyObject), nil) - XCTAssertEqual(ABIEncoder.convertToBigUInt("10" as AnyObject), 10) - XCTAssertEqual(ABIEncoder.convertToBigUInt("-10" as AnyObject), nil) - XCTAssertEqual(ABIEncoder.convertToBigUInt("FF" as AnyObject), 255) - XCTAssertEqual(ABIEncoder.convertToBigUInt("-FF" as AnyObject), nil) - XCTAssertEqual(ABIEncoder.convertToBigUInt("0xFF" as AnyObject), 255) - XCTAssertEqual(ABIEncoder.convertToBigUInt(" 10 " as AnyObject), 10) - XCTAssertEqual(ABIEncoder.convertToBigUInt(" -10 " as AnyObject), nil) - XCTAssertEqual(ABIEncoder.convertToBigUInt(" FF " as AnyObject), 255) - XCTAssertEqual(ABIEncoder.convertToBigUInt(" -FF " as AnyObject), nil) - XCTAssertEqual(ABIEncoder.convertToBigUInt(" 0xFF " as AnyObject), 255) + XCTAssertEqual(ABIEncoder.convertToBigUInt(BigInt(-29390909).serialize()), 4324358205) + XCTAssertEqual(ABIEncoder.convertToBigUInt(Data.fromHex("00FF")!), 255) + XCTAssertEqual(ABIEncoder.convertToBigUInt(BigInt(-29390909)), nil) + XCTAssertEqual(ABIEncoder.convertToBigUInt(BigUInt(29390909)), 29390909) + XCTAssertEqual(ABIEncoder.convertToBigUInt(UInt(123)), 123) + XCTAssertEqual(ABIEncoder.convertToBigUInt(UInt8(254)), 254) + XCTAssertEqual(ABIEncoder.convertToBigUInt(UInt16(9090)), 9090) + XCTAssertEqual(ABIEncoder.convertToBigUInt(UInt32(747474)), 747474) + XCTAssertEqual(ABIEncoder.convertToBigUInt(UInt64(45222)), 45222) + XCTAssertEqual(ABIEncoder.convertToBigUInt(Int(123)), 123) + XCTAssertEqual(ABIEncoder.convertToBigUInt(Int8(127)), 127) + XCTAssertEqual(ABIEncoder.convertToBigUInt(Int16(9090)), 9090) + XCTAssertEqual(ABIEncoder.convertToBigUInt(Int32(83888)), 83888) + XCTAssertEqual(ABIEncoder.convertToBigUInt(Int64(45222)), 45222) + XCTAssertEqual(ABIEncoder.convertToBigUInt(Int(-32213)), nil) + XCTAssertEqual(ABIEncoder.convertToBigUInt(Int8(-10)), nil) + XCTAssertEqual(ABIEncoder.convertToBigUInt(Int16(-32000)), nil) + XCTAssertEqual(ABIEncoder.convertToBigUInt(Int32(-50050500)), nil) + XCTAssertEqual(ABIEncoder.convertToBigUInt(Int64(-2)), nil) + XCTAssertEqual(ABIEncoder.convertToBigUInt("10"), 10) + XCTAssertEqual(ABIEncoder.convertToBigUInt("-10"), nil) + XCTAssertEqual(ABIEncoder.convertToBigUInt("FF"), 255) + XCTAssertEqual(ABIEncoder.convertToBigUInt("-FF"), nil) + XCTAssertEqual(ABIEncoder.convertToBigUInt("0xFF"), 255) + XCTAssertEqual(ABIEncoder.convertToBigUInt(" 10 "), 10) + XCTAssertEqual(ABIEncoder.convertToBigUInt(" -10 "), nil) + XCTAssertEqual(ABIEncoder.convertToBigUInt(" FF "), 255) + XCTAssertEqual(ABIEncoder.convertToBigUInt(" -FF "), nil) + XCTAssertEqual(ABIEncoder.convertToBigUInt(" 0xFF "), 255) } /// When dynamic types (string, non-fixed size array, dynamic bytes) are encoded @@ -187,15 +187,15 @@ class ABIEncoderTest: XCTestCase { /// how much bytes should be skipped from the beginning of the resulting byte array to reach the /// value of the dynamic type. func testDynamicTypesDataOffset() { - var hexData = ABIEncoder.encode(types: [.string], values: ["test"] as [AnyObject])?.toHexString() + var hexData = ABIEncoder.encode(types: [.string], values: ["test"])?.toHexString() XCTAssertEqual(hexData?[0..<64], "0000000000000000000000000000000000000000000000000000000000000020") XCTAssertEqual(hexData, "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000047465737400000000000000000000000000000000000000000000000000000000") - hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 0)], values: [[1,2,3,4]] as [AnyObject])?.toHexString() + hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 0)], values: [[1,2,3,4]])?.toHexString() XCTAssertEqual(hexData?[0..<64], "0000000000000000000000000000000000000000000000000000000000000020") XCTAssertEqual(hexData, "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004") // This one shouldn't have data offset - hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 4)], values: [[1,2,3,4]] as [AnyObject])?.toHexString() + hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 4)], values: [[1,2,3,4]])?.toHexString() // First 32 bytes are the first value from the array XCTAssertEqual(hexData?[0..<64], "0000000000000000000000000000000000000000000000000000000000000001") XCTAssertEqual(hexData, "0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004") @@ -204,7 +204,7 @@ class ABIEncoderTest: XCTestCase { .bool, .array(type: .uint(bits: 8), length: 0), .bytes(length: 2)] - let values: [AnyObject] = [10, false, [1,2,3,4], Data(count: 2)] as [AnyObject] + let values: [Any] = [10, false, [1,2,3,4], Data(count: 2)] hexData = ABIEncoder.encode(types: types, values: values)?.toHexString() XCTAssertEqual(hexData?[128..<192], "0000000000000000000000000000000000000000000000000000000000000080") XCTAssertEqual(hexData, "000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004") @@ -212,22 +212,22 @@ class ABIEncoderTest: XCTestCase { /// Test for the expected output when encoding dynamic types. func testAbiEncodingDynamicTypes() { - var encodedValue = ABIEncoder.encode(types: [.dynamicBytes], values: [Data.fromHex("6761766f66796f726b")!] as [AnyObject])!.toHexString() + var encodedValue = ABIEncoder.encode(types: [.dynamicBytes], values: [Data.fromHex("6761766f66796f726b")!])!.toHexString() XCTAssertEqual(encodedValue, "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000096761766f66796f726b0000000000000000000000000000000000000000000000") - encodedValue = ABIEncoder.encode(types: [.dynamicBytes], values: [Data.fromHex("731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b")!] as [AnyObject])!.toHexString() + encodedValue = ABIEncoder.encode(types: [.dynamicBytes], values: [Data.fromHex("731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b")!])!.toHexString() XCTAssertEqual(encodedValue, "00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b") - encodedValue = ABIEncoder.encode(types: [.dynamicBytes], values: [Data.fromHex("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1")!] as [AnyObject])!.toHexString() + encodedValue = ABIEncoder.encode(types: [.dynamicBytes], values: [Data.fromHex("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1")!])!.toHexString() XCTAssertEqual(encodedValue, "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000009ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff100") - encodedValue = ABIEncoder.encode(types: [.dynamicBytes], values: [Data.fromHex("c3a40000c3a4")!] as [AnyObject])!.toHexString() + encodedValue = ABIEncoder.encode(types: [.dynamicBytes], values: [Data.fromHex("c3a40000c3a4")!])!.toHexString() XCTAssertEqual(encodedValue, "00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000006c3a40000c3a40000000000000000000000000000000000000000000000000000") - encodedValue = ABIEncoder.encode(types: [.string], values: ["gavofyork"] as [AnyObject])!.toHexString() + encodedValue = ABIEncoder.encode(types: [.string], values: ["gavofyork"])!.toHexString() XCTAssertEqual(encodedValue, "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000096761766f66796f726b0000000000000000000000000000000000000000000000") - encodedValue = ABIEncoder.encode(types: [.string], values: ["Heeäööä👅D34ɝɣ24Єͽ-.,äü+#/"] as [AnyObject])!.toHexString() + encodedValue = ABIEncoder.encode(types: [.string], values: ["Heeäööä👅D34ɝɣ24Єͽ-.,äü+#/"])!.toHexString() XCTAssertEqual(encodedValue, "00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000026486565c3a4c3b6c3b6c3a4f09f9185443334c99dc9a33234d084cdbd2d2e2cc3a4c3bc2b232f0000000000000000000000000000000000000000000000000000") } } diff --git a/Tests/web3swiftTests/localTests/AdvancedABIv2Tests.swift b/Tests/web3swiftTests/localTests/AdvancedABIv2Tests.swift index 1be8abb35..c5ce050d9 100755 --- a/Tests/web3swiftTests/localTests/AdvancedABIv2Tests.swift +++ b/Tests/web3swiftTests/localTests/AdvancedABIv2Tests.swift @@ -56,7 +56,7 @@ class AdvancedABIv2Tests: LocalTestCase { let allAddresses = try await web3.eth.ownedAccounts() var contract = web3.contract(abiString, at: nil, abiVersion: 2)! - let parameters = [] as [AnyObject] + let parameters: [Any] = [] // MARK: Writing Data flow let deployTx = contract.prepareDeploy(bytecode: bytecode, parameters: parameters)! deployTx.transaction.from = allAddresses[0] @@ -92,7 +92,7 @@ class AdvancedABIv2Tests: LocalTestCase { let allAddresses = try await web3.eth.ownedAccounts() var contract = web3.contract(abiString, at: nil, abiVersion: 2)! - let parameters = [] as [AnyObject] + let parameters: [Any] = [] // MARK: Writing Data flow let deployTx = contract.prepareDeploy(bytecode: bytecode, parameters: parameters)! deployTx.transaction.from = allAddresses[0] @@ -127,7 +127,7 @@ class AdvancedABIv2Tests: LocalTestCase { let allAddresses = try await web3.eth.ownedAccounts() var contract = web3.contract(abiString, at: nil, abiVersion: 2)! - let parameters = [] as [AnyObject] + let parameters: [Any] = [] // MARK: Writing Data flow let deployTx = contract.prepareDeploy(bytecode: bytecode, parameters: parameters)! deployTx.transaction.from = allAddresses[0] @@ -163,7 +163,7 @@ class AdvancedABIv2Tests: LocalTestCase { let allAddresses = try await web3.eth.ownedAccounts() var contract = web3.contract(abiString, at: nil, abiVersion: 2)! - let parameters = [] as [AnyObject] + let parameters: [Any] = [] // MARK: Writing Data flow let deployTx = contract.prepareDeploy(bytecode: bytecode, parameters: parameters)! deployTx.transaction.from = allAddresses[0] diff --git a/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift b/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift index e71641ee3..fbb85e68b 100755 --- a/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift +++ b/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift @@ -21,7 +21,7 @@ class BasicLocalNodeTests: LocalTestCase { let contract = web3.contract(abiString, at: nil, abiVersion: 2)! - let parameters = [] as [AnyObject] + let parameters: [Any] = [] let deployTx = contract.prepareDeploy(bytecode: bytecode, parameters: parameters)! deployTx.transaction.from = allAddresses[0] let policies = Policies(gasLimitPolicy: .manual(3000000)) @@ -48,7 +48,7 @@ class BasicLocalNodeTests: LocalTestCase { let sendToAddress = EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")! let contract = web3.contract(Web3.Utils.coldWalletABI, at: sendToAddress, abiVersion: 2)! - let parameters = [] as [AnyObject] + let parameters: [Any] = [] let sendTx = contract.createWriteOperation("fallback", parameters: parameters)! let valueToSend = try XCTUnwrap(Utilities.parseToBigUInt("1.0", units: .ether)) diff --git a/Tests/web3swiftTests/localTests/EIP681Tests.swift b/Tests/web3swiftTests/localTests/EIP681Tests.swift index 2f347bf59..cabd53fa2 100755 --- a/Tests/web3swiftTests/localTests/EIP681Tests.swift +++ b/Tests/web3swiftTests/localTests/EIP681Tests.swift @@ -93,6 +93,11 @@ class EIP681Tests: XCTestCase { XCTAssertEqual(address, testAddress) } + guard eip681Code.parameters.count > 1 else { + XCTFail("'eip681Code.parameters.count' must be at least 2.") + return + } + XCTAssertEqual(eip681Code.functionName, "transfer") XCTAssertEqual(eip681Code.parameters[0].type, .address) /// `eip681Code.parameters[0].value` is not checked as it's fetched from remote and is unknown. @@ -115,6 +120,11 @@ class EIP681Tests: XCTestCase { XCTAssertEqual(address, testAddress) } + guard eip681Code.parameters.count > 1 else { + XCTFail("'eip681Code.parameters.count' must be at least 2.") + return + } + XCTAssertEqual(eip681Code.functionName, "transfer") XCTAssertEqual(eip681Code.parameters[0].type, .address) /// `eip681Code.parameters[0].value` is not checked as it's fetched from remote and is unknown. @@ -284,24 +294,24 @@ class EIP681Tests: XCTestCase { eip681Link.functionName = "setData" eip681Link.parameters = [Web3.EIP681Code.EIP681Parameter(type: .array(type: .bytes(length: 32), length: 0), value: [Data.fromHex("0x1234789565875498655487123478956587549865548712347895658754980000")!, - Data.fromHex("0x1234789565875498655487123478956587549865548712347895658754986554")!] as AnyObject), + Data.fromHex("0x1234789565875498655487123478956587549865548712347895658754986554")!]), Web3.EIP681Code.EIP681Parameter(type: .array(type: .dynamicBytes, length: 0), value: [Data.fromHex("0x12345607")!, - Data.fromHex("0x8965abcdef")!] as AnyObject), + Data.fromHex("0x8965abcdef")!]), Web3.EIP681Code.EIP681Parameter(type: .uint(bits: 256), - value: 98986565 as AnyObject), + value: 98986565), Web3.EIP681Code.EIP681Parameter(type: .int(bits: 256), - value: 155445566 as AnyObject), + value: 155445566), Web3.EIP681Code.EIP681Parameter(type: .address, - value: EthereumAddress("0x9aBbDB06A61cC686BD635484439549D45c2449cc")! as AnyObject), + value: EthereumAddress("0x9aBbDB06A61cC686BD635484439549D45c2449cc")!), Web3.EIP681Code.EIP681Parameter(type: .bytes(length: 5), - value: "0x9aBbDB06A6" as AnyObject), + value: "0x9aBbDB06A6"), Web3.EIP681Code.EIP681Parameter(type: .bytes(length: 3), - value: Data.fromHex("0x9aBbDB")! as AnyObject), + value: Data.fromHex("0x9aBbDB")!), Web3.EIP681Code.EIP681Parameter(type: .dynamicBytes, - value: Data.fromHex("0x11009aBbDB87879898656545")! as AnyObject), + value: Data.fromHex("0x11009aBbDB87879898656545")!), Web3.EIP681Code.EIP681Parameter(type: .string, - value: "this is EIP681 query parameter string" as AnyObject)] + value: "this is EIP681 query parameter string")] let unencodedResult = "ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc/setData?bytes32[]=[0x1234789565875498655487123478956587549865548712347895658754980000,0x1234789565875498655487123478956587549865548712347895658754986554]&bytes[]=[0x12345607,0x8965abcdef]&uint256=98986565&int256=155445566&address=0x9aBbDB06A61cC686BD635484439549D45c2449cc&bytes5=0x9abbdb06a6&bytes3=0x9abbdb&bytes=0x11009abbdb87879898656545&string=this is EIP681 query parameter string" diff --git a/Tests/web3swiftTests/localTests/EIP712Tests.swift b/Tests/web3swiftTests/localTests/EIP712Tests.swift index 538c651cf..3f527d2cf 100644 --- a/Tests/web3swiftTests/localTests/EIP712Tests.swift +++ b/Tests/web3swiftTests/localTests/EIP712Tests.swift @@ -17,8 +17,8 @@ class EIP712Tests: LocalTestCase { payable: false) let object = ABI.Element.function(function) let safeTxData = object.encodeParameters([ - EthereumAddress("0x41B5844f4680a8C38fBb695b7F9CFd1F64474a72")! as AnyObject, - amountLinen as AnyObject + EthereumAddress("0x41B5844f4680a8C38fBb695b7F9CFd1F64474a72")!, + amountLinen ])! let operation: EIP712.UInt8 = 1 let safeTxGas = EIP712.UInt256(250000) @@ -68,8 +68,8 @@ class EIP712Tests: LocalTestCase { payable: false) let object = ABI.Element.function(function) let safeTxData = object.encodeParameters([ - EthereumAddress("0x41B5844f4680a8C38fBb695b7F9CFd1F64474a72")! as AnyObject, - amount as AnyObject + EthereumAddress("0x41B5844f4680a8C38fBb695b7F9CFd1F64474a72")!, + amount ])! let operation: EIP712.UInt8 = 1 let safeTxGas = EIP712.UInt256(250000) diff --git a/Tests/web3swiftTests/localTests/ERC20Tests.swift b/Tests/web3swiftTests/localTests/ERC20Tests.swift index 231719d51..f79ae933f 100755 --- a/Tests/web3swiftTests/localTests/ERC20Tests.swift +++ b/Tests/web3swiftTests/localTests/ERC20Tests.swift @@ -26,7 +26,7 @@ class ERC20Tests: LocalTestCase { let addressOfUser = EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")! let contract = web3.contract(Web3.Utils.erc20ABI, at: receipt.contractAddress!, abiVersion: 2)! - guard let readTX = contract.createReadOperation("balanceOf", parameters: [addressOfUser] as [AnyObject]) else {return XCTFail()} + guard let readTX = contract.createReadOperation("balanceOf", parameters: [addressOfUser]) else {return XCTFail()} readTX.transaction.from = addressOfUser let tokenBalance = try await readTX.callContractMethod() guard let bal = tokenBalance["0"] as? BigUInt else {return XCTFail()} @@ -49,7 +49,7 @@ class ERC20Tests: LocalTestCase { // let method = "transfer" // let tx = contract.write( // method, -// parameters: [toAddress, amount] as [AnyObject], +// parameters: [toAddress, amount], // extraData: Data(), // transaction: options)! // } diff --git a/Tests/web3swiftTests/localTests/EthereumContractTest.swift b/Tests/web3swiftTests/localTests/EthereumContractTest.swift index 06251e388..be6c6cd4f 100644 --- a/Tests/web3swiftTests/localTests/EthereumContractTest.swift +++ b/Tests/web3swiftTests/localTests/EthereumContractTest.swift @@ -65,10 +65,10 @@ class EthereumContractTest: LocalTestCase { func test_encodeMethodBasedOnNameWithParameters() async throws { let web3 = try await Web3.new(LocalTestCase.url) let contract = try XCTUnwrap(web3.contract(EthereumContractTest.overloadedFunctionsABI, at: EthereumAddress("0x6394b37Cf80A7358b38068f0CA4760ad49983a1B"))) - let parameters: [AnyObject] = [ + let parameters: [Any] = [ [Data.randomBytes(length: 32), Data.randomBytes(length: 32)], [Data.randomBytes(length: 32), Data.randomBytes(length: 32)] - ] as [AnyObject] + ] let functionNameWithParameters = "setData(bytes32[],bytes[])" let transaction = contract.createWriteOperation(functionNameWithParameters, parameters: parameters) XCTAssertNotNil(transaction) @@ -88,7 +88,7 @@ class EthereumContractTest: LocalTestCase { func test_encodeMethodBasedOnHexSignature() async throws { let web3 = try await Web3.new(LocalTestCase.url) let contract = try XCTUnwrap(web3.contract(EthereumContractTest.overloadedFunctionsABI, at: EthereumAddress("0x6394b37Cf80A7358b38068f0CA4760ad49983a1B"))) - let parameters: [AnyObject] = [Data.randomBytes(length: 32), Data.randomBytes(length: 32)] as [AnyObject] + let parameters: [Any] = [Data.randomBytes(length: 32), Data.randomBytes(length: 32)] let functionSignature = getFuncSignature("setData(bytes32,bytes)") let transaction = contract.createWriteOperation(functionSignature, parameters: parameters) XCTAssertNotNil(transaction) diff --git a/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift b/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift index 141b23b0d..a46bb4b28 100755 --- a/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift +++ b/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift @@ -65,13 +65,13 @@ class PersonalSignatureTests: XCTestCase { // Calling contract contract = web3.contract(abiString, at: receipt.contractAddress!)! - var tx = contract.createReadOperation("hashPersonalMessage", parameters: [message as AnyObject]) + var tx = contract.createReadOperation("hashPersonalMessage", parameters: [message]) tx?.transaction.from = expectedAddress var result = try await tx!.callContractMethod() guard let hash = result["hash"]! as? Data else { return XCTFail() } XCTAssert(Utilities.hashPersonalMessage(message.data(using: .utf8)!)! == hash) - tx = contract.createReadOperation("recoverSigner", parameters: [message, unmarshalledSignature.v, Data(unmarshalledSignature.r), Data(unmarshalledSignature.s)] as [AnyObject]) + tx = contract.createReadOperation("recoverSigner", parameters: [message, unmarshalledSignature.v, Data(unmarshalledSignature.r), Data(unmarshalledSignature.s)]) tx?.transaction.from = expectedAddress result = try await tx!.callContractMethod() guard let signer = result["signer"]! as? EthereumAddress else { return XCTFail() } diff --git a/Tests/web3swiftTests/localTests/PromisesTests.swift b/Tests/web3swiftTests/localTests/PromisesTests.swift index 8063003d9..434c6389c 100755 --- a/Tests/web3swiftTests/localTests/PromisesTests.swift +++ b/Tests/web3swiftTests/localTests/PromisesTests.swift @@ -41,7 +41,7 @@ // let allAddresses = try await web3.eth.ownedAccounts() // let contract = web3.contract(Web3.Utils.estimateGasTestABI, at: nil, abiVersion: 2)! // -// let parameters = [] as [AnyObject] +// let parameters = [] // let deployTx = contract.deploy(bytecode: bytecode, parameters: parameters)! // deployTx.transaction.from = allAddresses[0] // deployTx.transaction.gasLimitPolicy = .manual(3000000) @@ -80,7 +80,7 @@ // // // MARK: Writing Data flow // guard let tx1 = contract.write("test", -// parameters: [amount1] as [AnyObject], +// parameters: [amount1], // extraData: Data(), // transaction: options) else { // return @@ -93,7 +93,7 @@ // // // MARK: Writing Data flow // guard let tx2 = contract.write("test", -// parameters: [amount2] as [AnyObject], +// parameters: [amount2], // extraData: Data(), // transaction: options) else { // return @@ -122,7 +122,7 @@ // let token = web3.contract(Web3.Utils.erc20ABI, at: receipt.contractAddress, abiVersion: 2)! // // let userAddress = EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")! -// let tokenBalance = try await token.read("balanceOf", parameters: [userAddress] as [AnyObject])!.decodedData() +// let tokenBalance = try await token.read("balanceOf", parameters: [userAddress])!.decodedData() // guard let bal = tokenBalance["0"] as? BigUInt else {return XCTFail()} // ) // } diff --git a/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift b/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift index 84782bbeb..285b2641f 100644 --- a/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift +++ b/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift @@ -37,11 +37,11 @@ class ST20AndSecurityTokenTests: XCTestCase { } switch function.name { case "symbol": - return ABIEncoder.encode(types: [.string], values: [expectedSymbol] as [AnyObject])! + return ABIEncoder.encode(types: [.string], values: [expectedSymbol])! case "name": - return ABIEncoder.encode(types: [.string], values: [expectedName] as [AnyObject])! + return ABIEncoder.encode(types: [.string], values: [expectedName])! case "decimals": - return ABIEncoder.encode(types: [.uint(bits: 8)], values: [expectedDecimals] as [AnyObject])! + return ABIEncoder.encode(types: [.uint(bits: 8)], values: [expectedDecimals])! default: // Unexpected function called XCTFail("Called function '\(String(describing: function.name))' which wasn't supposed to be called.") @@ -71,12 +71,12 @@ class ST20AndSecurityTokenTests: XCTestCase { case "balanceOf": let address = function.decodeInputData(transaction.data)?["0"] as? EthereumAddress XCTAssertEqual(address, userAddress) - return ABIEncoder.encode(types: [.uint(bits: 256)], values: [expectedBalance] as [AnyObject])! + return ABIEncoder.encode(types: [.uint(bits: 256)], values: [expectedBalance])! case "allowance": let transactionInput = function.decodeInputData(transaction.data) XCTAssertEqual(transactionInput?["0"] as? EthereumAddress, userAddress) XCTAssertEqual(transactionInput?["1"] as? EthereumAddress, delegate) - return ABIEncoder.encode(types: [.uint(bits: 256)], values: [expectedAllowance] as [AnyObject])! + return ABIEncoder.encode(types: [.uint(bits: 256)], values: [expectedAllowance])! default: // Unexpected function called XCTFail("Called function '\(String(describing: function.name))' which wasn't supposed to be called.") @@ -98,7 +98,7 @@ class ST20AndSecurityTokenTests: XCTestCase { return Data() } if function.name == "investorCount" { - return ABIEncoder.encode(types: [.uint(bits: 256)], values: [expectedNumberOfInvestors] as [AnyObject])! + return ABIEncoder.encode(types: [.uint(bits: 256)], values: [expectedNumberOfInvestors])! } // Unexpected function called XCTFail("Called function '\(String(describing: function.name))' which wasn't supposed to be called.") @@ -119,7 +119,7 @@ class ST20AndSecurityTokenTests: XCTestCase { } switch function.name { case "granularity": - return ABIEncoder.encode(types: [.uint(bits: 256)], values: [expectedGranularity] as [AnyObject])! + return ABIEncoder.encode(types: [.uint(bits: 256)], values: [expectedGranularity])! default: // Unexpected function called XCTFail("Called function '\(String(describing: function.name))' which wasn't supposed to be called.") diff --git a/Tests/web3swiftTests/localTests/TestHelpers.swift b/Tests/web3swiftTests/localTests/TestHelpers.swift index 674771ec9..ce049fce4 100644 --- a/Tests/web3swiftTests/localTests/TestHelpers.swift +++ b/Tests/web3swiftTests/localTests/TestHelpers.swift @@ -22,12 +22,12 @@ class TestHelpers { let contract = web3.contract(abiString, at: nil, abiVersion: 2)! // FIXME: This should be zipped, because Arrays don't guarantee it's elements order - let parameters = [ + let parameters: [Any] = [ "web3swift", "w3s", EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")!, 1024 - ] as [AnyObject] + ] let deployTx = contract.prepareDeploy(bytecode: bytecode, constructor: contract.contract.constructor, parameters: parameters)! diff --git a/Tests/web3swiftTests/localTests/UncategorizedTests.swift b/Tests/web3swiftTests/localTests/UncategorizedTests.swift index dc5600da9..2dbebb775 100755 --- a/Tests/web3swiftTests/localTests/UncategorizedTests.swift +++ b/Tests/web3swiftTests/localTests/UncategorizedTests.swift @@ -116,7 +116,7 @@ class UncategorizedTests: XCTestCase { XCTAssert(contract != nil) let allMethods = contract!.contract.allMethods let userDeviceCount = try await contract! - .createReadOperation("userDeviceCount", parameters: [addr as AnyObject])? + .createReadOperation("userDeviceCount", parameters: [addr])? .callContractMethod() let totalUsers = try await contract! @@ -124,7 +124,7 @@ class UncategorizedTests: XCTestCase { .callContractMethod() let user = try await contract! - .createReadOperation("users", parameters: [0 as AnyObject])? + .createReadOperation("users", parameters: [0])? .callContractMethod() diff --git a/Tests/web3swiftTests/localTests/UserCases.swift b/Tests/web3swiftTests/localTests/UserCases.swift index 49a95184f..c6377dda9 100755 --- a/Tests/web3swiftTests/localTests/UserCases.swift +++ b/Tests/web3swiftTests/localTests/UserCases.swift @@ -22,7 +22,7 @@ class UserCases: XCTestCase { let (web3, _, receipt, abiString) = try await TestHelpers.localDeployERC20() let account = EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")! let contract = web3.contract(abiString, at: receipt.contractAddress!)! - let readTransaction = contract.createReadOperation("balanceOf", parameters: [account] as [AnyObject])! + let readTransaction = contract.createReadOperation("balanceOf", parameters: [account])! readTransaction.transaction.from = account let response = try await readTransaction.callContractMethod() let balance = response["0"] as? BigUInt @@ -76,7 +76,7 @@ class UserCases: XCTestCase { let allAddresses = try await web3.eth.ownedAccounts() let contract = web3.contract(Web3.Utils.estimateGasTestABI, at: nil, abiVersion: 2)! - let parameters = [AnyObject]() + let parameters = [Any]() let deployTx = contract.prepareDeploy(bytecode: bytecode, parameters: parameters)! deployTx.transaction.from = allAddresses[0] let policies = Policies(gasLimitPolicy: .manual(3000000)) From 79886de7bf6312120428d030262198f6ba4a1e39 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 14 Jan 2023 00:18:39 +0200 Subject: [PATCH 010/210] fix: ERC20BaseProperties are back to inherit from AnyObject (restricting protocol to classes) --- Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift b/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift index 6146d467e..e0d861fe7 100644 --- a/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift +++ b/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift @@ -9,7 +9,7 @@ import Foundation /// Declares common properties of an [ERC-20](https://eips.ethereum.org/EIPS/eip-20) complient smart contract. /// Default implementation of access to these properties is declared in the extension of this protocol. -public protocol ERC20BaseProperties: Any { +public protocol ERC20BaseProperties: AnyObject { var basePropertiesProvider: ERC20BasePropertiesProvider { get } var contract: Web3.Contract { get } var name: String? { get } From 65349803fcd90ab8a83dd1f5425ebdb29a114adb Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 14 Jan 2023 00:18:59 +0200 Subject: [PATCH 011/210] fix: some spacing and docs fixed --- .../Web3Core/Contract/ContractProtocol.swift | 4 +- Sources/web3swift/Browser/browser.js | 16 ++--- .../Tokens/ERC1155/Web3+ERC1155.swift | 6 +- .../Tokens/ERC1376/Web3+ERC1376.swift | 32 +++++----- .../Tokens/ERC1400/Web3+ERC1400.swift | 60 +++++++++---------- .../Tokens/ERC1410/Web3+ERC1410.swift | 44 +++++++------- .../Tokens/ERC1594/Web3+ERC1594.swift | 18 +++--- .../Tokens/ERC1633/Web3+ERC1633.swift | 8 +-- .../Tokens/ERC1643/Web3+ERC1643.swift | 12 ++-- .../Tokens/ERC1644/Web3+ERC1644.swift | 12 ++-- .../web3swift/Tokens/ERC20/Web3+ERC20.swift | 8 +-- .../web3swift/Tokens/ERC721/Web3+ERC721.swift | 12 ++-- .../Tokens/ERC721x/Web3+ERC721x.swift | 22 +++---- .../web3swift/Tokens/ERC777/Web3+ERC777.swift | 26 ++++---- .../web3swift/Tokens/ERC888/Web3+ERC888.swift | 2 +- Sources/web3swift/Tokens/ST20/Web3+ST20.swift | 14 ++--- 16 files changed, 148 insertions(+), 148 deletions(-) diff --git a/Sources/Web3Core/Contract/ContractProtocol.swift b/Sources/Web3Core/Contract/ContractProtocol.swift index 33e25884d..f85819379 100755 --- a/Sources/Web3Core/Contract/ContractProtocol.swift +++ b/Sources/Web3Core/Contract/ContractProtocol.swift @@ -35,7 +35,7 @@ import BigInt /// let inputArgsTypes: [ABI.Element.InOut] = [.init(name: "firstArgument", type: ABI.Element.ParameterType.string), /// .init(name: "secondArgument", type: ABI.Element.ParameterType.uint(bits: 256))] /// let constructor = ABI.Element.Constructor(inputs: inputArgsTypes, constant: false, payable: payable) -/// let constructorArguments = ["This is the array of constructor arguments", 10_000] +/// let constructorArguments: [Any] = ["This is the array of constructor arguments", 10_000] /// /// contract.deploy(bytecode: smartContractBytecode, /// constructor: constructor, @@ -48,7 +48,7 @@ import BigInt /// /// ```swift /// let contract = EthereumContract(abiString) -/// let constructorArguments = ["This is the array of constructor arguments", 10_000] +/// let constructorArguments: [Any] = ["This is the array of constructor arguments", 10_000] /// /// contract.deploy(bytecode: smartContractBytecode, /// constructor: contract.constructor, diff --git a/Sources/web3swift/Browser/browser.js b/Sources/web3swift/Browser/browser.js index 88b5c8e4a..ea4090662 100644 --- a/Sources/web3swift/Browser/browser.js +++ b/Sources/web3swift/Browser/browser.js @@ -5379,7 +5379,7 @@ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. * The iteratee must complete with a boolean value as its result. * Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called as soon + * @param {Function} [callback] - A callback which is called as soon as any * iteratee returns `true`, or after all the `iteratee` functions have finished. * Result will be the first item in the array that passes the truth test * (iteratee) or the value `undefined` if none passed. Invoked with @@ -5412,7 +5412,7 @@ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. * The iteratee must complete with a boolean value as its result. * Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called as soon + * @param {Function} [callback] - A callback which is called as soon as any * iteratee returns `true`, or after all the `iteratee` functions have finished. * Result will be the first item in the array that passes the truth test * (iteratee) or the value `undefined` if none passed. Invoked with @@ -5434,7 +5434,7 @@ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. * The iteratee must complete with a boolean value as its result. * Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called as soon + * @param {Function} [callback] - A callback which is called as soon as any * iteratee returns `true`, or after all the `iteratee` functions have finished. * Result will be the first item in the array that passes the truth test * (iteratee) or the value `undefined` if none passed. Invoked with @@ -7297,7 +7297,7 @@ * in the collections in parallel. * The iteratee should complete with a boolean `result` value. * Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called as soon + * @param {Function} [callback] - A callback which is called as soon as any * iteratee returns `true`, or after all the iteratee functions have finished. * Result will be either `true` or `false` depending on the values of the async * tests. Invoked with (err, result). @@ -7329,7 +7329,7 @@ * in the collections in parallel. * The iteratee should complete with a boolean `result` value. * Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called as soon + * @param {Function} [callback] - A callback which is called as soon as any * iteratee returns `true`, or after all the iteratee functions have finished. * Result will be either `true` or `false` depending on the values of the async * tests. Invoked with (err, result). @@ -7351,7 +7351,7 @@ * in the collections in series. * The iteratee should complete with a boolean `result` value. * Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called as soon + * @param {Function} [callback] - A callback which is called as soon as any * iteratee returns `true`, or after all the iteratee functions have finished. * Result will be either `true` or `false` depending on the values of the async * tests. Invoked with (err, result). @@ -41538,7 +41538,7 @@ addUnderlyingListener( fullEventName, predicateEvent, - jsonPathCompiler( match[2] ) + jsonPathCompiler( match[2]) ); } } @@ -41566,7 +41566,7 @@ */ addListener = varArgs(function( eventId, parameters ){ - if( oboeApi[eventId] ) { + if( oboeApi[eventId]) { // for events added as .on(event, callback), if there is a // .event() equivalent with special behaviour , pass through diff --git a/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift b/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift index c03245a53..c09c6920a 100644 --- a/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift +++ b/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift @@ -84,7 +84,7 @@ public class ERC1155: IERC1155 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, id, value, data] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, id, value, data])! return tx } @@ -94,7 +94,7 @@ public class ERC1155: IERC1155 { self.transaction.to = self.address let tx = contract - .createWriteOperation("safeBatchTransferFrom", parameters: [originalOwner, to, ids, values, data] )! + .createWriteOperation("safeBatchTransferFrom", parameters: [originalOwner, to, ids, values, data])! return tx } @@ -121,7 +121,7 @@ public class ERC1155: IERC1155 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setApprovalForAll", parameters: [user, approved, scope] )! + let tx = contract.createWriteOperation("setApprovalForAll", parameters: [user, approved, scope])! return tx } diff --git a/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift b/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift index 766a08c76..9e541edb2 100644 --- a/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift +++ b/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift @@ -121,7 +121,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } @@ -143,7 +143,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } @@ -165,7 +165,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } @@ -187,7 +187,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } @@ -220,7 +220,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, eValue, nValue] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, eValue, nValue])! return tx } @@ -242,7 +242,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("increaseAllowance", parameters: [spender, amount] )! + let tx = contract.createWriteOperation("increaseAllowance", parameters: [spender, amount])! return tx } @@ -264,7 +264,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("decreaseAllowance", parameters: [spender, amount, strict] )! + let tx = contract.createWriteOperation("decreaseAllowance", parameters: [spender, amount, strict])! return tx } @@ -273,7 +273,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setERC20ApproveChecking", parameters: [approveChecking] )! + let tx = contract.createWriteOperation("setERC20ApproveChecking", parameters: [approveChecking])! return tx } @@ -302,7 +302,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(data, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [value] )! + let tx = contract.createWriteOperation("transfer", parameters: [value])! return tx } @@ -323,7 +323,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { guard let amount = Utilities.parseToBigUInt(value, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferAndCall", parameters: [to, amount, data] )! + let tx = contract.createWriteOperation("transferAndCall", parameters: [to, amount, data])! return tx } @@ -341,7 +341,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { self.transaction.to = self.address self.transaction.callOnBlock = .latest - let tx = contract.createWriteOperation("increaseNonce", parameters: [] )! + let tx = contract.createWriteOperation("increaseNonce", parameters: [])! return tx } @@ -365,7 +365,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { let modeValue = mode.rawValue - let tx = contract.createWriteOperation("delegateTransferAndCall", parameters: [nonce, fee, gasAmount, to, amount, data, modeValue, v, r, s] )! + let tx = contract.createWriteOperation("delegateTransferAndCall", parameters: [nonce, fee, gasAmount, to, amount, data, modeValue, v, r, s])! return tx } @@ -382,7 +382,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setupDirectDebit", parameters: [receiver, info] )! + let tx = contract.createWriteOperation("setupDirectDebit", parameters: [receiver, info])! return tx } @@ -391,7 +391,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("terminateDirectDebit", parameters: [receiver] )! + let tx = contract.createWriteOperation("terminateDirectDebit", parameters: [receiver])! return tx } @@ -400,7 +400,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("withdrawDirectDebit", parameters: [debtor] )! + let tx = contract.createWriteOperation("withdrawDirectDebit", parameters: [debtor])! return tx } @@ -409,7 +409,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("withdrawDirectDebit", parameters: [debtors, strict] )! + let tx = contract.createWriteOperation("withdrawDirectDebit", parameters: [debtors, strict])! return tx } } diff --git a/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift b/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift index a700d0fbf..cb6641c3f 100644 --- a/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift +++ b/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift @@ -118,7 +118,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } @@ -140,7 +140,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } @@ -162,7 +162,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } @@ -191,7 +191,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } @@ -209,7 +209,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setDocument", parameters: [name, uri, documentHash] )! + let tx = contract.createWriteOperation("setDocument", parameters: [name, uri, documentHash])! return tx } @@ -247,7 +247,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferWithData", parameters: [to, value, data] )! + let tx = contract.createWriteOperation("transferWithData", parameters: [to, value, data])! return tx } @@ -269,7 +269,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFromWithData", parameters: [originalOwner, to, value, data] )! + let tx = contract.createWriteOperation("transferFromWithData", parameters: [originalOwner, to, value, data])! return tx } @@ -291,7 +291,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferByPartition", parameters: [partition, to, value, data] )! + let tx = contract.createWriteOperation("transferByPartition", parameters: [partition, to, value, data])! return tx } @@ -313,7 +313,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("operatorTransferByPartition", parameters: [partition, originalOwner, to, value, data, operatorData] )! + let tx = contract.createWriteOperation("operatorTransferByPartition", parameters: [partition, originalOwner, to, value, data, operatorData])! return tx } @@ -343,7 +343,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("controllerTransfer", parameters: [originalOwner, to, value, data, operatorData] )! + let tx = contract.createWriteOperation("controllerTransfer", parameters: [originalOwner, to, value, data, operatorData])! return tx } @@ -365,7 +365,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("controllerRedeem", parameters: [tokenHolder, value, data, operatorData] )! + let tx = contract.createWriteOperation("controllerRedeem", parameters: [tokenHolder, value, data, operatorData])! return tx } @@ -374,7 +374,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("authorizeOperator", parameters: [user] )! + let tx = contract.createWriteOperation("authorizeOperator", parameters: [user])! return tx } @@ -383,7 +383,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("revokeOperator", parameters: [user] )! + let tx = contract.createWriteOperation("revokeOperator", parameters: [user])! return tx } @@ -392,7 +392,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("authorizeOperatorByPartition", parameters: [partition, user] )! + let tx = contract.createWriteOperation("authorizeOperatorByPartition", parameters: [partition, user])! return tx } @@ -401,7 +401,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("revokeOperatorByPartition", parameters: [partition, user] )! + let tx = contract.createWriteOperation("revokeOperatorByPartition", parameters: [partition, user])! return tx } @@ -447,7 +447,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("issue", parameters: [tokenHolder, value, data] )! + let tx = contract.createWriteOperation("issue", parameters: [tokenHolder, value, data])! return tx } @@ -469,7 +469,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("issueByPartition", parameters: [partition, tokenHolder, value, data] )! + let tx = contract.createWriteOperation("issueByPartition", parameters: [partition, tokenHolder, value, data])! return tx } @@ -491,7 +491,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("redeem", parameters: [value, data] )! + let tx = contract.createWriteOperation("redeem", parameters: [value, data])! return tx } @@ -513,7 +513,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("redeemFrom", parameters: [tokenHolder, value, data] )! + let tx = contract.createWriteOperation("redeemFrom", parameters: [tokenHolder, value, data])! return tx } @@ -535,7 +535,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("redeemByPartition", parameters: [partition, value, data] )! + let tx = contract.createWriteOperation("redeemByPartition", parameters: [partition, value, data])! return tx } @@ -557,7 +557,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("operatorRedeemByPartition", parameters: [partition, tokenHolder, value, operatorData] )! + let tx = contract.createWriteOperation("operatorRedeemByPartition", parameters: [partition, tokenHolder, value, operatorData])! return tx } @@ -647,7 +647,7 @@ extension ERC1400: IERC777 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer] )! + let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer])! return tx } @@ -656,7 +656,7 @@ extension ERC1400: IERC777 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager] )! + let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager])! return tx } @@ -673,7 +673,7 @@ extension ERC1400: IERC777 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId] )! + let tx = contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId])! return tx } @@ -707,7 +707,7 @@ extension ERC1400: IERC777 { self.transaction.to = self.address self.transaction.callOnBlock = .latest - let tx = contract.createWriteOperation("authorizeOperator", parameters: [user] )! + let tx = contract.createWriteOperation("authorizeOperator", parameters: [user])! return tx } @@ -717,7 +717,7 @@ extension ERC1400: IERC777 { self.transaction.to = self.address self.transaction.callOnBlock = .latest - let tx = contract.createWriteOperation("revokeOperator", parameters: [user] )! + let tx = contract.createWriteOperation("revokeOperator", parameters: [user])! return tx } @@ -746,7 +746,7 @@ extension ERC1400: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("send", parameters: [to, value, data] )! + let tx = contract.createWriteOperation("send", parameters: [to, value, data])! return tx } @@ -767,7 +767,7 @@ extension ERC1400: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData] )! + let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData])! return tx } @@ -788,7 +788,7 @@ extension ERC1400: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("burn", parameters: [value, data] )! + let tx = contract.createWriteOperation("burn", parameters: [value, data])! return tx } @@ -809,7 +809,7 @@ extension ERC1400: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData] )! + let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData])! return tx } } diff --git a/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift b/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift index f77011da9..8cdac8bec 100644 --- a/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift +++ b/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift @@ -97,7 +97,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } @@ -120,7 +120,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } @@ -143,7 +143,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } @@ -175,7 +175,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } @@ -216,7 +216,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferByPartition", parameters: [partition, to, value, data] )! + let tx = contract.createWriteOperation("transferByPartition", parameters: [partition, to, value, data])! return tx } @@ -239,7 +239,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("operatorTransferByPartition", parameters: [partition, originalOwner, to, value, data, operatorData] )! + let tx = contract.createWriteOperation("operatorTransferByPartition", parameters: [partition, originalOwner, to, value, data, operatorData])! return tx } @@ -286,7 +286,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("authorizeOperator", parameters: [user] )! + let tx = contract.createWriteOperation("authorizeOperator", parameters: [user])! return tx } @@ -296,7 +296,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("revokeOperator", parameters: [user] )! + let tx = contract.createWriteOperation("revokeOperator", parameters: [user])! return tx } @@ -306,7 +306,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("authorizeOperatorByPartition", parameters: [partition, user] )! + let tx = contract.createWriteOperation("authorizeOperatorByPartition", parameters: [partition, user])! return tx } @@ -316,7 +316,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("revokeOperatorByPartition", parameters: [partition, user] )! + let tx = contract.createWriteOperation("revokeOperatorByPartition", parameters: [partition, user])! return tx } @@ -339,7 +339,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("issueByPartition", parameters: [partition, tokenHolder, value, data] )! + let tx = contract.createWriteOperation("issueByPartition", parameters: [partition, tokenHolder, value, data])! return tx } @@ -362,7 +362,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("redeemByPartition", parameters: [partition, value, data] )! + let tx = contract.createWriteOperation("redeemByPartition", parameters: [partition, value, data])! return tx } @@ -385,7 +385,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("operatorRedeemByPartition", parameters: [partition, tokenHolder, value, operatorData] )! + let tx = contract.createWriteOperation("operatorRedeemByPartition", parameters: [partition, tokenHolder, value, operatorData])! return tx } } @@ -412,7 +412,7 @@ extension ERC1410: IERC777 { self.transaction.from = from - let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer] )! + let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer])! return tx } @@ -421,7 +421,7 @@ extension ERC1410: IERC777 { self.transaction.from = from - let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager] )! + let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager])! return tx } @@ -438,7 +438,7 @@ extension ERC1410: IERC777 { self.transaction.from = from - let tx = contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId] )! + let tx = contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId])! return tx } @@ -456,7 +456,7 @@ extension ERC1410: IERC777 { self.transaction.from = from self.transaction.callOnBlock = .latest - let tx = contract.createWriteOperation("authorizeOperator", parameters: [user] )! + let tx = contract.createWriteOperation("authorizeOperator", parameters: [user])! return tx } @@ -466,7 +466,7 @@ extension ERC1410: IERC777 { self.transaction.from = from self.transaction.callOnBlock = .latest - let tx = contract.createWriteOperation("revokeOperator", parameters: [user] )! + let tx = contract.createWriteOperation("revokeOperator", parameters: [user])! return tx } @@ -496,7 +496,7 @@ extension ERC1410: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("send", parameters: [to, value, data] )! + let tx = contract.createWriteOperation("send", parameters: [to, value, data])! return tx } @@ -518,7 +518,7 @@ extension ERC1410: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData] )! + let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData])! return tx } @@ -540,7 +540,7 @@ extension ERC1410: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("burn", parameters: [value, data] )! + let tx = contract.createWriteOperation("burn", parameters: [value, data])! return tx } @@ -562,7 +562,7 @@ extension ERC1410: IERC777 { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData] )! + let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData])! return tx } diff --git a/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift b/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift index e02bd6b18..ee7cf108a 100644 --- a/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift +++ b/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift @@ -87,7 +87,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } @@ -110,7 +110,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } @@ -133,7 +133,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } @@ -165,7 +165,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } @@ -189,7 +189,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferWithData", parameters: [to, value, data] )! + let tx = contract.createWriteOperation("transferWithData", parameters: [to, value, data])! return tx } @@ -212,7 +212,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFromWithData", parameters: [originalOwner, to, value, data] )! + let tx = contract.createWriteOperation("transferFromWithData", parameters: [originalOwner, to, value, data])! return tx } @@ -243,7 +243,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("issue", parameters: [tokenHolder, value, data] )! + let tx = contract.createWriteOperation("issue", parameters: [tokenHolder, value, data])! return tx } @@ -266,7 +266,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("redeem", parameters: [value, data] )! + let tx = contract.createWriteOperation("redeem", parameters: [value, data])! return tx } @@ -289,7 +289,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("redeemFrom", parameters: [tokenHolder, value, data] )! + let tx = contract.createWriteOperation("redeemFrom", parameters: [tokenHolder, value, data])! return tx } diff --git a/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift b/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift index 40480c564..2482eebfc 100644 --- a/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift +++ b/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift @@ -74,7 +74,7 @@ public class ERC1633: IERC1633, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } @@ -97,7 +97,7 @@ public class ERC1633: IERC1633, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } @@ -120,7 +120,7 @@ public class ERC1633: IERC1633, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } @@ -151,7 +151,7 @@ public class ERC1633: IERC1633, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } diff --git a/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift b/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift index 6227c19c7..cab883a75 100644 --- a/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift +++ b/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift @@ -77,7 +77,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } @@ -100,7 +100,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } @@ -123,7 +123,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } @@ -154,7 +154,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } @@ -173,7 +173,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setDocument", parameters: [name, uri, documentHash] )! + let tx = contract.createWriteOperation("setDocument", parameters: [name, uri, documentHash])! return tx } @@ -183,7 +183,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("removeDocument", parameters: [name] )! + let tx = contract.createWriteOperation("removeDocument", parameters: [name])! return tx } diff --git a/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift b/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift index 7e4cdf580..ba5e98f5a 100644 --- a/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift +++ b/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift @@ -76,7 +76,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } @@ -99,7 +99,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } @@ -122,7 +122,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } @@ -153,7 +153,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } @@ -185,7 +185,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("controllerTransfer", parameters: [originalOwner, to, value, data, operatorData] )! + let tx = contract.createWriteOperation("controllerTransfer", parameters: [originalOwner, to, value, data, operatorData])! return tx } @@ -208,7 +208,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("controllerRedeem", parameters: [tokenHolder, value, data, operatorData] )! + let tx = contract.createWriteOperation("controllerRedeem", parameters: [tokenHolder, value, data, operatorData])! return tx } } diff --git a/Sources/web3swift/Tokens/ERC20/Web3+ERC20.swift b/Sources/web3swift/Tokens/ERC20/Web3+ERC20.swift index aa20848cb..3b7d9f3c3 100644 --- a/Sources/web3swift/Tokens/ERC20/Web3+ERC20.swift +++ b/Sources/web3swift/Tokens/ERC20/Web3+ERC20.swift @@ -80,7 +80,7 @@ public class ERC20: IERC20, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } @@ -104,7 +104,7 @@ public class ERC20: IERC20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } @@ -128,7 +128,7 @@ public class ERC20: IERC20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } @@ -152,7 +152,7 @@ public class ERC20: IERC20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } diff --git a/Sources/web3swift/Tokens/ERC721/Web3+ERC721.swift b/Sources/web3swift/Tokens/ERC721/Web3+ERC721.swift index 2892ac4f0..9425185d9 100644 --- a/Sources/web3swift/Tokens/ERC721/Web3+ERC721.swift +++ b/Sources/web3swift/Tokens/ERC721/Web3+ERC721.swift @@ -132,7 +132,7 @@ public class ERC721: IERC721 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("transfer", parameters: [to, tokenId] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, tokenId])! return tx } @@ -141,7 +141,7 @@ public class ERC721: IERC721 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, tokenId] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, tokenId])! return tx } @@ -150,7 +150,7 @@ public class ERC721: IERC721 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId])! return tx } @@ -159,7 +159,7 @@ public class ERC721: IERC721 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, data] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, data])! return tx } @@ -168,7 +168,7 @@ public class ERC721: IERC721 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("approve", parameters: [approved, tokenId] )! + let tx = contract.createWriteOperation("approve", parameters: [approved, tokenId])! return tx } @@ -177,7 +177,7 @@ public class ERC721: IERC721 { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setApprovalForAll", parameters: [user, approved] )! + let tx = contract.createWriteOperation("setApprovalForAll", parameters: [user, approved])! return tx } diff --git a/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift b/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift index 941e68824..e730f58c7 100644 --- a/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift +++ b/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift @@ -114,7 +114,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("transfer", parameters: [to, tokenId] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, tokenId])! return tx } @@ -123,7 +123,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, tokenId] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, tokenId])! return tx } @@ -132,7 +132,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId])! return tx } @@ -141,7 +141,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, data] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, data])! return tx } @@ -150,7 +150,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("approve", parameters: [approved, tokenId] )! + let tx = contract.createWriteOperation("approve", parameters: [approved, tokenId])! return tx } @@ -159,7 +159,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setApprovalForAll", parameters: [user, approved] )! + let tx = contract.createWriteOperation("setApprovalForAll", parameters: [user, approved])! return tx } @@ -256,7 +256,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("transfer", parameters: [to, tokenId, quantity] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, tokenId, quantity])! return tx } @@ -265,7 +265,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, tokenId, quantity] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, tokenId, quantity])! return tx } @@ -274,7 +274,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, amount] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, amount])! return tx } @@ -283,7 +283,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, amount, data] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenId, amount, data])! return tx } @@ -292,7 +292,7 @@ public class ERC721x: IERC721x { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenIds, amounts, data] )! + let tx = contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, tokenIds, amounts, data])! return tx } } diff --git a/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift b/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift index 5e297f367..6333c3600 100644 --- a/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift +++ b/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift @@ -105,7 +105,7 @@ public class ERC777: IERC777, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } @@ -127,7 +127,7 @@ public class ERC777: IERC777, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } @@ -149,7 +149,7 @@ public class ERC777: IERC777, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } @@ -168,7 +168,7 @@ public class ERC777: IERC777, ERC20BaseProperties { self.transaction.to = self.address self.transaction.callOnBlock = .latest - let tx = contract.createWriteOperation("authorizeOperator", parameters: [user] )! + let tx = contract.createWriteOperation("authorizeOperator", parameters: [user])! return tx } @@ -178,7 +178,7 @@ public class ERC777: IERC777, ERC20BaseProperties { self.transaction.to = self.address self.transaction.callOnBlock = .latest - let tx = contract.createWriteOperation("revokeOperator", parameters: [user] )! + let tx = contract.createWriteOperation("revokeOperator", parameters: [user])! return tx } @@ -207,7 +207,7 @@ public class ERC777: IERC777, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("send", parameters: [to, value, data] )! + let tx = contract.createWriteOperation("send", parameters: [to, value, data])! return tx } @@ -228,7 +228,7 @@ public class ERC777: IERC777, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData] )! + let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData])! return tx } @@ -249,7 +249,7 @@ public class ERC777: IERC777, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("burn", parameters: [value, data] )! + let tx = contract.createWriteOperation("burn", parameters: [value, data])! return tx } @@ -270,7 +270,7 @@ public class ERC777: IERC777, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData] )! + let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData])! return tx } @@ -295,7 +295,7 @@ public class ERC777: IERC777, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer] )! + let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer])! return tx } @@ -304,7 +304,7 @@ public class ERC777: IERC777, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager] )! + let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager])! return tx } @@ -321,7 +321,7 @@ public class ERC777: IERC777, ERC20BaseProperties { self.transaction.from = from self.transaction.to = self.address - let tx = contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId] )! + let tx = contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId])! return tx } @@ -343,7 +343,7 @@ public class ERC777: IERC777, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } diff --git a/Sources/web3swift/Tokens/ERC888/Web3+ERC888.swift b/Sources/web3swift/Tokens/ERC888/Web3+ERC888.swift index 4ff2e9c5f..f687c0a32 100644 --- a/Sources/web3swift/Tokens/ERC888/Web3+ERC888.swift +++ b/Sources/web3swift/Tokens/ERC888/Web3+ERC888.swift @@ -63,7 +63,7 @@ public class ERC888: IERC888, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } diff --git a/Sources/web3swift/Tokens/ST20/Web3+ST20.swift b/Sources/web3swift/Tokens/ST20/Web3+ST20.swift index 66cfc8dd6..8c2f82e68 100644 --- a/Sources/web3swift/Tokens/ST20/Web3+ST20.swift +++ b/Sources/web3swift/Tokens/ST20/Web3+ST20.swift @@ -76,7 +76,7 @@ public class ST20: IST20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("verifyTransfer", parameters: [originalOwner, to, value] )! + let tx = contract.createWriteOperation("verifyTransfer", parameters: [originalOwner, to, value])! return tx } @@ -99,7 +99,7 @@ public class ST20: IST20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("mint", parameters: [investor, value] )! + let tx = contract.createWriteOperation("mint", parameters: [investor, value])! return tx } @@ -121,7 +121,7 @@ public class ST20: IST20, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("burn", parameters: [value] )! + let tx = contract.createWriteOperation("burn", parameters: [value])! return tx } @@ -159,7 +159,7 @@ public class ST20: IST20, ERC20BaseProperties { guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transfer", parameters: [to, value] )! + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } @@ -182,7 +182,7 @@ public class ST20: IST20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value] )! + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } @@ -205,7 +205,7 @@ public class ST20: IST20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("setAllowance", parameters: [to, value] )! + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } @@ -228,7 +228,7 @@ public class ST20: IST20, ERC20BaseProperties { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - let tx = contract.createWriteOperation("approve", parameters: [spender, value] )! + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } From 15f777023eaea683fd13fbb511c18c998bb5a983 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 14 Jan 2023 13:48:20 +0200 Subject: [PATCH 012/210] fix: Networks.fromInt must not return optional --- Sources/Web3Core/Structure/Event+Protocol.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Structure/Event+Protocol.swift b/Sources/Web3Core/Structure/Event+Protocol.swift index 87f361a08..aef5e3cd2 100755 --- a/Sources/Web3Core/Structure/Event+Protocol.swift +++ b/Sources/Web3Core/Structure/Event+Protocol.swift @@ -77,7 +77,7 @@ public enum Networks { static let allValues = [Mainnet, Ropsten, Kovan, Rinkeby] - public static func fromInt(_ networkID: UInt) -> Networks? { + public static func fromInt(_ networkID: UInt) -> Networks { switch networkID { case 1: return Networks.Mainnet From a49f771e4939e70d3ff2c794a3ba663ef09cba22 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 14 Jan 2023 13:50:15 +0200 Subject: [PATCH 013/210] fix: EIP681 - when parsing arguments chain ID must be defaulted to Mainnet instead of 0 --- Sources/web3swift/Utils/EIP/EIP681.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/web3swift/Utils/EIP/EIP681.swift b/Sources/web3swift/Utils/EIP/EIP681.swift index 7dde9af76..730085e6a 100755 --- a/Sources/web3swift/Utils/EIP/EIP681.swift +++ b/Sources/web3swift/Utils/EIP/EIP681.swift @@ -289,7 +289,7 @@ extension Web3 { guard let rawValue = comp.value, let functionArgument = await parseFunctionArgument(inputType, rawValue.trimmingCharacters(in: .whitespacesAndNewlines), - chainID: code.chainID ?? 0, + chainID: code.chainID, inputNumber: inputNumber) else { continue } @@ -348,7 +348,7 @@ extension Web3 { private static func parseFunctionArgument(_ inputType: ABI.Element.ParameterType, _ rawValue: String, - chainID: BigUInt, + chainID: BigUInt? = Networks.Mainnet.chainID, inputNumber: Int) async -> FunctionArgument? { var nativeValue: Any? switch inputType { @@ -359,7 +359,7 @@ extension Web3 { nativeValue = ethereumAddress case .ensAddress(let ens): do { - let web = await Web3(provider: InfuraProvider(Networks.fromInt(UInt(chainID)) ?? Networks.Mainnet)!) + let web = await Web3(provider: InfuraProvider(chainID == nil ? .Mainnet : .fromInt(UInt(chainID!)))!) let ensModel = ENS(web3: web) try await ensModel?.setENSResolver(withDomain: ens) let address = try await ensModel?.getAddress(forNode: ens) From af664691becb69b01a639c1a741e83d3d186d0c6 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 14 Jan 2023 16:44:37 +0200 Subject: [PATCH 014/210] chore: removed redundant `parameters: []` in read operation --- Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift | 2 +- Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift | 2 +- Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift | 4 ++-- Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift | 4 ++-- Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift | 4 ++-- Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift | 2 +- Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift | 4 ++-- Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift | 4 ++-- Sources/web3swift/Tokens/ST20/Web3+ST20.swift | 2 +- Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift | 2 +- Tests/web3swiftTests/localTests/UncategorizedTests.swift | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift b/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift index 2e731cad3..9c2d5ed01 100644 --- a/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift +++ b/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift @@ -69,7 +69,7 @@ public class ERC1155: IERC1155 { } guard contract.contract.address != nil else {return} - guard let tokenIdPromise = try await contract.createReadOperation("id", parameters: [])?.callContractMethod() else {return} + guard let tokenIdPromise = try await contract.createReadOperation("id")?.callContractMethod() else {return} guard let tokenId = tokenIdPromise["0"] as? BigUInt else {return} self._tokenId = tokenId diff --git a/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift b/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift index 714d52a42..876af62e0 100644 --- a/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift +++ b/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift @@ -298,7 +298,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { func increaseNonce(from: EthereumAddress) throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) - let tx = contract.createWriteOperation("increaseNonce", parameters: [])! + let tx = contract.createWriteOperation("increaseNonce")! return tx } diff --git a/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift b/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift index f099c2de1..1ba479a6f 100644 --- a/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift +++ b/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift @@ -596,14 +596,14 @@ extension ERC1400: IERC777 { } public func getGranularity() async throws -> BigUInt { - let result = try await contract.createReadOperation("granularity", parameters: [])!.callContractMethod() + let result = try await contract.createReadOperation("granularity")!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } public func getDefaultOperators() async throws -> [EthereumAddress] { - let result = try await contract.createReadOperation("defaultOperators", parameters: [])!.callContractMethod() + let result = try await contract.createReadOperation("defaultOperators")!.callContractMethod() guard let res = result["0"] as? [EthereumAddress] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res diff --git a/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift b/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift index 5b5f1b886..9e0b4acfb 100644 --- a/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift +++ b/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift @@ -474,14 +474,14 @@ extension ERC1410: IERC777 { } public func getGranularity() async throws -> BigUInt { - let result = try await contract.createReadOperation("granularity", parameters: [])!.callContractMethod() + let result = try await contract.createReadOperation("granularity")!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } public func getDefaultOperators() async throws -> [EthereumAddress] { - let result = try await contract.createReadOperation("defaultOperators", parameters: [])!.callContractMethod() + let result = try await contract.createReadOperation("defaultOperators")!.callContractMethod() guard let res = result["0"] as? [EthereumAddress] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res diff --git a/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift b/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift index 19f8a6f6e..ec98b95c8 100644 --- a/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift +++ b/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift @@ -138,14 +138,14 @@ public class ERC1633: IERC1633, ERC20BaseProperties { } func parentToken() async throws -> EthereumAddress { - let result = try await contract.createReadOperation("parentToken", parameters: [])!.callContractMethod() + let result = try await contract.createReadOperation("parentToken")!.callContractMethod() guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } func parentTokenId() async throws -> BigUInt { - let result = try await contract.createReadOperation("parentTokenId", parameters: [])!.callContractMethod() + let result = try await contract.createReadOperation("parentTokenId")!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res diff --git a/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift b/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift index e1fc3828d..2cb0ec869 100644 --- a/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift +++ b/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift @@ -161,7 +161,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { } public func getAllDocuments() async throws -> [Data] { - let result = try await contract.createReadOperation("getAllDocuments", parameters: [])!.callContractMethod() + let result = try await contract.createReadOperation("getAllDocuments")!.callContractMethod() guard let res = result["0"] as? [Data] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res diff --git a/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift b/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift index 62e8d9297..bce547e12 100644 --- a/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift +++ b/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift @@ -76,7 +76,7 @@ public class ERC721x: IERC721x { guard contract.contract.address != nil else {return} transaction.callOnBlock = .latest - guard let tokenIdPromise = try await contract.createReadOperation("tokenId", parameters: [])?.callContractMethod() else {return} + guard let tokenIdPromise = try await contract.createReadOperation("tokenId")?.callContractMethod() else {return} guard let tokenId = tokenIdPromise["0"] as? BigUInt else {return} self._tokenId = tokenId @@ -201,7 +201,7 @@ public class ERC721x: IERC721x { } func implementsERC721X() async throws -> Bool { - let result = try await contract.createReadOperation("implementsERC721X", parameters: [])!.callContractMethod() + let result = try await contract.createReadOperation("implementsERC721X")!.callContractMethod() guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res diff --git a/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift b/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift index 81f33ae31..c9a5fd125 100644 --- a/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift +++ b/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift @@ -57,14 +57,14 @@ public class ERC777: IERC777, ERC20BaseProperties { } public func getGranularity() async throws -> BigUInt { - let result = try await contract.createReadOperation("granularity", parameters: [])!.callContractMethod() + let result = try await contract.createReadOperation("granularity")!.callContractMethod() guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } public func getDefaultOperators() async throws -> [EthereumAddress] { - let result = try await contract.createReadOperation("defaultOperators", parameters: [])!.callContractMethod() + let result = try await contract.createReadOperation("defaultOperators")!.callContractMethod() guard let res = result["0"] as? [EthereumAddress] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res diff --git a/Sources/web3swift/Tokens/ST20/Web3+ST20.swift b/Sources/web3swift/Tokens/ST20/Web3+ST20.swift index 645daf42f..41b5ded7c 100644 --- a/Sources/web3swift/Tokens/ST20/Web3+ST20.swift +++ b/Sources/web3swift/Tokens/ST20/Web3+ST20.swift @@ -50,7 +50,7 @@ public class ST20: IST20, ERC20BaseProperties { } func tokenDetails() async throws -> [UInt32] { - let result = try await contract.createReadOperation("tokenDetails", parameters: [])!.callContractMethod() + let result = try await contract.createReadOperation("tokenDetails")!.callContractMethod() guard let res = result["0"] as? [UInt32] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res diff --git a/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift b/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift index 651f835bb..0fb8ef20a 100644 --- a/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift +++ b/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift @@ -66,7 +66,7 @@ public extension ENS { } public func getDefaultResolver() async throws -> EthereumAddress { - guard let transaction = self.contract.createReadOperation("defaultResolver", parameters: []) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createReadOperation("defaultResolver") else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let address = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Can't get answer")} diff --git a/Tests/web3swiftTests/localTests/UncategorizedTests.swift b/Tests/web3swiftTests/localTests/UncategorizedTests.swift index 2dbebb775..ccd1056b1 100755 --- a/Tests/web3swiftTests/localTests/UncategorizedTests.swift +++ b/Tests/web3swiftTests/localTests/UncategorizedTests.swift @@ -120,7 +120,7 @@ class UncategorizedTests: XCTestCase { .callContractMethod() let totalUsers = try await contract! - .createReadOperation("totalUsers", parameters: [])? + .createReadOperation("totalUsers")? .callContractMethod() let user = try await contract! From 922da4148223ee5d95405a1e800969784de28268 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 14 Jan 2023 16:47:58 +0200 Subject: [PATCH 015/210] fix: spacings --- Sources/web3swift/Browser/browser.js | 5 ++--- Tests/web3swiftTests/localTests/EIP1559BlockTests.swift | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Sources/web3swift/Browser/browser.js b/Sources/web3swift/Browser/browser.js index ea4090662..8cffd18b1 100644 --- a/Sources/web3swift/Browser/browser.js +++ b/Sources/web3swift/Browser/browser.js @@ -41538,7 +41538,7 @@ addUnderlyingListener( fullEventName, predicateEvent, - jsonPathCompiler( match[2]) + jsonPathCompiler( match[2] ) ); } } @@ -41566,7 +41566,7 @@ */ addListener = varArgs(function( eventId, parameters ){ - if( oboeApi[eventId]) { + if( oboeApi[eventId] ) { // for events added as .on(event, callback), if there is a // .event() equivalent with special behaviour , pass through @@ -68348,4 +68348,3 @@ //# sourceURL=/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy/wk.bridge.js },{}]},{},[1]); - diff --git a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift index e41c55e3f..a729ff117 100644 --- a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift +++ b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift @@ -18,7 +18,7 @@ class EIP1559BlockTests: LocalTestCase { logsBloom: EthereumBloomFilter(Data(from: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")!), // "logsBloom": transactionsRoot: Data(from: "0x3a1b03875115b79539e5bd33fb00d8f7b7cd61929d5a3c574f507b8acf415bee")!, // "transactionsRoot": stateRoot: Data(from: "0xf1133199d44695dfa8fd1bcfe424d82854b5cebef75bddd7e40ea94cda515bcb")!, // "stateRoot": - miner: EthereumAddress( Data(from: "0x8888f1f195afa192cfee860698584c030f4c9db1")!)!, // "miner": + miner: EthereumAddress(Data(from: "0x8888f1f195afa192cfee860698584c030f4c9db1")!)!, // "miner": difficulty: BigUInt(21345678965432), // "difficulty": totalDifficulty: BigUInt(324567845321), // "totalDifficulty": size: BigUInt(616), // "size": From 03f139523ccda57be310edbea23cea31557fa75c Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 14 Jan 2023 18:06:27 +0200 Subject: [PATCH 016/210] chore: removed spacing in `" )` --- .../Tokens/ERC1376/Web3+ERC1376.swift | 20 ++++---- .../Tokens/ERC1400/Web3+ERC1400.swift | 46 +++++++++---------- .../Tokens/ERC1410/Web3+ERC1410.swift | 28 +++++------ .../Tokens/ERC1594/Web3+ERC1594.swift | 22 ++++----- .../Tokens/ERC1633/Web3+ERC1633.swift | 8 ++-- .../Tokens/ERC1643/Web3+ERC1643.swift | 8 ++-- .../Tokens/ERC1644/Web3+ERC1644.swift | 12 ++--- .../web3swift/Tokens/ERC20/Web3+ERC20.swift | 8 ++-- .../web3swift/Tokens/ERC777/Web3+ERC777.swift | 16 +++---- .../web3swift/Tokens/ERC888/Web3+ERC888.swift | 2 +- Sources/web3swift/Tokens/ST20/Web3+ST20.swift | 14 +++--- .../Tokens/ST20/Web3+SecurityToken.swift | 4 +- 12 files changed, 94 insertions(+), 94 deletions(-) diff --git a/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift b/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift index 876af62e0..80a4f796b 100644 --- a/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift +++ b/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift @@ -106,7 +106,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -124,7 +124,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -142,7 +142,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -160,7 +160,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -185,7 +185,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -206,7 +206,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -224,7 +224,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -256,7 +256,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -274,7 +274,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -306,7 +306,7 @@ public class ERC1376: IERC1376, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} diff --git a/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift b/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift index 1ba479a6f..df0874a93 100644 --- a/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift +++ b/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift @@ -103,7 +103,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -122,7 +122,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -141,7 +141,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -167,7 +167,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -214,7 +214,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -233,7 +233,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -252,7 +252,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -271,7 +271,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -297,7 +297,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -316,7 +316,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -380,7 +380,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -399,7 +399,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -418,7 +418,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -437,7 +437,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -456,7 +456,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -475,7 +475,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -492,7 +492,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { public func canTransfer(to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) { // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -511,7 +511,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { public func canTransferFrom(originalOwner: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) { // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -530,7 +530,7 @@ public class ERC1400: IERC1400, ERC20BaseProperties { public func canTransferByPartition(originalOwner: EthereumAddress, to: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> ([UInt8], Data, Data) { // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -634,7 +634,7 @@ extension ERC1400: IERC777 { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -653,7 +653,7 @@ extension ERC1400: IERC777 { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -672,7 +672,7 @@ extension ERC1400: IERC777 { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -691,7 +691,7 @@ extension ERC1400: IERC777 { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} diff --git a/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift b/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift index 9e0b4acfb..ed947f435 100644 --- a/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift +++ b/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift @@ -81,7 +81,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -100,7 +100,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -119,7 +119,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -145,7 +145,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -179,7 +179,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -198,7 +198,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -215,7 +215,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { public func canTransferByPartition(originalOwner: EthereumAddress, to: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> ([UInt8], Data, Data) { // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -274,7 +274,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -293,7 +293,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -312,7 +312,7 @@ public class ERC1410: IERC1410, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -401,7 +401,7 @@ extension ERC1410: IERC777 { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -420,7 +420,7 @@ extension ERC1410: IERC777 { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -439,7 +439,7 @@ extension ERC1410: IERC777 { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -458,7 +458,7 @@ extension ERC1410: IERC777 { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} diff --git a/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift b/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift index 931c7aef2..3e83074d8 100644 --- a/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift +++ b/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift @@ -70,7 +70,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { public func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -89,7 +89,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -108,7 +108,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -134,7 +134,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -154,7 +154,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -173,7 +173,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -199,7 +199,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -218,7 +218,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -237,7 +237,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -254,7 +254,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { public func canTransfer(to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) { // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -273,7 +273,7 @@ public class ERC1594: IERC1594, ERC20BaseProperties { public func canTransferFrom(originalOwner: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) { // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} diff --git a/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift b/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift index ec98b95c8..e7551fce1 100644 --- a/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift +++ b/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift @@ -58,7 +58,7 @@ public class ERC1633: IERC1633, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -77,7 +77,7 @@ public class ERC1633: IERC1633, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -96,7 +96,7 @@ public class ERC1633: IERC1633, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -122,7 +122,7 @@ public class ERC1633: IERC1633, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} diff --git a/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift b/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift index 2cb0ec869..9e0c3fdec 100644 --- a/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift +++ b/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift @@ -61,7 +61,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -80,7 +80,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -99,7 +99,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -125,7 +125,7 @@ public class ERC1643: IERC1643, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} diff --git a/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift b/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift index c1172dee2..1acaf69a1 100644 --- a/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift +++ b/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift @@ -60,7 +60,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -79,7 +79,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -98,7 +98,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -124,7 +124,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -151,7 +151,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -170,7 +170,7 @@ public class ERC1644: IERC1644, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} diff --git a/Sources/web3swift/Tokens/ERC20/Web3+ERC20.swift b/Sources/web3swift/Tokens/ERC20/Web3+ERC20.swift index 8e5336ec9..a3426f754 100644 --- a/Sources/web3swift/Tokens/ERC20/Web3+ERC20.swift +++ b/Sources/web3swift/Tokens/ERC20/Web3+ERC20.swift @@ -64,7 +64,7 @@ public class ERC20: IERC20, ERC20BaseProperties { // get the decimals manually let callResult = try await contract - .createReadOperation("decimals" )! + .createReadOperation("decimals")! .callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { @@ -88,7 +88,7 @@ public class ERC20: IERC20, ERC20BaseProperties { // get the decimals manually let callResult = try await contract - .createReadOperation("decimals" )! + .createReadOperation("decimals")! .callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { @@ -112,7 +112,7 @@ public class ERC20: IERC20, ERC20BaseProperties { // get the decimals manually let callResult = try await contract - .createReadOperation("decimals" )! + .createReadOperation("decimals")! .callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { @@ -136,7 +136,7 @@ public class ERC20: IERC20, ERC20BaseProperties { // get the decimals manually let callResult = try await contract - .createReadOperation("decimals" )! + .createReadOperation("decimals")! .callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { diff --git a/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift b/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift index c9a5fd125..f7360d913 100644 --- a/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift +++ b/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift @@ -88,7 +88,7 @@ public class ERC777: IERC777, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -106,7 +106,7 @@ public class ERC777: IERC777, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -125,7 +125,7 @@ public class ERC777: IERC777, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -172,7 +172,7 @@ public class ERC777: IERC777, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -190,7 +190,7 @@ public class ERC777: IERC777, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -208,7 +208,7 @@ public class ERC777: IERC777, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -226,7 +226,7 @@ public class ERC777: IERC777, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -284,7 +284,7 @@ public class ERC777: IERC777, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} diff --git a/Sources/web3swift/Tokens/ERC888/Web3+ERC888.swift b/Sources/web3swift/Tokens/ERC888/Web3+ERC888.swift index 77c0047b5..1f462b08e 100644 --- a/Sources/web3swift/Tokens/ERC888/Web3+ERC888.swift +++ b/Sources/web3swift/Tokens/ERC888/Web3+ERC888.swift @@ -51,7 +51,7 @@ public class ERC888: IERC888, ERC20BaseProperties { transaction.callOnBlock = .latest contract.transaction = transaction // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} diff --git a/Sources/web3swift/Tokens/ST20/Web3+ST20.swift b/Sources/web3swift/Tokens/ST20/Web3+ST20.swift index 41b5ded7c..52f603380 100644 --- a/Sources/web3swift/Tokens/ST20/Web3+ST20.swift +++ b/Sources/web3swift/Tokens/ST20/Web3+ST20.swift @@ -60,7 +60,7 @@ public class ST20: IST20, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -79,7 +79,7 @@ public class ST20: IST20, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -98,7 +98,7 @@ public class ST20: IST20, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -131,7 +131,7 @@ public class ST20: IST20, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -150,7 +150,7 @@ public class ST20: IST20, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -169,7 +169,7 @@ public class ST20: IST20, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} @@ -188,7 +188,7 @@ public class ST20: IST20, ERC20BaseProperties { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) // get the decimals manually - let callResult = try await contract.createReadOperation("decimals" )!.callContractMethod() + let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() var decimals = BigUInt(0) guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} diff --git a/Sources/web3swift/Tokens/ST20/Web3+SecurityToken.swift b/Sources/web3swift/Tokens/ST20/Web3+SecurityToken.swift index 73d6bdde6..b7c4a513e 100644 --- a/Sources/web3swift/Tokens/ST20/Web3+SecurityToken.swift +++ b/Sources/web3swift/Tokens/ST20/Web3+SecurityToken.swift @@ -256,7 +256,7 @@ public class SecurityToken: ISecurityToken, ERC20BaseProperties { transaction.callOnBlock = .latest contract.transaction = transaction - return contract.createWriteOperation("renounceOwnership" )! + return contract.createWriteOperation("renounceOwnership")! } @@ -341,7 +341,7 @@ public class SecurityToken: ISecurityToken, ERC20BaseProperties { transaction.callOnBlock = .latest contract.transaction = transaction - return contract.createWriteOperation("createCheckpoint" )! + return contract.createWriteOperation("createCheckpoint")! } From 8e925660cf4fa286989da3cc148f42ef0c770538 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 14 Jan 2023 18:15:22 +0200 Subject: [PATCH 017/210] fix: removed as AnyObject from ENS related code --- Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift | 12 ++++++------ Sources/web3swift/Utils/ENS/ENSRegistry.swift | 6 +++--- .../web3swift/Utils/ENS/ENSReverseRegistrar.swift | 2 +- .../web3swift/Utils/ENS/ETHRegistrarController.swift | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift b/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift index dfcdedf2f..6722bc736 100644 --- a/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift +++ b/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift @@ -37,7 +37,7 @@ public extension ENS { defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("addController", parameters: [controllerAddress as AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("addController", parameters: [controllerAddress]) else {throw Web3Error.transactionSerializationError} return transaction } @@ -47,7 +47,7 @@ public extension ENS { defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("removeController", parameters: [controllerAddress as AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("removeController", parameters: [controllerAddress]) else {throw Web3Error.transactionSerializationError} return transaction } @@ -57,13 +57,13 @@ public extension ENS { defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("setResolver", parameters: [resolverAddress as AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("setResolver", parameters: [resolverAddress]) else {throw Web3Error.transactionSerializationError} return transaction } public func getNameExpirity(name: BigUInt) async throws -> BigUInt { - guard let transaction = self.contract.createReadOperation("nameExpires", parameters: [name as AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createReadOperation("nameExpires", parameters: [name]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let expirity = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Can't get answer")} @@ -72,7 +72,7 @@ public extension ENS { @available(*, message: "This function should not be used to check if a name can be registered by a user. To check if a name can be registered by a user, check name availablility via the controller") public func isNameAvailable(name: BigUInt) async throws -> Bool { - guard let transaction = self.contract.createReadOperation("available", parameters: [name as AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createReadOperation("available", parameters: [name]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let available = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Can't get answer")} @@ -83,7 +83,7 @@ public extension ENS { defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("reclaim", parameters: [record as AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("reclaim", parameters: [record]) else {throw Web3Error.transactionSerializationError} return transaction } diff --git a/Sources/web3swift/Utils/ENS/ENSRegistry.swift b/Sources/web3swift/Utils/ENS/ENSRegistry.swift index ce69986cd..bc5543f4f 100644 --- a/Sources/web3swift/Utils/ENS/ENSRegistry.swift +++ b/Sources/web3swift/Utils/ENS/ENSRegistry.swift @@ -49,7 +49,7 @@ public extension ENS { public func getOwner(node: String) async throws -> EthereumAddress { guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.registryContract.createReadOperation("owner", parameters: [nameHash as AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.registryContract.createReadOperation("owner", parameters: [nameHash]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let address = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "No address in result")} @@ -59,7 +59,7 @@ public extension ENS { public func getResolver(forDomain domain: String) async throws -> Resolver { guard let nameHash = NameHash.nameHash(domain) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.registryContract.createReadOperation("resolver", parameters: [nameHash as AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.registryContract.createReadOperation("resolver", parameters: [nameHash]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let resolverAddress = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "No address in result")} @@ -69,7 +69,7 @@ public extension ENS { public func getTTL(node: String) async throws -> BigUInt { guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.registryContract.createReadOperation("ttl", parameters: [nameHash as AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.registryContract.createReadOperation("ttl", parameters: [nameHash]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let ans = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "No answer in result")} diff --git a/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift b/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift index 0fb8ef20a..7ec38529b 100644 --- a/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift +++ b/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift @@ -34,7 +34,7 @@ public extension ENS { defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("claim", parameters: [owner as AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("claim", parameters: [owner]) else {throw Web3Error.transactionSerializationError} return transaction } diff --git a/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift b/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift index 34f1bc747..602d5902c 100644 --- a/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift +++ b/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift @@ -45,7 +45,7 @@ public extension ENS { } public func isNameAvailable(name: String) async throws -> Bool { - guard let transaction = self.contract.createReadOperation("available", parameters: [name as AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createReadOperation("available", parameters: [name]) else {throw Web3Error.transactionSerializationError} guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let available = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Can't get answer")} return available @@ -62,7 +62,7 @@ public extension ENS { defaultOptions.from = from defaultOptions.to = self.address - guard let transaction = self.contract.createWriteOperation("commit", parameters: [commitment as AnyObject]) else {throw Web3Error.transactionSerializationError} + guard let transaction = self.contract.createWriteOperation("commit", parameters: [commitment]) else {throw Web3Error.transactionSerializationError} return transaction } From c448970d1055b287fa7df45ccab63a82ed974c94 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 14 Jan 2023 18:15:49 +0200 Subject: [PATCH 018/210] chore: replaced [Any]() with [] for default parameter value --- Sources/web3swift/Web3/Web3+Contract.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/web3swift/Web3/Web3+Contract.swift b/Sources/web3swift/Web3/Web3+Contract.swift index da59285ed..300ac7678 100755 --- a/Sources/web3swift/Web3/Web3+Contract.swift +++ b/Sources/web3swift/Web3/Web3+Contract.swift @@ -83,7 +83,7 @@ extension Web3 { /// Elements of "parameters" can be other arrays or instances of String, Data, BigInt, BigUInt, Int or EthereumAddress. /// /// Returns a "Transaction intermediate" object. - public func createReadOperation(_ method: String = "fallback", parameters: [Any] = [Any](), extraData: Data = Data()) -> ReadOperation? { + public func createReadOperation(_ method: String = "fallback", parameters: [Any] = [], extraData: Data = Data()) -> ReadOperation? { // MARK: - Encoding ABI Data flow guard let data = contract.method(method, parameters: parameters, extraData: extraData) else { return nil } @@ -104,7 +104,7 @@ extension Web3 { /// Elements of "parameters" can be other arrays or instances of String, Data, BigInt, BigUInt, Int or EthereumAddress. /// /// Returns a "Transaction intermediate" object. - public func createWriteOperation(_ method: String = "fallback", parameters: [Any] = [Any](), extraData: Data = Data()) -> WriteOperation? { + public func createWriteOperation(_ method: String = "fallback", parameters: [Any] = [], extraData: Data = Data()) -> WriteOperation? { guard let data = contract.method(method, parameters: parameters, extraData: extraData) else { return nil } transaction.data = data if let network = web3.provider.network { From 2bd330342ff96ecd4df94349190f11a4aea8aad9 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 14 Jan 2023 18:16:31 +0200 Subject: [PATCH 019/210] chore: test refactoring - checking for nullability by using XCTAssertNotNil --- Tests/web3swiftTests/localTests/ERC20Tests.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/web3swiftTests/localTests/ERC20Tests.swift b/Tests/web3swiftTests/localTests/ERC20Tests.swift index f79ae933f..f569640b5 100755 --- a/Tests/web3swiftTests/localTests/ERC20Tests.swift +++ b/Tests/web3swiftTests/localTests/ERC20Tests.swift @@ -26,10 +26,10 @@ class ERC20Tests: LocalTestCase { let addressOfUser = EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")! let contract = web3.contract(Web3.Utils.erc20ABI, at: receipt.contractAddress!, abiVersion: 2)! - guard let readTX = contract.createReadOperation("balanceOf", parameters: [addressOfUser]) else {return XCTFail()} + guard let readTX = contract.createReadOperation("balanceOf", parameters: [addressOfUser]) else { return XCTFail() } readTX.transaction.from = addressOfUser - let tokenBalance = try await readTX.callContractMethod() - guard let bal = tokenBalance["0"] as? BigUInt else {return XCTFail()} + let tokenBalanceResponse = try await readTX.callContractMethod() + XCTAssertNotNil(tokenBalanceResponse["0"] as? BigUInt) } // FIXME: Make me work From ed43d2db481264e07544535db2a5f64211e25c67 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 15 Jan 2023 00:19:58 +0200 Subject: [PATCH 020/210] fix: RLP func encode for single value has named parameter It fixes the issue when trying to call func element() with [Any]. --- Sources/Web3Core/RLP/RLP.swift | 5 ++--- Tests/web3swiftTests/localTests/TransactionsTests.swift | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Sources/Web3Core/RLP/RLP.swift b/Sources/Web3Core/RLP/RLP.swift index 584f2914c..af5d8b29e 100755 --- a/Sources/Web3Core/RLP/RLP.swift +++ b/Sources/Web3Core/RLP/RLP.swift @@ -18,10 +18,9 @@ public struct RLP { static var length56 = BigUInt(UInt(56)) static var lengthMax = (BigUInt(UInt(1)) << 256) - internal static func encode(_ element: Any?) -> Data? { + internal static func encode(element: Any?) -> Data? { if let string = element as? String { return encode(string) - } else if let data = element as? Data { return encode(data) } else if let biguint = element as? BigUInt { @@ -115,7 +114,7 @@ public struct RLP { internal static func encode(_ elements: [Any?]) -> Data? { var encodedData = Data() for e in elements { - if let encoded = encode(e) { + if let encoded = encode(element: e) { encodedData.append(encoded) } else { guard let asArray = e as? [Any] else {return nil} diff --git a/Tests/web3swiftTests/localTests/TransactionsTests.swift b/Tests/web3swiftTests/localTests/TransactionsTests.swift index 99d102032..8471bbc1d 100755 --- a/Tests/web3swiftTests/localTests/TransactionsTests.swift +++ b/Tests/web3swiftTests/localTests/TransactionsTests.swift @@ -471,7 +471,6 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - return XCTFail(String(describing: error)) } } From a17a5bb7782e756b8db9ecce72718f133f0346a4 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 15 Jan 2023 01:00:55 +0200 Subject: [PATCH 021/210] fix: ENS parsing requires chainID if an ENS address is expected to be requested/decoded - we do not assume that client is using Ethereum Mainnet! According to EIP-681: chain_id is optional and contains the decimal chain ID, such that transactions on various test- and private networks can be requested. If no chain_id is present, the client's current network setting remains effective. In our case if no chainID is present we cannot validate ENS address and will not attempt to guess the network. --- Sources/web3swift/Utils/EIP/EIP681.swift | 5 +++-- Tests/web3swiftTests/localTests/EIP681Tests.swift | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Sources/web3swift/Utils/EIP/EIP681.swift b/Sources/web3swift/Utils/EIP/EIP681.swift index 730085e6a..2138da9d7 100755 --- a/Sources/web3swift/Utils/EIP/EIP681.swift +++ b/Sources/web3swift/Utils/EIP/EIP681.swift @@ -348,7 +348,7 @@ extension Web3 { private static func parseFunctionArgument(_ inputType: ABI.Element.ParameterType, _ rawValue: String, - chainID: BigUInt? = Networks.Mainnet.chainID, + chainID: BigUInt?, inputNumber: Int) async -> FunctionArgument? { var nativeValue: Any? switch inputType { @@ -358,8 +358,9 @@ extension Web3 { case .ethereumAddress(let ethereumAddress): nativeValue = ethereumAddress case .ensAddress(let ens): + guard let chainID = chainID else { return nil } do { - let web = await Web3(provider: InfuraProvider(chainID == nil ? .Mainnet : .fromInt(UInt(chainID!)))!) + let web = await Web3(provider: InfuraProvider(.fromInt(UInt(chainID)))!) let ensModel = ENS(web3: web) try await ensModel?.setENSResolver(withDomain: ens) let address = try await ensModel?.getAddress(forNode: ens) diff --git a/Tests/web3swiftTests/localTests/EIP681Tests.swift b/Tests/web3swiftTests/localTests/EIP681Tests.swift index cabd53fa2..1fbd027fc 100755 --- a/Tests/web3swiftTests/localTests/EIP681Tests.swift +++ b/Tests/web3swiftTests/localTests/EIP681Tests.swift @@ -83,7 +83,7 @@ class EIP681Tests: XCTestCase { func testENSParsing() async throws { let testAddress = "somename.eth" - let eip681Code = await Web3.EIP681CodeParser.parse("ethereum:\(testAddress)/transfer?address=somename.eth&uint256=1") + let eip681Code = await Web3.EIP681CodeParser.parse("ethereum:\(testAddress)@1/transfer?address=somename.eth&uint256=1") XCTAssert(eip681Code != nil) guard let eip681Code = eip681Code else { return } switch eip681Code.targetAddress { @@ -110,7 +110,7 @@ class EIP681Tests: XCTestCase { func testENSParsingWithEncoding() async throws { let testAddress = "somename.eth" - let eip681Code = await Web3.EIP681CodeParser.parse("ethereum:\(testAddress)/transfer?address=somename.eth&uint256=1".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!) + let eip681Code = await Web3.EIP681CodeParser.parse("ethereum:\(testAddress)@1/transfer?address=somename.eth&uint256=1".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!) XCTAssert(eip681Code != nil) guard let eip681Code = eip681Code else { return } switch eip681Code.targetAddress { From 8af8fa5fb7c3880e59b96b157bbd9ee0012e986f Mon Sep 17 00:00:00 2001 From: albertopeam Date: Wed, 18 Jan 2023 23:11:40 +0100 Subject: [PATCH 022/210] added backticks to BIP44 doc. replaced String with EthereumAddress in TransactionChecker --- Sources/Web3Core/KeystoreManager/BIP44.swift | 10 +++---- .../EtherscanTransactionChecker.swift | 11 ++++++-- .../localTests/BIP44Tests.swift | 4 +-- .../EtherscanTransactionCheckerTests.swift | 27 ++++++++++--------- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP44.swift b/Sources/Web3Core/KeystoreManager/BIP44.swift index d0d701e5d..9a80a396c 100644 --- a/Sources/Web3Core/KeystoreManager/BIP44.swift +++ b/Sources/Web3Core/KeystoreManager/BIP44.swift @@ -7,9 +7,9 @@ import Foundation public protocol BIP44 { /** - Derive an ``HDNode`` based on the provided path. The function will throw ``BIP44Error.warning`` if it was invoked with throwOnWarning equal to - `true` and the root key doesn't have a previous child with at least one transaction. If it is invoked with throwOnError equal to `false` the child node will be - derived directly using the derive function of ``HDNode``. This function needs to query the blockchain history when throwOnWarning is `true`, so it can throw + Derive an ``HDNode`` based on the provided path. The function will throw ``BIP44Error.warning`` if it was invoked with `throwOnWarning` equal to + `true` and the root key doesn't have a previous child with at least one transaction. If it is invoked with `throwOnWarning` equal to `false` the child node will be + derived directly using the derive function of ``HDNode``. This function needs to query the blockchain history when `throwOnWarning` is `true`, so it can throw network errors. - Parameter path: valid BIP44 path. - Parameter throwOnWarning: `true` to use @@ -41,7 +41,7 @@ public protocol TransactionChecker { - Throws: any error related to query the blockchain provider - Returns: `true` if the address has at least one transaction, `false` otherwise */ - func hasTransactions(address: String) async throws -> Bool + func hasTransactions(ethereumAddress: EthereumAddress) async throws -> Bool } extension HDNode: BIP44 { @@ -62,7 +62,7 @@ extension HDNode: BIP44 { if let searchPath = path.newPath(account: searchAccount, addressIndex: searchAddressIndex), let childNode = derive(path: searchPath, derivePrivateKey: true), let ethAddress = Utilities.publicToAddress(childNode.publicKey) { - hasTransactions = try await transactionChecker.hasTransactions(address: ethAddress.address) + hasTransactions = try await transactionChecker.hasTransactions(ethereumAddress: ethAddress) if hasTransactions { break } diff --git a/Sources/Web3Core/KeystoreManager/EtherscanTransactionChecker.swift b/Sources/Web3Core/KeystoreManager/EtherscanTransactionChecker.swift index 93318d151..1b0353285 100644 --- a/Sources/Web3Core/KeystoreManager/EtherscanTransactionChecker.swift +++ b/Sources/Web3Core/KeystoreManager/EtherscanTransactionChecker.swift @@ -8,6 +8,7 @@ import Foundation public struct EtherscanTransactionChecker: TransactionChecker { private let urlSession: URLSessionProxy private let apiKey: String + private let successRange = 200..<300 public init(urlSession: URLSession, apiKey: String) { self.urlSession = URLSessionProxyImplementation(urlSession: urlSession) @@ -19,13 +20,16 @@ public struct EtherscanTransactionChecker: TransactionChecker { self.apiKey = apiKey } - public func hasTransactions(address: String) async throws -> Bool { - let urlString = "https://api.etherscan.io/api?module=account&action=txlist&address=\(address)&startblock=0&page=1&offset=1&sort=asc&apikey=\(apiKey)" + public func hasTransactions(ethereumAddress: EthereumAddress) async throws -> Bool { + let urlString = "https://api.etherscan.io/api?module=account&action=txlist&address=\(ethereumAddress.address)&startblock=0&page=1&offset=1&sort=asc&apikey=\(apiKey)" guard let url = URL(string: urlString) else { throw EtherscanTransactionCheckerError.invalidUrl(url: urlString) } let request = URLRequest(url: url) let result = try await urlSession.data(for: request) + if let httpResponse = result.1 as? HTTPURLResponse, !successRange.contains(httpResponse.statusCode) { + throw EtherscanTransactionCheckerError.network(statusCode: httpResponse.statusCode) + } let response = try JSONDecoder().decode(Response.self, from: result.0) return !response.result.isEmpty } @@ -40,11 +44,14 @@ extension EtherscanTransactionChecker { public enum EtherscanTransactionCheckerError: LocalizedError, Equatable { case invalidUrl(url: String) + case network(statusCode: Int) public var errorDescription: String? { switch self { case let .invalidUrl(url): return "Couldn't create URL(string: \(url))" + case let .network(statusCode): + return "Network error, statusCode: \(statusCode)" } } } diff --git a/Tests/web3swiftTests/localTests/BIP44Tests.swift b/Tests/web3swiftTests/localTests/BIP44Tests.swift index 400a2f6bb..95aa115e9 100644 --- a/Tests/web3swiftTests/localTests/BIP44Tests.swift +++ b/Tests/web3swiftTests/localTests/BIP44Tests.swift @@ -192,8 +192,8 @@ private final class MockTransactionChecker: TransactionChecker { var addresses: [String] = .init() var results: [Bool] = .init() - func hasTransactions(address: String) async throws -> Bool { - addresses.append(address) + func hasTransactions(ethereumAddress: EthereumAddress) async throws -> Bool { + addresses.append(ethereumAddress.address) return results.removeFirst() } } diff --git a/Tests/web3swiftTests/remoteTests/EtherscanTransactionCheckerTests.swift b/Tests/web3swiftTests/remoteTests/EtherscanTransactionCheckerTests.swift index 68d91f933..c58d2fa44 100644 --- a/Tests/web3swiftTests/remoteTests/EtherscanTransactionCheckerTests.swift +++ b/Tests/web3swiftTests/remoteTests/EtherscanTransactionCheckerTests.swift @@ -9,12 +9,12 @@ import XCTest final class EtherscanTransactionCheckerTests: XCTestCase { private var testApiKey: String { "4HVPVMV1PN6NGZDFXZIYKEZRP53IA41KVC" } private var vitaliksAddress: String { "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B" } - private var emptyAddress: String { "0x1BeY3KhtHpfATH5Yqxz9d8Z1XbqZFSXtK7" } + private var emptyAddress: String { "0x3a0cd085155dc74cdddf3196f23c8cec9b217dd8" } func testHasTransactions() async throws { let sut = EtherscanTransactionChecker(urlSession: URLSession.shared, apiKey: testApiKey) - - let result = try await sut.hasTransactions(address: vitaliksAddress) + + let result = try await sut.hasTransactions(ethereumAddress: try XCTUnwrap(EthereumAddress(vitaliksAddress))) XCTAssertTrue(result) } @@ -22,7 +22,8 @@ final class EtherscanTransactionCheckerTests: XCTestCase { func testHasNotTransactions() async throws { let sut = EtherscanTransactionChecker(urlSession: URLSession.shared, apiKey: testApiKey) - let result = try await sut.hasTransactions(address: emptyAddress) + let ethAddr = try XCTUnwrap(EthereumAddress(emptyAddress)) + let result = try await sut.hasTransactions(ethereumAddress: ethAddr) XCTAssertFalse(result) } @@ -33,31 +34,31 @@ final class EtherscanTransactionCheckerTests: XCTestCase { urlSessionMock.response = (Data(), try XCTUnwrap(HTTPURLResponse(url: try XCTUnwrap(URL(string: "https://")), statusCode: 500, httpVersion: nil, headerFields: nil))) let sut = EtherscanTransactionChecker(urlSession: urlSessionMock, apiKey: testApiKey) - _ = try await sut.hasTransactions(address: vitaliksAddress) + _ = try await sut.hasTransactions(ethereumAddress: try XCTUnwrap(EthereumAddress(vitaliksAddress))) XCTFail("Network must throw an error") - } catch { - XCTAssertTrue(true) + } catch let EtherscanTransactionCheckerError.network(statusCode) { + XCTAssertEqual(statusCode, 500) } } func testInitURLError() async throws { do { - let sut = EtherscanTransactionChecker(urlSession: URLSessionMock(), apiKey: testApiKey) + let sut = EtherscanTransactionChecker(urlSession: URLSessionMock(), apiKey: " ") - _ = try await sut.hasTransactions(address: " ") + _ = try await sut.hasTransactions(ethereumAddress: try XCTUnwrap(EthereumAddress(vitaliksAddress))) XCTFail("URL init must throw an error") - } catch { - XCTAssertTrue(error is EtherscanTransactionCheckerError) + } catch EtherscanTransactionCheckerError.invalidUrl { + XCTAssertTrue(true) } } func testWrongApiKey() async throws { do { - let sut = EtherscanTransactionChecker(urlSession: URLSession.shared, apiKey: "") + let sut = EtherscanTransactionChecker(urlSession: URLSession.shared, apiKey: "-") - _ = try await sut.hasTransactions(address: "") + _ = try await sut.hasTransactions(ethereumAddress: try XCTUnwrap(EthereumAddress(vitaliksAddress))) XCTFail("API not returns a valid response") } catch DecodingError.typeMismatch { From be6c5854885fd14cbea46e3e97b93176bd391e90 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 22 Jan 2023 18:05:40 +0200 Subject: [PATCH 023/210] chore: EIP681 docs + more descriptive log message --- Sources/web3swift/Utils/EIP/EIP681.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/web3swift/Utils/EIP/EIP681.swift b/Sources/web3swift/Utils/EIP/EIP681.swift index 2138da9d7..1882420a4 100755 --- a/Sources/web3swift/Utils/EIP/EIP681.swift +++ b/Sources/web3swift/Utils/EIP/EIP681.swift @@ -238,6 +238,12 @@ extension Web3 { return await parse(string) } + // TODO: throws errors instead of returning `nil` + /// Attempts to parse given string as EIP681 code. + /// Note: that ENS addresses as paramteres will be attempted to be resolved into Ethereum addresses. + /// Thus, make sure that given raw EIP681 code has chain ID set or default Ethereum Mainnet chan ID will be used instead. + /// - Parameter string: raw, encoded EIP681 code. + /// - Returns: parsed EIP681 code or `nil` is something has failed. public static func parse(_ string: String) async -> EIP681Code? { guard string.hasPrefix("ethereum:") else { return nil } let striped = string.components(separatedBy: "ethereum:") @@ -366,7 +372,7 @@ extension Web3 { let address = try await ensModel?.getAddress(forNode: ens) nativeValue = address } catch { - NSLog(error.localizedDescription) + NSLog("Failed to resolve ENS address (parameter nr \(inputNumber)). Error: \(error.localizedDescription)") return nil } } From 1486d88149ff6bdb6ac6d470e3f752bb8c4bd2fd Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 29 Jan 2023 18:56:33 +0100 Subject: [PATCH 024/210] Upgrade GitHub Action checkout https://github.com/actions/checkout/releases --- .github/workflows/macOS-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index 9d2e1c690..749ce9e55 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -33,7 +33,7 @@ jobs: group: spm-${{ github.run_id }} cancel-in-progress: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Resolve dependencies run: swift package resolve - name: Build From 3850262e34a8d763c2a9129925b7a4839d88e9cb Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 29 Jan 2023 19:02:51 +0100 Subject: [PATCH 025/210] Fix typos discovered by codespell https://pypi.org/project/codespell --- CHANGELOG.md | 12 ++++---- README.md | 4 +-- Sources/Core/EthereumABI/ABIElements.swift | 6 ++-- .../Web3Core/Contract/ContractProtocol.swift | 4 +-- .../Web3Core/EthereumABI/ABIDecoding.swift | 2 +- .../Web3Core/EthereumABI/ABIElements.swift | 4 +-- .../EthereumABI/Sequence+ABIExtension.swift | 2 +- .../EthereumAddress/EthereumAddress.swift | 2 +- .../EthereumNetwork/Request/APIRequest.swift | 10 +++---- .../RequestParameter+Encodable.swift | 4 +-- .../Utility/HexDecodableProtocols.swift | 2 +- Sources/Web3Core/KeystoreManager/IBAN.swift | 4 +-- Sources/Web3Core/Oracle/GasOracle.swift | 4 +-- .../Transaction/CodableTransaction.swift | 10 +++---- .../Envelope/AbstractEnvelope.swift | 6 ++-- .../Envelope/EIP1559Envelope.swift | 2 +- .../Envelope/EnvelopeFactory.swift | 2 +- .../Transaction/Envelope/LegacyEnvelope.swift | 4 +-- .../Transaction/EventfilterParameters.swift | 4 +-- .../Transaction/TransactionMetadata.swift | 2 +- .../Utility/Decodable+Extensions.swift | 12 ++++---- .../Web3Core/Utility/String+Extension.swift | 2 +- Sources/Web3Core/Utility/Utilities.swift | 12 ++++---- Sources/secp256k1/ecmult_impl.h | 2 +- Sources/secp256k1/include/secp256k1.h | 2 +- .../Tokens/ERC20/ERC20BaseProperties.swift | 2 +- Sources/web3swift/Utils/EIP/EIP712.swift | 4 +-- Sources/web3swift/Utils/ENS/NameHash.swift | 2 +- Sources/web3swift/Web3/Web3+Contract.swift | 4 +-- Sources/web3swift/Web3/Web3+Personal.swift | 2 +- Sources/web3swift/Web3/Web3.swift | 4 +-- .../localTests/ABIEncoderTest.swift | 2 +- .../localTests/BasicLocalNodeTests.swift | 2 +- .../localTests/EIP1559BlockTests.swift | 28 +++++++++---------- .../localTests/ERC20ClassTests.swift | 2 +- .../localTests/TransactionsTests.swift | 4 +-- .../remoteTests/InfuraTests.swift | 4 +-- .../remoteTests/RemoteParsingTests.swift | 22 +++++++-------- 38 files changed, 101 insertions(+), 101 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6da5dbfb2..d1fef400b 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,7 +83,7 @@ - `subscribeOnLogs` method with specific contract address is not working!!!! [\#366](https://github.com/skywinder/web3swift/issues/366) - EthereumContract with Custom ABI returns nil [\#342](https://github.com/skywinder/web3swift/issues/342) - Error on running tests [\#290](https://github.com/skywinder/web3swift/issues/290) -- Serialisation of BIP32 misplaced address postition [\#257](https://github.com/skywinder/web3swift/issues/257) +- Serialisation of BIP32 misplaced address position [\#257](https://github.com/skywinder/web3swift/issues/257) - Xcode 10.2.1 carthage update hangs while building web3swift.xcodeproj [\#197](https://github.com/skywinder/web3swift/issues/197) **Closed issues:** @@ -118,7 +118,7 @@ - @ravi-ranjan-oodles thanks for the update. [\#329](https://github.com/skywinder/web3swift/issues/329) - Issue in Uploading to Test Flight [\#328](https://github.com/skywinder/web3swift/issues/328) - Update CryptoSwift podspec [\#322](https://github.com/skywinder/web3swift/issues/322) -- cann't open DApp, such as "https://uniswap.tokenpocket.pro/\#/swap" [\#321](https://github.com/skywinder/web3swift/issues/321) +- can't open DApp, such as "https://uniswap.tokenpocket.pro/\#/swap" [\#321](https://github.com/skywinder/web3swift/issues/321) - CryptoSwift version is too low to work properly in Xcode12.5 [\#318](https://github.com/skywinder/web3swift/issues/318) - web3swift.Web3Error.processingError\(desc: "Failed to fetch gas estimate"\)(BSC Chain) [\#317](https://github.com/skywinder/web3swift/issues/317) - Quick simple steps for minting ERC20 or ERC721 tokens [\#314](https://github.com/skywinder/web3swift/issues/314) @@ -126,7 +126,7 @@ - I can't find func 'Web3.InfuraKovanWeb3\(\)' [\#311](https://github.com/skywinder/web3swift/issues/311) - web3 instance error: Variable used within its own initial value [\#310](https://github.com/skywinder/web3swift/issues/310) - Failed to fetch gas estimate when sending erc20 [\#307](https://github.com/skywinder/web3swift/issues/307) -- DApp browser cann't open Uniswap in a right way [\#304](https://github.com/skywinder/web3swift/issues/304) +- DApp browser can't open Uniswap in a right way [\#304](https://github.com/skywinder/web3swift/issues/304) - Update cocoapods bigint to 5.0 [\#288](https://github.com/skywinder/web3swift/issues/288) - When I use getBlockByNumber , hash Unable to check [\#287](https://github.com/skywinder/web3swift/issues/287) - How to parse the return value of read transaction [\#284](https://github.com/skywinder/web3swift/issues/284) @@ -231,7 +231,7 @@ - policy [\#247](https://github.com/skywinder/web3swift/pull/247) ([BaldyAsh](https://github.com/BaldyAsh)) - Fix dependencies, build [\#245](https://github.com/skywinder/web3swift/pull/245) ([BaldyAsh](https://github.com/BaldyAsh)) - chore: update ENS Registry migration [\#243](https://github.com/skywinder/web3swift/pull/243) ([aranhaagency](https://github.com/aranhaagency)) -- improtant notice update [\#232](https://github.com/skywinder/web3swift/pull/232) ([skywinder](https://github.com/skywinder)) +- important notice update [\#232](https://github.com/skywinder/web3swift/pull/232) ([skywinder](https://github.com/skywinder)) - Add Alice Wallet to project list [\#230](https://github.com/skywinder/web3swift/pull/230) ([lmcmz](https://github.com/lmcmz)) - Update Extensions.swift [\#225](https://github.com/skywinder/web3swift/pull/225) ([kocherovets](https://github.com/kocherovets)) - correct gasLimit [\#222](https://github.com/skywinder/web3swift/pull/222) ([luqz](https://github.com/luqz)) @@ -249,10 +249,10 @@ **Closed issues:** - BigInt 3.1 [\#207](https://github.com/skywinder/web3swift/issues/207) -- recevied transaction id from geth node server but not able to see that transaction id at etherscan.io [\#200](https://github.com/skywinder/web3swift/issues/200) +- received transaction id from geth node server but not able to see that transaction id at etherscan.io [\#200](https://github.com/skywinder/web3swift/issues/200) - How do I fetch information such as balance, decimal,symbol and name of ERC20token ? [\#199](https://github.com/skywinder/web3swift/issues/199) - Starscream 3.1.0 not compatible with Swift 5.0 [\#195](https://github.com/skywinder/web3swift/issues/195) -- How to Connect infuraWebsocket and subsribe perticular event in swift? [\#193](https://github.com/skywinder/web3swift/issues/193) +- How to Connect infuraWebsocket and subsribe particular event in swift? [\#193](https://github.com/skywinder/web3swift/issues/193) - Use of unresolved identifier 'Wallet' [\#192](https://github.com/skywinder/web3swift/issues/192) - V in Signed Message Hash not being calculated properly [\#191](https://github.com/skywinder/web3swift/issues/191) - Not possible to calculate fast, normal and cheap transaction fee ? [\#190](https://github.com/skywinder/web3swift/issues/190) diff --git a/README.md b/README.md index 92c686767..43fbc8ec7 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # web3swift **web3swift** is an iOS toolbelt for interaction with the Ethereum network. -## Social medias +## Social media [Join our discord](https://discord.gg/8bHCNmhS7x) or [Telegram](https://t.me/web3swift) if you need support or want to contribute to web3swift development! ![matter-github-swift](https://github.com/web3swift-team/web3swift/blob/develop/web3swift-logo.png) @@ -57,7 +57,7 @@ - [x] 🕵️‍♂️ Possibility to **add or remove "middleware" that intercepts**, modifies and even **cancel transaction** workflow on stages "before assembly", "after assembly" and "before submission" - [x] ✅**Literally following the standards** (BIP, EIP, etc): - [x] **[BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) (HD Wallets), [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) (Seed phrases), [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) (Key generation prefixes)** -- [x] **[EIP-20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md)** (Standart interface for tokens - ERC-20), **[EIP-67](https://github.com/ethereum/EIPs/issues/67)** (Standard URI scheme), **[EIP-155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md)** (Replay attacks protection), **[EIP-2718](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2718.md)** (Typed Transaction Envelope), **[EIP-1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md)** (Gas Fee market change) +- [x] **[EIP-20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md)** (Standard interface for tokens - ERC-20), **[EIP-67](https://github.com/ethereum/EIPs/issues/67)** (Standard URI scheme), **[EIP-155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md)** (Replay attacks protection), **[EIP-2718](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2718.md)** (Typed Transaction Envelope), **[EIP-1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md)** (Gas Fee market change) - [x] **And many others** *(For details about this EIP's look at [Documentation page](https://github.com/web3swift-team/web3swift/blob/master/Documentation/))*: EIP-681, EIP-721, EIP-165, EIP-777, EIP-820, EIP-888, EIP-1400, EIP-1410, EIP-1594, EIP-1643, EIP-1644, EIP-1633, EIP-721, EIP-1155, EIP-1376, ST-20 - [x] **RLP encoding** - [x] Base58 encoding scheme diff --git a/Sources/Core/EthereumABI/ABIElements.swift b/Sources/Core/EthereumABI/ABIElements.swift index c947f6159..f3795bf8d 100755 --- a/Sources/Core/EthereumABI/ABIElements.swift +++ b/Sources/Core/EthereumABI/ABIElements.swift @@ -280,7 +280,7 @@ extension ABI.Element.Function { var returnArray = [String: Any]() - // set infomation + // set information returnArray["_abortedByRequire"] = true returnArray["_errorMessageFromRequire"] = message @@ -340,8 +340,8 @@ extension ABI.Element.Constructor { /// Generic input decoding function. /// - Parameters: -/// - rawData: data to decode. Must match the followin criteria: `data.count == 0 || data.count % 32 == 4`. -/// - methodEncoding: 4 bytes represeting method signature like `0xFFffFFff`. Can be ommited to avoid checking method encoding. +/// - rawData: data to decode. Must match the following criteria: `data.count == 0 || data.count % 32 == 4`. +/// - methodEncoding: 4 bytes representing method signature like `0xFFffFFff`. Can be omitted to avoid checking method encoding. /// - inputs: expected input types. Order must be the same as in function declaration. /// - Returns: decoded dictionary of input arguments mapped to their indices and arguments' names if these are not empty. /// If decoding of at least one argument fails, `rawData` size is invalid or `methodEncoding` doesn't match - `nil` is returned. diff --git a/Sources/Web3Core/Contract/ContractProtocol.swift b/Sources/Web3Core/Contract/ContractProtocol.swift index 9302cbc8e..2f191be1b 100755 --- a/Sources/Web3Core/Contract/ContractProtocol.swift +++ b/Sources/Web3Core/Contract/ContractProtocol.swift @@ -116,7 +116,7 @@ public protocol ContractProtocol { /// - bytecode: bytecode to deploy. /// - constructor: constructor of the smart contract bytecode is related to. Used to encode `parameters`. /// - parameters: parameters for `constructor`. - /// - extraData: any extra data. It can be encoded input arguments for a constuctor but then you should set `constructor` and + /// - extraData: any extra data. It can be encoded input arguments for a constructor but then you should set `constructor` and /// `parameters` to be `nil`. /// - Returns: Encoded data for a given parameters, which is should be assigned to ``CodableTransaction.data`` property func deploy(bytecode: Data, @@ -185,7 +185,7 @@ public protocol ContractProtocol { extension ContractProtocol { /// Overloading of ``ContractProtocol/deploy(bytecode:constructor:parameters:extraData:)`` to allow - /// omitting evertyhing but `bytecode`. + /// omitting everything but `bytecode`. /// /// See ``ContractProtocol/deploy(bytecode:constructor:parameters:extraData:)`` for details. func deploy(_ bytecode: Data, diff --git a/Sources/Web3Core/EthereumABI/ABIDecoding.swift b/Sources/Web3Core/EthereumABI/ABIDecoding.swift index 7dad9179f..57b25aa1a 100755 --- a/Sources/Web3Core/EthereumABI/ABIDecoding.swift +++ b/Sources/Web3Core/EthereumABI/ABIDecoding.swift @@ -196,7 +196,7 @@ extension ABIDecoder { let dataSlice = data[pointer ..< pointer + type.memoryUsage] let bn = BigUInt(dataSlice) if bn > UInt64.max || bn >= data.count { - // there are ERC20 contracts that use bytes32 intead of string. Let's be optimistic and return some data + // there are ERC20 contracts that use bytes32 instead of string. Let's be optimistic and return some data if case .string = type { let nextElement = pointer + type.memoryUsage let preambula = BigUInt(32).abiEncode(bits: 256)! diff --git a/Sources/Web3Core/EthereumABI/ABIElements.swift b/Sources/Web3Core/EthereumABI/ABIElements.swift index aadf61b9a..10118b64e 100755 --- a/Sources/Web3Core/EthereumABI/ABIElements.swift +++ b/Sources/Web3Core/EthereumABI/ABIElements.swift @@ -438,8 +438,8 @@ extension ABI.Element.Constructor { /// Generic input decoding function. /// - Parameters: -/// - rawData: data to decode. Must match the followin criteria: `data.count == 0 || data.count % 32 == 4`. -/// - methodEncoding: 4 bytes represeting method signature like `0xFFffFFff`. Can be ommited to avoid checking method encoding. +/// - rawData: data to decode. Must match the following criteria: `data.count == 0 || data.count % 32 == 4`. +/// - methodEncoding: 4 bytes representing method signature like `0xFFffFFff`. Can be omitted to avoid checking method encoding. /// - inputs: expected input types. Order must be the same as in function declaration. /// - Returns: decoded dictionary of input arguments mapped to their indices and arguments' names if these are not empty. /// If decoding of at least one argument fails, `rawData` size is invalid or `methodEncoding` doesn't match - `nil` is returned. diff --git a/Sources/Web3Core/EthereumABI/Sequence+ABIExtension.swift b/Sources/Web3Core/EthereumABI/Sequence+ABIExtension.swift index c13fb9f15..1d2f32744 100644 --- a/Sources/Web3Core/EthereumABI/Sequence+ABIExtension.swift +++ b/Sources/Web3Core/EthereumABI/Sequence+ABIExtension.swift @@ -63,7 +63,7 @@ public extension Sequence where Element == ABI.Element { /// Filters out ``ABI/Element/Constructor``. /// If there are multiple of them the first encountered will be returned and if there are none a default constructor will be returned /// that accepts no input parameters. - /// - Returns: the first ``ABI/Element/Constructor`` or default contructor with no input parameters. + /// - Returns: the first ``ABI/Element/Constructor`` or default constructor with no input parameters. func getConstructor() -> ABI.Element.Constructor { for case let .constructor(constructor) in self { return constructor diff --git a/Sources/Web3Core/EthereumAddress/EthereumAddress.swift b/Sources/Web3Core/EthereumAddress/EthereumAddress.swift index ba703f78e..2e8d0ef45 100755 --- a/Sources/Web3Core/EthereumAddress/EthereumAddress.swift +++ b/Sources/Web3Core/EthereumAddress/EthereumAddress.swift @@ -91,7 +91,7 @@ public struct EthereumAddress: Equatable { } /// In swift structs it's better to implement initializers in extension -/// Since it's make available syntetized initializer then for free. +/// Since it's make available synthesized initializer then for free. extension EthereumAddress { public init?(_ addressString: String, type: AddressType = .normal, ignoreChecksum: Bool = false) { switch type { diff --git a/Sources/Web3Core/EthereumNetwork/Request/APIRequest.swift b/Sources/Web3Core/EthereumNetwork/Request/APIRequest.swift index 39d9cae4d..cb057da7e 100644 --- a/Sources/Web3Core/EthereumNetwork/Request/APIRequest.swift +++ b/Sources/Web3Core/EthereumNetwork/Request/APIRequest.swift @@ -95,7 +95,7 @@ public enum APIRequest { /// Estimate required gas amount for transaction /// - Parameters: /// - TransactionParameters: parameters of planned transaction - /// - BlockNumber: block where it should be evalueated + /// - BlockNumber: block where it should be evaluated case estimateGas(CodableTransaction, BlockNumber) /// Send raw transaction @@ -114,7 +114,7 @@ public enum APIRequest { case getTransactionByHash(Hash) /// Get transaction receipt - /// - Paramters: + /// - Parameters: /// - Hash: transaction hash ID case getTransactionReceipt(Hash) @@ -134,7 +134,7 @@ public enum APIRequest { /// Mostly could be used for intreacting with a contracts, but also could be used for simple transaction sending /// - Parameters: /// - TransactionParameters: transaction to be sent into chain - /// - BlockNumber: block where it should be evalueated + /// - BlockNumber: block where it should be evaluated case call(CodableTransaction, BlockNumber) /// Get a transaction counts on a given block @@ -149,7 +149,7 @@ public enum APIRequest { /// Get a balance of a given address /// - Parameters: - /// - Address: address which balance would be recieved + /// - Address: address which balance would be received /// - BlockNumber: block to check case getBalance(Address, BlockNumber) @@ -190,7 +190,7 @@ public enum APIRequest { /// - BlockNumber: Highest block of the requested range. /// - [Double]: A monotonically increasing list of percentile values. /// For each block in the requested range, the transactions will be sorted in ascending order - /// by effective tip per gas and the coresponding effective tip for the percentile will be determined, accounting for gas consumed." + /// by effective tip per gas and the corresponding effective tip for the percentile will be determined, accounting for gas consumed." case feeHistory(BigUInt, BlockNumber, [Double]) // MARK: - Personal Ethereum API diff --git a/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+Encodable.swift b/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+Encodable.swift index 2a99dd1e0..a683d5fdc 100644 --- a/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+Encodable.swift +++ b/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+Encodable.swift @@ -9,7 +9,7 @@ import Foundation extension RequestParameter: Encodable { /** - This encoder encodes `RequestParameter` assotiated value ignoring self value + This encoder encodes `RequestParameter` associated value ignoring self value This is required to encode mixed types array, like @@ -48,7 +48,7 @@ extension RequestParameter: Encodable { case is CodableTransaction.Type: try enumContainer.encode(rawValue as! CodableTransaction) case is EventFilterParameters.Type: try enumContainer.encode(rawValue as! EventFilterParameters) - default: break /// can't be executed, coz possible `self.rawValue` types are strictly defined in it's inplementation.` + default: break /// can't be executed, coz possible `self.rawValue` types are strictly defined in it's implementation.` } // swiftlint:enable force_cast } diff --git a/Sources/Web3Core/EthereumNetwork/Utility/HexDecodableProtocols.swift b/Sources/Web3Core/EthereumNetwork/Utility/HexDecodableProtocols.swift index fede66d34..b4c57ca39 100644 --- a/Sources/Web3Core/EthereumNetwork/Utility/HexDecodableProtocols.swift +++ b/Sources/Web3Core/EthereumNetwork/Utility/HexDecodableProtocols.swift @@ -17,7 +17,7 @@ extension String: APIResultType { } /// /// You better not use it in any other part of a bit of code except `APIResponse` decoding. /// -/// This protocols intention is to work around that Ethereum API cases, when almost all numbers are comming as strings. +/// This protocols intention is to work around that Ethereum API cases, when almost all numbers are coming as strings. /// More than that their notation (e.g. 0x12d) are don't fit with the default Numeric decoders behaviours. /// So to work around that for generic cases we're going to force decode `APIResponse.result` field as `String` /// and then initiate it diff --git a/Sources/Web3Core/KeystoreManager/IBAN.swift b/Sources/Web3Core/KeystoreManager/IBAN.swift index 604f7dce7..164ff319f 100755 --- a/Sources/Web3Core/KeystoreManager/IBAN.swift +++ b/Sources/Web3Core/KeystoreManager/IBAN.swift @@ -64,9 +64,9 @@ public struct IBAN { internal static func decodeToInts(_ iban: String) -> String { let uppercasedIBAN = iban.replacingOccurrences(of: " ", with: "").uppercased() - let begining = String(uppercasedIBAN[0..<4]) + let beginning = String(uppercasedIBAN[0..<4]) let end = String(uppercasedIBAN[4...]) - let IBAN = end + begining + let IBAN = end + beginning var arrayOfInts = [Int]() for ch in IBAN { guard let dataPoint = String(ch).data(using: .ascii) else {return ""} diff --git a/Sources/Web3Core/Oracle/GasOracle.swift b/Sources/Web3Core/Oracle/GasOracle.swift index 2819f5adc..dee933f01 100644 --- a/Sources/Web3Core/Oracle/GasOracle.swift +++ b/Sources/Web3Core/Oracle/GasOracle.swift @@ -101,7 +101,7 @@ final public class Oracle { private func suggestTipValue() async throws -> [BigUInt] { var rearrengedArray: [[BigUInt]] = [] - /// reaarange `[[min, middle, max]]` to `[[min], [middle], [max]]` + /// rearrange `[[min, middle, max]]` to `[[min], [middle], [max]]` try await suggestGasValues().reward .forEach { percentiles in percentiles.enumerated().forEach { index, percentile in @@ -139,7 +139,7 @@ final public class Oracle { default: throw Web3Error.valueError(desc: "Unable to use '\(block)' policy to resolve block number to calculate gas fee suggestion.") } - /// checking if latest block number is greather than number of blocks to take in account + /// checking if latest block number is greater than number of blocks to take in account /// we're ignoring case when `latestBlockNumber` == `blockCount` since it's unlikely case /// which we could neglect guard latestBlockNumber > blockCount else { return [] } diff --git a/Sources/Web3Core/Transaction/CodableTransaction.swift b/Sources/Web3Core/Transaction/CodableTransaction.swift index 19f5773fe..b478dc0f0 100644 --- a/Sources/Web3Core/Transaction/CodableTransaction.swift +++ b/Sources/Web3Core/Transaction/CodableTransaction.swift @@ -11,7 +11,7 @@ import BigInt /// While most fields in this struct are optional, they are not necessarily /// optional for the type of transaction they apply to. public struct CodableTransaction { - /// internal acccess only. The transaction envelope object itself that contains all the transaction data + /// internal access only. The transaction envelope object itself that contains all the transaction data /// and type specific implementation internal var envelope: AbstractEnvelope @@ -73,7 +73,7 @@ public struct CodableTransaction { set { return envelope.gasLimit = newValue } } - /// the price per gas unit for the tranaction (Legacy and EIP-2930 only) + /// the price per gas unit for the transaction (Legacy and EIP-2930 only) public var gasPrice: BigUInt? { get { return envelope.gasPrice } set { return envelope.gasPrice = newValue } @@ -147,7 +147,7 @@ public struct CodableTransaction { /// Signs the transaction /// - /// This method signs transaction iteself and not related to contract call data signing. + /// This method signs transaction itself and not related to contract call data signing. /// - Parameters: /// - privateKey: the private key to use for signing /// - useExtraEntropy: boolean whether to use extra entropy when signing (default false) @@ -265,7 +265,7 @@ extension CodableTransaction: Codable { } extension CodableTransaction: CustomStringConvertible { - /// required by CustomString convertable + /// required by CustomString convertible /// returns a string description for the transaction and its data public var description: String { var toReturn = "" @@ -290,7 +290,7 @@ extension CodableTransaction { /// - v: signature v parameter (default 1) - will get set properly once signed /// - r: signature r parameter (default 0) - will get set properly once signed /// - s: signature s parameter (default 0) - will get set properly once signed - /// - parameters: EthereumParameters object containing additional parametrs for the transaction like gas + /// - parameters: EthereumParameters object containing additional parameters for the transaction like gas public init(type: TransactionType? = nil, to: EthereumAddress, nonce: BigUInt = 0, chainID: BigUInt = 0, value: BigUInt = 0, data: Data = Data(), gasLimit: BigUInt = 0, maxFeePerGas: BigUInt? = nil, maxPriorityFeePerGas: BigUInt? = nil, gasPrice: BigUInt? = nil, diff --git a/Sources/Web3Core/Transaction/Envelope/AbstractEnvelope.swift b/Sources/Web3Core/Transaction/Envelope/AbstractEnvelope.swift index 5bb32c104..7986cddb1 100644 --- a/Sources/Web3Core/Transaction/Envelope/AbstractEnvelope.swift +++ b/Sources/Web3Core/Transaction/Envelope/AbstractEnvelope.swift @@ -60,8 +60,8 @@ public enum EncodeType { /// Protocol definition for all transaction envelope types /// All envelopes must conform to this protocol to work with `CodableTransaction` -/// each implememtation holds all the type specific data -/// and implments the type specific encoding/decoding +/// each implementation holds all the type specific data +/// and implements the type specific encoding/decoding protocol AbstractEnvelope: CustomStringConvertible { // possibly add Codable? /// The type of transaction this envelope represents @@ -115,7 +115,7 @@ protocol AbstractEnvelope: CustomStringConvertible { // possibly add Codable? // for Decodable support /// initializer for creating an `CodableTransaction` with the Decodable protocol /// will return an new `CodableTransaction` object on success - /// thows a `Web3.dataError` if an error occurs while trying to decode a value + /// throws a `Web3.dataError` if an error occurs while trying to decode a value /// returns nil if a required field is not found in the decoder stream init?(from decoder: Decoder) throws // Decodable Protocol diff --git a/Sources/Web3Core/Transaction/Envelope/EIP1559Envelope.swift b/Sources/Web3Core/Transaction/Envelope/EIP1559Envelope.swift index 052b931d9..71a5beba9 100644 --- a/Sources/Web3Core/Transaction/Envelope/EIP1559Envelope.swift +++ b/Sources/Web3Core/Transaction/Envelope/EIP1559Envelope.swift @@ -45,7 +45,7 @@ public struct EIP1559Envelope: EIP2718Envelope, EIP2930Compatible { /// all exceed funds will be returned to the sender. /// /// If amount of this will be **lower** than sum of `Block.baseFeePerGas` and `maxPriorityFeePerGas` - /// miner will recieve amount calculated by the following equation: `maxFeePerGas - Block.baseFeePerGas` + /// miner will receive amount calculated by the following equation: `maxFeePerGas - Block.baseFeePerGas` /// where 'Block' is the block that the transaction will be included. public var maxFeePerGas: BigUInt? public var accessList: [AccessListEntry] // from EIP-2930 diff --git a/Sources/Web3Core/Transaction/Envelope/EnvelopeFactory.swift b/Sources/Web3Core/Transaction/Envelope/EnvelopeFactory.swift index 7fa3b0e9c..4e2f22749 100644 --- a/Sources/Web3Core/Transaction/Envelope/EnvelopeFactory.swift +++ b/Sources/Web3Core/Transaction/Envelope/EnvelopeFactory.swift @@ -74,7 +74,7 @@ public struct EnvelopeFactory { /// - v: signature v parameter (default 1) - will get set properly once signed /// - r: signature r parameter (default 0) - will get set properly once signed /// - s: signature s parameter (default 0) - will get set properly once signed - /// - options: TransactionParameters containing additional parametrs for the transaction like gas + /// - options: TransactionParameters containing additional parameters for the transaction like gas /// - Returns: a new envelope of type dictated by 'type' static func createEnvelope(type: TransactionType? = nil, to: EthereumAddress, nonce: BigUInt, chainID: BigUInt, value: BigUInt, data: Data, diff --git a/Sources/Web3Core/Transaction/Envelope/LegacyEnvelope.swift b/Sources/Web3Core/Transaction/Envelope/LegacyEnvelope.swift index 121ecb63b..a33df7c6e 100644 --- a/Sources/Web3Core/Transaction/Envelope/LegacyEnvelope.swift +++ b/Sources/Web3Core/Transaction/Envelope/LegacyEnvelope.swift @@ -35,7 +35,7 @@ public struct LegacyEnvelope: AbstractEnvelope { // legacy chainID Mechanism private var explicitChainID: BigUInt? // set directly or via options - // private var impliedChainID: BigUInt? // we calculate this once, or when explicitely asked to + // private var impliedChainID: BigUInt? // we calculate this once, or when explicitly asked to private var impliedChainID: BigUInt? { if r == 0 && s == 0 { return v } if v == 27 || v == 28 || v < 35 { return nil } @@ -54,7 +54,7 @@ public struct LegacyEnvelope: AbstractEnvelope { toReturn += "Data: " + self.data.toHexString().addHexPrefix().lowercased() + "\n" toReturn += "Resolved chainID: " + String(describing: self.chainID) + "\n" toReturn += "- Intrinsic chainID: " + String(describing: self.explicitChainID) + "\n" - toReturn += "- Infered chainID: " + String(describing: self.impliedChainID) + "\n" + toReturn += "- Inferred chainID: " + String(describing: self.impliedChainID) + "\n" toReturn += "v: " + String(self.v) + "\n" toReturn += "r: " + String(self.r) + "\n" toReturn += "s: " + String(self.s) + "\n" diff --git a/Sources/Web3Core/Transaction/EventfilterParameters.swift b/Sources/Web3Core/Transaction/EventfilterParameters.swift index bb959c9c3..7459f2dda 100755 --- a/Sources/Web3Core/Transaction/EventfilterParameters.swift +++ b/Sources/Web3Core/Transaction/EventfilterParameters.swift @@ -101,7 +101,7 @@ extension EventFilterParameters { var rawValue: String { switch self { case let .string(string): - // Assiciated value can contain only String or nil, both of them always encoded as a JSON could be represented as String again. + // Associated value can contain only String or nil, both of them always encoded as a JSON could be represented as String again. return String(data: try! JSONEncoder().encode(string), encoding: .utf8)! case let .strings(strings): return strings!.textRepresentation @@ -112,7 +112,7 @@ extension EventFilterParameters { extension EventFilterParameters: APIRequestParameterType { } -// - Why don't you develope some JSON composer to just send a server request, Yaroslav? +// - Why don't you develop some JSON composer to just send a server request, Yaroslav? // - Indeed, see no reason, why should i pass this. // Oh i wish to look deep in the Vitaliks eyes someday. extension Array where Element == EventFilterParameters.Topic? { diff --git a/Sources/Web3Core/Transaction/TransactionMetadata.swift b/Sources/Web3Core/Transaction/TransactionMetadata.swift index 28b6508d0..f70334290 100644 --- a/Sources/Web3Core/Transaction/TransactionMetadata.swift +++ b/Sources/Web3Core/Transaction/TransactionMetadata.swift @@ -44,7 +44,7 @@ public extension TransactionMetadata { } /// since metadata realistically can only come when a transaction is created from - /// JSON returned by a node, we only provide an intializer from JSON + /// JSON returned by a node, we only provide an initializer from JSON init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) diff --git a/Sources/Web3Core/Utility/Decodable+Extensions.swift b/Sources/Web3Core/Utility/Decodable+Extensions.swift index 0029df3cd..bd520b3fa 100644 --- a/Sources/Web3Core/Utility/Decodable+Extensions.swift +++ b/Sources/Web3Core/Utility/Decodable+Extensions.swift @@ -27,7 +27,7 @@ extension KeyedDecodingContainer { /// /// Currently this method supports only `Data.Type`, `BigUInt.Type`, `Date.Type`, `UInt.Type` /// - /// - Parameter type: Generic type `T` wich conforms to `DecodableFromHex` protocol + /// - Parameter type: Generic type `T` which conforms to `DecodableFromHex` protocol /// - Parameter key: The key that the decoded value is associated with. /// - Returns: A decoded value of type `T` /// - throws: `Web3Error.dataError` if value associated with key are unable to be initialized as `DecodableFromHex`. @@ -41,7 +41,7 @@ extension KeyedDecodingContainer { /// /// Currently this method supports only `Data.Type`, `BigUInt.Type`, `Date.Type`, `UInt.Type` /// - /// - Parameter type: Array of a generic type `T` wich conforms to `DecodableFromHex` protocol + /// - Parameter type: Array of a generic type `T` which conforms to `DecodableFromHex` protocol /// - Parameter key: The key that the decoded value is associated with. /// - Returns: A decoded value of type `[T]` /// - throws: `Web3Error.dataError` if value associated with key are unable to be initialized as `[[DecodableFromHex]]`. @@ -55,7 +55,7 @@ extension KeyedDecodingContainer { /// /// Currently this method supports only `Data.Type`, `BigUInt.Type`, `Date.Type`, `EthereumAddress`, `UInt.Type` /// - /// - Parameter type: Array of a generic type `T` wich conforms to `DecodableFromHex` protocol + /// - Parameter type: Array of a generic type `T` which conforms to `DecodableFromHex` protocol /// - Parameter key: The key that the decoded value is associated with. /// - Returns: A decoded value of type `[[T]]` /// - throws: `Web3Error.dataError` if value associated with key are unable to be initialized as `[[DecodableFromHex]]`. @@ -69,7 +69,7 @@ extension KeyedDecodingContainer { /// /// Currently this method supports only `Data.Type`, `BigUInt.Type`, `Date.Type`, `UInt.Type` /// - /// - Parameter type: Generic type `T` wich conforms to `DecodableFromHex` protocol + /// - Parameter type: Generic type `T` which conforms to `DecodableFromHex` protocol /// - Parameter key: The key that the decoded value is associated with. /// - Returns: A decoded value of type `T`, or nil if key is not present /// - throws: `Web3Error.dataError` if value associated with key are unable to be initialized as `DecodableFromHex`. @@ -84,7 +84,7 @@ extension UnkeyedDecodingContainer { /// /// Currently this method supports only `Data.Type`, `BigUInt.Type`, `Date.Type`, `EthereumAddress` /// - /// - Parameter type: Generic type `T` wich conforms to `DecodableFromHex` protocol + /// - Parameter type: Generic type `T` which conforms to `DecodableFromHex` protocol /// - Parameter key: The key that the decoded value is associated with. /// - Returns: A decoded value of type `BigUInt` /// - throws: `Web3Error.dataError` if value associated with key are unable to be initialized as `[DecodableFromHex]`. @@ -102,7 +102,7 @@ extension UnkeyedDecodingContainer { /// /// Currently this method supports only `Data.Type`, `BigUInt.Type`, `Date.Type`, `EthereumAddress` /// - /// - Parameter type: Generic type `T` wich conforms to `DecodableFromHex` protocol + /// - Parameter type: Generic type `T` which conforms to `DecodableFromHex` protocol /// - Parameter key: The key that the decoded value is associated with. /// - Returns: A decoded value of type `BigUInt` /// - throws: `Web3Error.dataError` if value associated with key are unable to be initialized as `[[DecodableFromHex]]`. diff --git a/Sources/Web3Core/Utility/String+Extension.swift b/Sources/Web3Core/Utility/String+Extension.swift index cf7537663..f63e077da 100755 --- a/Sources/Web3Core/Utility/String+Extension.swift +++ b/Sources/Web3Core/Utility/String+Extension.swift @@ -86,7 +86,7 @@ extension String { /// Strips leading zeroes from a HEX string. /// ONLY HEX string format is supported. - /// - Returns: string with stripped leading zeroes (and 0x prefix) or unchaged string. + /// - Returns: string with stripped leading zeroes (and 0x prefix) or unchanged string. func stripLeadingZeroes() -> String { let hex = addHexPrefix() guard let matcher = try? NSRegularExpression(pattern: "^(?0x)(?0+)(?[0-9a-fA-F]*)$", diff --git a/Sources/Web3Core/Utility/Utilities.swift b/Sources/Web3Core/Utility/Utilities.swift index 7b0557f6a..5a71cdd04 100644 --- a/Sources/Web3Core/Utility/Utilities.swift +++ b/Sources/Web3Core/Utility/Utilities.swift @@ -19,17 +19,17 @@ public struct Utilities { guard let decompressedKey = SECP256K1.combineSerializedPublicKeys(keys: [publicKey], outputCompressed: false) else {return nil} return publicToAddressData(decompressedKey) } - var stipped = publicKey - if stipped.count == 65 { - if stipped[0] != 4 { + var stripped = publicKey + if stripped.count == 65 { + if stripped[0] != 4 { return nil } - stipped = stipped[1...64] + stripped = stripped[1...64] } - if stipped.count != 64 { + if stripped.count != 64 { return nil } - let sha3 = stipped.sha3(.keccak256) + let sha3 = stripped.sha3(.keccak256) let addressData = sha3[12...31] return addressData } diff --git a/Sources/secp256k1/ecmult_impl.h b/Sources/secp256k1/ecmult_impl.h index feab1b741..61a5ffd23 100755 --- a/Sources/secp256k1/ecmult_impl.h +++ b/Sources/secp256k1/ecmult_impl.h @@ -339,7 +339,7 @@ static void secp256k1_ecmult_strauss_wnaf(const secp256k1_ecmult_context *ctx, c secp256k1_ge tmpa; secp256k1_fe Z; #ifdef USE_ENDOMORPHISM - /* Splitted G factors. */ + /* Split G factors. */ secp256k1_scalar ng_1, ng_128; int wnaf_ng_1[129]; int bits_ng_1 = 0; diff --git a/Sources/secp256k1/include/secp256k1.h b/Sources/secp256k1/include/secp256k1.h index ea2bc0155..c1fc13fac 100755 --- a/Sources/secp256k1/include/secp256k1.h +++ b/Sources/secp256k1/include/secp256k1.h @@ -399,7 +399,7 @@ SECP256K1_API int secp256k1_ecdsa_signature_serialize_compact( /** Verify an ECDSA signature. * * Returns: 1: correct signature - * 0: incorrect or unparseable signature + * 0: incorrect or unparsable signature * Args: ctx: a secp256k1 context object, initialized for verification. * In: sig: the signature being verified (cannot be NULL) * msg32: the 32-byte message hash being verified (cannot be NULL) diff --git a/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift b/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift index e0d861fe7..806a038ee 100644 --- a/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift +++ b/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift @@ -7,7 +7,7 @@ import Foundation -/// Declares common properties of an [ERC-20](https://eips.ethereum.org/EIPS/eip-20) complient smart contract. +/// Declares common properties of an [ERC-20](https://eips.ethereum.org/EIPS/eip-20) compliant smart contract. /// Default implementation of access to these properties is declared in the extension of this protocol. public protocol ERC20BaseProperties: AnyObject { var basePropertiesProvider: ERC20BasePropertiesProvider { get } diff --git a/Sources/web3swift/Utils/EIP/EIP712.swift b/Sources/web3swift/Utils/EIP/EIP712.swift index 4cb913ffd..1bb65436f 100644 --- a/Sources/web3swift/Utils/EIP/EIP712.swift +++ b/Sources/web3swift/Utils/EIP/EIP712.swift @@ -100,7 +100,7 @@ fileprivate extension EIP712Hashable { } func encodePrimaryType() -> String { - let parametrs: [String] = Mirror(reflecting: self).children.compactMap { key, value in + let parameters: [String] = Mirror(reflecting: self).children.compactMap { key, value in guard let key = key else { return nil } func checkIfValueIsNil(value: Any) -> Bool { @@ -127,7 +127,7 @@ fileprivate extension EIP712Hashable { } return typeName + " " + key } - return name + "(" + parametrs.joined(separator: ",") + ")" + return name + "(" + parameters.joined(separator: ",") + ")" } } diff --git a/Sources/web3swift/Utils/ENS/NameHash.swift b/Sources/web3swift/Utils/ENS/NameHash.swift index 723da72c4..c6e58412e 100755 --- a/Sources/web3swift/Utils/ENS/NameHash.swift +++ b/Sources/web3swift/Utils/ENS/NameHash.swift @@ -8,7 +8,7 @@ import CryptoSwift public struct NameHash { public static func normalizeDomainName(_ domain: String) -> String? { - // TODO use ICU4C library later for domain name normalization, althoug f**k it for now, it's few megabytes large piece + // TODO use ICU4C library later for domain name normalization, although f**k it for now, it's few megabytes large piece let normalized = domain.lowercased() return normalized } diff --git a/Sources/web3swift/Web3/Web3+Contract.swift b/Sources/web3swift/Web3/Web3+Contract.swift index ebb9bc41a..76285887c 100755 --- a/Sources/web3swift/Web3/Web3+Contract.swift +++ b/Sources/web3swift/Web3/Web3+Contract.swift @@ -78,7 +78,7 @@ extension Web3 { // FIXME: Actually this is not rading contract or smth, this is about composing appropriate binary data to iterate with it later. // FIXME: Rewrite this to CodableTransaction /// Creates and object responsible for calling a particular function of the contract. If method name is not found in ABI - returns nil. - /// If extraData is supplied it is appended to encoded function parameters. Can be usefull if one wants to call + /// If extraData is supplied it is appended to encoded function parameters. Can be useful if one wants to call /// the function not listed in ABI. "Parameters" should be an array corresponding to the list of parameters of the function. /// Elements of "parameters" can be other arrays or instances of String, Data, BigInt, BigUInt, Int or EthereumAddress. /// @@ -99,7 +99,7 @@ extension Web3 { // FIXME: Rewrite this to CodableTransaction /// Creates and object responsible for calling a particular function of the contract. If method name is not found in ABI - returns nil. - /// If extraData is supplied it is appended to encoded function parameters. Can be usefull if one wants to call + /// If extraData is supplied it is appended to encoded function parameters. Can be useful if one wants to call /// the function not listed in ABI. "Parameters" should be an array corresponding to the list of parameters of the function. /// Elements of "parameters" can be other arrays or instances of String, Data, BigInt, BigUInt, Int or EthereumAddress. /// diff --git a/Sources/web3swift/Web3/Web3+Personal.swift b/Sources/web3swift/Web3/Web3+Personal.swift index 3949fcd7f..f83d328b8 100755 --- a/Sources/web3swift/Web3/Web3+Personal.swift +++ b/Sources/web3swift/Web3/Web3+Personal.swift @@ -34,7 +34,7 @@ extension Web3.Personal { - parameters: - account: EthereumAddress of the account to unlock - password: Password to use for the account - - seconds: Time inteval before automatic account lock by Ethereum node + - seconds: Time interval before automatic account lock by Ethereum node - returns: - Result object diff --git a/Sources/web3swift/Web3/Web3.swift b/Sources/web3swift/Web3/Web3.swift index 29c881130..e8b1a72df 100755 --- a/Sources/web3swift/Web3/Web3.swift +++ b/Sources/web3swift/Web3/Web3.swift @@ -6,14 +6,14 @@ import Foundation import Web3Core -/// An arbitary Web3 object. Is used only to construct provider bound fully functional object by either supplying provider URL +/// An arbitrary Web3 object. Is used only to construct provider bound fully functional object by either supplying provider URL /// or using pre-coded Infura nodes extension Web3 { /// Initialized provider-bound Web3 instance using a provider's URL. Under the hood it performs a synchronous call to get /// the Network ID for EIP155 purposes public static func new(_ providerURL: URL, network: Networks = .Mainnet) async throws -> Web3 { - // FIXME: Change this hardcoded value to dynamicly fethed from a Node + // FIXME: Change this hardcoded value to dynamically fethed from a Node guard let provider = await Web3HttpProvider(providerURL, network: network) else { throw Web3Error.inputError(desc: "Wrong provider - should be Web3HttpProvider with endpoint scheme http or https") } diff --git a/Tests/web3swiftTests/localTests/ABIEncoderTest.swift b/Tests/web3swiftTests/localTests/ABIEncoderTest.swift index 4b50fdecd..3f69fb2db 100644 --- a/Tests/web3swiftTests/localTests/ABIEncoderTest.swift +++ b/Tests/web3swiftTests/localTests/ABIEncoderTest.swift @@ -30,7 +30,7 @@ class ABIEncoderTest: XCTestCase { hex = try ABIEncoder.soliditySha3("Hello!%").toHexString().addHexPrefix() assert(hex == "0x661136a4267dba9ccdf6bfddb7c00e714de936674c4bdb065a531cf1cb15c7fc") - // This is not JS. '234' (with single or double qoutes) will be a String, not any kind of number. + // This is not JS. '234' (with single or double quotes) will be a String, not any kind of number. // From Web3JS docs:> web3.utils.soliditySha3('234'); // auto detects: uint256 hex = try ABIEncoder.soliditySha3(0xea).toHexString().addHexPrefix() diff --git a/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift b/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift index e71641ee3..632c4c755 100755 --- a/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift +++ b/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift @@ -2,7 +2,7 @@ // Created by Alex Vlasov. // Copyright © 2018 Alex Vlasov. All rights reserved. // -// TODO: Replace `XCTAssert` with more explicite `XCTAssertEqual`, where Applicable +// TODO: Replace `XCTAssert` with more explicit `XCTAssertEqual`, where Applicable import XCTest import CryptoSwift import BigInt diff --git a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift index e41c55e3f..26f567017 100644 --- a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift +++ b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift @@ -57,8 +57,8 @@ class EIP1559BlockTests: LocalTestCase { (40_000_000, 12_965_000, 39_960_938, false) // Lower limit -1 ] - headerArray.forEach { (touple: (parentGasLimit: BigUInt, parentNumber: BigUInt, currentGasLimit: BigUInt, is1559: Bool)) in - let parent = Block(number: touple.parentNumber, + headerArray.forEach { (tuple: (parentGasLimit: BigUInt, parentNumber: BigUInt, currentGasLimit: BigUInt, is1559: Bool)) in + let parent = Block(number: tuple.parentNumber, hash: uselessBlockPart.hash, parentHash: uselessBlockPart.parentHash, nonce: uselessBlockPart.nonce, @@ -72,14 +72,14 @@ class EIP1559BlockTests: LocalTestCase { totalDifficulty: uselessBlockPart.totalDifficulty, extraData: uselessBlockPart.extraData, size: uselessBlockPart.size, - gasLimit: touple.parentGasLimit, - gasUsed: touple.parentGasLimit / 2, + gasLimit: tuple.parentGasLimit, + gasUsed: tuple.parentGasLimit / 2, baseFeePerGas: Web3.InitialBaseFee, timestamp: uselessBlockPart.timestamp, transactions: uselessBlockPart.transactions, uncles: uselessBlockPart.uncles) - let current = Block(number: touple.parentNumber + 1, + let current = Block(number: tuple.parentNumber + 1, hash: uselessBlockPart.hash, parentHash: uselessBlockPart.parentHash, nonce: uselessBlockPart.nonce, @@ -93,16 +93,16 @@ class EIP1559BlockTests: LocalTestCase { totalDifficulty: uselessBlockPart.totalDifficulty, extraData: uselessBlockPart.extraData, size: uselessBlockPart.size, - gasLimit: touple.currentGasLimit, - gasUsed: touple.currentGasLimit / 2, + gasLimit: tuple.currentGasLimit, + gasUsed: tuple.currentGasLimit / 2, baseFeePerGas: Web3.InitialBaseFee, timestamp: uselessBlockPart.timestamp, transactions: uselessBlockPart.transactions, uncles: uselessBlockPart.uncles) - if touple.is1559 { + if tuple.is1559 { XCTAssertTrue(Web3.isEip1559Block(parent: parent, current: current), - "Shoult not fail, got parent: \(parent.gasLimit), current: \(current.gasLimit)") + "Should not fail, got parent: \(parent.gasLimit), current: \(current.gasLimit)") } else { XCTAssertFalse(Web3.isEip1559Block(parent: parent, current: current), "Should fail, got parent: \(parent.gasLimit), current: \(current.gasLimit)") @@ -124,8 +124,8 @@ class EIP1559BlockTests: LocalTestCase { (Web3.InitialBaseFee, 12_965_000, 20000000, 11000000, 1012500000) // current above target ] - headerArray.forEach { (touple: (parentBaseFee: BigUInt, parentNumber: BigUInt, parentGasLimit: BigUInt, parentGasUsed: BigUInt, expectedBaseFee: BigUInt)) in - let parent = Block(number: touple.parentNumber, + headerArray.forEach { (tuple: (parentBaseFee: BigUInt, parentNumber: BigUInt, parentGasLimit: BigUInt, parentGasUsed: BigUInt, expectedBaseFee: BigUInt)) in + let parent = Block(number: tuple.parentNumber, hash: uselessBlockPart.hash, parentHash: uselessBlockPart.parentHash, nonce: uselessBlockPart.nonce, @@ -139,8 +139,8 @@ class EIP1559BlockTests: LocalTestCase { totalDifficulty: uselessBlockPart.totalDifficulty, extraData: uselessBlockPart.extraData, size: uselessBlockPart.size, - gasLimit: touple.parentGasLimit, - gasUsed: touple.parentGasUsed, + gasLimit: tuple.parentGasLimit, + gasUsed: tuple.parentGasUsed, baseFeePerGas: Web3.InitialBaseFee, timestamp: uselessBlockPart.timestamp, transactions: uselessBlockPart.transactions, @@ -148,7 +148,7 @@ class EIP1559BlockTests: LocalTestCase { let calculatedBaseFee = Web3.calcBaseFee(parent) - XCTAssertEqual(calculatedBaseFee, touple.expectedBaseFee, "Base fee calculation fails: should be \(touple.expectedBaseFee), got: \(String(describing: calculatedBaseFee))") + XCTAssertEqual(calculatedBaseFee, tuple.expectedBaseFee, "Base fee calculation fails: should be \(tuple.expectedBaseFee), got: \(String(describing: calculatedBaseFee))") } } } diff --git a/Tests/web3swiftTests/localTests/ERC20ClassTests.swift b/Tests/web3swiftTests/localTests/ERC20ClassTests.swift index c9ba5b75e..9c95addca 100755 --- a/Tests/web3swiftTests/localTests/ERC20ClassTests.swift +++ b/Tests/web3swiftTests/localTests/ERC20ClassTests.swift @@ -22,7 +22,7 @@ class ERC20ClassTests: LocalTestCase { } /// We had an issue with multiple async reads performed at the same point in time /// sometimes returning wrong values (actually values of each other). - /// The issue is most likely related to async/await feautre of Swift. + /// The issue is most likely related to async/await feature of Swift. /// Due to that was decided to add a loop to execute the same async calls that checks the same ERC20 properties /// multiple times. All calls must succeed. /// Each run executes 3 async read operations. diff --git a/Tests/web3swiftTests/localTests/TransactionsTests.swift b/Tests/web3swiftTests/localTests/TransactionsTests.swift index 02a560b2f..7dd9a8e65 100755 --- a/Tests/web3swiftTests/localTests/TransactionsTests.swift +++ b/Tests/web3swiftTests/localTests/TransactionsTests.swift @@ -594,7 +594,7 @@ class TransactionsTests: XCTestCase { } // ***** Legacy Tests ***** - // TODO: Replace `XCTAssert` with more explicite `XCTAssertEqual`, where Applicable + // TODO: Replace `XCTAssert` with more explicit `XCTAssertEqual`, where Applicable func testDirectTransaction() throws { do { @@ -657,7 +657,7 @@ class TransactionsTests: XCTestCase { let details = try await web3.eth.transactionDetails(txHash) - // FIXME: Reenable this test. + // FIXME: Re-enable this test. // XCTAssertEqual(details.transaction.gasLimit, BigUInt(78423)) } catch Web3Error.nodeError(let descr) { guard descr == "insufficient funds for gas * price + value" else {return XCTFail()} diff --git a/Tests/web3swiftTests/remoteTests/InfuraTests.swift b/Tests/web3swiftTests/remoteTests/InfuraTests.swift index 88d630f45..c53020293 100755 --- a/Tests/web3swiftTests/remoteTests/InfuraTests.swift +++ b/Tests/web3swiftTests/remoteTests/InfuraTests.swift @@ -94,7 +94,7 @@ class InfuraTests: XCTestCase { // let web3 = Web3.InfuraRinkebyWeb3(accessToken: Constants.infuraToken) // let contract = web3.contract(jsonString, at: contractAddress, abiVersion: 2) // guard let eventParser = contract?.createEventParser("Deposit", filter: nil) else {return XCTFail()} -// let pres = try eventParser.parseBlockByNumber(UInt64(2138657)) -// XCTAssert(pres.count == 1) +// let present = try eventParser.parseBlockByNumber(UInt64(2138657)) +// XCTAssert(present.count == 1) // } } diff --git a/Tests/web3swiftTests/remoteTests/RemoteParsingTests.swift b/Tests/web3swiftTests/remoteTests/RemoteParsingTests.swift index e42e2b2e0..b4b272b20 100755 --- a/Tests/web3swiftTests/remoteTests/RemoteParsingTests.swift +++ b/Tests/web3swiftTests/remoteTests/RemoteParsingTests.swift @@ -25,18 +25,18 @@ class RemoteParsingTests: XCTestCase { // // guard let eventParser = contract?.createEventParser("Transfer", filter: nil) else {return XCTFail()} // -// let pres = try eventParser.parseBlockByNumber(UInt64(5200088)) +// let present = try eventParser.parseBlockByNumber(UInt64(5200088)) // -// XCTAssert(pres.count == 1) +// XCTAssert(present.count == 1) // -// let decoded = pres[0].decodedResult +// let decoded = present[0].decodedResult // // XCTAssert(decoded["name"] as! String == "Transfer") // XCTAssert(decoded["_to"] as! EthereumAddress == EthereumAddress("0xa5dcf6e0fee38f635c4a8d50d90e24400ed547d2")!) // XCTAssert(decoded["_from"] as! EthereumAddress == EthereumAddress("0xdbf493e8d7db835192c02b992bd1ab72e96fd2e3")!) // XCTAssert(decoded["_value"] as! BigUInt == BigUInt("3946fe37ffce3a0000", radix: 16)!) -// XCTAssert(pres[0].contractAddress == EthereumAddress("0x45245bc59219eeaaf6cd3f382e078a461ff9de7b")!) -// XCTAssert(pres[0].transactionReceipt!.transactionHash.toHexString().addHexPrefix() == "0xcb235e8c6ecda032bc82c1084d2159ab82e7e4de35be703da6e80034bc577673") +// XCTAssert(present[0].contractAddress == EthereumAddress("0x45245bc59219eeaaf6cd3f382e078a461ff9de7b")!) +// XCTAssert(present[0].transactionReceipt!.transactionHash.toHexString().addHexPrefix() == "0xcb235e8c6ecda032bc82c1084d2159ab82e7e4de35be703da6e80034bc577673") // } // func testEventParsing2usingABIv2() throws { @@ -44,8 +44,8 @@ class RemoteParsingTests: XCTestCase { // let web3 = Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) // let contract = web3.contract(jsonString, at: nil, abiVersion: 2) // guard let eventParser = contract?.createEventParser("Transfer", filter: nil) else {return XCTFail()} -// let pres = try eventParser.parseBlockByNumber(UInt64(5200120)) -// XCTAssert(pres.count == 81) +// let present = try eventParser.parseBlockByNumber(UInt64(5200120)) +// XCTAssert(present.count == 81) // } // func testEventParsing3usingABIv2() throws { @@ -62,8 +62,8 @@ class RemoteParsingTests: XCTestCase { // } // // for i in currentBlockAsInt-1 ... currentBlockAsInt { -// let pres = try eventParser.parseBlockByNumber(i) -// for p in pres { +// let present = try eventParser.parseBlockByNumber(i) +// for p in present { // + "\n") // // .addHexPrefix() + "\n") @@ -82,8 +82,8 @@ class RemoteParsingTests: XCTestCase { // filter.addresses = [EthereumAddress("0x53066cddbc0099eb6c96785d9b3df2aaeede5da3")!] // filter.parameterFilters = [([EthereumAddress("0xefdcf2c36f3756ce7247628afdb632fa4ee12ec5")!] as [EventFilterable]), ([EthereumAddress("0xd5395c132c791a7f46fa8fc27f0ab6bacd824484")!] as [EventFilterable])] // guard let eventParser = contract?.createEventParser("Transfer", filter: filter) else {return XCTFail()} -// let pres = try eventParser.parseBlockByNumber(UInt64(5200120)) -// XCTAssert(pres.count == 1) +// let present = try eventParser.parseBlockByNumber(UInt64(5200120)) +// XCTAssert(present.count == 1) // //TODO: - Make following assert //// with filter would be //// [web3swift_iOS.EventLog(address: web3swift_iOS.EthereumAddress(_address: "0x53066cddbc0099eb6c96785d9b3df2aaeede5da3", type: web3swift_iOS.EthereumAddress.AddressType.normal), data: 32 bytes, logIndex: 132, removed: false, topics: [32 bytes, 32 bytes, 32 bytes])], status: web3swift_iOS.TransactionReceipt.TXStatus.ok, logsBloom: Optional(web3swift_iOS.EthereumBloomFilter(bytes: 256 bytes))), contractAddress: web3swift_iOS.EthereumAddress(_address: "0x53066cddbc0099eb6c96785d9b3df2aaeede5da3", type: web3swift_iOS.EthereumAddress.AddressType.normal), decodedResult: ["name": "Transfer", "1": web3swift_iOS.EthereumAddress(_address: "0xd5395c132c791a7f46fa8fc27f0ab6bacd824484", type: web3swift_iOS.EthereumAddress.AddressType.normal), "_from": web3swift_iOS.EthereumAddress(_address: "0xefdcf2c36f3756ce7247628afdb632fa4ee12ec5", type: web3swift_iOS.EthereumAddress.AddressType.normal), "_to": web3swift_iOS.EthereumAddress(_address: "0xd5395c132c791a7f46fa8fc27f0ab6bacd824484", type: web3swift_iOS.EthereumAddress.AddressType.normal), "2": 5000000000000000000, "0": web3swift_iOS.EthereumAddress(_address: "0xefdcf2c36f3756ce7247628afdb632fa4ee12ec5", type: web3swift_iOS.EthereumAddress.AddressType.normal), "_value": 5000000000000000000])] From fb796ea8d60849a242743f0a882581f335a2607b Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 31 Jan 2023 15:15:54 +0100 Subject: [PATCH 026/210] Make typos in code --- Sources/Web3Core/KeystoreManager/IBAN.swift | 4 +-- Sources/Web3Core/Utility/Utilities.swift | 12 ++++---- Sources/web3swift/Utils/EIP/EIP712.swift | 4 +-- .../localTests/EIP1559BlockTests.swift | 28 +++++++++---------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/IBAN.swift b/Sources/Web3Core/KeystoreManager/IBAN.swift index 164ff319f..604f7dce7 100755 --- a/Sources/Web3Core/KeystoreManager/IBAN.swift +++ b/Sources/Web3Core/KeystoreManager/IBAN.swift @@ -64,9 +64,9 @@ public struct IBAN { internal static func decodeToInts(_ iban: String) -> String { let uppercasedIBAN = iban.replacingOccurrences(of: " ", with: "").uppercased() - let beginning = String(uppercasedIBAN[0..<4]) + let begining = String(uppercasedIBAN[0..<4]) let end = String(uppercasedIBAN[4...]) - let IBAN = end + beginning + let IBAN = end + begining var arrayOfInts = [Int]() for ch in IBAN { guard let dataPoint = String(ch).data(using: .ascii) else {return ""} diff --git a/Sources/Web3Core/Utility/Utilities.swift b/Sources/Web3Core/Utility/Utilities.swift index 5a71cdd04..7b0557f6a 100644 --- a/Sources/Web3Core/Utility/Utilities.swift +++ b/Sources/Web3Core/Utility/Utilities.swift @@ -19,17 +19,17 @@ public struct Utilities { guard let decompressedKey = SECP256K1.combineSerializedPublicKeys(keys: [publicKey], outputCompressed: false) else {return nil} return publicToAddressData(decompressedKey) } - var stripped = publicKey - if stripped.count == 65 { - if stripped[0] != 4 { + var stipped = publicKey + if stipped.count == 65 { + if stipped[0] != 4 { return nil } - stripped = stripped[1...64] + stipped = stipped[1...64] } - if stripped.count != 64 { + if stipped.count != 64 { return nil } - let sha3 = stripped.sha3(.keccak256) + let sha3 = stipped.sha3(.keccak256) let addressData = sha3[12...31] return addressData } diff --git a/Sources/web3swift/Utils/EIP/EIP712.swift b/Sources/web3swift/Utils/EIP/EIP712.swift index 1bb65436f..4cb913ffd 100644 --- a/Sources/web3swift/Utils/EIP/EIP712.swift +++ b/Sources/web3swift/Utils/EIP/EIP712.swift @@ -100,7 +100,7 @@ fileprivate extension EIP712Hashable { } func encodePrimaryType() -> String { - let parameters: [String] = Mirror(reflecting: self).children.compactMap { key, value in + let parametrs: [String] = Mirror(reflecting: self).children.compactMap { key, value in guard let key = key else { return nil } func checkIfValueIsNil(value: Any) -> Bool { @@ -127,7 +127,7 @@ fileprivate extension EIP712Hashable { } return typeName + " " + key } - return name + "(" + parameters.joined(separator: ",") + ")" + return name + "(" + parametrs.joined(separator: ",") + ")" } } diff --git a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift index 26f567017..e41c55e3f 100644 --- a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift +++ b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift @@ -57,8 +57,8 @@ class EIP1559BlockTests: LocalTestCase { (40_000_000, 12_965_000, 39_960_938, false) // Lower limit -1 ] - headerArray.forEach { (tuple: (parentGasLimit: BigUInt, parentNumber: BigUInt, currentGasLimit: BigUInt, is1559: Bool)) in - let parent = Block(number: tuple.parentNumber, + headerArray.forEach { (touple: (parentGasLimit: BigUInt, parentNumber: BigUInt, currentGasLimit: BigUInt, is1559: Bool)) in + let parent = Block(number: touple.parentNumber, hash: uselessBlockPart.hash, parentHash: uselessBlockPart.parentHash, nonce: uselessBlockPart.nonce, @@ -72,14 +72,14 @@ class EIP1559BlockTests: LocalTestCase { totalDifficulty: uselessBlockPart.totalDifficulty, extraData: uselessBlockPart.extraData, size: uselessBlockPart.size, - gasLimit: tuple.parentGasLimit, - gasUsed: tuple.parentGasLimit / 2, + gasLimit: touple.parentGasLimit, + gasUsed: touple.parentGasLimit / 2, baseFeePerGas: Web3.InitialBaseFee, timestamp: uselessBlockPart.timestamp, transactions: uselessBlockPart.transactions, uncles: uselessBlockPart.uncles) - let current = Block(number: tuple.parentNumber + 1, + let current = Block(number: touple.parentNumber + 1, hash: uselessBlockPart.hash, parentHash: uselessBlockPart.parentHash, nonce: uselessBlockPart.nonce, @@ -93,16 +93,16 @@ class EIP1559BlockTests: LocalTestCase { totalDifficulty: uselessBlockPart.totalDifficulty, extraData: uselessBlockPart.extraData, size: uselessBlockPart.size, - gasLimit: tuple.currentGasLimit, - gasUsed: tuple.currentGasLimit / 2, + gasLimit: touple.currentGasLimit, + gasUsed: touple.currentGasLimit / 2, baseFeePerGas: Web3.InitialBaseFee, timestamp: uselessBlockPart.timestamp, transactions: uselessBlockPart.transactions, uncles: uselessBlockPart.uncles) - if tuple.is1559 { + if touple.is1559 { XCTAssertTrue(Web3.isEip1559Block(parent: parent, current: current), - "Should not fail, got parent: \(parent.gasLimit), current: \(current.gasLimit)") + "Shoult not fail, got parent: \(parent.gasLimit), current: \(current.gasLimit)") } else { XCTAssertFalse(Web3.isEip1559Block(parent: parent, current: current), "Should fail, got parent: \(parent.gasLimit), current: \(current.gasLimit)") @@ -124,8 +124,8 @@ class EIP1559BlockTests: LocalTestCase { (Web3.InitialBaseFee, 12_965_000, 20000000, 11000000, 1012500000) // current above target ] - headerArray.forEach { (tuple: (parentBaseFee: BigUInt, parentNumber: BigUInt, parentGasLimit: BigUInt, parentGasUsed: BigUInt, expectedBaseFee: BigUInt)) in - let parent = Block(number: tuple.parentNumber, + headerArray.forEach { (touple: (parentBaseFee: BigUInt, parentNumber: BigUInt, parentGasLimit: BigUInt, parentGasUsed: BigUInt, expectedBaseFee: BigUInt)) in + let parent = Block(number: touple.parentNumber, hash: uselessBlockPart.hash, parentHash: uselessBlockPart.parentHash, nonce: uselessBlockPart.nonce, @@ -139,8 +139,8 @@ class EIP1559BlockTests: LocalTestCase { totalDifficulty: uselessBlockPart.totalDifficulty, extraData: uselessBlockPart.extraData, size: uselessBlockPart.size, - gasLimit: tuple.parentGasLimit, - gasUsed: tuple.parentGasUsed, + gasLimit: touple.parentGasLimit, + gasUsed: touple.parentGasUsed, baseFeePerGas: Web3.InitialBaseFee, timestamp: uselessBlockPart.timestamp, transactions: uselessBlockPart.transactions, @@ -148,7 +148,7 @@ class EIP1559BlockTests: LocalTestCase { let calculatedBaseFee = Web3.calcBaseFee(parent) - XCTAssertEqual(calculatedBaseFee, tuple.expectedBaseFee, "Base fee calculation fails: should be \(tuple.expectedBaseFee), got: \(String(describing: calculatedBaseFee))") + XCTAssertEqual(calculatedBaseFee, touple.expectedBaseFee, "Base fee calculation fails: should be \(touple.expectedBaseFee), got: \(String(describing: calculatedBaseFee))") } } } From 04b3cfef90db278e1c4f9dcc515b93842902f9bf Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 31 Jan 2023 15:35:08 +0100 Subject: [PATCH 027/210] Let's spell stripped correctly --- Sources/Web3Core/Utility/Utilities.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/Web3Core/Utility/Utilities.swift b/Sources/Web3Core/Utility/Utilities.swift index 7b0557f6a..5a71cdd04 100644 --- a/Sources/Web3Core/Utility/Utilities.swift +++ b/Sources/Web3Core/Utility/Utilities.swift @@ -19,17 +19,17 @@ public struct Utilities { guard let decompressedKey = SECP256K1.combineSerializedPublicKeys(keys: [publicKey], outputCompressed: false) else {return nil} return publicToAddressData(decompressedKey) } - var stipped = publicKey - if stipped.count == 65 { - if stipped[0] != 4 { + var stripped = publicKey + if stripped.count == 65 { + if stripped[0] != 4 { return nil } - stipped = stipped[1...64] + stripped = stripped[1...64] } - if stipped.count != 64 { + if stripped.count != 64 { return nil } - let sha3 = stipped.sha3(.keccak256) + let sha3 = stripped.sha3(.keccak256) let addressData = sha3[12...31] return addressData } From 987fa5e1c71b0a10d92662ff522654dc5a87c633 Mon Sep 17 00:00:00 2001 From: august Date: Wed, 1 Feb 2023 15:11:24 +0800 Subject: [PATCH 028/210] remove module_name from Web3Core.podspec --- Web3Core.podspec | 1 - 1 file changed, 1 deletion(-) diff --git a/Web3Core.podspec b/Web3Core.podspec index 80873eece..20828cdf8 100644 --- a/Web3Core.podspec +++ b/Web3Core.podspec @@ -3,7 +3,6 @@ Pod::Spec.new do |spec| spec.name = 'Web3Core' spec.version = '3.0.6' - spec.module_name = 'Core' spec.ios.deployment_target = "13.0" spec.osx.deployment_target = "10.15" spec.license = { :type => 'Apache License 2.0', :file => 'LICENSE.md' } From be3f55a1cc1a88531cc620378d130bbb3031a49a Mon Sep 17 00:00:00 2001 From: august Date: Wed, 1 Feb 2023 15:24:20 +0800 Subject: [PATCH 029/210] update Web3Core.spec source file path --- Web3Core.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Web3Core.podspec b/Web3Core.podspec index 20828cdf8..d0ded29c5 100644 --- a/Web3Core.podspec +++ b/Web3Core.podspec @@ -15,5 +15,5 @@ Pod::Spec.new do |spec| spec.dependency 'secp256k1.c', '~> 0.1' spec.dependency 'BigInt', '~> 5.2.0' # no newer version in pods. spec.dependency 'CryptoSwift', '~> 1.5.1' - spec.source_files = "Sources/Core/**/*.swift" + spec.source_files = "Sources/Web3Core/**/*.swift" end From 58b2e4fc9c982e14f852e85ae510247a96a08f44 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Wed, 1 Feb 2023 18:08:53 +0200 Subject: [PATCH 030/210] feat: convertToData handles Bool --- Sources/Web3Core/EthereumABI/ABIEncoding.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/Web3Core/EthereumABI/ABIEncoding.swift b/Sources/Web3Core/EthereumABI/ABIEncoding.swift index f62177ec8..727196a10 100755 --- a/Sources/Web3Core/EthereumABI/ABIEncoding.swift +++ b/Sources/Web3Core/EthereumABI/ABIEncoding.swift @@ -98,7 +98,7 @@ public struct ABIEncoder { /// Attempts to convert given object into `Data`. /// Used as a part of ABI encoding process. - /// Supported types are `Data`, `String`, `[UInt8]`, ``EthereumAddress`` and `[IntegerLiteralType]`. + /// Supported types are `Data`, `String`, `[UInt8]`, ``EthereumAddress``, `[IntegerLiteralType]` and `Bool`. /// Note: if `String` has `0x` prefix an attempt to interpret it as a hexadecimal number will take place. Otherwise, UTF-8 bytes are returned. /// - Parameter value: any object. /// - Returns: `Data` representation of an object ready for ABI encoding. @@ -123,6 +123,8 @@ public struct ABIEncoder { bytesArray.append(UInt8(el)) } return Data(bytesArray) + case let b as Bool: + return b ? Data([UInt8(1)]) : Data(count: 1) default: return nil } From 5edb12d24106f53fdcddcace3aff397599749ec9 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 1 Feb 2023 17:35:18 +0100 Subject: [PATCH 031/210] chore: Let's spell parameters correctly (#745) --- Sources/web3swift/Utils/EIP/EIP712.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/web3swift/Utils/EIP/EIP712.swift b/Sources/web3swift/Utils/EIP/EIP712.swift index 4cb913ffd..1bb65436f 100644 --- a/Sources/web3swift/Utils/EIP/EIP712.swift +++ b/Sources/web3swift/Utils/EIP/EIP712.swift @@ -100,7 +100,7 @@ fileprivate extension EIP712Hashable { } func encodePrimaryType() -> String { - let parametrs: [String] = Mirror(reflecting: self).children.compactMap { key, value in + let parameters: [String] = Mirror(reflecting: self).children.compactMap { key, value in guard let key = key else { return nil } func checkIfValueIsNil(value: Any) -> Bool { @@ -127,7 +127,7 @@ fileprivate extension EIP712Hashable { } return typeName + " " + key } - return name + "(" + parametrs.joined(separator: ",") + ")" + return name + "(" + parameters.joined(separator: ",") + ")" } } From 60d789605ca60266a74aaf1d6bf7499ca6f75da8 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 1 Feb 2023 17:35:53 +0100 Subject: [PATCH 032/210] chore: Let's spell beginning correctly (#746) --- Sources/Web3Core/KeystoreManager/IBAN.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/IBAN.swift b/Sources/Web3Core/KeystoreManager/IBAN.swift index 604f7dce7..164ff319f 100755 --- a/Sources/Web3Core/KeystoreManager/IBAN.swift +++ b/Sources/Web3Core/KeystoreManager/IBAN.swift @@ -64,9 +64,9 @@ public struct IBAN { internal static func decodeToInts(_ iban: String) -> String { let uppercasedIBAN = iban.replacingOccurrences(of: " ", with: "").uppercased() - let begining = String(uppercasedIBAN[0..<4]) + let beginning = String(uppercasedIBAN[0..<4]) let end = String(uppercasedIBAN[4...]) - let IBAN = end + begining + let IBAN = end + beginning var arrayOfInts = [Int]() for ch in IBAN { guard let dataPoint = String(ch).data(using: .ascii) else {return ""} From 4ec728f5a2d102b1b7409d1baa6323a01140f6bd Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Wed, 1 Feb 2023 19:18:28 +0200 Subject: [PATCH 033/210] chore: refactoring of func publicToAddressData and docs --- Sources/Web3Core/Utility/Utilities.swift | 42 ++++++++++++++---------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/Sources/Web3Core/Utility/Utilities.swift b/Sources/Web3Core/Utility/Utilities.swift index 5a71cdd04..3d347e79a 100644 --- a/Sources/Web3Core/Utility/Utilities.swift +++ b/Sources/Web3Core/Utility/Utilities.swift @@ -10,34 +10,39 @@ import BigInt public struct Utilities { - /// Convert a public key to the corresponding EthereumAddress. Accepts public keys in compressed (33 bytes), non-compressed (65 bytes) - /// or raw concat(X, Y) (64 bytes) format. + /// Convert a public key to the corresponding ``EthereumAddress``. Accepts public keys in compressed (33 bytes), uncompressed (65 bytes) + /// or uncompressed without prefix (64 bytes) format. /// - /// Returns 20 bytes of address data. + /// - Parameter publicKey: compressed 33, non-compressed (65 bytes) or non-compressed without prefix (64 bytes) + /// - Returns: 20 bytes of address data. static func publicToAddressData(_ publicKey: Data) -> Data? { + var publicKey = publicKey if publicKey.count == 33 { - guard let decompressedKey = SECP256K1.combineSerializedPublicKeys(keys: [publicKey], outputCompressed: false) else {return nil} - return publicToAddressData(decompressedKey) - } - var stripped = publicKey - if stripped.count == 65 { - if stripped[0] != 4 { + guard (publicKey[0] == 2 || publicKey[0] == 3), + let decompressedKey = SECP256K1.combineSerializedPublicKeys(keys: [publicKey], outputCompressed: false) else { return nil } - stripped = stripped[1...64] + publicKey = decompressedKey } - if stripped.count != 64 { + + if publicKey.count == 65 { + guard publicKey[0] == 4 else { + return nil + } + publicKey = publicKey[1...64] + } else if publicKey.count != 64 { return nil } - let sha3 = stripped.sha3(.keccak256) + let sha3 = publicKey.sha3(.keccak256) let addressData = sha3[12...31] return addressData } - /// Convert a public key to the corresponding EthereumAddress. Accepts public keys in compressed (33 bytes), non-compressed (65 bytes) - /// or raw concat(X, Y) (64 bytes) format. + /// Convert a public key to the corresponding ``EthereumAddress``. Accepts public keys in compressed (33 bytes), uncompressed (65 bytes) + /// or uncompressed without prefix (64 bytes) format. /// - /// Returns the EthereumAddress object. + /// - Parameter publicKey: compressed 33, non-compressed (65 bytes) or non-compressed without prefix (64 bytes) + /// - Returns: `EthereumAddress` object. public static func publicToAddress(_ publicKey: Data) -> EthereumAddress? { guard let addressData = publicToAddressData(publicKey) else {return nil} let address = addressData.toHexString().addHexPrefix().lowercased() @@ -50,10 +55,11 @@ public struct Utilities { return publicKey } - /// Convert a public key to the corresponding EthereumAddress. Accepts public keys in compressed (33 bytes), non-compressed (65 bytes) - /// or raw concat(X, Y) (64 bytes) format. + /// Convert a public key to the corresponding ``EthereumAddress``. Accepts public keys in compressed (33 bytes), uncompressed (65 bytes) + /// or uncompressed without prefix (64 bytes) format. /// - /// Returns a 0x prefixed hex string. + /// - Parameter publicKey: compressed 33, non-compressed (65 bytes) or non-compressed without prefix (64 bytes) + /// - Returns: `0x` prefixed hex string. public static func publicToAddressString(_ publicKey: Data) -> String? { guard let addressData = Utilities.publicToAddressData(publicKey) else {return nil} let address = addressData.toHexString().addHexPrefix().lowercased() From 600b8834c62b2df8c36d0a436c726eff6ba13847 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Wed, 1 Feb 2023 19:22:18 +0200 Subject: [PATCH 034/210] test: added test cases for `func publicToAddress` --- .../localTests/UtilitiesTests.swift | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Tests/web3swiftTests/localTests/UtilitiesTests.swift b/Tests/web3swiftTests/localTests/UtilitiesTests.swift index 53a6761fc..5751afde0 100644 --- a/Tests/web3swiftTests/localTests/UtilitiesTests.swift +++ b/Tests/web3swiftTests/localTests/UtilitiesTests.swift @@ -47,4 +47,39 @@ class UtilitiesTests: XCTestCase { XCTAssertEqual(test.input.decimals, test.output) } } + + func testPublicKeyWithNoPrefixToAddress() throws { + var address = Utilities.publicToAddress(Data.fromHex("0x18ed2e1ec629e2d3dae7be1103d4f911c24e0c80e70038f5eb5548245c475f504c220d01e1ca419cb1ba4b3393b615e99dd20aa6bf071078f70fd949008e7411")!)?.address + XCTAssertEqual(address, "0x28828f43df370651AC5A6cFd02fBD0885Fbb3c00") + address = Utilities.publicToAddress(Data.fromHex("0x52972572d465d016d4c501887b8df303eee3ed602c056b1eb09260dfa0da0ab288742f4dc97d9edb6fd946babc002fdfb06f26caf117b9405ed79275763fdb1c")!)?.address + XCTAssertEqual(address, "0x6eDBe1F6D48FbF1b053D6c9FA7997C710B84f55F") + } + + func testPublicKeyWithPrefixToAddress() throws { + var address = Utilities.publicToAddress(Data.fromHex("0x0418ed2e1ec629e2d3dae7be1103d4f911c24e0c80e70038f5eb5548245c475f504c220d01e1ca419cb1ba4b3393b615e99dd20aa6bf071078f70fd949008e7411")!)?.address + XCTAssertEqual(address, "0x28828f43df370651AC5A6cFd02fBD0885Fbb3c00") + address = Utilities.publicToAddress(Data.fromHex("0x0452972572d465d016d4c501887b8df303eee3ed602c056b1eb09260dfa0da0ab288742f4dc97d9edb6fd946babc002fdfb06f26caf117b9405ed79275763fdb1c")!)?.address + XCTAssertEqual(address, "0x6eDBe1F6D48FbF1b053D6c9FA7997C710B84f55F") + } + + func testPublicKeyWithInvalidPrefixToAddress() throws { + var address = Utilities.publicToAddress(Data.fromHex("0x0318ed2e1ec629e2d3dae7be1103d4f911c24e0c80e70038f5eb5548245c475f504c220d01e1ca419cb1ba4b3393b615e99dd20aa6bf071078f70fd949008e7411")!)?.address + XCTAssertEqual(address, nil) + address = Utilities.publicToAddress(Data.fromHex("0x0152972572d465d016d4c501887b8df303eee3ed602c056b1eb09260dfa0da0ab288742f4dc97d9edb6fd946babc002fdfb06f26caf117b9405ed79275763fdb1c")!)?.address + XCTAssertEqual(address, nil) + } + + func testCompressedPublicKeyToAddress() throws { + var address = Utilities.publicToAddress(Data.fromHex("0x0318ed2e1ec629e2d3dae7be1103d4f911c24e0c80e70038f5eb5548245c475f50")!)?.address + XCTAssertEqual(address, "0x28828f43df370651AC5A6cFd02fBD0885Fbb3c00") + address = Utilities.publicToAddress(Data.fromHex("0x0252972572d465d016d4c501887b8df303eee3ed602c056b1eb09260dfa0da0ab2")!)?.address + XCTAssertEqual(address, "0x6eDBe1F6D48FbF1b053D6c9FA7997C710B84f55F") + } + + func testCompressedPublicKeyWithInvalidPrefixToAddress() throws { + var address = Utilities.publicToAddress(Data.fromHex("0x0718ed2e1ec629e2d3dae7be1103d4f911c24e0c80e70038f5eb5548245c475f50")!)?.address + XCTAssertEqual(address, nil) + address = Utilities.publicToAddress(Data.fromHex("0x0852972572d465d016d4c501887b8df303eee3ed602c056b1eb09260dfa0da0ab2")!)?.address + XCTAssertEqual(address, nil) + } } From 83491520b76973e7f60e25f75812826ed59a10fb Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 1 Feb 2023 18:25:56 +0100 Subject: [PATCH 035/210] chore: Let's spell tuple correctly (#748) --- .../localTests/EIP1559BlockTests.swift | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift index e41c55e3f..e99dc837b 100644 --- a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift +++ b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift @@ -57,8 +57,8 @@ class EIP1559BlockTests: LocalTestCase { (40_000_000, 12_965_000, 39_960_938, false) // Lower limit -1 ] - headerArray.forEach { (touple: (parentGasLimit: BigUInt, parentNumber: BigUInt, currentGasLimit: BigUInt, is1559: Bool)) in - let parent = Block(number: touple.parentNumber, + headerArray.forEach { (tuple: (parentGasLimit: BigUInt, parentNumber: BigUInt, currentGasLimit: BigUInt, is1559: Bool)) in + let parent = Block(number: tuple.parentNumber, hash: uselessBlockPart.hash, parentHash: uselessBlockPart.parentHash, nonce: uselessBlockPart.nonce, @@ -72,14 +72,14 @@ class EIP1559BlockTests: LocalTestCase { totalDifficulty: uselessBlockPart.totalDifficulty, extraData: uselessBlockPart.extraData, size: uselessBlockPart.size, - gasLimit: touple.parentGasLimit, - gasUsed: touple.parentGasLimit / 2, + gasLimit: tuple.parentGasLimit, + gasUsed: tuple.parentGasLimit / 2, baseFeePerGas: Web3.InitialBaseFee, timestamp: uselessBlockPart.timestamp, transactions: uselessBlockPart.transactions, uncles: uselessBlockPart.uncles) - let current = Block(number: touple.parentNumber + 1, + let current = Block(number: tuple.parentNumber + 1, hash: uselessBlockPart.hash, parentHash: uselessBlockPart.parentHash, nonce: uselessBlockPart.nonce, @@ -93,14 +93,14 @@ class EIP1559BlockTests: LocalTestCase { totalDifficulty: uselessBlockPart.totalDifficulty, extraData: uselessBlockPart.extraData, size: uselessBlockPart.size, - gasLimit: touple.currentGasLimit, - gasUsed: touple.currentGasLimit / 2, + gasLimit: tuple.currentGasLimit, + gasUsed: tuple.currentGasLimit / 2, baseFeePerGas: Web3.InitialBaseFee, timestamp: uselessBlockPart.timestamp, transactions: uselessBlockPart.transactions, uncles: uselessBlockPart.uncles) - if touple.is1559 { + if tuple.is1559 { XCTAssertTrue(Web3.isEip1559Block(parent: parent, current: current), "Shoult not fail, got parent: \(parent.gasLimit), current: \(current.gasLimit)") } else { @@ -124,8 +124,8 @@ class EIP1559BlockTests: LocalTestCase { (Web3.InitialBaseFee, 12_965_000, 20000000, 11000000, 1012500000) // current above target ] - headerArray.forEach { (touple: (parentBaseFee: BigUInt, parentNumber: BigUInt, parentGasLimit: BigUInt, parentGasUsed: BigUInt, expectedBaseFee: BigUInt)) in - let parent = Block(number: touple.parentNumber, + headerArray.forEach { (tuple: (parentBaseFee: BigUInt, parentNumber: BigUInt, parentGasLimit: BigUInt, parentGasUsed: BigUInt, expectedBaseFee: BigUInt)) in + let parent = Block(number: tuple.parentNumber, hash: uselessBlockPart.hash, parentHash: uselessBlockPart.parentHash, nonce: uselessBlockPart.nonce, @@ -139,8 +139,8 @@ class EIP1559BlockTests: LocalTestCase { totalDifficulty: uselessBlockPart.totalDifficulty, extraData: uselessBlockPart.extraData, size: uselessBlockPart.size, - gasLimit: touple.parentGasLimit, - gasUsed: touple.parentGasUsed, + gasLimit: tuple.parentGasLimit, + gasUsed: tuple.parentGasUsed, baseFeePerGas: Web3.InitialBaseFee, timestamp: uselessBlockPart.timestamp, transactions: uselessBlockPart.transactions, @@ -148,7 +148,7 @@ class EIP1559BlockTests: LocalTestCase { let calculatedBaseFee = Web3.calcBaseFee(parent) - XCTAssertEqual(calculatedBaseFee, touple.expectedBaseFee, "Base fee calculation fails: should be \(touple.expectedBaseFee), got: \(String(describing: calculatedBaseFee))") + XCTAssertEqual(calculatedBaseFee, tuple.expectedBaseFee, "Base fee calculation fails: should be \(tuple.expectedBaseFee), got: \(String(describing: calculatedBaseFee))") } } } From 44e5965fc057d59fa3b3d84a982f535b00ce5d09 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Wed, 1 Feb 2023 22:18:43 +0200 Subject: [PATCH 036/210] fix: attempt to encode uint with a negative value results in a crash --- Sources/Web3Core/EthereumABI/ABIEncoding.swift | 16 ++++------------ .../localTests/ABIEncoderTest.swift | 10 ++++++++++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Sources/Web3Core/EthereumABI/ABIEncoding.swift b/Sources/Web3Core/EthereumABI/ABIEncoding.swift index f62177ec8..6005214a0 100755 --- a/Sources/Web3Core/EthereumABI/ABIEncoding.swift +++ b/Sources/Web3Core/EthereumABI/ABIEncoding.swift @@ -218,19 +218,11 @@ public struct ABIEncoder { public static func encodeSingleType(type: ABI.Element.ParameterType, value: AnyObject) -> Data? { switch type { case .uint: - if let biguint = convertToBigUInt(value) { - return biguint.abiEncode(bits: 256) - } - if let bigint = convertToBigInt(value) { - return bigint.abiEncode(bits: 256) - } + let biguint = convertToBigUInt(value) + return biguint == nil ? nil : biguint!.abiEncode(bits: 256) case .int: - if let biguint = convertToBigUInt(value) { - return biguint.abiEncode(bits: 256) - } - if let bigint = convertToBigInt(value) { - return bigint.abiEncode(bits: 256) - } + let bigint = convertToBigInt(value) + return bigint == nil ? nil : bigint!.abiEncode(bits: 256) case .address: if let string = value as? String { guard let address = EthereumAddress(string) else {return nil} diff --git a/Tests/web3swiftTests/localTests/ABIEncoderTest.swift b/Tests/web3swiftTests/localTests/ABIEncoderTest.swift index 3f69fb2db..73fabe701 100644 --- a/Tests/web3swiftTests/localTests/ABIEncoderTest.swift +++ b/Tests/web3swiftTests/localTests/ABIEncoderTest.swift @@ -14,6 +14,16 @@ import BigInt class ABIEncoderTest: XCTestCase { + func testEncodeInt() { + XCTAssertEqual(ABIEncoder.encodeSingleType(type: .int(bits: 32), value: -10 as AnyObject)?.toHexString(), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6") + XCTAssertEqual(ABIEncoder.encodeSingleType(type: .int(bits: 32), value: 10 as AnyObject)?.toHexString(), "000000000000000000000000000000000000000000000000000000000000000a") + } + + func testEncodeUInt() { + XCTAssertEqual(ABIEncoder.encodeSingleType(type: .uint(bits: 32), value: -10 as AnyObject), nil) + XCTAssertEqual(ABIEncoder.encodeSingleType(type: .uint(bits: 32), value: 10 as AnyObject)?.toHexString(), "000000000000000000000000000000000000000000000000000000000000000a") + } + func testSoliditySha3() throws { var hex = try ABIEncoder.soliditySha3(true).toHexString().addHexPrefix() assert(hex == "0x5fe7f977e71dba2ea1a68e21057beebb9be2ac30c6410aa38d4f3fbe41dcffd2") From b32bcb3f24684af247b6a336a92099c3af03bf59 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 2 Feb 2023 00:22:57 +0100 Subject: [PATCH 037/210] GitHub Actions: Add codespell to find typos Use https://github.com/codespell-project/actions-codespell to discover typos like #743, #745, #746, #747, #748 --- .github/workflows/macOS-tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index 749ce9e55..b9da49623 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -34,6 +34,10 @@ jobs: cancel-in-progress: false steps: - uses: actions/checkout@v3 + - uses: codespell-project/actions-codespell@v1 + with: + ignore_words_list: ans,deriver,inout,packag + skip: "*.js,*WordLists.swift" - name: Resolve dependencies run: swift package resolve - name: Build From 239f17c0e47f84ac3e425452a1ec917657176245 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 2 Feb 2023 00:26:09 +0100 Subject: [PATCH 038/210] pip install codespell --- .github/workflows/macOS-tests.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index b9da49623..5ca4f97b0 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -34,10 +34,9 @@ jobs: cancel-in-progress: false steps: - uses: actions/checkout@v3 - - uses: codespell-project/actions-codespell@v1 - with: - ignore_words_list: ans,deriver,inout,packag - skip: "*.js,*WordLists.swift" + - run: | + pip install codespell + codespell --count --ignore-words-list=ans,deriver,inout,packag --skip="*.js,*WordLists.swift" - name: Resolve dependencies run: swift package resolve - name: Build From 3f1f80a09ee6d73442053bd2edbdb8aff383ae61 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 2 Feb 2023 00:28:00 +0100 Subject: [PATCH 039/210] Update macOS-tests.yml --- .github/workflows/macOS-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index 5ca4f97b0..707ea5278 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -35,7 +35,7 @@ jobs: steps: - uses: actions/checkout@v3 - run: | - pip install codespell + pip3 install codespell || python3 -m pip install codespell codespell --count --ignore-words-list=ans,deriver,inout,packag --skip="*.js,*WordLists.swift" - name: Resolve dependencies run: swift package resolve From 2af0c29d31f74ec30558543f7cfc1646e4ee5a3c Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 2 Feb 2023 00:31:03 +0100 Subject: [PATCH 040/210] Update macOS-tests.yml --- .github/workflows/macOS-tests.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index 707ea5278..9c842cd4f 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -34,8 +34,10 @@ jobs: cancel-in-progress: false steps: - uses: actions/checkout@v3 - - run: | - pip3 install codespell || python3 -m pip install codespell + - name: Discover typos + run: | + pip3 install --upgrade pip + pip3 install codespell codespell --count --ignore-words-list=ans,deriver,inout,packag --skip="*.js,*WordLists.swift" - name: Resolve dependencies run: swift package resolve From 7226a7957027b939663116e67a5afbabdec8a426 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 2 Feb 2023 00:32:22 +0100 Subject: [PATCH 041/210] Let's spell should correctly --- Tests/web3swiftTests/localTests/EIP1559BlockTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift index e99dc837b..26f567017 100644 --- a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift +++ b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift @@ -102,7 +102,7 @@ class EIP1559BlockTests: LocalTestCase { if tuple.is1559 { XCTAssertTrue(Web3.isEip1559Block(parent: parent, current: current), - "Shoult not fail, got parent: \(parent.gasLimit), current: \(current.gasLimit)") + "Should not fail, got parent: \(parent.gasLimit), current: \(current.gasLimit)") } else { XCTAssertFalse(Web3.isEip1559Block(parent: parent, current: current), "Should fail, got parent: \(parent.gasLimit), current: \(current.gasLimit)") From 1ac6df5b9b0ccb100c5b43d264938e96ab8a5c74 Mon Sep 17 00:00:00 2001 From: august Date: Thu, 2 Feb 2023 11:08:32 +0800 Subject: [PATCH 042/210] update podspec version --- Web3Core.podspec | 2 +- web3swift.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Web3Core.podspec b/Web3Core.podspec index d0ded29c5..df71e5207 100644 --- a/Web3Core.podspec +++ b/Web3Core.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |spec| spec.compiler_flags = '-DCOCOAPODS' spec.name = 'Web3Core' - spec.version = '3.0.6' + spec.version = '3.1.0' spec.ios.deployment_target = "13.0" spec.osx.deployment_target = "10.15" spec.license = { :type => 'Apache License 2.0', :file => 'LICENSE.md' } diff --git a/web3swift.podspec b/web3swift.podspec index 48d930d88..475718533 100755 --- a/web3swift.podspec +++ b/web3swift.podspec @@ -1,4 +1,4 @@ -WEB3CORE_VERSION ||= '3.0.6' +WEB3CORE_VERSION ||= '3.1.0' Pod::Spec.new do |spec| spec.name = 'web3swift' From 47288dffb7aa80d4e613d8602afc6821a9f92405 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Thu, 2 Feb 2023 16:38:32 +0200 Subject: [PATCH 043/210] feat: git hooks implementation --- .githooks/init_hooks.sh | 45 +++++++++++++++++++++++++++++++++++++++++ .githooks/pre-commit | 43 +++++++++++++++++++++++++++++++++++++++ README.md | 4 ++++ 3 files changed, 92 insertions(+) create mode 100755 .githooks/init_hooks.sh create mode 100755 .githooks/pre-commit diff --git a/.githooks/init_hooks.sh b/.githooks/init_hooks.sh new file mode 100755 index 000000000..18a870b10 --- /dev/null +++ b/.githooks/init_hooks.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# Creates symlinks of hooks in .githooks directory in .git/hooks +# If user already has hooks in .git/hooks then hooks from .githooks +# will be added as separate files with different names and a command +# to run these hooks will be added to the respective existing hooks +# on the last line of the file. + +current_dir=${PWD##*/} + +if [ "$current_dir" != ".githooks" ]; then + cd .githooks +fi + +shopt -s nullglob +raw_githooks=(*) +exclude=(init_hooks.sh) +githooks=( "${raw_githooks[@]/$exclude}" ) + +for hook in ${githooks[*]} +do + git_hook_path="../.git/hooks/$hook" + + web3swift_hook_comment="# web3swift git hook to perform actions like SwiftLint and codespell" + web3swift_hook_path="source $(pwd)/${hook}" + + is_hook_linked=false + + if test -f $git_hook_path; then + last_line=$( tac ${git_hook_path} | grep -m 1 -E '[^[:space:]]' ) + if [ "$last_line" = "$web3swift_hook_path" ]; then + is_hook_linked=true + fi + else + touch $git_hook_path + chmod +x $git_hook_path + echo "#!/bin/sh\n" >> $git_hook_path + fi + + if [ "$is_hook_linked" = false ] ; then + echo "$web3swift_hook_path" >> $git_hook_path + echo "${hook} is linked successfully." + else + echo "${hook} is already linked." + fi +done \ No newline at end of file diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 000000000..8bfc24695 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,43 @@ +#!/bin/sh + +if ! command -v pip3 &> /dev/null +then + >&2 echo "\033[31mpip3 could not be found. Please, install pip3 following the guide on https://pip.pypa.io/en/stable/installation/\033[0m" + exit 1 +fi + +codespell_out=$(pip3 show codespell | grep "Location") +codespell_path=(${codespell_out//"Location: "/ }) + +if [ -z "$codespell_path" ] +then + echo "codespell not found. Installing codespell..." + pip3 install --upgrade pip + pip3 install codespell + + codespell_out=$(pip3 show codespell | grep "Location") + codespell_path=(${codespell_out//"Location: "/ }) + codespell_path="${codespell_path}/bin/codespell" +else + codespell_path="${codespell_path}/bin/codespell" +fi + +$codespell_path --count --ignore-words-list=ans,deriver,inout,packag --skip="*.js,*WordLists.swift" Sources/ Tests/ Package.swift CHANGELOG.md CONTRIBUTION.md README.md Web3Core.podspec Web3Swift.podspec + +if [ $? -eq 65 ]; then + echo "codespell returned exit code 65. Please, fix the errors." + exit 1 +fi + +if [ "$(uname -s)" = "Darwin" ]; then + export PATH="$PATH:/opt/homebrew/bin" + + if ! command -v swiftlint &> /dev/null + then + echo "swiftlint wasn't found. Installing it from Homebrew." + brew install swiftlint + fi + + swiftlint Sources + swiftlint Tests +fi diff --git a/README.md b/README.md index 43fbc8ec7..c6d631576 100755 --- a/README.md +++ b/README.md @@ -188,6 +188,10 @@ $ ganache This will create a local blockchain and also some test accounts that are used throughout our tests. Make sure that `ganache` is running on its default port `8546`. To change the port in test cases locate `LocalTestCase.swift` and modify the static `url` variable. +### Before you commit + +Please, run `.githooks/init_hooks.sh` to initialize git hooks that will do `codespell`, `swiftlint` and other checks. _Issues may arise with hooks on platforms other than Mac OS._ + ## Contribute Want to improve? It's awesome: Then good news for you: **We are ready to pay for your contribution via [@gitcoin bot](https://gitcoin.co/grants/358/web3swift)!** From 467b4b9e2d92bb83a28a6bf9ce5f8380611108b4 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Thu, 2 Feb 2023 16:51:05 +0200 Subject: [PATCH 044/210] chore: doc refactoring for init_hooks.sh --- .githooks/init_hooks.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.githooks/init_hooks.sh b/.githooks/init_hooks.sh index 18a870b10..f3b3e74c0 100755 --- a/.githooks/init_hooks.sh +++ b/.githooks/init_hooks.sh @@ -1,9 +1,8 @@ #!/bin/sh -# Creates symlinks of hooks in .githooks directory in .git/hooks -# If user already has hooks in .git/hooks then hooks from .githooks -# will be added as separate files with different names and a command -# to run these hooks will be added to the respective existing hooks -# on the last line of the file. +# Creates hooks in .git/hooks directory based on the hooks available in .githooks. +# If user already has hooks in .git/hooks then hooks from .githooks will be added +# as separate files with different names and a command to run these hooks will be +# added to the respective existing hooks on the last line of the file. current_dir=${PWD##*/} @@ -42,4 +41,4 @@ do else echo "${hook} is already linked." fi -done \ No newline at end of file +done From 0f18c39cd8f4f8639a82bfc513d6c43118b01390 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Thu, 2 Feb 2023 17:04:19 +0200 Subject: [PATCH 045/210] fix: surrond source call with file existence check --- .githooks/init_hooks.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.githooks/init_hooks.sh b/.githooks/init_hooks.sh index f3b3e74c0..28913e262 100755 --- a/.githooks/init_hooks.sh +++ b/.githooks/init_hooks.sh @@ -20,13 +20,14 @@ do git_hook_path="../.git/hooks/$hook" web3swift_hook_comment="# web3swift git hook to perform actions like SwiftLint and codespell" - web3swift_hook_path="source $(pwd)/${hook}" + web3swift_hook_path="$(pwd)/${hook}" + web3swift_hook_command="source $(pwd)/${hook}" is_hook_linked=false if test -f $git_hook_path; then last_line=$( tac ${git_hook_path} | grep -m 1 -E '[^[:space:]]' ) - if [ "$last_line" = "$web3swift_hook_path" ]; then + if [ "$last_line" = "$web3swift_hook_command" ]; then is_hook_linked=true fi else @@ -36,7 +37,13 @@ do fi if [ "$is_hook_linked" = false ] ; then - echo "$web3swift_hook_path" >> $git_hook_path + cat << EOF >> $git_hook_path +web3swift_hook_path=${web3swift_hook_path} + +if test -f \$web3swift_hook_path; then + ${web3swift_hook_command} +fi +EOF echo "${hook} is linked successfully." else echo "${hook} is already linked." From dfa960a74475f9c654ca04fd98041e32f02ae79d Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Thu, 2 Feb 2023 17:20:45 +0200 Subject: [PATCH 046/210] chore: a few swiftlint rules to ignore for now --- .swiftlint.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.swiftlint.yml b/.swiftlint.yml index a0d7900d6..1e8e778fa 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -6,6 +6,8 @@ excluded: - DerivedData disabled_rules: + - function_parameter_count + - nesting - type_name - identifier_name - line_length From c5cf027b46cdc7ad109806c095bb1c40fe64c8f4 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Thu, 2 Feb 2023 17:21:12 +0200 Subject: [PATCH 047/210] fix: EthereumKeystoreV3 ignore cyclomatic complexity --- Sources/Web3Core/KeystoreManager/EthereumKeystoreV3.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/Web3Core/KeystoreManager/EthereumKeystoreV3.swift b/Sources/Web3Core/KeystoreManager/EthereumKeystoreV3.swift index 9f68dc2c8..d2602637c 100755 --- a/Sources/Web3Core/KeystoreManager/EthereumKeystoreV3.swift +++ b/Sources/Web3Core/KeystoreManager/EthereumKeystoreV3.swift @@ -6,6 +6,7 @@ import Foundation import CryptoSwift +// swiftlint:disable cyclomatic_complexity public class EthereumKeystoreV3: AbstractKeystore { // Protocol public var isHDKeystore: Bool = false From e90dfb25f5085da05403e52d64fb974e1528f9fd Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Thu, 2 Feb 2023 18:07:01 +0200 Subject: [PATCH 048/210] chore: swiftlint --fix --- .../Web3Core/EthereumABI/ABIElements.swift | 52 +++++++++---------- .../Transaction/CodableTransaction.swift | 2 +- .../Ethereum/IEth+Defaults.swift | 2 +- .../Tokens/ERC1376/Web3+ERC1376.swift | 1 - .../Tokens/ERC1643/Web3+ERC1643.swift | 1 - .../web3swift/Tokens/ERC777/Web3+ERC777.swift | 1 - Sources/web3swift/Web3/Web3+Eventloop.swift | 19 +++---- .../web3swift/Web3/Web3+HttpProvider.swift | 2 +- Sources/web3swift/Web3/Web3+Personal.swift | 28 +++++----- .../ABIElementErrorDecodingTest.swift | 8 +-- .../localTests/ABIEncoderTest.swift | 8 +-- .../localTests/AdvancedABIv2Tests.swift | 15 ++---- .../localTests/BasicLocalNodeTests.swift | 6 --- .../localTests/DataConversionTests.swift | 11 ---- .../localTests/EIP1559BlockTests.swift | 1 - .../localTests/EIP67Tests.swift | 2 +- .../localTests/EventloopTests.swift | 2 +- .../localTests/KeystoresTests.swift | 9 ++-- .../NumberFormattingUtilTests.swift | 2 +- .../localTests/PersonalSignatureTests.swift | 6 +-- .../web3swiftTests/localTests/RLPTests.swift | 2 +- .../ST20AndSecurityTokenTests.swift | 2 +- .../localTests/TestHelpers.swift | 1 - .../localTests/TransactionsTests.swift | 37 +++++++------ .../localTests/UncategorizedTests.swift | 9 ++-- .../web3swiftTests/localTests/UserCases.swift | 8 +-- .../localTests/UtilitiesTests.swift | 8 +-- .../localTests/Web3ErrorTests.swift | 1 - .../web3swiftTests/remoteTests/ENSTests.swift | 2 +- .../EtherscanTransactionCheckerTests.swift | 2 +- .../remoteTests/PolicyResolverTests.swift | 6 +-- 31 files changed, 107 insertions(+), 149 deletions(-) diff --git a/Sources/Web3Core/EthereumABI/ABIElements.swift b/Sources/Web3Core/EthereumABI/ABIElements.swift index 10118b64e..bfc387246 100755 --- a/Sources/Web3Core/EthereumABI/ABIElements.swift +++ b/Sources/Web3Core/EthereumABI/ABIElements.swift @@ -274,35 +274,35 @@ extension ABI.Element.Function { /// /// Return cases: /// - when no `outputs` declared and `data` is not an error response: - ///```swift - ///["_success": true] - ///``` + /// ```swift + /// ["_success": true] + /// ``` /// - when `outputs` declared and decoding completed successfully: - ///```swift - ///["_success": true, "0": value_1, "1": value_2, ...] - ///``` - ///Additionally this dictionary will have mappings to output names if these names are specified in the ABI; + /// ```swift + /// ["_success": true, "0": value_1, "1": value_2, ...] + /// ``` + /// Additionally this dictionary will have mappings to output names if these names are specified in the ABI; /// - function call was aborted using `revert(message)` or `require(expression, message)`: - ///```swift - ///["_success": false, "_abortedByRevertOrRequire": true, "_errorMessage": message]` - ///``` + /// ```swift + /// ["_success": false, "_abortedByRevertOrRequire": true, "_errorMessage": message]` + /// ``` /// - function call was aborted using `revert CustomMessage()` and `errors` argument contains the ABI of that custom error type: - ///```swift - ///["_success": false, - ///"_abortedByRevertOrRequire": true, - ///"_error": error_name_and_types, // e.g. `MyCustomError(uint256, address senderAddress)` - ///"0": error_arg1, - ///"1": error_arg2, - ///..., - ///"error_arg1_name": error_arg1, // Only named arguments will be mapped to their names, e.g. `"senderAddress": EthereumAddress` - ///"error_arg2_name": error_arg2, // Otherwise, you can query them by position index. - ///...] - ///``` - ///- in case of any error: - ///```swift - ///["_success": false, "_failureReason": String] - ///``` - ///Error reasons include: + /// ```swift + /// ["_success": false, + /// "_abortedByRevertOrRequire": true, + /// "_error": error_name_and_types, // e.g. `MyCustomError(uint256, address senderAddress)` + /// "0": error_arg1, + /// "1": error_arg2, + /// ..., + /// "error_arg1_name": error_arg1, // Only named arguments will be mapped to their names, e.g. `"senderAddress": EthereumAddress` + /// "error_arg2_name": error_arg2, // Otherwise, you can query them by position index. + /// ...] + /// ``` + /// - in case of any error: + /// ```swift + /// ["_success": false, "_failureReason": String] + /// ``` + /// Error reasons include: /// - `outputs` declared but at least one value failed to be decoded; /// - `data.count` is less than `outputs.count * 32`; /// - `outputs` defined and `data` is empty; diff --git a/Sources/Web3Core/Transaction/CodableTransaction.swift b/Sources/Web3Core/Transaction/CodableTransaction.swift index b478dc0f0..af407e00f 100644 --- a/Sources/Web3Core/Transaction/CodableTransaction.swift +++ b/Sources/Web3Core/Transaction/CodableTransaction.swift @@ -54,7 +54,7 @@ public struct CodableTransaction { set { envelope.value = newValue } } - public var data: Data { + public var data: Data { get { return envelope.data } set { envelope.data = newValue } } diff --git a/Sources/web3swift/EthereumAPICalls/Ethereum/IEth+Defaults.swift b/Sources/web3swift/EthereumAPICalls/Ethereum/IEth+Defaults.swift index 6c5424689..c2732c66e 100644 --- a/Sources/web3swift/EthereumAPICalls/Ethereum/IEth+Defaults.swift +++ b/Sources/web3swift/EthereumAPICalls/Ethereum/IEth+Defaults.swift @@ -19,7 +19,7 @@ public extension IEth { func estimateGas(for transaction: CodableTransaction) async throws -> BigUInt { try await estimateGas(for: transaction, onBlock: .latest) } - + func estimateGas(for transaction: CodableTransaction, onBlock: BlockNumber) async throws -> BigUInt { let request = APIRequest.estimateGas(transaction, onBlock) return try await APIRequest.sendRequest(with: provider, for: request).result diff --git a/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift b/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift index 8b5a7b34d..a27dbc01b 100644 --- a/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift +++ b/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift @@ -366,4 +366,3 @@ extension ERC1376 { } } - diff --git a/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift b/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift index 3885a1cf4..6c875120c 100644 --- a/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift +++ b/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift @@ -173,4 +173,3 @@ extension ERC1643 { } } - diff --git a/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift b/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift index 3af0acdef..9a9057432 100644 --- a/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift +++ b/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift @@ -310,4 +310,3 @@ extension ERC777 { } } - diff --git a/Sources/web3swift/Web3/Web3+Eventloop.swift b/Sources/web3swift/Web3/Web3+Eventloop.swift index 258dc97b7..64eb09892 100755 --- a/Sources/web3swift/Web3/Web3+Eventloop.swift +++ b/Sources/web3swift/Web3/Web3+Eventloop.swift @@ -9,22 +9,15 @@ extension Web3.Eventloop { // @available(iOS 10.0, *) public func start(_ timeInterval: TimeInterval) { - if self.timer != nil { - self.timer!.suspend() - self.timer = nil - } - - self.timer = RepeatingTimer(timeInterval: timeInterval) - self.timer?.eventHandler = self.runnable - self.timer?.resume() - + timer?.suspend() + timer = RepeatingTimer(timeInterval: timeInterval) + timer?.eventHandler = self.runnable + timer?.resume() } public func stop() { - if self.timer != nil { - self.timer!.suspend() - self.timer = nil - } + timer?.suspend() + timer = nil } func runnable() { diff --git a/Sources/web3swift/Web3/Web3+HttpProvider.swift b/Sources/web3swift/Web3/Web3+HttpProvider.swift index e56243740..29ad59831 100755 --- a/Sources/web3swift/Web3/Web3+HttpProvider.swift +++ b/Sources/web3swift/Web3/Web3+HttpProvider.swift @@ -39,7 +39,7 @@ public class Web3HttpProvider: Web3Provider { } attachedKeystoreManager = manager } - + public init(url: URL, network: Networks, keystoreManager: KeystoreManager? = nil) { self.url = url self.network = network diff --git a/Sources/web3swift/Web3/Web3+Personal.swift b/Sources/web3swift/Web3/Web3+Personal.swift index f83d328b8..6a7882849 100755 --- a/Sources/web3swift/Web3/Web3+Personal.swift +++ b/Sources/web3swift/Web3/Web3+Personal.swift @@ -13,12 +13,12 @@ extension Web3.Personal { *Locally or remotely sign a message (arbitrary data) with the private key. To avoid potential signing of a transaction the message is first prepended by a special header and then hashed.* - parameters: - - message: Message Data - - from: Use a private key that corresponds to this account - - password: Password for account if signing locally + - message: Message Data + - from: Use a private key that corresponds to this account + - password: Password for account if signing locally - returns: - - Result object + - Result object - important: This call is synchronous @@ -32,12 +32,12 @@ extension Web3.Personal { *Unlock an account on the remote node to be able to send transactions and sign messages.* - parameters: - - account: EthereumAddress of the account to unlock - - password: Password to use for the account - - seconds: Time interval before automatic account lock by Ethereum node + - account: EthereumAddress of the account to unlock + - password: Password to use for the account + - seconds: Time interval before automatic account lock by Ethereum node - returns: - - Result object + - Result object - important: This call is synchronous. Does nothing if private keys are stored locally. @@ -51,11 +51,11 @@ extension Web3.Personal { *Recovers a signer of some message. Message is first prepended by special prefix (check the "signPersonalMessage" method description) and then hashed.* - parameters: - - personalMessage: Message Data - - signature: Serialized signature, 65 bytes + - personalMessage: Message Data + - signature: Serialized signature, 65 bytes - returns: - - Result object + - Result object */ public func ecrecover(personalMessage: Data, signature: Data) throws -> EthereumAddress { @@ -69,11 +69,11 @@ extension Web3.Personal { *Recovers a signer of some hash. Checking what is under this hash is on behalf of the user.* - parameters: - - hash: Signed hash - - signature: Serialized signature, 65 bytes + - hash: Signed hash + - signature: Serialized signature, 65 bytes - returns: - - Result object + - Result object */ public func ecrecover(hash: Data, signature: Data) throws -> EthereumAddress { diff --git a/Tests/web3swiftTests/localTests/ABIElementErrorDecodingTest.swift b/Tests/web3swiftTests/localTests/ABIElementErrorDecodingTest.swift index 9c7d238f9..181337d19 100644 --- a/Tests/web3swiftTests/localTests/ABIElementErrorDecodingTest.swift +++ b/Tests/web3swiftTests/localTests/ABIElementErrorDecodingTest.swift @@ -51,7 +51,7 @@ class ABIElementErrorDecodingTest: XCTestCase { .init(name: "rand_bytes", type: .bytes(length: 123)), .init(name: "", type: .dynamicBytes), .init(name: "arrarrarray123", type: .array(type: .bool, length: 0)), - .init(name: "error_message_maybe", type: .string), + .init(name: "error_message_maybe", type: .string) ] XCTAssertEqual(EthError(name: "VeryCustomErrorName", inputs: allTypesNamedAndNot).errorDeclaration, @@ -113,7 +113,7 @@ class ABIElementErrorDecodingTest: XCTestCase { /// 82b42900 - Unauthorized() function selector /// 00000000000000000000000000000000000000000000000000000000 - padding bytes let errorResponse = Data.fromHex("82b4290000000000000000000000000000000000000000000000000000000000")! - let errors: [String: EthError] = ["82b42900" : .init(name: "Unauthorized", inputs: [])] + let errors: [String: EthError] = ["82b42900": .init(name: "Unauthorized", inputs: [])] guard let errorData = emptyFunction.decodeErrorResponse(errorResponse, errors: errors) else { XCTFail("Data must be decoded as a `revert(\"Not enough Ether provided.\")` or `require(false, \"Not enough Ether provided.\")` but decoding failed completely.") return @@ -136,7 +136,7 @@ class ABIElementErrorDecodingTest: XCTestCase { /// 82b42900 - Unauthorized() function selector /// 00000000000000000000000000000000000000000000000000000000 - padding bytes let errorResponse = Data.fromHex("82b4290000000000000000000000000000000000000000000000000000000000")! - let errors: [String: EthError] = ["82b42900" : .init(name: "Unauthorized", inputs: [.init(name: "", type: .string)])] + let errors: [String: EthError] = ["82b42900": .init(name: "Unauthorized", inputs: [.init(name: "", type: .string)])] guard let errorData = emptyFunction.decodeErrorResponse(errorResponse, errors: errors) else { XCTFail("Data must be decoded as a `revert(\"Not enough Ether provided.\")` or `require(false, \"Not enough Ether provided.\")` but decoding failed completely.") return @@ -164,7 +164,7 @@ class ABIElementErrorDecodingTest: XCTestCase { /// 526561736f6e0000000000000000000000000000000000000000000000000000 - first custom argument bytes + 0 bytes padding /// 0000... - some more 0 bytes padding to make the number of bytes match 32 bytes chunks let errorResponse = Data.fromHex("973d02cb00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000006526561736f6e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")! - let errors: [String: EthError] = ["973d02cb" : .init(name: "Unauthorized", inputs: [.init(name: "message_arg", type: .string)])] + let errors: [String: EthError] = ["973d02cb": .init(name: "Unauthorized", inputs: [.init(name: "message_arg", type: .string)])] guard let errorData = emptyFunction.decodeErrorResponse(errorResponse, errors: errors) else { XCTFail("Data must be decoded as a `revert(\"Not enough Ether provided.\")` or `require(false, \"Not enough Ether provided.\")` but decoding failed completely.") return diff --git a/Tests/web3swiftTests/localTests/ABIEncoderTest.swift b/Tests/web3swiftTests/localTests/ABIEncoderTest.swift index 3f69fb2db..6e4480e91 100644 --- a/Tests/web3swiftTests/localTests/ABIEncoderTest.swift +++ b/Tests/web3swiftTests/localTests/ABIEncoderTest.swift @@ -190,12 +190,12 @@ class ABIEncoderTest: XCTestCase { var hexData = ABIEncoder.encode(types: [.string], values: ["test"] as [AnyObject])?.toHexString() XCTAssertEqual(hexData?[0..<64], "0000000000000000000000000000000000000000000000000000000000000020") XCTAssertEqual(hexData, "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000047465737400000000000000000000000000000000000000000000000000000000") - hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 0)], values: [[1,2,3,4]] as [AnyObject])?.toHexString() + hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 0)], values: [[1, 2, 3, 4]] as [AnyObject])?.toHexString() XCTAssertEqual(hexData?[0..<64], "0000000000000000000000000000000000000000000000000000000000000020") XCTAssertEqual(hexData, "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004") // This one shouldn't have data offset - hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 4)], values: [[1,2,3,4]] as [AnyObject])?.toHexString() + hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 4)], values: [[1, 2, 3, 4]] as [AnyObject])?.toHexString() // First 32 bytes are the first value from the array XCTAssertEqual(hexData?[0..<64], "0000000000000000000000000000000000000000000000000000000000000001") XCTAssertEqual(hexData, "0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004") @@ -204,7 +204,7 @@ class ABIEncoderTest: XCTestCase { .bool, .array(type: .uint(bits: 8), length: 0), .bytes(length: 2)] - let values: [AnyObject] = [10, false, [1,2,3,4], Data(count: 2)] as [AnyObject] + let values: [AnyObject] = [10, false, [1, 2, 3, 4], Data(count: 2)] as [AnyObject] hexData = ABIEncoder.encode(types: types, values: values)?.toHexString() XCTAssertEqual(hexData?[128..<192], "0000000000000000000000000000000000000000000000000000000000000080") XCTAssertEqual(hexData, "000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004") @@ -220,7 +220,7 @@ class ABIEncoderTest: XCTestCase { encodedValue = ABIEncoder.encode(types: [.dynamicBytes], values: [Data.fromHex("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1")!] as [AnyObject])!.toHexString() XCTAssertEqual(encodedValue, "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000009ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff100") - + encodedValue = ABIEncoder.encode(types: [.dynamicBytes], values: [Data.fromHex("c3a40000c3a4")!] as [AnyObject])!.toHexString() XCTAssertEqual(encodedValue, "00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000006c3a40000c3a40000000000000000000000000000000000000000000000000000") diff --git a/Tests/web3swiftTests/localTests/AdvancedABIv2Tests.swift b/Tests/web3swiftTests/localTests/AdvancedABIv2Tests.swift index f9bc88ef2..c45c87f11 100755 --- a/Tests/web3swiftTests/localTests/AdvancedABIv2Tests.swift +++ b/Tests/web3swiftTests/localTests/AdvancedABIv2Tests.swift @@ -31,7 +31,6 @@ class AdvancedABIv2Tests: LocalTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(Data.fromHex(txHash)!) - switch receipt.status { case .notYetProcessed: @@ -44,7 +43,7 @@ class AdvancedABIv2Tests: LocalTestCase { // MARK: Read data from ABI flow // MARK: - Encoding ABI Data flow let tx = contract.createReadOperation("testSingle") - let _ = try await tx!.callContractMethod() + _ = try await tx!.callContractMethod() } func testAdvancedABIv2staticArray() async throws { @@ -66,7 +65,6 @@ class AdvancedABIv2Tests: LocalTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(Data.fromHex(txHash)!) - switch receipt.status { case .notYetProcessed: @@ -79,7 +77,7 @@ class AdvancedABIv2Tests: LocalTestCase { // MARK: Read data from ABI flow // MARK: - Encoding ABI Data flow let tx = contract.createReadOperation("testStaticArray") - let _ = try await tx!.callContractMethod() + _ = try await tx!.callContractMethod() } func testAdvancedABIv2dynamicArray() async throws { @@ -101,7 +99,6 @@ class AdvancedABIv2Tests: LocalTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(Data.fromHex(txHash)!) - switch receipt.status { case .notYetProcessed: @@ -113,7 +110,7 @@ class AdvancedABIv2Tests: LocalTestCase { contract = web3.contract(abiString, at: receipt.contractAddress, abiVersion: 2)! let tx = contract.createReadOperation("testDynArray") - let _ = try await tx!.callContractMethod() + _ = try await tx!.callContractMethod() } func testAdvancedABIv2dynamicArrayOfStrings() async throws { @@ -135,7 +132,6 @@ class AdvancedABIv2Tests: LocalTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(Data.fromHex(txHash)!) - switch receipt.status { case .notYetProcessed: @@ -148,7 +144,7 @@ class AdvancedABIv2Tests: LocalTestCase { // MARK: Read data from ABI flow // MARK: - Encoding ABI Data flow let tx = contract.createReadOperation("testDynOfDyn") - let _ = try await tx!.callContractMethod() + _ = try await tx!.callContractMethod() } func testAdvancedABIv2staticArrayOfStrings() async throws { @@ -170,7 +166,6 @@ class AdvancedABIv2Tests: LocalTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(Data.fromHex(txHash)!) - switch receipt.status { case .notYetProcessed: @@ -183,7 +178,7 @@ class AdvancedABIv2Tests: LocalTestCase { // MARK: Read data from ABI flow // MARK: - Encoding ABI Data flow let tx = contract.createReadOperation("testStOfDyn") - let _ = try await tx!.callContractMethod() + _ = try await tx!.callContractMethod() } func testEmptyArrayDecoding() async throws { diff --git a/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift b/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift index 632c4c755..d6e59b2b9 100755 --- a/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift +++ b/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift @@ -57,8 +57,6 @@ class BasicLocalNodeTests: LocalTestCase { let balanceBeforeTo = try await web3.eth.getBalance(for: sendToAddress) let balanceBeforeFrom = try await web3.eth.getBalance(for: allAddresses[0]) - - let result = try await sendTx.writeToChain(password: "web3swift", sendRaw: false) let txHash = Data.fromHex(result.hash.stripHexPrefix())! @@ -66,7 +64,6 @@ class BasicLocalNodeTests: LocalTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(txHash) - switch receipt.status { case .notYetProcessed: @@ -76,12 +73,9 @@ class BasicLocalNodeTests: LocalTestCase { } let details = try await web3.eth.transactionDetails(txHash) - let balanceAfterTo = try await web3.eth.getBalance(for: sendToAddress) let balanceAfterFrom = try await web3.eth.getBalance(for: allAddresses[0]) - - XCTAssertEqual(balanceAfterTo - balanceBeforeTo, valueToSend) let txnGasPrice = details.transaction.meta?.gasPrice ?? 0 diff --git a/Tests/web3swiftTests/localTests/DataConversionTests.swift b/Tests/web3swiftTests/localTests/DataConversionTests.swift index 62211ec88..bba7db52d 100644 --- a/Tests/web3swiftTests/localTests/DataConversionTests.swift +++ b/Tests/web3swiftTests/localTests/DataConversionTests.swift @@ -22,15 +22,12 @@ class DataConversionTests: LocalTestCase { func testBase58() throws { let vector = "" - guard let resultDecoded = vector.base58DecodedData else { return XCTFail("base58 decode unexpectedly returned nil") } XCTAssert(resultDecoded.count == 0) - let resultEncoded1 = vector.base58EncodedString XCTAssert(resultEncoded1 == vector) - let arr = resultDecoded.withUnsafeBytes { Array($0) } let resultEncoded2 = arr.base58EncodedString XCTAssert(resultEncoded2 == vector) @@ -41,13 +38,11 @@ class DataConversionTests: LocalTestCase { let vector = "2NEpo7TZRRrLZSi2U" let expected = "Hello World!" - guard let resultDecoded = vector.base58DecodedData else { return XCTFail("base58 decode unexpectedly returned nil") } let arr = resultDecoded.withUnsafeBytes { Array($0) } let str = String(bytes: arr, encoding: .utf8) XCTAssert(str == expected) - let resultEncoded = expected.base58EncodedString XCTAssert(resultEncoded == vector) } @@ -57,13 +52,11 @@ class DataConversionTests: LocalTestCase { let vector = "USm3fpXnKG5EUBx2ndxBDMPVciP5hGey2Jh4NDv6gmeo1LkMeiKrLJUUBk6Z" let expected = "The quick brown fox jumps over the lazy dog." - guard let resultDecoded = vector.base58DecodedData else { return XCTFail("base58 decode unexpectedly returned nil") } let arr = resultDecoded.withUnsafeBytes { Array($0) } let str = String(bytes: arr, encoding: .utf8) XCTAssert(str == expected) - let resultEncoded = expected.base58EncodedString XCTAssert(resultEncoded == vector) } @@ -73,12 +66,10 @@ class DataConversionTests: LocalTestCase { let vector = "111233QC4" let expected = "0x000000287fb4cd" - guard let resultDecoded = vector.base58DecodedData else { return XCTFail("base58 decode unexpectedly returned nil") } let str = resultDecoded.toHexString().addHexPrefix() XCTAssert(str == expected) - let arr = resultDecoded.withUnsafeBytes { Array($0) } let resultEncoded = arr.base58EncodedString XCTAssert(resultEncoded == vector) @@ -89,12 +80,10 @@ class DataConversionTests: LocalTestCase { let vector = "11111111111111111111111111111111" let expected = "0x0000000000000000000000000000000000000000000000000000000000000000" - guard let resultDecoded = vector.base58DecodedData else { return XCTFail("base58 decode unexpectedly returned nil") } let str = resultDecoded.toHexString().addHexPrefix() XCTAssert(str == expected) - let arr = resultDecoded.withUnsafeBytes { Array($0) } let resultEncoded = arr.base58EncodedString XCTAssert(resultEncoded == vector) diff --git a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift index e99dc837b..f070dd5d9 100644 --- a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift +++ b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift @@ -4,7 +4,6 @@ import BigInt @testable import web3swift -@testable import Web3Core class EIP1559BlockTests: LocalTestCase { diff --git a/Tests/web3swiftTests/localTests/EIP67Tests.swift b/Tests/web3swiftTests/localTests/EIP67Tests.swift index 9a105e5b5..de9f694d1 100755 --- a/Tests/web3swiftTests/localTests/EIP67Tests.swift +++ b/Tests/web3swiftTests/localTests/EIP67Tests.swift @@ -18,7 +18,7 @@ class EIP67Tests: LocalTestCase { eip67Data.amount = BigUInt("1000000000000000000") // eip67Data.data = let encoding = eip67Data.toString() - + } func testEIP67codeGeneration() throws { diff --git a/Tests/web3swiftTests/localTests/EventloopTests.swift b/Tests/web3swiftTests/localTests/EventloopTests.swift index 923aaf774..2e8b0df25 100755 --- a/Tests/web3swiftTests/localTests/EventloopTests.swift +++ b/Tests/web3swiftTests/localTests/EventloopTests.swift @@ -21,7 +21,7 @@ class EventloopTests: XCTestCase { expectation.fulfill() } } catch { - + } } diff --git a/Tests/web3swiftTests/localTests/KeystoresTests.swift b/Tests/web3swiftTests/localTests/KeystoresTests.swift index 3348ac9c9..cab2dae5f 100755 --- a/Tests/web3swiftTests/localTests/KeystoresTests.swift +++ b/Tests/web3swiftTests/localTests/KeystoresTests.swift @@ -81,7 +81,7 @@ class KeystoresTests: LocalTestCase { let keystore = try! EthereumKeystoreV3(password: "") XCTAssertNotNil(keystore) let account = keystore!.addresses![0] - + let data = try! keystore!.serialize() let key = try! keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) XCTAssertNotNil(key) @@ -172,7 +172,7 @@ class KeystoresTests: LocalTestCase { let account = keystore!.addresses![1] let key = try! keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) XCTAssertNotNil(key) - + } func testByBIP32keystoreSaveAndDeriva() throws { @@ -186,10 +186,7 @@ class KeystoresTests: LocalTestCase { let recreatedStore = BIP32Keystore.init(data!) XCTAssert(keystore?.addresses?.count == recreatedStore?.addresses?.count) XCTAssert(keystore?.rootPrefix == recreatedStore?.rootPrefix) - - - - + XCTAssert(keystore?.addresses![0] == recreatedStore?.addresses![0]) XCTAssert(keystore?.addresses![1] == recreatedStore?.addresses![1]) } diff --git a/Tests/web3swiftTests/localTests/NumberFormattingUtilTests.swift b/Tests/web3swiftTests/localTests/NumberFormattingUtilTests.swift index e8a95463d..676eb533c 100755 --- a/Tests/web3swiftTests/localTests/NumberFormattingUtilTests.swift +++ b/Tests/web3swiftTests/localTests/NumberFormattingUtilTests.swift @@ -65,7 +65,7 @@ class NumberFormattingUtilTests: LocalTestCase { let formatted = Utilities.formatToPrecision(balance, units: .ether, formattingDecimals: 4, decimalSeparator: ",", fallbackToScientific: true) XCTAssert(formatted == "1,0000e-12") } - + func testFormatPreccissionFallbacksToUnitsDecimals() throws { let bInt = BigInt(1_700_000_000_000_000_000) let result = Utilities.formatToPrecision(bInt, units: .ether, formattingDecimals: Utilities.Units.ether.decimals + 1, decimalSeparator: ",") diff --git a/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift b/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift index 852137efd..d7e567f75 100755 --- a/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift +++ b/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift @@ -19,7 +19,7 @@ class PersonalSignatureTests: XCTestCase { web3.addKeystoreManager(keystoreManager) let message = "Hello World" let expectedAddress = keystoreManager.addresses![0] - + let signature = try await web3.personal.signPersonalMessage(message: message.data(using: .utf8)!, from: expectedAddress, password: "") let unmarshalledSignature = SECP256K1.unmarshalSignature(signatureData: signature)! let signer = try web3.personal.ecrecover(personalMessage: message.data(using: .utf8)!, signature: signature) @@ -44,7 +44,7 @@ class PersonalSignatureTests: XCTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(txHash) - + switch receipt.status { case .notYetProcessed: return @@ -58,7 +58,7 @@ class PersonalSignatureTests: XCTestCase { web3.addKeystoreManager(keystoreManager) let message = "Hello World" let expectedAddress = keystoreManager.addresses![0] - + let signature = try await web3.personal.signPersonalMessage(message: message.data(using: .utf8)!, from: expectedAddress, password: "") let unmarshalledSignature = SECP256K1.unmarshalSignature(signatureData: signature)! diff --git a/Tests/web3swiftTests/localTests/RLPTests.swift b/Tests/web3swiftTests/localTests/RLPTests.swift index a17e41300..e6fa28cc9 100755 --- a/Tests/web3swiftTests/localTests/RLPTests.swift +++ b/Tests/web3swiftTests/localTests/RLPTests.swift @@ -14,6 +14,6 @@ class RLPTests: LocalTestCase { func testRLPdecodeTransaction() throws { let input = Data.fromHex("0xf90890558504e3b292008309153a8080b9083d6060604052336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550341561004f57600080fd5b60405160208061081d83398101604052808051906020019091905050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156100a757600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610725806100f86000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638da5cb5b14610067578063b2b2c008146100bc578063d59ba0df146101eb578063d8ffdcc414610247575b600080fd5b341561007257600080fd5b61007a61029c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156100c757600080fd5b61019460048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919050506102c1565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156101d75780820151818401526020810190506101bc565b505050509050019250505060405180910390f35b34156101f657600080fd5b61022d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080351515906020019091905050610601565b604051808215151515815260200191505060405180910390f35b341561025257600080fd5b61025a6106bf565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6102c96106e5565b6102d16106e5565b6000806000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561032e57600080fd5b8651885114151561033e57600080fd5b875160405180591061034d5750595b9080825280602002602001820160405250935060009250600091505b87518210156105f357600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd87848151811015156103be57fe5b906020019060200201518a858151811015156103d657fe5b906020019060200201518a868151811015156103ee57fe5b906020019060200201516000604051602001526040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15156104b857600080fd5b6102c65a03f115156104c957600080fd5b50505060405180519050905080156105e65787828151811015156104e957fe5b90602001906020020151848481518110151561050157fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508280600101935050868281518110151561055357fe5b90602001906020020151888381518110151561056b57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff16878481518110151561059957fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff167f334b3b1d4ad406523ee8e24beb689f5adbe99883a662c37d43275de52389da1460405160405180910390a45b8180600101925050610369565b839450505050509392505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561065e57600080fd5b81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001905092915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6020604051908101604052806000815250905600a165627a7a723058200618093d895b780d4616f24638637da0e0f9767e6d3675a9525fee1d6ed7f431002900000000000000000000000045245bc59219eeaaf6cd3f382e078a461ff9de7b25a0d1efc3c97d1aa9053aa0f59bf148d73f59764343bf3cae576c8769a14866948da0613d0265634fddd436397bc858e2672653833b57a05cfc8b93c14a6c05166e4a")! let transaction = CodableTransaction(rawValue: input) - + } } diff --git a/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift b/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift index 84782bbeb..fa02a34a6 100644 --- a/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift +++ b/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift @@ -111,7 +111,7 @@ class ST20AndSecurityTokenTests: XCTestCase { func testSecurityTokenGranularity() async throws { let expectedGranularity = BigUInt.randomInteger(lessThan: BigUInt(10000000000)) - + ethMock.onCallTransaction = { transaction in guard let function = self.securityToken.contract.contract.getFunctionCalled(transaction.data) else { XCTFail("Failed to decode function call to determine what shall be returned") diff --git a/Tests/web3swiftTests/localTests/TestHelpers.swift b/Tests/web3swiftTests/localTests/TestHelpers.swift index 674771ec9..19ed587f7 100644 --- a/Tests/web3swiftTests/localTests/TestHelpers.swift +++ b/Tests/web3swiftTests/localTests/TestHelpers.swift @@ -39,7 +39,6 @@ class TestHelpers { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(txHash) - switch receipt.status { case .notYetProcessed: diff --git a/Tests/web3swiftTests/localTests/TransactionsTests.swift b/Tests/web3swiftTests/localTests/TransactionsTests.swift index 7dd9a8e65..932bc1b5f 100755 --- a/Tests/web3swiftTests/localTests/TransactionsTests.swift +++ b/Tests/web3swiftTests/localTests/TransactionsTests.swift @@ -195,7 +195,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -243,7 +243,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -264,7 +264,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -312,7 +312,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -333,7 +333,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -381,7 +381,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -402,7 +402,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -450,7 +450,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -471,7 +471,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -519,7 +519,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -540,7 +540,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -588,7 +588,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -612,16 +612,16 @@ class TransactionsTests: XCTestCase { let publicKey = Utilities.privateToPublic(privateKeyData, compressed: false) let sender = Utilities.publicToAddress(publicKey!) transaction.chainID = 1 - + let hash = transaction.hashForSignature() let expectedHash = "0xdaf5a779ae972f972197303d7b574746c7ef83eadac0f2791ad23db92e4c8e53".stripHexPrefix() XCTAssertEqual(hash!.toHexString(), expectedHash, "Transaction signature failed") try transaction.sign(privateKey: privateKeyData, useExtraEntropy: false) - + XCTAssertEqual(transaction.v, 37, "Transaction signature failed") XCTAssertEqual(sender, transaction.sender) } catch { - + XCTFail() } } @@ -640,12 +640,11 @@ class TransactionsTests: XCTestCase { let policies = Policies(gasLimitPolicy: .manual(78423)) let result = try await writeTX.writeToChain(password: "", policies: policies, sendRaw: false) let txHash = Data.fromHex(result.hash.stripHexPrefix())! - Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(txHash) - + XCTAssert(receipt.status == .ok) switch receipt.status { @@ -656,13 +655,13 @@ class TransactionsTests: XCTestCase { } let details = try await web3.eth.transactionDetails(txHash) - + // FIXME: Re-enable this test. // XCTAssertEqual(details.transaction.gasLimit, BigUInt(78423)) } catch Web3Error.nodeError(let descr) { guard descr == "insufficient funds for gas * price + value" else {return XCTFail()} } catch { - + XCTFail() } } diff --git a/Tests/web3swiftTests/localTests/UncategorizedTests.swift b/Tests/web3swiftTests/localTests/UncategorizedTests.swift index dc5600da9..37c644b3d 100755 --- a/Tests/web3swiftTests/localTests/UncategorizedTests.swift +++ b/Tests/web3swiftTests/localTests/UncategorizedTests.swift @@ -69,7 +69,7 @@ class UncategorizedTests: XCTestCase { bloom.add(BigUInt(data)) let newBytes = bloom.bytes if newBytes != oldBytes { - + } } for str in positive { @@ -118,16 +118,15 @@ class UncategorizedTests: XCTestCase { let userDeviceCount = try await contract! .createReadOperation("userDeviceCount", parameters: [addr as AnyObject])? .callContractMethod() - + let totalUsers = try await contract! .createReadOperation("totalUsers", parameters: [])? .callContractMethod() - + let user = try await contract! .createReadOperation("users", parameters: [0 as AnyObject])? .callContractMethod() - - + } func testBloomFilterPerformance() throws { diff --git a/Tests/web3swiftTests/localTests/UserCases.swift b/Tests/web3swiftTests/localTests/UserCases.swift index 49a95184f..7a56ea0c6 100755 --- a/Tests/web3swiftTests/localTests/UserCases.swift +++ b/Tests/web3swiftTests/localTests/UserCases.swift @@ -26,7 +26,7 @@ class UserCases: XCTestCase { readTransaction.transaction.from = account let response = try await readTransaction.callContractMethod() let balance = response["0"] as? BigUInt - + } func testUserCase2() async { @@ -86,7 +86,7 @@ class UserCases: XCTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(txHash) - + XCTAssert(receipt.contractAddress != nil) switch receipt.status { @@ -97,7 +97,7 @@ class UserCases: XCTestCase { } let details = try await web3.eth.transactionDetails(txHash) - + XCTAssert(details.transaction.to == .contractDeploymentAddress()) } @@ -105,6 +105,6 @@ class UserCases: XCTestCase { let web3 = try await Web3.new(LocalTestCase.url) let address = EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")! let balanceResult = try await web3.eth.getBalance(for: address) - + } } diff --git a/Tests/web3swiftTests/localTests/UtilitiesTests.swift b/Tests/web3swiftTests/localTests/UtilitiesTests.swift index 53a6761fc..3f640bc1b 100644 --- a/Tests/web3swiftTests/localTests/UtilitiesTests.swift +++ b/Tests/web3swiftTests/localTests/UtilitiesTests.swift @@ -10,14 +10,14 @@ import Web3Core @testable import web3swift -class UtilitiesTests: XCTestCase { +class UtilitiesTests: XCTestCase { // MARK: - units - + struct Test { let input: Utilities.Units let output: Int } - + func testUnitsDecimals() throws { let units: [Test] = [.init(input: .wei, output: 0), .init(input: .kwei, output: 3), @@ -41,7 +41,7 @@ class UtilitiesTests: XCTestCase { .init(input: .grand, output: 21), .init(input: .mether, output: 24), .init(input: .gether, output: 27), - .init(input: .tether, output: 30), + .init(input: .tether, output: 30) ] units.forEach { test in XCTAssertEqual(test.input.decimals, test.output) diff --git a/Tests/web3swiftTests/localTests/Web3ErrorTests.swift b/Tests/web3swiftTests/localTests/Web3ErrorTests.swift index c66ff9012..7eba7b8eb 100644 --- a/Tests/web3swiftTests/localTests/Web3ErrorTests.swift +++ b/Tests/web3swiftTests/localTests/Web3ErrorTests.swift @@ -22,4 +22,3 @@ class Web3ErrorTests: XCTestCase { } } - diff --git a/Tests/web3swiftTests/remoteTests/ENSTests.swift b/Tests/web3swiftTests/remoteTests/ENSTests.swift index 052142bd9..55a254848 100755 --- a/Tests/web3swiftTests/remoteTests/ENSTests.swift +++ b/Tests/web3swiftTests/remoteTests/ENSTests.swift @@ -27,7 +27,7 @@ class ENSTests: XCTestCase { let ens = ENS(web3: web3) let domain = "somename.eth" let address = try await ens?.registry.getResolver(forDomain: domain).resolverContractAddress - + XCTAssertEqual(address?.address.lowercased(), "0x4976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41") } diff --git a/Tests/web3swiftTests/remoteTests/EtherscanTransactionCheckerTests.swift b/Tests/web3swiftTests/remoteTests/EtherscanTransactionCheckerTests.swift index c58d2fa44..88de5f92b 100644 --- a/Tests/web3swiftTests/remoteTests/EtherscanTransactionCheckerTests.swift +++ b/Tests/web3swiftTests/remoteTests/EtherscanTransactionCheckerTests.swift @@ -13,7 +13,7 @@ final class EtherscanTransactionCheckerTests: XCTestCase { func testHasTransactions() async throws { let sut = EtherscanTransactionChecker(urlSession: URLSession.shared, apiKey: testApiKey) - + let result = try await sut.hasTransactions(ethereumAddress: try XCTUnwrap(EthereumAddress(vitaliksAddress))) XCTAssertTrue(result) diff --git a/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift b/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift index 7e10946a5..f84324794 100644 --- a/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift +++ b/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift @@ -27,8 +27,7 @@ final class PolicyResolverTests: XCTestCase { tx.from = EthereumAddress("0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B")! let policies = Policies(gasLimitPolicy: .manual(21_000)) try await resolver.resolveAll(for: &tx, with: policies) - - + XCTAssertGreaterThan(tx.gasLimit, 0) XCTAssertGreaterThan(tx.maxFeePerGas ?? 0, 0) XCTAssertGreaterThan(tx.maxPriorityFeePerGas ?? 0, 0) @@ -49,8 +48,7 @@ final class PolicyResolverTests: XCTestCase { tx.from = EthereumAddress("0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B")! let policies = Policies(gasLimitPolicy: .manual(21_000)) try await resolver.resolveAll(for: &tx, with: policies) - - + XCTAssertGreaterThan(tx.gasLimit, 0) XCTAssertGreaterThan(tx.gasPrice ?? 0, 0) XCTAssertGreaterThan(tx.nonce, 0) From c86697cf24f4dc5cd929db29e034bdfdffb691b8 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Thu, 2 Feb 2023 18:09:17 +0200 Subject: [PATCH 049/210] chore: swiftlint --fix --- .../Tokens/ERC1400/Web3+ERC1400.swift | 258 +++++++++--------- .../Tokens/ERC1410/Web3+ERC1410.swift | 178 ++++++------ .../Tokens/ERC1594/Web3+ERC1594.swift | 104 +++---- .../Tokens/ERC1633/Web3+ERC1633.swift | 62 ++--- .../Tokens/ERC1643/Web3+ERC1643.swift | 60 ++-- .../Tokens/ERC1644/Web3+ERC1644.swift | 64 ++--- Sources/web3swift/Tokens/ST20/Web3+ST20.swift | 74 ++--- .../Utils/ENS/ETHRegistrarController.swift | 20 +- Sources/web3swift/Web3/Web3+Signing.swift | 6 +- .../localTests/ABIEncoderTest.swift | 8 +- 10 files changed, 417 insertions(+), 417 deletions(-) diff --git a/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift b/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift index df0874a93..b800f70bd 100644 --- a/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift +++ b/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift @@ -10,49 +10,49 @@ import Web3Core // Security Token Standard protocol IERC1400: IERC20 { - + // Document Management func getDocument(name: Data) async throws -> (String, Data) func setDocument(from: EthereumAddress, name: Data, uri: String, documentHash: Data) async throws -> WriteOperation - + // Token Information func balanceOfByPartition(partition: Data, tokenHolder: EthereumAddress) async throws -> BigUInt func partitionsOf(tokenHolder: EthereumAddress) async throws -> [Data] - + // Transfers func transferWithData(from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func transferFromWithData(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation - + // Partition Token Transfers func transferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func operatorTransferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation - + // Controller Operation func isControllable() async throws -> Bool func controllerTransfer(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation func controllerRedeem(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation - + // Operator Management func authorizeOperator(from: EthereumAddress, operator user: EthereumAddress) async throws -> WriteOperation func revokeOperator(from: EthereumAddress, operator user: EthereumAddress) async throws -> WriteOperation func authorizeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) async throws -> WriteOperation func revokeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) async throws -> WriteOperation - + // Operator Information func isOperator(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool func isOperatorForPartition(partition: Data, operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool - + // Token Issuance func isIssuable() async throws -> Bool func issue(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func issueByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation - + // Token Redemption func redeem(from: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func redeemFrom(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func redeemByPartition(from: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> WriteOperation func operatorRedeemByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, operatorData: [UInt8]) async throws -> WriteOperation - + // Transfer Validity func canTransfer(to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) func canTransferFrom(originalOwner: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) @@ -70,9 +70,9 @@ public class ERC1400: IERC1400, ERC20BaseProperties { public var provider: Web3Provider public var address: EthereumAddress public var abi: String - + public let contract: Web3.Contract - + public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.erc1400ABI, transaction: CodableTransaction = .emptyTransaction) { self.web3 = web3 self.provider = provider @@ -84,21 +84,21 @@ public class ERC1400: IERC1400, ERC20BaseProperties { contract = web3.contract(abi, at: address)! basePropertiesProvider = ERC20BasePropertiesProvider(contract: contract) } - + public func getBalance(account: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOf", parameters: [account])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -108,16 +108,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } - + public func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -127,16 +127,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } - + public func setAllowance(from: EthereumAddress, to: EthereumAddress, newAmount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -146,23 +146,23 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(newAmount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } - + public func totalSupply() async throws -> BigUInt { let result = try await contract.createReadOperation("totalSupply")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -172,44 +172,44 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } - + // ERC1400 methods public func getDocument(name: Data) async throws -> (String, Data) { let result = try await contract.createReadOperation("getDocument", parameters: [name])!.callContractMethod() - + guard let res = result["0"] as? (String, Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func setDocument(from: EthereumAddress, name: Data, uri: String, documentHash: Data) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("setDocument", parameters: [name, uri, documentHash])! return tx } - + public func balanceOfByPartition(partition: Data, tokenHolder: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOfByPartition", parameters: [partition, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func partitionsOf(tokenHolder: EthereumAddress) async throws -> [Data] { let result = try await contract.createReadOperation("partitionsOf", parameters: [tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? [Data] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transferWithData(from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -219,16 +219,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferWithData", parameters: [to, value, data])! return tx } - + public func transferFromWithData(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -238,16 +238,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFromWithData", parameters: [originalOwner, to, value, data])! return tx } - + public func transferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -257,16 +257,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferByPartition", parameters: [partition, to, value, data])! return tx } - + public func operatorTransferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -276,23 +276,23 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("operatorTransferByPartition", parameters: [partition, originalOwner, to, value, data, operatorData])! return tx } - + public func isControllable() async throws -> Bool { let result = try await contract.createReadOperation("isControllable")!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func controllerTransfer(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -302,16 +302,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("controllerTransfer", parameters: [originalOwner, to, value, data, operatorData])! return tx } - + public func controllerRedeem(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -321,61 +321,61 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("controllerRedeem", parameters: [tokenHolder, value, data, operatorData])! return tx } - + public func authorizeOperator(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("authorizeOperator", parameters: [user])! return tx } - + public func revokeOperator(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("revokeOperator", parameters: [user])! return tx } - + public func authorizeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("authorizeOperatorByPartition", parameters: [partition, user])! return tx } - + public func revokeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("revokeOperatorByPartition", parameters: [partition, user])! return tx } - + public func isOperator(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let result = try await contract.createReadOperation("isOperator", parameters: [user, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func isOperatorForPartition(partition: Data, operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let result = try await contract.createReadOperation("isOperatorForPartition", parameters: [partition, user, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func isIssuable() async throws -> Bool { let result = try await contract.createReadOperation("isIssuable")!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func issue(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -385,16 +385,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("issue", parameters: [tokenHolder, value, data])! return tx } - + public func issueByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -404,16 +404,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("issueByPartition", parameters: [partition, tokenHolder, value, data])! return tx } - + public func redeem(from: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -423,16 +423,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("redeem", parameters: [value, data])! return tx } - + public func redeemFrom(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -442,16 +442,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("redeemFrom", parameters: [tokenHolder, value, data])! return tx } - + public func redeemByPartition(from: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -461,16 +461,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("redeemByPartition", parameters: [partition, value, data])! return tx } - + public func operatorRedeemByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -480,16 +480,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("operatorRedeemByPartition", parameters: [partition, tokenHolder, value, operatorData])! return tx } - + public func canTransfer(to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) { // get the decimals manually let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() @@ -497,18 +497,18 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let result = try await contract.createReadOperation("canTransfer", parameters: [to, value, data])!.callContractMethod() - + guard let res = result["0"] as? ([UInt8], Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func canTransferFrom(originalOwner: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) { // get the decimals manually let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() @@ -516,18 +516,18 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, value, data])!.callContractMethod() - + guard let res = result["0"] as? ([UInt8], Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func canTransferByPartition(originalOwner: EthereumAddress, to: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> ([UInt8], Data, Data) { // get the decimals manually let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() @@ -535,14 +535,14 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, partition, value, data])!.callContractMethod() - + guard let res = result["0"] as? ([UInt8], Data, Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -551,85 +551,85 @@ public class ERC1400: IERC1400, ERC20BaseProperties { extension ERC1400: IERC777 { public func canImplementInterfaceForAddress(interfaceHash: Data, addr: EthereumAddress) async throws -> Data { let result = try await contract.createReadOperation("canImplementInterfaceForAddress", parameters: [interfaceHash, addr])!.callContractMethod() - + guard let res = result["0"] as? Data else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getInterfaceImplementer(addr: EthereumAddress, interfaceHash: Data) async throws -> EthereumAddress { let result = try await contract.createReadOperation("getInterfaceImplementer", parameters: [addr, interfaceHash])!.callContractMethod() - + guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func setInterfaceImplementer(from: EthereumAddress, addr: EthereumAddress, interfaceHash: Data, implementer: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer])! return tx } - + public func setManager(from: EthereumAddress, addr: EthereumAddress, newManager: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager])! return tx } - + public func interfaceHash(interfaceName: String) async throws -> Data { let result = try await contract.createReadOperation("interfaceHash", parameters: [interfaceName])!.callContractMethod() - + guard let res = result["0"] as? Data else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func updateERC165Cache(from: EthereumAddress, contract: EthereumAddress, interfaceId: [UInt8]) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = self.contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId])! return tx } - + public func supportsInterface(interfaceID: String) async throws -> Bool { let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getGranularity() async throws -> BigUInt { let result = try await contract.createReadOperation("granularity")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getDefaultOperators() async throws -> [EthereumAddress] { let result = try await contract.createReadOperation("defaultOperators")!.callContractMethod() - + guard let res = result["0"] as? [EthereumAddress] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func authorize(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("authorizeOperator", parameters: [user])! return tx } - + public func revoke(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("revokeOperator", parameters: [user])! return tx } - + public func isOperatorFor(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let result = try await contract.createReadOperation("isOperatorFor", parameters: [user, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func send(from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -639,16 +639,16 @@ extension ERC1400: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("send", parameters: [to, value, data])! return tx } - + public func operatorSend(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -658,16 +658,16 @@ extension ERC1400: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData])! return tx } - + public func burn(from: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -677,16 +677,16 @@ extension ERC1400: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("burn", parameters: [value, data])! return tx } - + public func operatorBurn(from: EthereumAddress, amount: String, originalOwner: EthereumAddress, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -696,12 +696,12 @@ extension ERC1400: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData])! return tx } @@ -710,11 +710,11 @@ extension ERC1400: IERC777 { // MARK: - Private extension ERC1400 { - + private func updateTransactionAndContract(from: EthereumAddress) { transaction.from = from transaction.to = address contract.transaction = transaction } - + } diff --git a/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift b/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift index ed947f435..ad4ae54b0 100644 --- a/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift +++ b/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift @@ -11,33 +11,33 @@ import Web3Core // Partially Fungible Token Standard protocol IERC1410: IERC20 { - + // Token Information func getBalance(account: EthereumAddress) async throws -> BigUInt func balanceOfByPartition(partition: Data, tokenHolder: EthereumAddress) async throws -> BigUInt func partitionsOf(tokenHolder: EthereumAddress) async throws -> [Data] func totalSupply() async throws -> BigUInt - + // Token Transfers func transferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func operatorTransferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation func canTransferByPartition(originalOwner: EthereumAddress, to: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> ([UInt8], Data, Data) - + // Operator Information func isOperator(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool func isOperatorForPartition(partition: Data, operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool - + // Operator Management func authorizeOperator(from: EthereumAddress, operator user: EthereumAddress) async throws -> WriteOperation func revokeOperator(from: EthereumAddress, operator user: EthereumAddress) async throws -> WriteOperation func authorizeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) async throws -> WriteOperation func revokeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) async throws -> WriteOperation - + // Issuance / Redemption func issueByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func redeemByPartition(from: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> WriteOperation func operatorRedeemByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, operatorData: [UInt8]) async throws -> WriteOperation - + } // FIXME: Rewrite this to CodableTransaction @@ -48,9 +48,9 @@ public class ERC1410: IERC1410, ERC20BaseProperties { public var provider: Web3Provider public var address: EthereumAddress public var abi: String - + public let contract: Web3.Contract - + public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.erc1410ABI, transaction: CodableTransaction = .emptyTransaction) { self.web3 = web3 self.provider = provider @@ -62,21 +62,21 @@ public class ERC1410: IERC1410, ERC20BaseProperties { contract = web3.contract(abi, at: address)! basePropertiesProvider = ERC20BasePropertiesProvider(contract: contract) } - + public func getBalance(account: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOf", parameters: [account])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -86,16 +86,16 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } - + public func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -105,16 +105,16 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } - + public func setAllowance(from: EthereumAddress, to: EthereumAddress, newAmount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -124,23 +124,23 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(newAmount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } - + public func totalSupply() async throws -> BigUInt { let result = try await contract.createReadOperation("totalSupply")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -150,31 +150,31 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } - + // ERC1410 methods public func balanceOfByPartition(partition: Data, tokenHolder: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOfByPartition", parameters: [partition, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func partitionsOf(tokenHolder: EthereumAddress) async throws -> [Data] { let result = try await contract.createReadOperation("partitionsOf", parameters: [tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? [Data] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -184,16 +184,16 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferByPartition", parameters: [partition, to, value, data])! return tx } - + public func operatorTransferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -203,16 +203,16 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("operatorTransferByPartition", parameters: [partition, originalOwner, to, value, data, operatorData])! return tx } - + public func canTransferByPartition(originalOwner: EthereumAddress, to: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> ([UInt8], Data, Data) { // get the decimals manually let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() @@ -220,56 +220,56 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, partition, value, data])!.callContractMethod() - + guard let res = result["0"] as? ([UInt8], Data, Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func isOperator(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let result = try await contract.createReadOperation("isOperator", parameters: [user, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func isOperatorForPartition(partition: Data, operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let result = try await contract.createReadOperation("isOperatorForPartition", parameters: [partition, user, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func authorizeOperator(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("authorizeOperator", parameters: [user])! return tx } - + public func revokeOperator(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("revokeOperator", parameters: [user])! return tx } - + public func authorizeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("authorizeOperatorByPartition", parameters: [partition, user])! return tx } - + public func revokeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("revokeOperatorByPartition", parameters: [partition, user])! return tx } - + public func issueByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -279,16 +279,16 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("issueByPartition", parameters: [partition, tokenHolder, value, data])! return tx } - + public func redeemByPartition(from: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -298,16 +298,16 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("redeemByPartition", parameters: [partition, value, data])! return tx } - + public func operatorRedeemByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -317,12 +317,12 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("operatorRedeemByPartition", parameters: [partition, tokenHolder, value, operatorData])! return tx } @@ -331,72 +331,72 @@ public class ERC1410: IERC1410, ERC20BaseProperties { extension ERC1410: IERC777 { public func canImplementInterfaceForAddress(interfaceHash: Data, addr: EthereumAddress) async throws -> Data { let result = try await contract.createReadOperation("canImplementInterfaceForAddress", parameters: [interfaceHash, addr])!.callContractMethod() - + guard let res = result["0"] as? Data else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getInterfaceImplementer(addr: EthereumAddress, interfaceHash: Data) async throws -> EthereumAddress { let result = try await contract.createReadOperation("getInterfaceImplementer", parameters: [addr, interfaceHash])!.callContractMethod() - + guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func setInterfaceImplementer(from: EthereumAddress, addr: EthereumAddress, interfaceHash: Data, implementer: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer])! return tx } - + public func setManager(from: EthereumAddress, addr: EthereumAddress, newManager: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager])! return tx } - + public func interfaceHash(interfaceName: String) async throws -> Data { let result = try await contract.createReadOperation("interfaceHash", parameters: [interfaceName])!.callContractMethod() - + guard let res = result["0"] as? Data else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func updateERC165Cache(from: EthereumAddress, contract: EthereumAddress, interfaceId: [UInt8]) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = self.contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId])! return tx } - + public func supportsInterface(interfaceID: String) async throws -> Bool { transaction.callOnBlock = .latest let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func authorize(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("authorizeOperator", parameters: [user])! return tx } - + public func revoke(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("revokeOperator", parameters: [user])! return tx } - + public func isOperatorFor(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let result = try await contract.createReadOperation("isOperatorFor", parameters: [user, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func send(from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -406,16 +406,16 @@ extension ERC1410: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("send", parameters: [to, value, data])! return tx } - + public func operatorSend(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -425,16 +425,16 @@ extension ERC1410: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData])! return tx } - + public func burn(from: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -444,16 +444,16 @@ extension ERC1410: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("burn", parameters: [value, data])! return tx } - + public func operatorBurn(from: EthereumAddress, amount: String, originalOwner: EthereumAddress, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -463,26 +463,26 @@ extension ERC1410: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData])! return tx } - + public func getGranularity() async throws -> BigUInt { let result = try await contract.createReadOperation("granularity")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getDefaultOperators() async throws -> [EthereumAddress] { let result = try await contract.createReadOperation("defaultOperators")!.callContractMethod() - + guard let res = result["0"] as? [EthereumAddress] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -491,11 +491,11 @@ extension ERC1410: IERC777 { // MARK: - Private extension ERC1410 { - + private func updateTransactionAndContract(from: EthereumAddress) { transaction.from = from transaction.to = address contract.transaction = transaction } - + } diff --git a/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift b/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift index 3e83074d8..07dba9fc7 100644 --- a/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift +++ b/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift @@ -11,23 +11,23 @@ import Web3Core // Core Security Token Standard protocol IERC1594: IERC20 { - + // Transfers func transferWithData(from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func transferFromWithData(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation - + // Token Issuance func isIssuable() async throws -> Bool func issue(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation - + // Token Redemption func redeem(from: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func redeemFrom(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation - + // Transfer Validity func canTransfer(to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) func canTransferFrom(originalOwner: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) - + } // FIXME: Rewrite this to CodableTransaction @@ -38,9 +38,9 @@ public class ERC1594: IERC1594, ERC20BaseProperties { public var provider: Web3Provider public var address: EthereumAddress public var abi: String - + public let contract: Web3.Contract - + public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.erc1594ABI, transaction: CodableTransaction = .emptyTransaction) { self.web3 = web3 self.provider = provider @@ -52,21 +52,21 @@ public class ERC1594: IERC1594, ERC20BaseProperties { contract = web3.contract(abi, at: address)! basePropertiesProvider = ERC20BasePropertiesProvider(contract: contract) } - + public func getBalance(account: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOf", parameters: [account])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { updateTransactionAndContract(from: from) // get the decimals manually @@ -75,16 +75,16 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } - + public func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -94,16 +94,16 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } - + public func setAllowance(from: EthereumAddress, to: EthereumAddress, newAmount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -113,23 +113,23 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(newAmount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } - + public func totalSupply() async throws -> BigUInt { let result = try await contract.createReadOperation("totalSupply")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -139,16 +139,16 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } - + // ERC1594 public func transferWithData(from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest @@ -159,16 +159,16 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferWithData", parameters: [to, value, data])! return tx } - + public func transferFromWithData(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -178,23 +178,23 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFromWithData", parameters: [originalOwner, to, value, data])! return tx } - + public func isIssuable() async throws -> Bool { let result = try await contract.createReadOperation("isIssuable")!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func issue(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -204,16 +204,16 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("issue", parameters: [tokenHolder, value, data])! return tx } - + public func redeem(from: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -223,16 +223,16 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("redeem", parameters: [value, data])! return tx } - + public func redeemFrom(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -242,16 +242,16 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("redeemFrom", parameters: [tokenHolder, value, data])! return tx } - + public func canTransfer(to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) { // get the decimals manually let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() @@ -259,18 +259,18 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let result = try await contract.createReadOperation("canTransfer", parameters: [to, value, data])!.callContractMethod() - + guard let res = result["0"] as? ([UInt8], Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func canTransferFrom(originalOwner: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) { // get the decimals manually let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() @@ -278,14 +278,14 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, value, data])!.callContractMethod() - + guard let res = result["0"] as? ([UInt8], Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -294,11 +294,11 @@ public class ERC1594: IERC1594, ERC20BaseProperties { // MARK: - Private extension ERC1594 { - + private func updateTransactionAndContract(from: EthereumAddress) { transaction.from = from transaction.to = address contract.transaction = transaction } - + } diff --git a/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift b/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift index e7551fce1..dfc2ed271 100644 --- a/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift +++ b/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift @@ -12,10 +12,10 @@ import Web3Core // Re-Fungible Token Standard (RFT) // FIXME: Rewrite this to CodableTransaction protocol IERC1633: IERC20, IERC165 { - + func parentToken() async throws -> EthereumAddress func parentTokenId() async throws -> BigUInt - + } public class ERC1633: IERC1633, ERC20BaseProperties { @@ -25,9 +25,9 @@ public class ERC1633: IERC1633, ERC20BaseProperties { public var provider: Web3Provider public var address: EthereumAddress public var abi: String - + public let contract: Web3.Contract - + public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.erc1633ABI, transaction: CodableTransaction = .emptyTransaction) { self.web3 = web3 self.provider = provider @@ -39,21 +39,21 @@ public class ERC1633: IERC1633, ERC20BaseProperties { contract = web3.contract(abi, at: address)! basePropertiesProvider = ERC20BasePropertiesProvider(contract: contract) } - + public func getBalance(account: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOf", parameters: [account])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -63,16 +63,16 @@ public class ERC1633: IERC1633, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } - + public func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -82,16 +82,16 @@ public class ERC1633: IERC1633, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } - + public func setAllowance(from: EthereumAddress, to: EthereumAddress, newAmount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -101,23 +101,23 @@ public class ERC1633: IERC1633, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(newAmount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } - + public func totalSupply() async throws -> BigUInt { let result = try await contract.createReadOperation("totalSupply")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -127,47 +127,47 @@ public class ERC1633: IERC1633, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } - + func parentToken() async throws -> EthereumAddress { let result = try await contract.createReadOperation("parentToken")!.callContractMethod() - + guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + func parentTokenId() async throws -> BigUInt { let result = try await contract.createReadOperation("parentTokenId")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func supportsInterface(interfaceID: String) async throws -> Bool { let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + } // MARK: - Private extension ERC1633 { - + private func updateTransactionAndContract(from: EthereumAddress) { transaction.from = from transaction.to = address contract.transaction = transaction } - + } diff --git a/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift b/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift index ce8b2c2a8..c70ae346d 100644 --- a/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift +++ b/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift @@ -11,13 +11,13 @@ import Web3Core // Document Management Standard protocol IERC1643: IERC20 { - + // Document Management func getDocument(name: Data) async throws -> (String, Data) func setDocument(from: EthereumAddress, name: Data, uri: String, documentHash: Data) async throws -> WriteOperation func removeDocument(from: EthereumAddress, name: Data) async throws -> WriteOperation func getAllDocuments() async throws -> [Data] - + } // FIXME: Rewrite this to CodableTransaction @@ -28,9 +28,9 @@ public class ERC1643: IERC1643, ERC20BaseProperties { public var provider: Web3Provider public var address: EthereumAddress public var abi: String - + public let contract: Web3.Contract - + public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.erc1643ABI, transaction: CodableTransaction = .emptyTransaction) { self.web3 = web3 self.provider = provider @@ -42,21 +42,21 @@ public class ERC1643: IERC1643, ERC20BaseProperties { contract = web3.contract(abi, at: address)! basePropertiesProvider = ERC20BasePropertiesProvider(contract: contract) } - + public func getBalance(account: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOf", parameters: [account])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -66,16 +66,16 @@ public class ERC1643: IERC1643, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } - + public func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -85,16 +85,16 @@ public class ERC1643: IERC1643, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } - + public func setAllowance(from: EthereumAddress, to: EthereumAddress, newAmount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -104,23 +104,23 @@ public class ERC1643: IERC1643, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(newAmount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } - + public func totalSupply() async throws -> BigUInt { let result = try await contract.createReadOperation("totalSupply")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -130,39 +130,39 @@ public class ERC1643: IERC1643, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } - + // ERC1643 methods public func getDocument(name: Data) async throws -> (String, Data) { let result = try await contract.createReadOperation("getDocument", parameters: [name])!.callContractMethod() - + guard let res = result["0"] as? (String, Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func setDocument(from: EthereumAddress, name: Data, uri: String, documentHash: Data) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("setDocument", parameters: [name, uri, documentHash])! return tx } - + public func removeDocument(from: EthereumAddress, name: Data) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("removeDocument", parameters: [name])! return tx } - + public func getAllDocuments() async throws -> [Data] { let result = try await contract.createReadOperation("getAllDocuments")!.callContractMethod() - + guard let res = result["0"] as? [Data] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -171,11 +171,11 @@ public class ERC1643: IERC1643, ERC20BaseProperties { // MARK: - Private extension ERC1643 { - + private func updateTransactionAndContract(from: EthereumAddress) { transaction.from = from transaction.to = address contract.transaction = transaction } - + } diff --git a/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift b/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift index 1acaf69a1..31e5795d8 100644 --- a/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift +++ b/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift @@ -11,12 +11,12 @@ import Web3Core // Controller Token Operation Standard protocol IERC1644: IERC20 { - + // Controller Operation func isControllable() async throws -> Bool func controllerTransfer(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation func controllerRedeem(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation - + } // FIXME: Rewrite this to CodableTransaction @@ -27,9 +27,9 @@ public class ERC1644: IERC1644, ERC20BaseProperties { public var provider: Web3Provider public var address: EthereumAddress public var abi: String - + public let contract: Web3.Contract - + public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.erc1644ABI, transaction: CodableTransaction = .emptyTransaction) { self.web3 = web3 self.provider = provider @@ -41,21 +41,21 @@ public class ERC1644: IERC1644, ERC20BaseProperties { contract = web3.contract(abi, at: address)! basePropertiesProvider = ERC20BasePropertiesProvider(contract: contract) } - + public func getBalance(account: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOf", parameters: [account])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -65,16 +65,16 @@ public class ERC1644: IERC1644, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } - + public func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -84,16 +84,16 @@ public class ERC1644: IERC1644, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } - + public func setAllowance(from: EthereumAddress, to: EthereumAddress, newAmount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -103,23 +103,23 @@ public class ERC1644: IERC1644, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(newAmount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } - + public func totalSupply() async throws -> BigUInt { let result = try await contract.createReadOperation("totalSupply")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -129,24 +129,24 @@ public class ERC1644: IERC1644, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } - + // ERC1644 public func isControllable() async throws -> Bool { let result = try await contract.createReadOperation("isControllable")!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func controllerTransfer(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -156,16 +156,16 @@ public class ERC1644: IERC1644, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("controllerTransfer", parameters: [originalOwner, to, value, data, operatorData])! return tx } - + public func controllerRedeem(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -175,12 +175,12 @@ public class ERC1644: IERC1644, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("controllerRedeem", parameters: [tokenHolder, value, data, operatorData])! return tx } @@ -189,11 +189,11 @@ public class ERC1644: IERC1644, ERC20BaseProperties { // MARK: - Private extension ERC1644 { - + private func updateTransactionAndContract(from: EthereumAddress) { transaction.from = from transaction.to = address contract.transaction = transaction } - + } diff --git a/Sources/web3swift/Tokens/ST20/Web3+ST20.swift b/Sources/web3swift/Tokens/ST20/Web3+ST20.swift index 52f603380..b3688bd9e 100644 --- a/Sources/web3swift/Tokens/ST20/Web3+ST20.swift +++ b/Sources/web3swift/Tokens/ST20/Web3+ST20.swift @@ -13,13 +13,13 @@ import Web3Core protocol IST20: IERC20 { // off-chain hash func tokenDetails() async throws -> [UInt32] - + // transfer, transferFrom must respect the result of verifyTransfer func verifyTransfer(from: EthereumAddress, originalOwner: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation - + // used to create tokens func mint(from: EthereumAddress, investor: EthereumAddress, amount: String) async throws -> WriteOperation - + // Burn function used to burn the securityToken func burn(from: EthereumAddress, amount: String) async throws -> WriteOperation } @@ -34,9 +34,9 @@ public class ST20: IST20, ERC20BaseProperties { public var provider: Web3Provider public var address: EthereumAddress public var abi: String - + public let contract: Web3.Contract - + public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.st20ABI, transaction: CodableTransaction = .emptyTransaction) { self.web3 = web3 self.provider = provider @@ -48,14 +48,14 @@ public class ST20: IST20, ERC20BaseProperties { contract = web3.contract(abi, at: address)! basePropertiesProvider = ERC20BasePropertiesProvider(contract: contract) } - + func tokenDetails() async throws -> [UInt32] { let result = try await contract.createReadOperation("tokenDetails")!.callContractMethod() - + guard let res = result["0"] as? [UInt32] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + func verifyTransfer(from: EthereumAddress, originalOwner: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -65,16 +65,16 @@ public class ST20: IST20, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("verifyTransfer", parameters: [originalOwner, to, value])! return tx } - + func mint(from: EthereumAddress, investor: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -84,16 +84,16 @@ public class ST20: IST20, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("mint", parameters: [investor, value])! return tx } - + public func burn(from: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -103,30 +103,30 @@ public class ST20: IST20, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("burn", parameters: [value])! return tx } - + public func getBalance(account: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOf", parameters: [account])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -136,16 +136,16 @@ public class ST20: IST20, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } - + public func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -155,16 +155,16 @@ public class ST20: IST20, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } - + public func setAllowance(from: EthereumAddress, to: EthereumAddress, newAmount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -174,16 +174,16 @@ public class ST20: IST20, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(newAmount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } - + public func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -193,33 +193,33 @@ public class ST20: IST20, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } - + public func totalSupply() async throws -> BigUInt { let result = try await contract.createReadOperation("totalSupply")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + } // MARK: - Private extension ST20 { - + private func updateTransactionAndContract(from: EthereumAddress) { transaction.from = from transaction.to = address contract.transaction = transaction } - + } diff --git a/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift b/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift index 8802d5c33..6fdda1e12 100644 --- a/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift +++ b/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift @@ -13,7 +13,7 @@ public extension ENS { class ETHRegistrarController { public let web3: Web3 public let address: EthereumAddress - + lazy var contract: Web3.Contract = { let contract = self.web3.contract(Web3.Utils.ethRegistrarControllerABI, at: self.address, abiVersion: 2) precondition(contract != nil) @@ -23,47 +23,47 @@ public extension ENS { lazy var defaultTransaction: CodableTransaction = { return CodableTransaction.emptyTransaction }() - + public init(web3: Web3, address: EthereumAddress) { self.web3 = web3 self.address = address } - + public func getRentPrice(name: String, duration: UInt) async throws -> BigUInt { guard let transaction = self.contract.createReadOperation("rentPrice", parameters: [name, duration]) else { throw Web3Error.transactionSerializationError } guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let price = result["0"] as? BigUInt else { throw Web3Error.processingError(desc: "Can't get answer") } return price } - + public func checkNameValidity(name: String) async throws -> Bool { guard let transaction = self.contract.createReadOperation("valid", parameters: [name]) else { throw Web3Error.transactionSerializationError } guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let valid = result["0"] as? Bool else { throw Web3Error.processingError(desc: "Can't get answer") } return valid } - + public func isNameAvailable(name: String) async throws -> Bool { guard let transaction = self.contract.createReadOperation("available", parameters: [name]) else { throw Web3Error.transactionSerializationError } guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let available = result["0"] as? Bool else { throw Web3Error.processingError(desc: "Can't get answer") } return available } - + public func calculateCommitmentHash(name: String, owner: EthereumAddress, secret: String) async throws -> Data { guard let transaction = self.contract.createReadOperation("makeCommitment", parameters: [name, owner.address, secret]) else { throw Web3Error.transactionSerializationError } guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let hash = result["0"] as? Data else { throw Web3Error.processingError(desc: "Can't get answer") } return hash } - + public func sumbitCommitment(from: EthereumAddress, commitment: Data) throws -> WriteOperation { defaultTransaction.from = from defaultTransaction.to = self.address guard let transaction = self.contract.createWriteOperation("commit", parameters: [commitment]) else { throw Web3Error.transactionSerializationError } return transaction } - + public func registerName(from: EthereumAddress, name: String, owner: EthereumAddress, duration: UInt, secret: String, price: String) throws -> WriteOperation { guard let amount = Utilities.parseToBigUInt(price, units: .ether) else {throw Web3Error.inputError(desc: "Wrong price: no way for parsing to ether units")} defaultTransaction.value = amount @@ -72,7 +72,7 @@ public extension ENS { guard let transaction = self.contract.createWriteOperation("register", parameters: [name, owner.address, duration, secret]) else { throw Web3Error.transactionSerializationError } return transaction } - + public func extendNameRegistration(from: EthereumAddress, name: String, duration: UInt32, price: String) throws -> WriteOperation { guard let amount = Utilities.parseToBigUInt(price, units: .ether) else {throw Web3Error.inputError(desc: "Wrong price: no way for parsing to ether units")} defaultTransaction.value = amount @@ -81,7 +81,7 @@ public extension ENS { guard let transaction = self.contract.createWriteOperation("renew", parameters: [name, duration]) else { throw Web3Error.transactionSerializationError } return transaction } - + @available(*, message: "Available for only owner") public func withdraw(from: EthereumAddress) throws -> WriteOperation { defaultTransaction.from = from diff --git a/Sources/web3swift/Web3/Web3+Signing.swift b/Sources/web3swift/Web3/Web3+Signing.swift index d1b57f270..2e135c6c0 100755 --- a/Sources/web3swift/Web3/Web3+Signing.swift +++ b/Sources/web3swift/Web3/Web3+Signing.swift @@ -18,7 +18,7 @@ public struct Web3Signer { defer { Data.zero(&privateKey) } try transaction.sign(privateKey: privateKey, useExtraEntropy: useExtraEntropy) } - + public static func signPersonalMessage(_ personalMessage: Data, keystore: T, account: EthereumAddress, @@ -32,14 +32,14 @@ public struct Web3Signer { useExtraEntropy: useExtraEntropy) return compressedSignature } - + public static func signEIP712(_ eip712Hashable: EIP712Hashable, keystore: BIP32Keystore, verifyingContract: EthereumAddress, account: EthereumAddress, password: String? = nil, chainId: BigUInt? = nil) throws -> Data { - + let domainSeparator: EIP712Hashable = EIP712Domain(chainId: chainId, verifyingContract: verifyingContract) let hash = try eip712encode(domainSeparator: domainSeparator, message: eip712Hashable) guard let signature = try Web3Signer.signPersonalMessage(hash, diff --git a/Tests/web3swiftTests/localTests/ABIEncoderTest.swift b/Tests/web3swiftTests/localTests/ABIEncoderTest.swift index 01cfecb81..1cf414247 100644 --- a/Tests/web3swiftTests/localTests/ABIEncoderTest.swift +++ b/Tests/web3swiftTests/localTests/ABIEncoderTest.swift @@ -190,12 +190,12 @@ class ABIEncoderTest: XCTestCase { var hexData = ABIEncoder.encode(types: [.string], values: ["test"])?.toHexString() XCTAssertEqual(hexData?[0..<64], "0000000000000000000000000000000000000000000000000000000000000020") XCTAssertEqual(hexData, "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000047465737400000000000000000000000000000000000000000000000000000000") - hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 0)], values: [[1,2,3,4]])?.toHexString() + hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 0)], values: [[1, 2, 3, 4]])?.toHexString() XCTAssertEqual(hexData?[0..<64], "0000000000000000000000000000000000000000000000000000000000000020") XCTAssertEqual(hexData, "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004") // This one shouldn't have data offset - hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 4)], values: [[1,2,3,4]])?.toHexString() + hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 4)], values: [[1, 2, 3, 4]])?.toHexString() // First 32 bytes are the first value from the array XCTAssertEqual(hexData?[0..<64], "0000000000000000000000000000000000000000000000000000000000000001") XCTAssertEqual(hexData, "0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004") @@ -204,7 +204,7 @@ class ABIEncoderTest: XCTestCase { .bool, .array(type: .uint(bits: 8), length: 0), .bytes(length: 2)] - let values: [Any] = [10, false, [1,2,3,4], Data(count: 2)] + let values: [Any] = [10, false, [1, 2, 3, 4], Data(count: 2)] hexData = ABIEncoder.encode(types: types, values: values)?.toHexString() XCTAssertEqual(hexData?[128..<192], "0000000000000000000000000000000000000000000000000000000000000080") XCTAssertEqual(hexData, "000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004") @@ -220,7 +220,7 @@ class ABIEncoderTest: XCTestCase { encodedValue = ABIEncoder.encode(types: [.dynamicBytes], values: [Data.fromHex("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1")!])!.toHexString() XCTAssertEqual(encodedValue, "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000009ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff100") - + encodedValue = ABIEncoder.encode(types: [.dynamicBytes], values: [Data.fromHex("c3a40000c3a4")!])!.toHexString() XCTAssertEqual(encodedValue, "00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000006c3a40000c3a40000000000000000000000000000000000000000000000000000") From 08f3d00d0c71f0120e1e14723e3d901d131e2df0 Mon Sep 17 00:00:00 2001 From: JD Date: Thu, 2 Feb 2023 12:22:56 +0100 Subject: [PATCH 050/210] Delete again --- Sources/Core/EthereumABI/ABIElements.swift | 394 --------------------- 1 file changed, 394 deletions(-) delete mode 100755 Sources/Core/EthereumABI/ABIElements.swift diff --git a/Sources/Core/EthereumABI/ABIElements.swift b/Sources/Core/EthereumABI/ABIElements.swift deleted file mode 100755 index 8d01d6f5b..000000000 --- a/Sources/Core/EthereumABI/ABIElements.swift +++ /dev/null @@ -1,394 +0,0 @@ -// -// Created by Alex Vlasov on 25/10/2018. -// Copyright © 2018 Alex Vlasov. All rights reserved. -// - -import Foundation -import BigInt - -public extension ABI { - struct Input: Decodable { - public var name: String? - public var type: String - public var indexed: Bool? - public var components: [Input]? - } - - struct Output: Decodable { - public var name: String? - public var type: String - public var components: [Output]? - } - - struct Record: Decodable { - public var name: String? - public var type: String? - public var payable: Bool? - public var constant: Bool? - public var stateMutability: String? - public var inputs: [ABI.Input]? - public var outputs: [ABI.Output]? - public var anonymous: Bool? - } - - enum Element { - public enum ArraySize { // bytes for convenience - case staticSize(UInt64) - case dynamicSize - case notArray - } - - case function(Function) - case constructor(Constructor) - case fallback(Fallback) - case event(Event) - case receive(Receive) - case error(EthError) - - public enum StateMutability { - case payable - case mutating - case view - case pure - - var isConstant: Bool { - switch self { - case .payable: - return false - case .mutating: - return false - default: - return true - } - } - - var isPayable: Bool { - switch self { - case .payable: - return true - default: - return false - } - } - } - - public struct InOut { - public let name: String - public let type: ParameterType - - public init(name: String, type: ParameterType) { - self.name = name - self.type = type - } - } - - public struct Function { - public let name: String? - public let inputs: [InOut] - public let outputs: [InOut] - public let stateMutability: StateMutability? = nil - public let constant: Bool - public let payable: Bool - - public init(name: String?, inputs: [InOut], outputs: [InOut], constant: Bool, payable: Bool) { - self.name = name - self.inputs = inputs - self.outputs = outputs - self.constant = constant - self.payable = payable - } - } - - public struct Constructor { - public let inputs: [InOut] - public let constant: Bool - public let payable: Bool - public init(inputs: [InOut], constant: Bool, payable: Bool) { - self.inputs = inputs - self.constant = constant - self.payable = payable - } - } - - public struct Fallback { - public let constant: Bool - public let payable: Bool - - public init(constant: Bool, payable: Bool) { - self.constant = constant - self.payable = payable - } - } - - public struct Event { - public let name: String - public let inputs: [Input] - public let anonymous: Bool - - public init(name: String, inputs: [Input], anonymous: Bool) { - self.name = name - self.inputs = inputs - self.anonymous = anonymous - } - - public struct Input { - public let name: String - public let type: ParameterType - public let indexed: Bool - - public init(name: String, type: ParameterType, indexed: Bool) { - self.name = name - self.type = type - self.indexed = indexed - } - } - } - public struct Receive { - public let payable: Bool - public let inputs: [InOut] - - public init(inputs: [InOut], payable: Bool) { - self.inputs = inputs - self.payable = payable - } - } - /// Custom structured error type available since solidity 0.8.4 - public struct EthError { - public let name: String - public let inputs: [Input] - - public struct Input { - public let name: String - public let type: ParameterType - - public init(name: String, type: ParameterType) { - self.name = name - self.type = type - } - } - } - } -} - -// MARK: - Function parameters encoding - -extension ABI.Element { - public func encodeParameters(_ parameters: [Any]) -> Data? { - switch self { - case .constructor(let constructor): - return constructor.encodeParameters(parameters) - case .event: - return nil - case .fallback: - return nil - case .function(let function): - return function.encodeParameters(parameters) - case .receive: - return nil - case .error: - return nil - } - } -} - -extension ABI.Element.Constructor { - public func encodeParameters(_ parameters: [Any]) -> Data? { - guard parameters.count == inputs.count else { return nil } - return ABIEncoder.encode(types: inputs, values: parameters) - } -} - -extension ABI.Element.Function { - - /// Encode parameters of a given contract method - /// - Parameter parameters: Parameters to pass to Ethereum contract - /// - Returns: Encoded data - public func encodeParameters(_ parameters: [Any]) -> Data? { - guard parameters.count == inputs.count, - let data = ABIEncoder.encode(types: inputs, values: parameters) else { return nil } - return methodEncoding + data - } -} - -// MARK: - Event logs decoding - -extension ABI.Element.Event { - public func decodeReturnedLogs(eventLogTopics: [Data], eventLogData: Data) -> [String: Any]? { - guard let eventContent = ABIDecoder.decodeLog(event: self, eventLogTopics: eventLogTopics, eventLogData: eventLogData) else {return nil} - return eventContent - } -} - -// MARK: - Function input/output decoding - -extension ABI.Element { - public func decodeReturnData(_ data: Data) -> [String: Any]? { - switch self { - case .constructor: - return nil - case .event: - return nil - case .fallback: - return nil - case .function(let function): - return function.decodeReturnData(data) - case .receive: - return nil - case .error: - return nil - } - } - - public func decodeInputData(_ data: Data) -> [String: Any]? { - guard data.count == 0 || data.count % 32 == 4 else { return nil } - - switch self { - case .constructor(let constructor): - return constructor.decodeInputData(data) - case .event: - return nil - case .fallback: - return nil - case .function(let function): - return function.decodeInputData(data) - case .receive: - return nil - case .error: - return nil - } - } -} - -extension ABI.Element.Function { - public func decodeInputData(_ rawData: Data) -> [String: Any]? { - return Core.decodeInputData(rawData, methodEncoding: methodEncoding, inputs: inputs) - } - - public func decodeReturnData(_ data: Data) -> [String: Any]? { - // the response size greater than equal 100 bytes, when read function aborted by "require" statement. - // if "require" statement has no message argument, the response is empty (0 byte). - if data.bytes.count >= 100 { - let check00_31 = BigUInt("08C379A000000000000000000000000000000000000000000000000000000000", radix: 16)! - let check32_63 = BigUInt("0000002000000000000000000000000000000000000000000000000000000000", radix: 16)! - - // check data[00-31] and data[32-63] - if check00_31 == BigUInt(data[0...31]) && check32_63 == BigUInt(data[32...63]) { - // data.bytes[64-67] contains the length of require message - let len = (Int(data.bytes[64])<<24) | (Int(data.bytes[65])<<16) | (Int(data.bytes[66])<<8) | Int(data.bytes[67]) - - let message = String(bytes: data.bytes[68..<(68+len)], encoding: .utf8)! - - var returnArray = [String: Any]() - - // set information - returnArray["_abortedByRequire"] = true - returnArray["_errorMessageFromRequire"] = message - - // set empty values - for i in 0 ..< outputs.count { - let name = "\(i)" - returnArray[name] = outputs[i].type.emptyValue - if outputs[i].name != "" { - returnArray[outputs[i].name] = outputs[i].type.emptyValue - } - } - - return returnArray - } - } - - var returnArray = [String: Any]() - - // the "require" statement with no message argument will be caught here - if data.count == 0 && outputs.count == 1 { - let name = "0" - let value = outputs[0].type.emptyValue - returnArray[name] = value - if outputs[0].name != "" { - returnArray[outputs[0].name] = value - } - } else { - guard outputs.count * 32 <= data.count else { return nil } - - var i = 0 - guard let values = ABIDecoder.decode(types: outputs, data: data) else { return nil } - for output in outputs { - let name = "\(i)" - returnArray[name] = values[i] - if output.name != "" { - returnArray[output.name] = values[i] - } - i = i + 1 - } - // set a flag to detect the request succeeded - } - - if returnArray.isEmpty { - return nil - } - - returnArray["_success"] = true - return returnArray - } -} - -extension ABI.Element.Constructor { - public func decodeInputData(_ rawData: Data) -> [String: Any]? { - return Core.decodeInputData(rawData, inputs: inputs) - } -} - -/// Generic input decoding function. -/// - Parameters: -/// - rawData: data to decode. Must match the following criteria: `data.count == 0 || data.count % 32 == 4`. -/// - methodEncoding: 4 bytes representing method signature like `0xFFffFFff`. Can be omitted to avoid checking method encoding. -/// - inputs: expected input types. Order must be the same as in function declaration. -/// - Returns: decoded dictionary of input arguments mapped to their indices and arguments' names if these are not empty. -/// If decoding of at least one argument fails, `rawData` size is invalid or `methodEncoding` doesn't match - `nil` is returned. -private func decodeInputData(_ rawData: Data, - methodEncoding: Data? = nil, - inputs: [ABI.Element.InOut]) -> [String: Any]? { - let data: Data - let sig: Data? - - switch rawData.count % 32 { - case 0: - sig = nil - data = Data() - break - case 4: - sig = rawData[0 ..< 4] - data = Data(rawData[4 ..< rawData.count]) - default: - return nil - } - - if methodEncoding != nil && sig != nil && sig != methodEncoding { - return nil - } - - var returnArray = [String: Any]() - - if data.count == 0 && inputs.count == 1 { - let name = "0" - let value = inputs[0].type.emptyValue - returnArray[name] = value - if inputs[0].name != "" { - returnArray[inputs[0].name] = value - } - } else { - guard inputs.count * 32 <= data.count else { return nil } - - var i = 0 - guard let values = ABIDecoder.decode(types: inputs, data: data) else {return nil} - for input in inputs { - let name = "\(i)" - returnArray[name] = values[i] - if input.name != "" { - returnArray[input.name] = values[i] - } - i = i + 1 - } - } - return returnArray -} From d05e46d37293f1a0124540fa80a5a5b99096e34a Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 00:09:35 +0200 Subject: [PATCH 051/210] chore: installed pre-commit --- .githooks/init_hooks.sh | 51 ------------------- .githooks/pre-commit | 43 ---------------- .pre-commit-config.yaml | 23 +++++++++ .../localTests/TransactionsTests.swift | 40 +++++++-------- 4 files changed, 43 insertions(+), 114 deletions(-) delete mode 100755 .githooks/init_hooks.sh delete mode 100755 .githooks/pre-commit create mode 100644 .pre-commit-config.yaml diff --git a/.githooks/init_hooks.sh b/.githooks/init_hooks.sh deleted file mode 100755 index 28913e262..000000000 --- a/.githooks/init_hooks.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# Creates hooks in .git/hooks directory based on the hooks available in .githooks. -# If user already has hooks in .git/hooks then hooks from .githooks will be added -# as separate files with different names and a command to run these hooks will be -# added to the respective existing hooks on the last line of the file. - -current_dir=${PWD##*/} - -if [ "$current_dir" != ".githooks" ]; then - cd .githooks -fi - -shopt -s nullglob -raw_githooks=(*) -exclude=(init_hooks.sh) -githooks=( "${raw_githooks[@]/$exclude}" ) - -for hook in ${githooks[*]} -do - git_hook_path="../.git/hooks/$hook" - - web3swift_hook_comment="# web3swift git hook to perform actions like SwiftLint and codespell" - web3swift_hook_path="$(pwd)/${hook}" - web3swift_hook_command="source $(pwd)/${hook}" - - is_hook_linked=false - - if test -f $git_hook_path; then - last_line=$( tac ${git_hook_path} | grep -m 1 -E '[^[:space:]]' ) - if [ "$last_line" = "$web3swift_hook_command" ]; then - is_hook_linked=true - fi - else - touch $git_hook_path - chmod +x $git_hook_path - echo "#!/bin/sh\n" >> $git_hook_path - fi - - if [ "$is_hook_linked" = false ] ; then - cat << EOF >> $git_hook_path -web3swift_hook_path=${web3swift_hook_path} - -if test -f \$web3swift_hook_path; then - ${web3swift_hook_command} -fi -EOF - echo "${hook} is linked successfully." - else - echo "${hook} is already linked." - fi -done diff --git a/.githooks/pre-commit b/.githooks/pre-commit deleted file mode 100755 index 8bfc24695..000000000 --- a/.githooks/pre-commit +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -if ! command -v pip3 &> /dev/null -then - >&2 echo "\033[31mpip3 could not be found. Please, install pip3 following the guide on https://pip.pypa.io/en/stable/installation/\033[0m" - exit 1 -fi - -codespell_out=$(pip3 show codespell | grep "Location") -codespell_path=(${codespell_out//"Location: "/ }) - -if [ -z "$codespell_path" ] -then - echo "codespell not found. Installing codespell..." - pip3 install --upgrade pip - pip3 install codespell - - codespell_out=$(pip3 show codespell | grep "Location") - codespell_path=(${codespell_out//"Location: "/ }) - codespell_path="${codespell_path}/bin/codespell" -else - codespell_path="${codespell_path}/bin/codespell" -fi - -$codespell_path --count --ignore-words-list=ans,deriver,inout,packag --skip="*.js,*WordLists.swift" Sources/ Tests/ Package.swift CHANGELOG.md CONTRIBUTION.md README.md Web3Core.podspec Web3Swift.podspec - -if [ $? -eq 65 ]; then - echo "codespell returned exit code 65. Please, fix the errors." - exit 1 -fi - -if [ "$(uname -s)" = "Darwin" ]; then - export PATH="$PATH:/opt/homebrew/bin" - - if ! command -v swiftlint &> /dev/null - then - echo "swiftlint wasn't found. Installing it from Homebrew." - brew install swiftlint - fi - - swiftlint Sources - swiftlint Tests -fi diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..9b103875e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,23 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-case-conflict + - id: check-json + - id: mixed-line-ending + - id: no-commit-to-branch + args: [--branch, staging, --branch, main, --branch, master, --branch, develop-4.0, --branch, develop-upstream] +- repo: https://github.com/codespell-project/codespell + rev: v2.2.2 + hooks: + - id: codespell + args: ["--count --ignore-words-list=ans,deriver,inout,packag --skip=\"*.js,*WordLists.swift\" Sources/ Tests/ Package.swift CHANGELOG.md CONTRIBUTION.md README.md Web3Core.podspec Web3Swift.podspec"] +- repo: https://github.com/realm/SwiftLint + rev: 0.50.3 + hooks: + - id: swiftlint + args: [Sources, Tests] diff --git a/Tests/web3swiftTests/localTests/TransactionsTests.swift b/Tests/web3swiftTests/localTests/TransactionsTests.swift index 7dd9a8e65..4b21a8f98 100755 --- a/Tests/web3swiftTests/localTests/TransactionsTests.swift +++ b/Tests/web3swiftTests/localTests/TransactionsTests.swift @@ -195,7 +195,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -243,7 +243,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -264,7 +264,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -312,7 +312,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -333,7 +333,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -381,7 +381,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -402,7 +402,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -450,7 +450,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -467,11 +467,11 @@ class TransactionsTests: XCTestCase { // check that the transaction type is eip1559 XCTAssertEqual(jsonTxn.type, .eip1559, "Transaction Type Mismatch") // check the hash, if they match everything was parsed, and re-encoded correctly - XCTAssertEqual(jsonTxn.hash!.toHexString().addHexPrefix(), vector.hash, "Transaction Hash Mismatch") + XCTAssertEqual(jsonTxn.hash!.toHexString().addHexPrefix(), vector.hash, "Transaction Hash Mismatch Shoult") // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -519,7 +519,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -540,7 +540,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -588,7 +588,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -612,16 +612,16 @@ class TransactionsTests: XCTestCase { let publicKey = Utilities.privateToPublic(privateKeyData, compressed: false) let sender = Utilities.publicToAddress(publicKey!) transaction.chainID = 1 - + let hash = transaction.hashForSignature() let expectedHash = "0xdaf5a779ae972f972197303d7b574746c7ef83eadac0f2791ad23db92e4c8e53".stripHexPrefix() XCTAssertEqual(hash!.toHexString(), expectedHash, "Transaction signature failed") try transaction.sign(privateKey: privateKeyData, useExtraEntropy: false) - + XCTAssertEqual(transaction.v, 37, "Transaction signature failed") XCTAssertEqual(sender, transaction.sender) } catch { - + XCTFail() } } @@ -640,12 +640,12 @@ class TransactionsTests: XCTestCase { let policies = Policies(gasLimitPolicy: .manual(78423)) let result = try await writeTX.writeToChain(password: "", policies: policies, sendRaw: false) let txHash = Data.fromHex(result.hash.stripHexPrefix())! - + Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(txHash) - + XCTAssert(receipt.status == .ok) switch receipt.status { @@ -656,13 +656,13 @@ class TransactionsTests: XCTestCase { } let details = try await web3.eth.transactionDetails(txHash) - + // FIXME: Re-enable this test. // XCTAssertEqual(details.transaction.gasLimit, BigUInt(78423)) } catch Web3Error.nodeError(let descr) { guard descr == "insufficient funds for gas * price + value" else {return XCTFail()} } catch { - + XCTFail() } } From afc373a7d7ffbf258ea7273337731e00de64f9f5 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Fri, 3 Feb 2023 00:30:15 +0200 Subject: [PATCH 052/210] chore: README.md update to explain pre-commit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c6d631576..ca98ed871 100755 --- a/README.md +++ b/README.md @@ -190,7 +190,7 @@ Make sure that `ganache` is running on its default port `8546`. To change the po ### Before you commit -Please, run `.githooks/init_hooks.sh` to initialize git hooks that will do `codespell`, `swiftlint` and other checks. _Issues may arise with hooks on platforms other than Mac OS._ +We are using [pre-commit](https://pre-commit.com) to run validations locally before a commit is created. Please, install pre-commit and run `pre-commit install` from project's root directory. After that before every commit git hook will run and execute `codespell`, `swiftlint` and other checks. ## Contribute Want to improve? It's awesome: From e29826325c1b0f60731064cc3ba1f66471e71d33 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 2 Feb 2023 23:50:35 +0100 Subject: [PATCH 053/210] =?UTF-8?q?Let=E2=80=99s=20spell=20parameters=20co?= =?UTF-8?q?rrectly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/web3swift/Utils/EIP/EIP681.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/web3swift/Utils/EIP/EIP681.swift b/Sources/web3swift/Utils/EIP/EIP681.swift index 1882420a4..264dc5d37 100755 --- a/Sources/web3swift/Utils/EIP/EIP681.swift +++ b/Sources/web3swift/Utils/EIP/EIP681.swift @@ -240,7 +240,7 @@ extension Web3 { // TODO: throws errors instead of returning `nil` /// Attempts to parse given string as EIP681 code. - /// Note: that ENS addresses as paramteres will be attempted to be resolved into Ethereum addresses. + /// Note: that ENS addresses as parameters will be attempted to be resolved into Ethereum addresses. /// Thus, make sure that given raw EIP681 code has chain ID set or default Ethereum Mainnet chan ID will be used instead. /// - Parameter string: raw, encoded EIP681 code. /// - Returns: parsed EIP681 code or `nil` is something has failed. From a6d8e521058c0d5a645b57cfed766271935cdf36 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Fri, 3 Feb 2023 10:47:58 +0200 Subject: [PATCH 054/210] Update .pre-commit-config.yaml Co-authored-by: Christian Clauss --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9b103875e..64315dd15 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: rev: v2.2.2 hooks: - id: codespell - args: ["--count --ignore-words-list=ans,deriver,inout,packag --skip=\"*.js,*WordLists.swift\" Sources/ Tests/ Package.swift CHANGELOG.md CONTRIBUTION.md README.md Web3Core.podspec Web3Swift.podspec"] + args: ["--count --ignore-words-list=ans,deriver,inout,packag --skip=\"*.js,*WordLists.swift\""] - repo: https://github.com/realm/SwiftLint rev: 0.50.3 hooks: From 6986a33d2ce336945ec0dbe36cb2e5f492b1d2bc Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Fri, 3 Feb 2023 10:56:32 +0200 Subject: [PATCH 055/210] fix: added new folders to skip Skipping .git,Carthage,.build,build --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 64315dd15..04860ea2e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: rev: v2.2.2 hooks: - id: codespell - args: ["--count --ignore-words-list=ans,deriver,inout,packag --skip=\"*.js,*WordLists.swift\""] + args: ["--count --ignore-words-list=ans,deriver,inout,packag --skip=\"*.js,*WordLists.swift\",.git,Carthage,.build,build"] - repo: https://github.com/realm/SwiftLint rev: 0.50.3 hooks: From e9fc1090834ea82279a952f86374915c1b11a5e6 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Fri, 3 Feb 2023 11:00:10 +0200 Subject: [PATCH 056/210] fix: quotes mismatch --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 04860ea2e..7303e5928 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: rev: v2.2.2 hooks: - id: codespell - args: ["--count --ignore-words-list=ans,deriver,inout,packag --skip=\"*.js,*WordLists.swift\",.git,Carthage,.build,build"] + args: ["--count --ignore-words-list=ans,deriver,inout,packag --skip=\"*.js,*WordLists.swift,.git,Carthage,.build,build\""] - repo: https://github.com/realm/SwiftLint rev: 0.50.3 hooks: From 84838272a9e46c6022eb4ebb85aed05c1428f568 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 11:01:42 +0200 Subject: [PATCH 057/210] fix: removed explicitly inserted typo that was intended only for testing --- Tests/web3swiftTests/localTests/TransactionsTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/web3swiftTests/localTests/TransactionsTests.swift b/Tests/web3swiftTests/localTests/TransactionsTests.swift index 211818f2f..f9578b6a4 100644 --- a/Tests/web3swiftTests/localTests/TransactionsTests.swift +++ b/Tests/web3swiftTests/localTests/TransactionsTests.swift @@ -467,7 +467,7 @@ class TransactionsTests: XCTestCase { // check that the transaction type is eip1559 XCTAssertEqual(jsonTxn.type, .eip1559, "Transaction Type Mismatch") // check the hash, if they match everything was parsed, and re-encoded correctly - XCTAssertEqual(jsonTxn.hash!.toHexString().addHexPrefix(), vector.hash, "Transaction Hash Mismatch Shoult") + XCTAssertEqual(jsonTxn.hash!.toHexString().addHexPrefix(), vector.hash, "Transaction Hash Mismatch") // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { From 50d64582ecdc8017d0ca59f17ed2464d771a0df8 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Fri, 3 Feb 2023 14:25:50 +0200 Subject: [PATCH 058/210] fix: commented out SwiftLint hook --- .pre-commit-config.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7303e5928..9dcbbe83d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,8 +16,10 @@ repos: hooks: - id: codespell args: ["--count --ignore-words-list=ans,deriver,inout,packag --skip=\"*.js,*WordLists.swift,.git,Carthage,.build,build\""] -- repo: https://github.com/realm/SwiftLint - rev: 0.50.3 - hooks: - - id: swiftlint - args: [Sources, Tests] +# SwiftLint is commented out until we fix all SwiftLint warnings and errors. +# https://github.com/web3swift-team/web3swift/pull/756 +#- repo: https://github.com/realm/SwiftLint +# rev: 0.50.3 +# hooks: +# - id: swiftlint +# args: [Sources, Tests] From f8f9f2ace90e7a1aaede49af312924e9ade8a6d6 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 15:58:15 +0200 Subject: [PATCH 059/210] chore: disable swiftlint indentation_width rule as it doesn't allow multiline function calls --- .swiftlint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index 1e8e778fa..40e5d4c90 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -13,6 +13,7 @@ disabled_rules: - line_length - multiple_closures_with_trailing_closure - todo + - indentation_width opt_in_rules: - weak_delegate @@ -28,7 +29,6 @@ opt_in_rules: - empty_string - closure_body_length - fallthrough - - indentation_width # force warnings force_cast: error From 8b37e6fc50ba11f018a1a949a1630b8105ac82a6 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 15:59:19 +0200 Subject: [PATCH 060/210] fix: swiftlint errors in SECP256K1.swift --- Sources/Web3Core/Structure/SECP256k1.swift | 71 +++++++++++----------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index eb4552616..c01e6fd44 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -1,7 +1,4 @@ // -// secp256k1.swift -// secp256k1_swift -// // Created by Alexander Vlasov on 30.05.2018. // Copyright © 2018 Alexander Vlasov. All rights reserved. // @@ -27,7 +24,7 @@ extension SECP256K1 { static let context = secp256k1_context_create(UInt32(SECP256K1_CONTEXT_SIGN|SECP256K1_CONTEXT_VERIFY)) public static func signForRecovery(hash: Data, privateKey: Data, useExtraEntropy: Bool = false) -> (serializedSignature: Data?, rawSignature: Data?) { - if hash.count != 32 || privateKey.count != 32 {return (nil, nil)} + if hash.count != 32 || privateKey.count != 32 { return (nil, nil) } if !SECP256K1.verifyPrivateKey(privateKey: privateKey) { return (nil, nil) } @@ -48,15 +45,15 @@ extension SECP256K1 { } public static func privateToPublic(privateKey: Data, compressed: Bool = false) -> Data? { - if privateKey.count != 32 {return nil} - guard var publicKey = SECP256K1.privateKeyToPublicKey(privateKey: privateKey) else {return nil} - guard let serializedKey = serializePublicKey(publicKey: &publicKey, compressed: compressed) else {return nil} + if privateKey.count != 32 { return nil } + guard var publicKey = SECP256K1.privateKeyToPublicKey(privateKey: privateKey) else { return nil } + guard let serializedKey = serializePublicKey(publicKey: &publicKey, compressed: compressed) else { return nil } return serializedKey } public static func combineSerializedPublicKeys(keys: [Data], outputCompressed: Bool = false) -> Data? { let numToCombine = keys.count - guard numToCombine >= 1 else { return nil} + guard let context = context, numToCombine >= 1 else { return nil } var storage = ContiguousArray() let arrayOfPointers = UnsafeMutablePointer< UnsafePointer? >.allocate(capacity: numToCombine) defer { @@ -65,7 +62,7 @@ extension SECP256K1 { } for i in 0 ..< numToCombine { let key = keys[i] - guard let pubkey = SECP256K1.parsePublicKey(serializedKey: key) else {return nil} + guard let pubkey = SECP256K1.parsePublicKey(serializedKey: key) else { return nil } storage.append(pubkey) } for i in 0 ..< numToCombine { @@ -76,7 +73,7 @@ extension SECP256K1 { let immutablePointer = UnsafePointer(arrayOfPointers) var publicKey: secp256k1_pubkey = secp256k1_pubkey() let result = withUnsafeMutablePointer(to: &publicKey) { (pubKeyPtr: UnsafeMutablePointer) -> Int32 in - let res = secp256k1_ec_pubkey_combine(context!, pubKeyPtr, immutablePointer, numToCombine) + let res = secp256k1_ec_pubkey_combine(context, pubKeyPtr, immutablePointer, numToCombine) return res } if result == 0 { @@ -87,15 +84,14 @@ extension SECP256K1 { } internal static func recoverPublicKey(hash: Data, recoverableSignature: inout secp256k1_ecdsa_recoverable_signature) -> secp256k1_pubkey? { - guard hash.count == 32 else {return nil} + guard let context = context, hash.count == 32 else { return nil } var publicKey: secp256k1_pubkey = secp256k1_pubkey() let result = hash.withUnsafeBytes({ (hashRawBufferPointer: UnsafeRawBufferPointer) -> Int32? in if let hashRawPointer = hashRawBufferPointer.baseAddress, hashRawBufferPointer.count > 0 { let hashPointer = hashRawPointer.assumingMemoryBound(to: UInt8.self) return withUnsafePointer(to: &recoverableSignature, { (signaturePointer: UnsafePointer) -> Int32 in withUnsafeMutablePointer(to: &publicKey, { (pubKeyPtr: UnsafeMutablePointer) -> Int32 in - let res = secp256k1_ecdsa_recover(context!, pubKeyPtr, - signaturePointer, hashPointer) + let res = secp256k1_ecdsa_recover(context, pubKeyPtr, signaturePointer, hashPointer) return res }) }) @@ -110,12 +106,13 @@ extension SECP256K1 { } internal static func privateKeyToPublicKey(privateKey: Data) -> secp256k1_pubkey? { - if privateKey.count != 32 {return nil} + guard let context = context else { return nil } + if privateKey.count != 32 { return nil } var publicKey = secp256k1_pubkey() let result = privateKey.withUnsafeBytes { (pkRawBufferPointer: UnsafeRawBufferPointer) -> Int32? in if let pkRawPointer = pkRawBufferPointer.baseAddress, pkRawBufferPointer.count > 0 { let privateKeyPointer = pkRawPointer.assumingMemoryBound(to: UInt8.self) - let res = secp256k1_ec_pubkey_create(context!, &publicKey, privateKeyPointer) + let res = secp256k1_ec_pubkey_create(context, &publicKey, privateKeyPointer) return res } else { return nil @@ -128,6 +125,7 @@ extension SECP256K1 { } public static func serializePublicKey(publicKey: inout secp256k1_pubkey, compressed: Bool = false) -> Data? { + guard let context = context else { return nil } var keyLength = compressed ? 33 : 65 var serializedPubkey = Data(repeating: 0x00, count: keyLength) let result = serializedPubkey.withUnsafeMutableBytes { serializedPubkeyRawBuffPointer -> Int32? in @@ -135,7 +133,7 @@ extension SECP256K1 { let serializedPubkeyPointer = serializedPkRawPointer.assumingMemoryBound(to: UInt8.self) return withUnsafeMutablePointer(to: &keyLength, { (keyPtr: UnsafeMutablePointer) -> Int32 in withUnsafeMutablePointer(to: &publicKey, { (pubKeyPtr: UnsafeMutablePointer) -> Int32 in - let res = secp256k1_ec_pubkey_serialize(context!, + let res = secp256k1_ec_pubkey_serialize(context, serializedPubkeyPointer, keyPtr, pubKeyPtr, @@ -154,7 +152,8 @@ extension SECP256K1 { } internal static func parsePublicKey(serializedKey: Data) -> secp256k1_pubkey? { - guard serializedKey.count == 33 || serializedKey.count == 65 else { + guard let context = context, + serializedKey.count == 33 || serializedKey.count == 65 else { return nil } let keyLen: Int = Int(serializedKey.count) @@ -162,7 +161,7 @@ extension SECP256K1 { let result = serializedKey.withUnsafeBytes { (serializedKeyRawBufferPointer: UnsafeRawBufferPointer) -> Int32? in if let serializedKeyRawPointer = serializedKeyRawBufferPointer.baseAddress, serializedKeyRawBufferPointer.count > 0 { let serializedKeyPointer = serializedKeyRawPointer.assumingMemoryBound(to: UInt8.self) - let res = secp256k1_ec_pubkey_parse(context!, &publicKey, serializedKeyPointer, keyLen) + let res = secp256k1_ec_pubkey_parse(context, &publicKey, serializedKeyPointer, keyLen) return res } else { return nil @@ -175,7 +174,7 @@ extension SECP256K1 { } public static func parseSignature(signature: Data) -> secp256k1_ecdsa_recoverable_signature? { - guard signature.count == 65 else {return nil} + guard let context = context, signature.count == 65 else { return nil } var recoverableSignature: secp256k1_ecdsa_recoverable_signature = secp256k1_ecdsa_recoverable_signature() let serializedSignature = Data(signature[0..<64]) var v = Int32(signature[64]) @@ -190,7 +189,7 @@ extension SECP256K1 { if let serRawPtr = serRawBufferPtr.baseAddress, serRawBufferPtr.count > 0 { let serPtr = serRawPtr.assumingMemoryBound(to: UInt8.self) return withUnsafeMutablePointer(to: &recoverableSignature, { (signaturePointer: UnsafeMutablePointer) -> Int32 in - let res = secp256k1_ecdsa_recoverable_signature_parse_compact(context!, signaturePointer, serPtr, v) + let res = secp256k1_ecdsa_recoverable_signature_parse_compact(context, signaturePointer, serPtr, v) return res }) } else { @@ -204,6 +203,7 @@ extension SECP256K1 { } internal static func serializeSignature(recoverableSignature: inout secp256k1_ecdsa_recoverable_signature) -> Data? { + guard let context = context else { return nil } var serializedSignature = Data(repeating: 0x00, count: 64) var v: Int32 = 0 let result = serializedSignature.withUnsafeMutableBytes { (serSignatureRawBufferPointer: UnsafeMutableRawBufferPointer) -> Int32? in @@ -211,7 +211,7 @@ extension SECP256K1 { let serSignaturePointer = serSignatureRawPointer.assumingMemoryBound(to: UInt8.self) return withUnsafePointer(to: &recoverableSignature) { (signaturePointer: UnsafePointer) -> Int32 in withUnsafeMutablePointer(to: &v, { (vPtr: UnsafeMutablePointer) -> Int32 in - let res = secp256k1_ecdsa_recoverable_signature_serialize_compact(context!, serSignaturePointer, vPtr, signaturePointer) + let res = secp256k1_ecdsa_recoverable_signature_serialize_compact(context, serSignaturePointer, vPtr, signaturePointer) return res }) } @@ -236,11 +236,11 @@ extension SECP256K1 { if hash.count != 32 || privateKey.count != 32 { return nil } - if !SECP256K1.verifyPrivateKey(privateKey: privateKey) { + guard let context = context, SECP256K1.verifyPrivateKey(privateKey: privateKey) else { return nil } var recoverableSignature: secp256k1_ecdsa_recoverable_signature = secp256k1_ecdsa_recoverable_signature() - guard let extraEntropy = SECP256K1.randomBytes(length: 32) else {return nil} + guard let extraEntropy = SECP256K1.randomBytes(length: 32) else { return nil } let result = hash.withUnsafeBytes { hashRBPointer -> Int32? in if let hashRPointer = hashRBPointer.baseAddress, hashRBPointer.count > 0 { let hashPointer = hashRPointer.assumingMemoryBound(to: UInt8.self) @@ -251,7 +251,7 @@ extension SECP256K1 { if let extraEntropyRPointer = extraEntropyRBPointer.baseAddress, extraEntropyRBPointer.count > 0 { let extraEntropyPointer = extraEntropyRPointer.assumingMemoryBound(to: UInt8.self) return withUnsafeMutablePointer(to: &recoverableSignature, { (recSignaturePtr: UnsafeMutablePointer) -> Int32 in - let res = secp256k1_ecdsa_sign_recoverable(context!, recSignaturePtr, hashPointer, privateKeyPointer, nil, useExtraEntropy ? extraEntropyPointer : nil) + let res = secp256k1_ecdsa_sign_recoverable(context, recSignaturePtr, hashPointer, privateKeyPointer, nil, useExtraEntropy ? extraEntropyPointer : nil) return res }) } else { @@ -273,19 +273,19 @@ extension SECP256K1 { } public static func recoverPublicKey(hash: Data, signature: Data, compressed: Bool = false) -> Data? { - guard hash.count == 32, signature.count == 65 else {return nil} - guard var recoverableSignature = parseSignature(signature: signature) else {return nil} - guard var publicKey = SECP256K1.recoverPublicKey(hash: hash, recoverableSignature: &recoverableSignature) else {return nil} - guard let serializedKey = SECP256K1.serializePublicKey(publicKey: &publicKey, compressed: compressed) else {return nil} + guard hash.count == 32, signature.count == 65 else { return nil } + guard var recoverableSignature = parseSignature(signature: signature) else { return nil } + guard var publicKey = SECP256K1.recoverPublicKey(hash: hash, recoverableSignature: &recoverableSignature) else { return nil } + guard let serializedKey = SECP256K1.serializePublicKey(publicKey: &publicKey, compressed: compressed) else { return nil } return serializedKey } public static func verifyPrivateKey(privateKey: Data) -> Bool { - if privateKey.count != 32 {return false} + guard let context = context, privateKey.count == 32 else { return false } let result = privateKey.withUnsafeBytes { privateKeyRBPointer -> Int32? in if let privateKeyRPointer = privateKeyRBPointer.baseAddress, privateKeyRBPointer.count > 0 { let privateKeyPointer = privateKeyRPointer.assumingMemoryBound(to: UInt8.self) - let res = secp256k1_ec_seckey_verify(context!, privateKeyPointer) + let res = secp256k1_ec_seckey_verify(context, privateKeyPointer) return res } else { return nil @@ -311,7 +311,7 @@ extension SECP256K1 { } public static func unmarshalSignature(signatureData: Data) -> UnmarshaledSignature? { - if signatureData.count != 65 {return nil} + if signatureData.count != 65 { return nil } let v = signatureData[64] let r = Data(signatureData[0..<32]) let s = Data(signatureData[32..<64]) @@ -319,7 +319,7 @@ extension SECP256K1 { } public static func marshalSignature(v: UInt8, r: [UInt8], s: [UInt8]) -> Data? { - guard r.count == 32, s.count == 32 else {return nil} + guard r.count == 32, s.count == 32 else { return nil } var completeSignature = Data(r) completeSignature.append(Data(s)) completeSignature.append(Data([v])) @@ -327,7 +327,7 @@ extension SECP256K1 { } public static func marshalSignature(v: Data, r: Data, s: Data) -> Data? { - guard r.count == 32, s.count == 32 else {return nil} + guard r.count == 32, s.count == 32 else { return nil } var completeSignature = Data(r) completeSignature.append(s) completeSignature.append(v) @@ -361,12 +361,13 @@ extension SECP256K1 { internal static func fromByteArray(_ value: [UInt8], _: T.Type) -> T { return value.withUnsafeBytes { - $0.baseAddress!.load(as: T.self) + guard let baseAddress = $0.baseAddress else { fatalError("baseAddress of \($0) byte is nil.") } + return baseAddress.load(as: T.self) } } internal static func constantTimeComparison(_ lhs: Data, _ rhs: Data) -> Bool { - guard lhs.count == rhs.count else {return false} + guard lhs.count == rhs.count else { return false } var difference = UInt8(0x00) for i in 0.. Date: Fri, 3 Feb 2023 15:59:40 +0200 Subject: [PATCH 061/210] fix: swiftlint errors in Web3+Instance.swift --- Sources/web3swift/Web3/Web3+Instance.swift | 65 ++++++---------------- 1 file changed, 18 insertions(+), 47 deletions(-) diff --git a/Sources/web3swift/Web3/Web3+Instance.swift b/Sources/web3swift/Web3/Web3+Instance.swift index 5fdd99217..a098e2255 100755 --- a/Sources/web3swift/Web3/Web3+Instance.swift +++ b/Sources/web3swift/Web3/Web3+Instance.swift @@ -27,11 +27,9 @@ public class Web3 { /// Public web3.eth.* namespace. public var eth: IEth { - if ethInstance != nil { - return ethInstance! - } - ethInstance = Web3.Eth(provider: provider) - return ethInstance! + let ethInstance = ethInstance ?? Web3.Eth(provider: provider) + self.ethInstance = ethInstance + return ethInstance } // FIXME: Rewrite this to CodableTransaction @@ -47,11 +45,9 @@ public class Web3 { /// Public web3.personal.* namespace. public var personal: Web3.Personal { - if self.personalInstance != nil { - return self.personalInstance! - } - self.personalInstance = Web3.Personal(provider: self.provider, web3: self) - return self.personalInstance! + let personalInstance = personalInstance ?? Web3.Personal(provider: provider, web3: self) + self.personalInstance = personalInstance + return personalInstance } // FIXME: Rewrite this to CodableTransaction @@ -69,11 +65,9 @@ public class Web3 { /// Public web3.personal.* namespace. public var txPool: Web3.TxPool { - if self.txPoolInstance != nil { - return self.txPoolInstance! - } - self.txPoolInstance = Web3.TxPool(provider: self.provider, web3: self) - return self.txPoolInstance! + let txPoolInstance = txPoolInstance ?? Web3.TxPool(provider: provider, web3: self) + self.txPoolInstance = txPoolInstance + return txPoolInstance } // FIXME: Rewrite this to CodableTransaction @@ -91,11 +85,9 @@ public class Web3 { /// Public web3.wallet.* namespace. public var wallet: Web3.Web3Wallet { - if self.walletInstance != nil { - return self.walletInstance! - } - self.walletInstance = Web3.Web3Wallet(provider: self.provider, web3: self) - return self.walletInstance! + let walletInstance = walletInstance ?? Web3.Web3Wallet(provider: provider, web3: self) + self.walletInstance = walletInstance + return walletInstance } public class Web3Wallet { @@ -112,11 +104,9 @@ public class Web3 { /// Public web3.browserFunctions.* namespace. public var browserFunctions: Web3.BrowserFunctions { - if self.browserFunctionsInstance != nil { - return self.browserFunctionsInstance! - } - self.browserFunctionsInstance = Web3.BrowserFunctions(provider: self.provider, web3: self) - return self.browserFunctionsInstance! + let browserFunctionsInstance = browserFunctionsInstance ?? Web3.BrowserFunctions(provider: provider, web3: self) + self.browserFunctionsInstance = browserFunctionsInstance + return browserFunctionsInstance } // FIXME: Rewrite this to CodableTransaction @@ -134,11 +124,9 @@ public class Web3 { /// Public web3.browserFunctions.* namespace. public var eventLoop: Web3.Eventloop { - if self.eventLoopInstance != nil { - return self.eventLoopInstance! - } - self.eventLoopInstance = Web3.Eventloop(provider: self.provider, web3: self) - return self.eventLoopInstance! + let eventLoopInstance = eventLoopInstance ?? Web3.Eventloop(provider: provider, web3: self) + self.eventLoopInstance = eventLoopInstance + return eventLoopInstance } // FIXME: Rewrite this to CodableTransaction @@ -158,7 +146,6 @@ public class Web3 { var timer: RepeatingTimer? public var monitoredProperties: [MonitoredProperty] = [MonitoredProperty]() - // public var monitoredContracts: [MonitoredContract] = [MonitoredContract]() public var monitoredUserFunctions: [EventLoopRunnableProtocol] = [EventLoopRunnableProtocol]() public init(provider prov: Web3Provider, web3 web3instance: Web3) { provider = prov @@ -166,28 +153,12 @@ public class Web3 { } } -// public typealias AssemblyHookFunction = ((inout CodableTransaction, EthereumContract)) -> Bool -// -// public typealias SubmissionHookFunction = (inout CodableTransaction) -> Bool - public typealias SubmissionResultHookFunction = (TransactionSendingResult) -> Void -// public struct AssemblyHook { -// public var function: AssemblyHookFunction -// } - -// public struct SubmissionHook { -// public var function: SubmissionHookFunction -// } - public struct SubmissionResultHook { public var function: SubmissionResultHookFunction } -// public var preAssemblyHooks: [AssemblyHook] = [AssemblyHook]() -// public var postAssemblyHooks: [AssemblyHook] = [AssemblyHook]() -// -// public var preSubmissionHooks: [SubmissionHook] = [SubmissionHook]() public var postSubmissionHooks: [SubmissionResultHook] = [SubmissionResultHook]() } From 5dcb1002f4af1dcf51cd3a28020553f1173b34e6 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 16:00:43 +0200 Subject: [PATCH 062/210] fix: swiftlint errors in Web3+Eventloop.swift --- Sources/web3swift/Web3/Web3+Eventloop.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/web3swift/Web3/Web3+Eventloop.swift b/Sources/web3swift/Web3/Web3+Eventloop.swift index 64eb09892..0dffdaa48 100755 --- a/Sources/web3swift/Web3/Web3+Eventloop.swift +++ b/Sources/web3swift/Web3/Web3+Eventloop.swift @@ -49,9 +49,9 @@ class RepeatingTimer { private lazy var timer: DispatchSourceTimer = { let t = DispatchSource.makeTimerSource() t.schedule(deadline: .now() + self.timeInterval, repeating: self.timeInterval) - t.setEventHandler(handler: { [weak self] in + t.setEventHandler { [weak self] in self?.eventHandler?() - }) + } return t }() From ded3fee1bbb7123bfe01d45980a17f4c0c665b28 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 16:07:08 +0200 Subject: [PATCH 063/210] fix: swiftlint errors in Web3.swift --- Sources/web3swift/Web3/Web3.swift | 20 +++++++++---------- .../localTests/EIP1559BlockTests.swift | 1 + .../remoteTests/EIP1559Tests.swift | 13 ++++++++++-- .../remoteTests/GasOracleTests.swift | 18 ++++++++++++++--- .../remoteTests/PolicyResolverTests.swift | 19 +++++++++++++++--- 5 files changed, 53 insertions(+), 18 deletions(-) diff --git a/Sources/web3swift/Web3/Web3.swift b/Sources/web3swift/Web3/Web3.swift index e8b1a72df..d5c543946 100755 --- a/Sources/web3swift/Web3/Web3.swift +++ b/Sources/web3swift/Web3/Web3.swift @@ -21,35 +21,35 @@ extension Web3 { } /// Initialized Web3 instance bound to Infura's mainnet provider. - public static func InfuraMainnetWeb3(accessToken: String? = nil) async -> Web3 { - let infura = await InfuraProvider(Networks.Mainnet, accessToken: accessToken)! + public static func InfuraMainnetWeb3(accessToken: String? = nil) async -> Web3? { + guard let infura = await InfuraProvider(Networks.Mainnet, accessToken: accessToken) else { return nil } return Web3(provider: infura) } /// Initialized Web3 instance bound to Infura's goerli provider. - public static func InfuraGoerliWeb3(accessToken: String? = nil) async -> Web3 { - let infura = await InfuraProvider(Networks.Goerli, accessToken: accessToken)! + public static func InfuraGoerliWeb3(accessToken: String? = nil) async -> Web3? { + guard let infura = await InfuraProvider(Networks.Goerli, accessToken: accessToken) else { return nil } return Web3(provider: infura) } /// Initialized Web3 instance bound to Infura's rinkeby provider. @available(*, deprecated, message: "This network support was deprecated by Infura") - public static func InfuraRinkebyWeb3(accessToken: String? = nil) async -> Web3 { - let infura = await InfuraProvider(Networks.Rinkeby, accessToken: accessToken)! + public static func InfuraRinkebyWeb3(accessToken: String? = nil) async -> Web3? { + guard let infura = await InfuraProvider(Networks.Rinkeby, accessToken: accessToken) else { return nil } return Web3(provider: infura) } /// Initialized Web3 instance bound to Infura's ropsten provider. @available(*, deprecated, message: "This network support was deprecated by Infura") - public static func InfuraRopstenWeb3(accessToken: String? = nil) async -> Web3 { - let infura = await InfuraProvider(Networks.Ropsten, accessToken: accessToken)! + public static func InfuraRopstenWeb3(accessToken: String? = nil) async -> Web3? { + guard let infura = await InfuraProvider(Networks.Ropsten, accessToken: accessToken) else { return nil } return Web3(provider: infura) } /// Initialized Web3 instance bound to Infura's kovan provider. @available(*, deprecated, message: "This network support was deprecated by Infura") - public static func InfuraKovanWeb3(accessToken: String? = nil) async -> Web3 { - let infura = await InfuraProvider(Networks.Kovan, accessToken: accessToken)! + public static func InfuraKovanWeb3(accessToken: String? = nil) async -> Web3? { + guard let infura = await InfuraProvider(Networks.Kovan, accessToken: accessToken) else { return nil } return Web3(provider: infura) } diff --git a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift index 2287b4683..d9c0aeaee 100644 --- a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift +++ b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift @@ -4,6 +4,7 @@ import BigInt @testable import web3swift +@testable import Web3Core class EIP1559BlockTests: LocalTestCase { diff --git a/Tests/web3swiftTests/remoteTests/EIP1559Tests.swift b/Tests/web3swiftTests/remoteTests/EIP1559Tests.swift index 7f2848429..e493edace 100644 --- a/Tests/web3swiftTests/remoteTests/EIP1559Tests.swift +++ b/Tests/web3swiftTests/remoteTests/EIP1559Tests.swift @@ -10,10 +10,15 @@ import Web3Core @testable import web3swift +// swiftlint:disable force_unwrapping final class EIP1559Tests: XCTestCase { func testEIP1159MainnetTransaction() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } var tx = CodableTransaction( type: .eip1559, to: EthereumAddress("0xb47292B7bBedA4447564B8336E4eD1f93735e7C7")!, @@ -29,7 +34,11 @@ final class EIP1559Tests: XCTestCase { } func testEIP1159GoerliTransaction() async throws { - let web3 = await Web3.InfuraGoerliWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraGoerliWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraGoerli using token \(Constants.infuraToken)") + return + } var tx = CodableTransaction( type: .eip1559, to: EthereumAddress("0xeBec795c9c8bBD61FFc14A6662944748F299cAcf")!, diff --git a/Tests/web3swiftTests/remoteTests/GasOracleTests.swift b/Tests/web3swiftTests/remoteTests/GasOracleTests.swift index e2c51ec75..9b7769b82 100644 --- a/Tests/web3swiftTests/remoteTests/GasOracleTests.swift +++ b/Tests/web3swiftTests/remoteTests/GasOracleTests.swift @@ -16,7 +16,11 @@ class GasOracleTests: XCTestCase { let blockNumber: BigUInt = 14571792 func testPretictBaseFee() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } lazy var oracle: Oracle = .init(web3.provider, block: .exact(blockNumber), blockCount: 20, percentiles: [10, 40, 60, 90]) let etalonPercentiles: [BigUInt] = [ 94217344703, // 10 percentile @@ -30,7 +34,11 @@ class GasOracleTests: XCTestCase { } func testPredictTip() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } lazy var oracle: Oracle = .init(web3.provider, block: .exact(blockNumber), blockCount: 20, percentiles: [10, 40, 60, 90]) let etalonPercentiles: [BigUInt] = [ 1217066957, // 10 percentile @@ -44,7 +52,11 @@ class GasOracleTests: XCTestCase { } func testPredictBothFee() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } lazy var oracle: Oracle = .init(web3.provider, block: .exact(blockNumber), blockCount: 20, percentiles: [10, 40, 60, 90]) let etalonPercentiles: ([BigUInt], [BigUInt]) = ( baseFee: [ diff --git a/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift b/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift index f84324794..84db3b8df 100644 --- a/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift +++ b/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift @@ -11,10 +11,15 @@ import Web3Core @testable import web3swift +// swiftlint:disable force_unwrapping final class PolicyResolverTests: XCTestCase { func testResolveAllForEIP1159Transaction() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } let resolver = PolicyResolver(provider: web3.provider) var tx = CodableTransaction( type: .eip1559, @@ -35,7 +40,11 @@ final class PolicyResolverTests: XCTestCase { } func testResolveAllForLegacyTransaction() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } let resolver = PolicyResolver(provider: web3.provider) var tx = CodableTransaction( type: .legacy, @@ -59,7 +68,11 @@ final class PolicyResolverTests: XCTestCase { let expectedGasLimit = BigUInt(22_000) let expectedBaseFee = BigUInt(20) let expectedPriorityFee = BigUInt(9) - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } let resolver = PolicyResolver(provider: web3.provider) var tx = CodableTransaction( type: .eip1559, From ae205a78f78275360a25d7044a1c962b96d5a06f Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 16:08:12 +0200 Subject: [PATCH 064/210] fix: swiftlint errors in Web3+InfuraProviders.swift --- Sources/web3swift/Web3/Web3+InfuraProviders.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/web3swift/Web3/Web3+InfuraProviders.swift b/Sources/web3swift/Web3/Web3+InfuraProviders.swift index 493d6bc65..18e71d3ec 100755 --- a/Sources/web3swift/Web3/Web3+InfuraProviders.swift +++ b/Sources/web3swift/Web3/Web3+InfuraProviders.swift @@ -11,7 +11,9 @@ public final class InfuraProvider: Web3HttpProvider { public init?(_ net: Networks, accessToken token: String? = nil, keystoreManager manager: KeystoreManager? = nil) async { var requestURLstring = "https://" + net.name + Constants.infuraHttpScheme requestURLstring += token ?? Constants.infuraToken - let providerURL = URL(string: requestURLstring) - await super.init(providerURL!, network: net, keystoreManager: manager) + guard let providerURL = URL(string: requestURLstring) else { + return nil + } + await super.init(providerURL, network: net, keystoreManager: manager) } } From a5a528a9725ba7daf0ba2257410bf833b3ed7276 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 16:39:38 +0200 Subject: [PATCH 065/210] fix: swiftlint issues in Web3+Utils.swift --- Sources/web3swift/Web3/Web3+Utils.swift | 47 +++++++++++-------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/Sources/web3swift/Web3/Web3+Utils.swift b/Sources/web3swift/Web3/Web3+Utils.swift index a5a3310b9..5c426f1a8 100755 --- a/Sources/web3swift/Web3/Web3+Utils.swift +++ b/Sources/web3swift/Web3/Web3+Utils.swift @@ -13,24 +13,19 @@ public typealias Web3Utils = Web3.Utils extension Web3 { /// Namespaced Utils functions. Are not bound to particular web3 instance, so capitalization matters. public struct Utils { + // swiftlint:disable nesting typealias Iban = IBAN + // swiftlint:enable nesting } } +// swiftlint:disable file_length +// swiftlint:disable line_length extension Web3.Utils { - // /// Calculate address of deployed contract deterministically based on the address of the deploying Ethereum address - // /// and the nonce of this address - // public static func calculateContractAddress(from: EthereumAddress, nonce: BigUInt) -> EthereumAddress? { - // guard let normalizedAddress = from.addressData.setLengthLeft(32) else {return nil} - // guard let data = RLP.encode([normalizedAddress, nonce]) else {return nil} - // guard let contractAddressData = Utilities.sha3(data)?[12..<32] else {return nil} - // guard let contractAddress = EthereumAddress(Data(contractAddressData)) else {return nil} - // return contractAddress - // } - /// Various units used in Ethereum ecosystem public enum Units { + // swiftlint:disable identifier_name case eth case wei case Kwei @@ -40,23 +35,21 @@ extension Web3.Utils { case Finney var decimals: Int { - get { - switch self { - case .eth: - return 18 - case .wei: - return 0 - case .Kwei: - return 3 - case .Mwei: - return 6 - case .Gwei: - return 9 - case .Microether: - return 12 - case .Finney: - return 15 - } + switch self { + case .eth: + return 18 + case .wei: + return 0 + case .Kwei: + return 3 + case .Mwei: + return 6 + case .Gwei: + return 9 + case .Microether: + return 12 + case .Finney: + return 15 } } } From 9f8f8fc6822940d2ba39b567f7335b54d857d0a9 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 16:40:06 +0200 Subject: [PATCH 066/210] fix: commented_out_code rule regular expression --- .swiftlint.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index 40e5d4c90..b0db1517e 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -29,6 +29,7 @@ opt_in_rules: - empty_string - closure_body_length - fallthrough + - commented_out_code # force warnings force_cast: error @@ -39,7 +40,7 @@ custom_rules: included: ".*\\.swift" # regex that defines paths to include during linting. optional. excluded: ".*Test(s)?\\.swift" # regex that defines paths to exclude during linting. optional name: "Commented out code" # rule name. optional. - regex: "^\\/\\/\\s*(@|\\.?([a-z]|(\\})))" # matching pattern + regex: "^\\s*(\/\/(?!\\s*swiftlint:).*|\/\\*[\\s\\S]*?\\*\/)" # matching pattern capture_group: 0 # number of regex capture group to highlight the rule violation at. optional. match_kinds: # SyntaxKinds to match. optional. - comment From d3a427bed62f91fbd68b9be310cb187188296c80 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 16:42:10 +0200 Subject: [PATCH 067/210] fix: swiftlint issues in Web3+EIP1559.swift --- Sources/web3swift/Web3/Web3+EIP1559.swift | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Sources/web3swift/Web3/Web3+EIP1559.swift b/Sources/web3swift/Web3/Web3+EIP1559.swift index 9e0e9de8b..b7a5237f5 100644 --- a/Sources/web3swift/Web3/Web3+EIP1559.swift +++ b/Sources/web3swift/Web3/Web3+EIP1559.swift @@ -140,13 +140,13 @@ public extension Web3 { var mainNetFisrtBlockNumber: BigUInt { switch self { - case .Byzantium: return 4_370_000 - case .Constantinople: return 7_280_000 - case .Istanbul: return 9_069_000 - case .MuirGlacier: return 9_200_000 - case .Berlin: return 12_244_000 - case .London: return 12_965_000 - case .ArrowGlacier: return 13_773_000 + case .Byzantium: return 4_370_000 + case .Constantinople: return 7_280_000 + case .Istanbul: return 9_069_000 + case .MuirGlacier: return 9_200_000 + case .Berlin: return 12_244_000 + case .London: return 12_965_000 + case .ArrowGlacier: return 13_773_000 } } } @@ -156,7 +156,7 @@ public extension Web3 { // to get the block's ChainVersion. if block < MainChainVersion.Constantinople.mainNetFisrtBlockNumber { return .Byzantium - // ~= means included in a given range + // ~= means included in a given range } else if MainChainVersion.Constantinople.mainNetFisrtBlockNumber.. Bool { return lhs.mainNetFisrtBlockNumber < rhs.mainNetFisrtBlockNumber } - } +} extension Block { /// Returns chain version of mainnet block with such number From 60560c3d27b7cffa64345b410a14885afd9db1c9 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 16:53:45 +0200 Subject: [PATCH 068/210] fix: swiftlint issues in ENSReverseRegistrar.swift --- Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift b/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift index dfcff58f6..f78e0d457 100644 --- a/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift +++ b/Sources/web3swift/Utils/ENS/ENSReverseRegistrar.swift @@ -15,9 +15,11 @@ public extension ENS { public let address: EthereumAddress lazy var contract: Web3.Contract = { + // swiftlint:disable force_unwrapping let contract = self.web3.contract(Web3.Utils.reverseRegistrarABI, at: self.address, abiVersion: 2) precondition(contract != nil) return contract! + // swiftlint:enable force_unwrapping }() lazy var defaultTransaction: CodableTransaction = { @@ -53,7 +55,7 @@ public extension ENS { public func getReverseRecordName(address: EthereumAddress) async throws -> Data { guard let transaction = self.contract.createReadOperation("node", parameters: [address]) else { throw Web3Error.transactionSerializationError } - guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let result = try? await transaction.callContractMethod() else { throw Web3Error.processingError(desc: "Can't call transaction") } guard let name = result["0"] as? Data else { throw Web3Error.processingError(desc: "Can't get answer") } return name } @@ -61,7 +63,7 @@ public extension ENS { public func getDefaultResolver() async throws -> EthereumAddress { guard let transaction = self.contract.createReadOperation("defaultResolver") else { throw Web3Error.transactionSerializationError } - guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let result = try? await transaction.callContractMethod() else { throw Web3Error.processingError(desc: "Can't call transaction") } guard let address = result["0"] as? EthereumAddress else { throw Web3Error.processingError(desc: "Can't get answer") } return address } From e96d42633726dc915d68bd9189f1162fd1f41db5 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 16:54:35 +0200 Subject: [PATCH 069/210] fix: swiftlint issues in NameHash.swift --- Sources/web3swift/Utils/ENS/NameHash.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/web3swift/Utils/ENS/NameHash.swift b/Sources/web3swift/Utils/ENS/NameHash.swift index c6e58412e..8e82eb2f8 100755 --- a/Sources/web3swift/Utils/ENS/NameHash.swift +++ b/Sources/web3swift/Utils/ENS/NameHash.swift @@ -19,7 +19,7 @@ public struct NameHash { } static func namehash(_ name: String) -> Data? { - if name == "" { + if name.isEmpty { return Data(repeating: 0, count: 32) } let parts = name.split(separator: ".") From 909b323067711cc03cc83dc43dd2cbb863f6adda Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 16:55:52 +0200 Subject: [PATCH 070/210] fix: swiflint issues in ETHRegistrarController.swift --- .../Utils/ENS/ETHRegistrarController.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift b/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift index 6fdda1e12..4c7ef3471 100644 --- a/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift +++ b/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift @@ -15,9 +15,11 @@ public extension ENS { public let address: EthereumAddress lazy var contract: Web3.Contract = { + // swiftlint:disable force_unwrapping let contract = self.web3.contract(Web3.Utils.ethRegistrarControllerABI, at: self.address, abiVersion: 2) precondition(contract != nil) return contract! + // swiftlint:enable force_unwrapping }() lazy var defaultTransaction: CodableTransaction = { @@ -31,28 +33,28 @@ public extension ENS { public func getRentPrice(name: String, duration: UInt) async throws -> BigUInt { guard let transaction = self.contract.createReadOperation("rentPrice", parameters: [name, duration]) else { throw Web3Error.transactionSerializationError } - guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let result = try? await transaction.callContractMethod() else { throw Web3Error.processingError(desc: "Can't call transaction") } guard let price = result["0"] as? BigUInt else { throw Web3Error.processingError(desc: "Can't get answer") } return price } public func checkNameValidity(name: String) async throws -> Bool { guard let transaction = self.contract.createReadOperation("valid", parameters: [name]) else { throw Web3Error.transactionSerializationError } - guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let result = try? await transaction.callContractMethod() else { throw Web3Error.processingError(desc: "Can't call transaction") } guard let valid = result["0"] as? Bool else { throw Web3Error.processingError(desc: "Can't get answer") } return valid } public func isNameAvailable(name: String) async throws -> Bool { guard let transaction = self.contract.createReadOperation("available", parameters: [name]) else { throw Web3Error.transactionSerializationError } - guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let result = try? await transaction.callContractMethod() else { throw Web3Error.processingError(desc: "Can't call transaction") } guard let available = result["0"] as? Bool else { throw Web3Error.processingError(desc: "Can't get answer") } return available } public func calculateCommitmentHash(name: String, owner: EthereumAddress, secret: String) async throws -> Data { guard let transaction = self.contract.createReadOperation("makeCommitment", parameters: [name, owner.address, secret]) else { throw Web3Error.transactionSerializationError } - guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let result = try? await transaction.callContractMethod() else { throw Web3Error.processingError(desc: "Can't call transaction") } guard let hash = result["0"] as? Data else { throw Web3Error.processingError(desc: "Can't get answer") } return hash } @@ -65,7 +67,7 @@ public extension ENS { } public func registerName(from: EthereumAddress, name: String, owner: EthereumAddress, duration: UInt, secret: String, price: String) throws -> WriteOperation { - guard let amount = Utilities.parseToBigUInt(price, units: .ether) else {throw Web3Error.inputError(desc: "Wrong price: no way for parsing to ether units")} + guard let amount = Utilities.parseToBigUInt(price, units: .ether) else { throw Web3Error.inputError(desc: "Wrong price: no way for parsing to ether units") } defaultTransaction.value = amount defaultTransaction.from = from defaultTransaction.to = self.address @@ -74,7 +76,7 @@ public extension ENS { } public func extendNameRegistration(from: EthereumAddress, name: String, duration: UInt32, price: String) throws -> WriteOperation { - guard let amount = Utilities.parseToBigUInt(price, units: .ether) else {throw Web3Error.inputError(desc: "Wrong price: no way for parsing to ether units")} + guard let amount = Utilities.parseToBigUInt(price, units: .ether) else { throw Web3Error.inputError(desc: "Wrong price: no way for parsing to ether units") } defaultTransaction.value = amount defaultTransaction.from = from defaultTransaction.to = self.address From 78c8f6c0640e5e6f1a94a8eb778b9ca066d72dae Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 17:14:22 +0200 Subject: [PATCH 071/210] fix: swiftlint commented_out_code rule fixes --- .swiftlint.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index b0db1517e..97f0123e5 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -6,14 +6,14 @@ excluded: - DerivedData disabled_rules: - - function_parameter_count - - nesting - type_name - identifier_name - line_length - multiple_closures_with_trailing_closure - todo - indentation_width + - function_parameter_count + - nesting opt_in_rules: - weak_delegate @@ -29,7 +29,6 @@ opt_in_rules: - empty_string - closure_body_length - fallthrough - - commented_out_code # force warnings force_cast: error @@ -37,12 +36,12 @@ force_try: error custom_rules: commented_out_code: - included: ".*\\.swift" # regex that defines paths to include during linting. optional. - excluded: ".*Test(s)?\\.swift" # regex that defines paths to exclude during linting. optional - name: "Commented out code" # rule name. optional. - regex: "^\\s*(\/\/(?!\\s*swiftlint:).*|\/\\*[\\s\\S]*?\\*\/)" # matching pattern + included: .*\.swift # regex that defines paths to include during linting. optional. + excluded: .*Test(s)?\.swift # regex that defines paths to exclude during linting. optional + name: Commented out code # rule name. optional. + regex: ^\s*(\/\/(?!\s*swiftlint:).*|\/\*[\s\S]*?\*\/) # matching pattern capture_group: 0 # number of regex capture group to highlight the rule violation at. optional. match_kinds: # SyntaxKinds to match. optional. - comment - message: "No commented code in devel branch allowed." # violation message. optional. + message: No commented code in devel branch allowed. # violation message. optional. severity: warning # violation severity. optional. From b18fbe795b30a3548c4084525792a59523bef00e Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 17:14:52 +0200 Subject: [PATCH 072/210] fix: removed swiflint:disable nested rule from Web3+Utils.swift --- Sources/web3swift/Web3/Web3+Utils.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sources/web3swift/Web3/Web3+Utils.swift b/Sources/web3swift/Web3/Web3+Utils.swift index 5c426f1a8..666e642a7 100755 --- a/Sources/web3swift/Web3/Web3+Utils.swift +++ b/Sources/web3swift/Web3/Web3+Utils.swift @@ -13,9 +13,7 @@ public typealias Web3Utils = Web3.Utils extension Web3 { /// Namespaced Utils functions. Are not bound to particular web3 instance, so capitalization matters. public struct Utils { - // swiftlint:disable nesting typealias Iban = IBAN - // swiftlint:enable nesting } } From ae4ba9ef0175e3e5eef11e159622e9ae0626ee86 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 17:24:31 +0200 Subject: [PATCH 073/210] fix: swiftlint issues in EIP4361.swift --- Sources/web3swift/Utils/EIP/EIP4361.swift | 41 ++++++++++++++--------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/Sources/web3swift/Utils/EIP/EIP4361.swift b/Sources/web3swift/Utils/EIP/EIP4361.swift index 5e445d5eb..0fa9c0161 100644 --- a/Sources/web3swift/Utils/EIP/EIP4361.swift +++ b/Sources/web3swift/Utils/EIP/EIP4361.swift @@ -46,18 +46,18 @@ private let uriPattern = "(([^:?#\\s]+):)?(([^?#\\s]*))?([^?#\\s]*)(\\?([^#\\s]* public final class EIP4361 { public enum EIP4361Field: String { - case domain = "domain" - case address = "address" - case statement = "statement" - case uri = "uri" - case version = "version" - case chainId = "chainId" - case nonce = "nonce" - case issuedAt = "issuedAt" - case expirationTime = "expirationTime" - case notBefore = "notBefore" - case requestId = "requestId" - case resources = "resources" + case domain + case address + case statement + case uri + case version + case chainId + case nonce + case issuedAt + case expirationTime + case notBefore + case requestId + case resources } private static let domain = "(?<\(EIP4361Field.domain.rawValue)>([^?#]*)) wants you to sign in with your Ethereum account:" @@ -77,9 +77,9 @@ public final class EIP4361 { "^\(domain)\(address)\(statementParagraph)\(uri)\(version)\(chainId)\(nonce)\(issuedAt)\(expirationTime)\(notBefore)\(requestId)\(resourcesParagraph)$" } - private static var _eip4361OptionalPattern: String! + private static var _eip4361OptionalPattern: String? private static var eip4361OptionalPattern: String { - guard _eip4361OptionalPattern == nil else { return _eip4361OptionalPattern! } + if let _eip4361OptionalPattern = _eip4361OptionalPattern { return _eip4361OptionalPattern } let domain = "(?<\(EIP4361Field.domain.rawValue)>(.*)) wants you to sign in with your Ethereum account:" let address = "\\n(?<\(EIP4361Field.address.rawValue)>.*)\\n\\n" @@ -106,20 +106,27 @@ public final class EIP4361 { "\(requestId)", "\(resourcesParagraph)$"] - _eip4361OptionalPattern = patternParts.joined() - return _eip4361OptionalPattern! + let eip4361OptionalPattern = patternParts.joined() + _eip4361OptionalPattern = eip4361OptionalPattern + return eip4361OptionalPattern } public static func validate(_ message: String) -> EIP4361ValidationResponse { + // swiftlint:disable force_try let siweConstantMessageRegex = try! NSRegularExpression(pattern: "^\(domain)\\n") guard siweConstantMessageRegex.firstMatch(in: message, range: message.fullNSRange) != nil else { return EIP4361ValidationResponse(isEIP4361: false, eip4361: nil, capturedFields: [:]) } let eip4361Regex = try! NSRegularExpression(pattern: eip4361OptionalPattern) + // swiftlint:enable force_try var capturedFields: [EIP4361Field: String] = [:] for (key, value) in eip4361Regex.captureGroups(string: message) { + /// We are using EIP4361Field.rawValue to create regular expression. + /// These values must decode back from raw representation always. + // swiftlint:disable force_unwrapping capturedFields[.init(rawValue: key)!] = value + // swiftlint:enable force_unwrapping } return EIP4361ValidationResponse(isEIP4361: true, eip4361: EIP4361(message), @@ -153,7 +160,9 @@ public final class EIP4361 { public let resources: [URL]? public init?(_ message: String) { + // swiftlint:disable force_try let eip4361Regex = try! NSRegularExpression(pattern: EIP4361.eip4361Pattern) + // swiftlint:enable force_try let groups = eip4361Regex.captureGroups(string: message) let dateFormatter = ISO8601DateFormatter() dateFormatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds] From 43303048092c9b0bee0179c91b68f4e903ff84e2 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 17:41:44 +0200 Subject: [PATCH 074/210] fix: ERC1155 swiftlint fixes --- .../web3swift/Tokens/ERC1155/Web3+ERC1155.swift | 14 ++++++++------ .../localTests/EthereumAddressTest.swift | 8 ++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 Tests/web3swiftTests/localTests/EthereumAddressTest.swift diff --git a/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift b/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift index 9c2d5ed01..c00606e59 100644 --- a/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift +++ b/Sources/web3swift/Tokens/ERC1155/Web3+ERC1155.swift @@ -41,9 +41,11 @@ public class ERC1155: IERC1155 { public var abi: String lazy var contract: Web3.Contract = { + // swiftlint:disable force_unwrapping let contract = self.web3.contract(self.abi, at: self.address, abiVersion: 2) precondition(contract != nil) return contract! + // swiftlint:enable force_unwrapping }() public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.erc1155ABI, transaction: CodableTransaction = .emptyTransaction) { @@ -67,11 +69,11 @@ public class ERC1155: IERC1155 { if self._hasReadProperties { return } - guard contract.contract.address != nil else {return} + guard contract.contract.address != nil else { return } - guard let tokenIdPromise = try await contract.createReadOperation("id")?.callContractMethod() else {return} + guard let tokenIdPromise = try await contract.createReadOperation("id")?.callContractMethod() else { return } - guard let tokenId = tokenIdPromise["0"] as? BigUInt else {return} + guard let tokenId = tokenIdPromise["0"] as? BigUInt else { return } self._tokenId = tokenId self._hasReadProperties = true @@ -94,7 +96,7 @@ public class ERC1155: IERC1155 { let result = try await contract .createReadOperation("balanceOf", parameters: [account, id])! .callContractMethod() - guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} + guard let res = result["0"] as? BigUInt else { throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node") } return res } @@ -107,14 +109,14 @@ public class ERC1155: IERC1155 { public func isApprovedForAll(owner: EthereumAddress, operator user: EthereumAddress, scope: Data) async throws -> Bool { let result = try await contract.createReadOperation("isApprovedForAll", parameters: [owner, user, scope])!.callContractMethod() - guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} + guard let res = result["0"] as? Bool else { throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node") } return res } public func supportsInterface(interfaceID: String) async throws -> Bool { let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID])!.callContractMethod() - guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} + guard let res = result["0"] as? Bool else { throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node") } return res } } diff --git a/Tests/web3swiftTests/localTests/EthereumAddressTest.swift b/Tests/web3swiftTests/localTests/EthereumAddressTest.swift new file mode 100644 index 000000000..4e2a99b88 --- /dev/null +++ b/Tests/web3swiftTests/localTests/EthereumAddressTest.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by JeneaVranceanu on 03.02.2023. +// + +import Foundation From 3ad9a6bf6f29ed6d75e02a4068e3aaaeddc8d455 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 17:42:09 +0200 Subject: [PATCH 075/210] chore: minor refactoring of guard statements --- .../web3swift/Tokens/ERC20/ERC20BasePropertiesProvider.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/web3swift/Tokens/ERC20/ERC20BasePropertiesProvider.swift b/Sources/web3swift/Tokens/ERC20/ERC20BasePropertiesProvider.swift index d26e517e5..7f5c1a75d 100644 --- a/Sources/web3swift/Tokens/ERC20/ERC20BasePropertiesProvider.swift +++ b/Sources/web3swift/Tokens/ERC20/ERC20BasePropertiesProvider.swift @@ -21,8 +21,7 @@ public final class ERC20BasePropertiesProvider { } public func readProperties() async throws { - guard !hasReadProperties else { return } - guard contract.contract.address != nil else {return} + guard !hasReadProperties && contract.contract.address != nil else { return } name = try await contract .createReadOperation("name")? .callContractMethod()["0"] as? String From 275d2cdd6ea2e9e6af5290bac4bf4835a6f509f4 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 17:42:37 +0200 Subject: [PATCH 076/210] fix: ERC721 swiftlint --- Sources/web3swift/Tokens/ERC721/Web3+ERC721.swift | 8 +++++--- Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Sources/web3swift/Tokens/ERC721/Web3+ERC721.swift b/Sources/web3swift/Tokens/ERC721/Web3+ERC721.swift index f7db95dd7..db72d3784 100644 --- a/Sources/web3swift/Tokens/ERC721/Web3+ERC721.swift +++ b/Sources/web3swift/Tokens/ERC721/Web3+ERC721.swift @@ -63,9 +63,11 @@ public class ERC721: IERC721 { public var address: EthereumAddress lazy var contract: Web3.Contract = { + // swiftlint:disable force_unwrapping let contract = self.web3.contract(Web3.Utils.erc721ABI, at: self.address, abiVersion: 2) precondition(contract != nil) return contract! + // swiftlint:enable force_unwrapping }() public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, transaction: CodableTransaction = .emptyTransaction) { @@ -88,12 +90,12 @@ public class ERC721: IERC721 { if self._hasReadProperties { return } - guard contract.contract.address != nil else {return} + guard contract.contract.address != nil else { return } async let tokenIdPromise = contract.createReadOperation("tokenId")?.callContractMethod() - guard let tokenIdResult = try await tokenIdPromise else {return} - guard let tokenId = tokenIdResult["0"] as? BigUInt else {return} + guard let tokenIdResult = try await tokenIdPromise else { return } + guard let tokenId = tokenIdResult["0"] as? BigUInt else { return } self._tokenId = tokenId self._hasReadProperties = true diff --git a/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift b/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift index bce547e12..8407e446a 100644 --- a/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift +++ b/Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift @@ -47,9 +47,11 @@ public class ERC721x: IERC721x { public var abi: String lazy var contract: Web3.Contract = { + // swiftlint:disable force_unwrapping let contract = self.web3.contract(self.abi, at: self.address, abiVersion: 2) precondition(contract != nil) return contract! + // swiftlint:enable force_unwrapping }() public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.erc721xABI, transaction: CodableTransaction = .emptyTransaction) { @@ -73,12 +75,12 @@ public class ERC721x: IERC721x { if self._hasReadProperties { return } - guard contract.contract.address != nil else {return} + guard contract.contract.address != nil else { return } transaction.callOnBlock = .latest - guard let tokenIdPromise = try await contract.createReadOperation("tokenId")?.callContractMethod() else {return} + guard let tokenIdPromise = try await contract.createReadOperation("tokenId")?.callContractMethod() else { return } - guard let tokenId = tokenIdPromise["0"] as? BigUInt else {return} + guard let tokenId = tokenIdPromise["0"] as? BigUInt else { return } self._tokenId = tokenId self._hasReadProperties = true From 42bb154098b949f0b9229d5871a931fa2488541a Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 17:42:47 +0200 Subject: [PATCH 077/210] fix: ERC712 swiftlint --- Sources/web3swift/Utils/EIP/EIP712.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/web3swift/Utils/EIP/EIP712.swift b/Sources/web3swift/Utils/EIP/EIP712.swift index 3d7606ebe..e3a4bcb87 100644 --- a/Sources/web3swift/Utils/EIP/EIP712.swift +++ b/Sources/web3swift/Utils/EIP/EIP712.swift @@ -27,7 +27,9 @@ public struct EIP712Domain: EIP712Hashable { public extension EIP712.Address { static var zero: Self { + // swiftlint:disable force_unwrapping EthereumAddress(Data(count: 20))! + // swiftlint:enable force_unwrapping } } From ac0566479ae0ece6799dc97861d8bfb592cc5575 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 17:43:12 +0200 Subject: [PATCH 078/210] chore: implemented EthereumAddress tests --- .../localTests/EthereumAddressTest.swift | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Tests/web3swiftTests/localTests/EthereumAddressTest.swift b/Tests/web3swiftTests/localTests/EthereumAddressTest.swift index 4e2a99b88..7747d2155 100644 --- a/Tests/web3swiftTests/localTests/EthereumAddressTest.swift +++ b/Tests/web3swiftTests/localTests/EthereumAddressTest.swift @@ -1,8 +1,38 @@ // -// File.swift +// EthereumAddressTest.swift // // // Created by JeneaVranceanu on 03.02.2023. // import Foundation +import XCTest + +@testable import Web3Core + +class EthereumAddressTest: XCTestCase { + + func testZeroAddress() { + XCTAssertNotNil(EthereumAddress(Data(count: 20))) + } + + func testAddress() { + let rawAddress = "0x200eb5ccda1c35b0f5bf82552fdd65a8aee98e79" + let ethereumAddress = EthereumAddress(rawAddress) + XCTAssertNotNil(ethereumAddress) + XCTAssertEqual(ethereumAddress?.address.lowercased(), rawAddress) + } + + func testInvalidAddress() { + var rawAddress = "0x200eb5ccda1c35b0f5bf82552e98e79" + var ethereumAddress = EthereumAddress(rawAddress) + XCTAssertNil(ethereumAddress) + rawAddress = "0x200eb5ccDA1c35b0f5bf82552fdd65a8aeeabcde" + ethereumAddress = EthereumAddress(rawAddress) + XCTAssertNil(ethereumAddress) + rawAddress = "0x200eb5ccda1c35b0f5bf82552fdd65a8aeeabcdef" + ethereumAddress = EthereumAddress(rawAddress) + XCTAssertNil(ethereumAddress) + } + +} From 1b991c6ea9cc8365e5485c6ede316db4d8bf368a Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 17:43:44 +0200 Subject: [PATCH 079/210] fix: fixed tests --- .../web3swiftTests/remoteTests/ENSTests.swift | 48 +++++++++++++++---- .../remoteTests/InfuraTests.swift | 42 +++++++++++++--- 2 files changed, 75 insertions(+), 15 deletions(-) diff --git a/Tests/web3swiftTests/remoteTests/ENSTests.swift b/Tests/web3swiftTests/remoteTests/ENSTests.swift index 55a254848..1a9872ccb 100755 --- a/Tests/web3swiftTests/remoteTests/ENSTests.swift +++ b/Tests/web3swiftTests/remoteTests/ENSTests.swift @@ -23,7 +23,11 @@ class ENSTests: XCTestCase { } func testResolverAddress() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } let ens = ENS(web3: web3) let domain = "somename.eth" let address = try await ens?.registry.getResolver(forDomain: domain).resolverContractAddress @@ -32,7 +36,11 @@ class ENSTests: XCTestCase { } func testResolver() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } let ens = ENS(web3: web3) let domain = "somename.eth" let address = try await ens?.getAddress(forNode: domain) @@ -40,7 +48,11 @@ class ENSTests: XCTestCase { } func testSupportsInterface() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } let ens = ENS(web3: web3) let domain = "somename.eth" let resolver = try await ens?.registry.getResolver(forDomain: domain) @@ -55,7 +67,11 @@ class ENSTests: XCTestCase { } func testABI() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } let ens = ENS(web3: web3) let domain = "somename.eth" let resolver = try await ens?.registry.getResolver(forDomain: domain) @@ -70,7 +86,11 @@ class ENSTests: XCTestCase { } func testOwner() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } let ens = ENS(web3: web3) let domain = "somename.eth" let owner = try await ens?.registry.getOwner(node: domain) @@ -78,7 +98,11 @@ class ENSTests: XCTestCase { } func testTTL() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } let ens = try XCTUnwrap(ENS(web3: web3)) let domain = "somename.eth" let ttl = try await ens.registry.getTTL(node: domain) @@ -86,7 +110,11 @@ class ENSTests: XCTestCase { } func testGetAddress() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } let ens = ENS(web3: web3) let domain = "somename.eth" let resolver = try await ens?.registry.getResolver(forDomain: domain) @@ -95,7 +123,11 @@ class ENSTests: XCTestCase { } func testGetPubkey() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } let ens = ENS(web3: web3) let domain = "somename.eth" let resolver = try await ens?.registry.getResolver(forDomain: domain) diff --git a/Tests/web3swiftTests/remoteTests/InfuraTests.swift b/Tests/web3swiftTests/remoteTests/InfuraTests.swift index c53020293..8de339cdd 100755 --- a/Tests/web3swiftTests/remoteTests/InfuraTests.swift +++ b/Tests/web3swiftTests/remoteTests/InfuraTests.swift @@ -12,7 +12,11 @@ import Web3Core class InfuraTests: XCTestCase { func testGetBalance() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } let address = EthereumAddress("0xd61b5ca425F8C8775882d4defefC68A6979DBbce")! let balance = try await web3.eth.getBalance(for: address) let balString = Utilities.formatToPrecision(balance, units: .ether, formattingDecimals: 3) @@ -20,30 +24,50 @@ class InfuraTests: XCTestCase { } func testGetBlockByHash() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } let result = try await web3.eth.block(by: "0x6d05ba24da6b7a1af22dc6cc2a1fe42f58b2a5ea4c406b19c8cf672ed8ec0695", fullTransactions: false) XCTAssertEqual(result.number, 5184323) } func testGetBlockByHash_hashAsData() async throws { let blockHash = Data.fromHex("6d05ba24da6b7a1af22dc6cc2a1fe42f58b2a5ea4c406b19c8cf672ed8ec0695")! - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } let result = try await web3.eth.block(by: blockHash, fullTransactions: false) XCTAssertEqual(result.number, 5184323) } func testGetBlockByNumber1() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } _ = try await web3.eth.block(by: .latest, fullTransactions: false) } func testGetBlockByNumber2() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } _ = try await web3.eth.block(by: .exact(5184323), fullTransactions: true) } func testGetBlockByNumber3() async { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } do { _ = try await web3.eth.block(by: .exact(10000000000000), fullTransactions: true) XCTFail("The expression above must throw DecodingError.") @@ -54,7 +78,11 @@ class InfuraTests: XCTestCase { } func testGasPrice() async throws { - let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + else { + XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") + return + } _ = try await web3.eth.gasPrice() } From 1018a9f268b0ea89d416ba0b75a26cae80026a08 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 17:45:15 +0200 Subject: [PATCH 080/210] fix: added space around return statements in '{return nil}' --- .../Web3Core/EthereumABI/ABIDecoding.swift | 12 ++--- .../Web3Core/EthereumABI/ABIElements.swift | 4 +- .../Web3Core/EthereumABI/ABIEncoding.swift | 24 +++++----- .../EthereumAddress/EthereumAddress.swift | 12 ++--- .../KeystoreManager/BIP32HDNode.swift | 46 +++++++++---------- .../KeystoreManager/BIP32Keystore.swift | 10 ++-- Sources/Web3Core/KeystoreManager/BIP39.swift | 16 +++---- Sources/Web3Core/KeystoreManager/IBAN.swift | 6 +-- .../KeystoreManager/PlainKeystore.swift | 8 ++-- Sources/Web3Core/RLP/RLP.swift | 38 +++++++-------- .../Transaction/EthereumBloomFilter.swift | 2 +- .../Web3Core/Utility/BigUInt+Extension.swift | 2 +- .../Web3Core/Utility/CryptoExtension.swift | 6 +-- Sources/Web3Core/Utility/Data+Extension.swift | 6 +-- Sources/Web3Core/Utility/Utilities.swift | 42 ++++++++--------- .../Web3+BrowserFunctions.swift | 34 +++++++------- Sources/web3swift/Utils/EIP/EIP67Code.swift | 26 +++++------ Sources/web3swift/Utils/ENS/NameHash.swift | 2 +- Sources/web3swift/Web3/Web3+Contract.swift | 2 +- Sources/web3swift/Web3/Web3+EventParser.swift | 2 +- .../web3swiftTests/localTests/UserCases.swift | 4 +- 21 files changed, 152 insertions(+), 152 deletions(-) diff --git a/Sources/Web3Core/EthereumABI/ABIDecoding.swift b/Sources/Web3Core/EthereumABI/ABIDecoding.swift index d03a0adb4..cb220fec6 100755 --- a/Sources/Web3Core/EthereumABI/ABIDecoding.swift +++ b/Sources/Web3Core/EthereumABI/ABIDecoding.swift @@ -21,11 +21,11 @@ extension ABIDecoder { var consumed: UInt64 = 0 for i in 0 ..< types.count { let (v, c) = decodeSingleType(type: types[i], data: data, pointer: consumed) - guard let valueUnwrapped = v, let consumedUnwrapped = c else {return nil} + guard let valueUnwrapped = v, let consumedUnwrapped = c else { return nil } toReturn.append(valueUnwrapped) consumed = consumed + consumedUnwrapped } - guard toReturn.count == types.count else {return nil} + guard toReturn.count == types.count else { return nil } return toReturn } @@ -235,23 +235,23 @@ extension ABIDecoder { let nonIndexedTypes = nonIndexedInputs.compactMap { inp -> ABI.Element.ParameterType in return inp.type } - guard logs.count == indexedInputs.count + 1 else {return nil} + guard logs.count == indexedInputs.count + 1 else { return nil } var indexedValues = [Any]() for i in 0 ..< indexedInputs.count { let data = logs[i+1] let input = indexedInputs[i] if !input.type.isStatic || input.type.isArray || input.type.memoryUsage != 32 { let (v, _) = ABIDecoder.decodeSingleType(type: .bytes(length: 32), data: data) - guard let valueUnwrapped = v else {return nil} + guard let valueUnwrapped = v else { return nil } indexedValues.append(valueUnwrapped) } else { let (v, _) = ABIDecoder.decodeSingleType(type: input.type, data: data) - guard let valueUnwrapped = v else {return nil} + guard let valueUnwrapped = v else { return nil } indexedValues.append(valueUnwrapped) } } let v = ABIDecoder.decode(types: nonIndexedTypes, data: dataForProcessing) - guard let nonIndexedValues = v else {return nil} + guard let nonIndexedValues = v else { return nil } var indexedInputCounter = 0 var nonIndexedInputCounter = 0 for i in 0 ..< event.inputs.count { diff --git a/Sources/Web3Core/EthereumABI/ABIElements.swift b/Sources/Web3Core/EthereumABI/ABIElements.swift index a9a28bcd0..aa1453ba2 100755 --- a/Sources/Web3Core/EthereumABI/ABIElements.swift +++ b/Sources/Web3Core/EthereumABI/ABIElements.swift @@ -215,7 +215,7 @@ extension ABI.Element.Function { extension ABI.Element.Event { public func decodeReturnedLogs(eventLogTopics: [Data], eventLogData: Data) -> [String: Any]? { - guard let eventContent = ABIDecoder.decodeLog(event: self, eventLogTopics: eventLogTopics, eventLogData: eventLogData) else {return nil} + guard let eventContent = ABIDecoder.decodeLog(event: self, eventLogTopics: eventLogTopics, eventLogData: eventLogData) else { return nil } return eventContent } } @@ -478,7 +478,7 @@ private func decodeInputData(_ rawData: Data, guard inputs.count * 32 <= data.count else { return nil } var i = 0 - guard let values = ABIDecoder.decode(types: inputs, data: data) else {return nil} + guard let values = ABIDecoder.decode(types: inputs, data: data) else { return nil } for input in inputs { let name = "\(i)" returnArray[name] = values[i] diff --git a/Sources/Web3Core/EthereumABI/ABIEncoding.swift b/Sources/Web3Core/EthereumABI/ABIEncoding.swift index a55a1fd63..2f061c577 100755 --- a/Sources/Web3Core/EthereumABI/ABIEncoding.swift +++ b/Sources/Web3Core/EthereumABI/ABIEncoding.swift @@ -119,7 +119,7 @@ public struct ABIEncoder { case let d as [IntegerLiteralType]: var bytesArray = [UInt8]() for el in d { - guard el >= 0, el <= 255 else {return nil} + guard el >= 0, el <= 255 else { return nil } bytesArray.append(UInt8(el)) } return Data(bytesArray) @@ -138,7 +138,7 @@ public struct ABIEncoder { /// - `types.count != values.count`; /// - encoding of at least one value has failed (e.g. type mismatch). public static func encode(types: [ABI.Element.InOut], values: [Any]) -> Data? { - guard types.count == values.count else {return nil} + guard types.count == values.count else { return nil } let params = types.compactMap { el -> ABI.Element.ParameterType in return el.type } @@ -154,12 +154,12 @@ public struct ABIEncoder { /// - `types.count != values.count`; /// - encoding of at least one value has failed (e.g. type mismatch). public static func encode(types: [ABI.Element.ParameterType], values: [Any]) -> Data? { - guard types.count == values.count else {return nil} + guard types.count == values.count else { return nil } var tails = [Data]() var heads = [Data]() for i in 0 ..< types.count { let enc = encodeSingleType(type: types[i], value: values[i]) - guard let encoding = enc else {return nil} + guard let encoding = enc else { return nil } if types[i].isStatic { heads.append(encoding) tails.append(Data()) @@ -179,7 +179,7 @@ public struct ABIEncoder { let head = heads[i] let tail = tails[i] if !types[i].isStatic { - guard let newHead = tailsPointer.abiEncode(bits: 256) else {return nil} + guard let newHead = tailsPointer.abiEncode(bits: 256) else { return nil } headsConcatenated.append(newHead) tailsConcatenated.append(tail) tailsPointer = tailsPointer + BigUInt(tail.count) @@ -225,7 +225,7 @@ public struct ABIEncoder { return bigint == nil ? nil : bigint!.abiEncode(bits: 256) case .address: if let string = value as? String { - guard let address = EthereumAddress(string) else {return nil} + guard let address = EthereumAddress(string) else { return nil } let data = address.addressData return data.setLengthLeft(32) } else if let address = value as? EthereumAddress { @@ -293,7 +293,7 @@ public struct ABIEncoder { var heads = [Data]() for i in 0 ..< val.count { let enc = encodeSingleType(type: subType, value: val[i]) - guard let encoding = enc else {return nil} + guard let encoding = enc else { return nil } heads.append(Data(repeating: 0x0, count: 32)) tails.append(encoding) } @@ -308,7 +308,7 @@ public struct ABIEncoder { let head = heads[i] let tail = tails[i] if tail != Data() { - guard let newHead = tailsPointer.abiEncode(bits: 256) else {return nil} + guard let newHead = tailsPointer.abiEncode(bits: 256) else { return nil } headsConcatenated.append(newHead) tailsConcatenated.append(tail) tailsPointer = tailsPointer + BigUInt(tail.count) @@ -340,7 +340,7 @@ public struct ABIEncoder { var heads = [Data]() for i in 0 ..< val.count { let enc = encodeSingleType(type: subType, value: val[i]) - guard let encoding = enc else {return nil} + guard let encoding = enc else { return nil } heads.append(Data(repeating: 0x0, count: 32)) tails.append(encoding) } @@ -353,7 +353,7 @@ public struct ABIEncoder { var tailsConcatenated = Data() for i in 0 ..< val.count { let tail = tails[i] - guard let newHead = tailsPointer.abiEncode(bits: 256) else {return nil} + guard let newHead = tailsPointer.abiEncode(bits: 256) else { return nil } headsConcatenated.append(newHead) tailsConcatenated.append(tail) tailsPointer = tailsPointer + BigUInt(tail.count) @@ -370,7 +370,7 @@ public struct ABIEncoder { guard let val = value as? [Any] else {break} for i in 0 ..< subTypes.count { let enc = encodeSingleType(type: subTypes[i], value: val[i]) - guard let encoding = enc else {return nil} + guard let encoding = enc else { return nil } if subTypes[i].isStatic { heads.append(encoding) tails.append(Data()) @@ -390,7 +390,7 @@ public struct ABIEncoder { let head = heads[i] let tail = tails[i] if !subTypes[i].isStatic { - guard let newHead = tailsPointer.abiEncode(bits: 256) else {return nil} + guard let newHead = tailsPointer.abiEncode(bits: 256) else { return nil } headsConcatenated.append(newHead) tailsConcatenated.append(tail) tailsPointer = tailsPointer + BigUInt(tail.count) diff --git a/Sources/Web3Core/EthereumAddress/EthereumAddress.swift b/Sources/Web3Core/EthereumAddress/EthereumAddress.swift index 2e8d0ef45..cec972433 100755 --- a/Sources/Web3Core/EthereumAddress/EthereumAddress.swift +++ b/Sources/Web3Core/EthereumAddress/EthereumAddress.swift @@ -63,7 +63,7 @@ public struct EthereumAddress: Equatable { /// represented as `ASCII` data. Otherwise, checksummed address is returned with `0x` prefix. public static func toChecksumAddress(_ addr: String) -> String? { let address = addr.lowercased().stripHexPrefix() - guard let hash = address.data(using: .ascii)?.sha3(.keccak256).toHexString().stripHexPrefix() else {return nil} + guard let hash = address.data(using: .ascii)?.sha3(.keccak256).toHexString().stripHexPrefix() else { return nil } var ret = "0x" for (i, char) in address.enumerated() { @@ -71,7 +71,7 @@ public struct EthereumAddress: Equatable { let endIdx = hash.index(hash.startIndex, offsetBy: i+1) let hashChar = String(hash[startIdx..= 8 { ret += c.uppercased() } else { @@ -96,8 +96,8 @@ extension EthereumAddress { public init?(_ addressString: String, type: AddressType = .normal, ignoreChecksum: Bool = false) { switch type { case .normal: - guard let data = Data.fromHex(addressString) else {return nil} - guard data.count == 20 else {return nil} + guard let data = Data.fromHex(addressString) else { return nil } + guard data.count == 20 else { return nil } if !addressString.hasHexPrefix() { return nil } @@ -113,7 +113,7 @@ extension EthereumAddress { return } else { let checksummedAddress = EthereumAddress.toChecksumAddress(data.toHexString().addHexPrefix()) - guard checksummedAddress == addressString else {return nil} + guard checksummedAddress == addressString else { return nil } self._address = data.toHexString().addHexPrefix() self.type = .normal return @@ -131,7 +131,7 @@ extension EthereumAddress { } public init?(_ addressData: Data, type: AddressType = .normal) { - guard addressData.count == 20 else {return nil} + guard addressData.count == 20 else { return nil } self._address = addressData.toHexString().addHexPrefix() self.type = type } diff --git a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift index fd86f1a54..ca9a205b9 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift @@ -69,7 +69,7 @@ public class HDNode { } public init?(_ data: Data) { - guard data.count == 82 else {return nil} + guard data.count == 82 else { return nil } let header = data[0..<4] var serializePrivate = false if header == HDNode.HDversion().privatePrefix { @@ -81,30 +81,30 @@ public class HDNode { chaincode = data[13..<45] if serializePrivate { privateKey = data[46..<78] - guard let pubKey = Utilities.privateToPublic(privateKey!, compressed: true) else {return nil} - if pubKey[0] != 0x02 && pubKey[0] != 0x03 {return nil} + guard let pubKey = Utilities.privateToPublic(privateKey!, compressed: true) else { return nil } + if pubKey[0] != 0x02 && pubKey[0] != 0x03 { return nil } publicKey = pubKey } else { publicKey = data[45..<78] } let hashedData = data[0..<78].sha256().sha256() let checksum = hashedData[0..<4] - if checksum != data[78..<82] {return nil} + if checksum != data[78..<82] { return nil } } public init?(seed: Data) { - guard seed.count >= 16 else {return nil} + guard seed.count >= 16 else { return nil } let hmacKey = "Bitcoin seed".data(using: .ascii)! let hmac: Authenticator = HMAC(key: hmacKey.bytes, variant: HMAC.Variant.sha2(.sha512)) - guard let entropy = try? hmac.authenticate(seed.bytes) else {return nil} + guard let entropy = try? hmac.authenticate(seed.bytes) else { return nil } guard entropy.count == 64 else { return nil} let I_L = entropy[0..<32] let I_R = entropy[32..<64] chaincode = Data(I_R) let privKeyCandidate = Data(I_L) - guard SECP256K1.verifyPrivateKey(privateKey: privKeyCandidate) else {return nil} - guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: privKeyCandidate, compressed: true) else {return nil} - guard pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03 else {return nil} + guard SECP256K1.verifyPrivateKey(privateKey: privKeyCandidate) else { return nil } + guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: privKeyCandidate, compressed: true) else { return nil } + guard pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03 else { return nil } publicKey = pubKeyCandidate privateKey = privKeyCandidate depth = 0x00 @@ -165,11 +165,11 @@ extension HDNode { } return nil } - guard let privKeyCandidate = newPK.serialize().setLengthLeft(32) else {return nil} + guard let privKeyCandidate = newPK.serialize().setLengthLeft(32) else { return nil } guard SECP256K1.verifyPrivateKey(privateKey: privKeyCandidate) else {return nil } - guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: privKeyCandidate, compressed: true) else {return nil} - guard pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03 else {return nil} - guard self.depth < UInt8.max else {return nil} + guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: privKeyCandidate, compressed: true) else { return nil } + guard pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03 else { return nil } + guard self.depth < UInt8.max else { return nil } let newNode = HDNode() newNode.chaincode = cc newNode.depth = self.depth + 1 @@ -215,13 +215,13 @@ extension HDNode { } return nil } - guard let tempKey = bn.serialize().setLengthLeft(32) else {return nil} + guard let tempKey = bn.serialize().setLengthLeft(32) else { return nil } guard SECP256K1.verifyPrivateKey(privateKey: tempKey) else {return nil } - guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: tempKey, compressed: true) else {return nil} - guard pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03 else {return nil} - guard let newPublicKey = SECP256K1.combineSerializedPublicKeys(keys: [self.publicKey, pubKeyCandidate], outputCompressed: true) else {return nil} - guard newPublicKey.bytes[0] == 0x02 || newPublicKey.bytes[0] == 0x03 else {return nil} - guard self.depth < UInt8.max else {return nil} + guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: tempKey, compressed: true) else { return nil } + guard pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03 else { return nil } + guard let newPublicKey = SECP256K1.combineSerializedPublicKeys(keys: [self.publicKey, pubKeyCandidate], outputCompressed: true) else { return nil } + guard newPublicKey.bytes[0] == 0x02 || newPublicKey.bytes[0] == 0x03 else { return nil } + guard self.depth < UInt8.max else { return nil } let newNode = HDNode() newNode.chaincode = cc newNode.depth = self.depth + 1 @@ -255,22 +255,22 @@ extension HDNode { if component.hasSuffix("'") { hardened = true } - guard let index = UInt32(component.trimmingCharacters(in: CharacterSet(charactersIn: "'"))) else {return nil} - guard let newNode = currentNode.derive(index: index, derivePrivateKey: derivePrivateKey, hardened: hardened) else {return nil} + guard let index = UInt32(component.trimmingCharacters(in: CharacterSet(charactersIn: "'"))) else { return nil } + guard let newNode = currentNode.derive(index: index, derivePrivateKey: derivePrivateKey, hardened: hardened) else { return nil } currentNode = newNode } return currentNode } public func serializeToString(serializePublic: Bool = true, version: HDversion = HDversion()) -> String? { - guard let data = self.serialize(serializePublic: serializePublic, version: version) else {return nil} + guard let data = self.serialize(serializePublic: serializePublic, version: version) else { return nil } let encoded = Base58.base58FromBytes(data.bytes) return encoded } public func serialize(serializePublic: Bool = true, version: HDversion = HDversion()) -> Data? { var data = Data() - if !serializePublic && !self.hasPrivate {return nil} + if !serializePublic && !self.hasPrivate { return nil } if serializePublic { data.append(version.publicPrefix) } else { diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index 67a95e3ef..89205dde0 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -74,10 +74,10 @@ public class BIP32Keystore: AbstractKeystore { } public init?(_ jsonData: Data) { - guard var keystorePars = try? JSONDecoder().decode(KeystoreParamsBIP32.self, from: jsonData) else {return nil} - if keystorePars.version != Self.KeystoreParamsBIP32Version {return nil} - if keystorePars.crypto.version != nil && keystorePars.crypto.version != "1" {return nil} - if !keystorePars.isHDWallet {return nil} + guard var keystorePars = try? JSONDecoder().decode(KeystoreParamsBIP32.self, from: jsonData) else { return nil } + if keystorePars.version != Self.KeystoreParamsBIP32Version { return nil } + if keystorePars.crypto.version != nil && keystorePars.crypto.version != "1" { return nil } + if !keystorePars.isHDWallet { return nil } addressStorage = PathAddressStorage(pathAddressPairs: keystorePars.pathAddressPairs) @@ -100,7 +100,7 @@ public class BIP32Keystore: AbstractKeystore { public init? (seed: Data, password: String, prefixPath: String = HDNode.defaultPathMetamaskPrefix, aesMode: String = "aes-128-cbc") throws { addressStorage = PathAddressStorage() - guard let rootNode = HDNode(seed: seed)?.derive(path: prefixPath, derivePrivateKey: true) else {return nil} + guard let rootNode = HDNode(seed: seed)?.derive(path: prefixPath, derivePrivateKey: true) else { return nil } self.rootPrefix = prefixPath try createNewAccount(parentNode: rootNode, password: password) guard let serializedRootNode = rootNode.serialize(serializePublic: false) else { diff --git a/Sources/Web3Core/KeystoreManager/BIP39.swift b/Sources/Web3Core/KeystoreManager/BIP39.swift index a7966cdd3..32ba25294 100755 --- a/Sources/Web3Core/KeystoreManager/BIP39.swift +++ b/Sources/Web3Core/KeystoreManager/BIP39.swift @@ -71,7 +71,7 @@ public enum BIP39Language { public class BIP39 { static public func generateMnemonicsFromEntropy(entropy: Data, language: BIP39Language = BIP39Language.english) -> String? { - guard entropy.count >= 16, entropy.count & 4 == 0 else {return nil} + guard entropy.count >= 16, entropy.count & 4 == 0 else { return nil } let checksum = entropy.sha256() let checksumBits = entropy.count*8/32 var fullEntropy = Data() @@ -79,9 +79,9 @@ public class BIP39 { fullEntropy.append(checksum[0 ..< (checksumBits+7)/8 ]) var wordList = [String]() for i in 0 ..< fullEntropy.count*8/11 { - guard let bits = fullEntropy.bitsInRange(i*11, 11) else {return nil} + guard let bits = fullEntropy.bitsInRange(i*11, 11) else { return nil } let index = Int(bits) - guard language.words.count > index else {return nil} + guard language.words.count > index else { return nil } let word = language.words[index] wordList.append(word) } @@ -95,7 +95,7 @@ public class BIP39 { /// - language: words language, default english /// - Returns: random 12-24 words, that represent new Mnemonic phrase. static public func generateMnemonics(bitsOfEntropy: Int, language: BIP39Language = BIP39Language.english) throws -> String? { - guard bitsOfEntropy >= 128 && bitsOfEntropy <= 256 && bitsOfEntropy.isMultiple(of: 32) else {return nil} + guard bitsOfEntropy >= 128 && bitsOfEntropy <= 256 && bitsOfEntropy.isMultiple(of: 32) else { return nil } guard let entropy = Data.randomBytes(length: bitsOfEntropy/8) else {throw AbstractKeystoreError.noEntropyError} return BIP39.generateMnemonicsFromEntropy(entropy: entropy, language: language) @@ -104,7 +104,7 @@ public class BIP39 { static public func mnemonicsToEntropy(_ mnemonics: String, language: BIP39Language = BIP39Language.english) -> Data? { let wordList = mnemonics.components(separatedBy: " ") - guard wordList.count >= 12 && wordList.count.isMultiple(of: 3) && wordList.count <= 24 else {return nil} + guard wordList.count >= 12 && wordList.count.isMultiple(of: 3) && wordList.count <= 24 else { return nil } var bitString = "" for word in wordList { let idx = language.words.firstIndex(of: word) @@ -136,10 +136,10 @@ public class BIP39 { if !valid { return nil } - guard let mnemData = mnemonics.decomposedStringWithCompatibilityMapping.data(using: .utf8) else {return nil} + guard let mnemData = mnemonics.decomposedStringWithCompatibilityMapping.data(using: .utf8) else { return nil } let salt = "mnemonic" + password - guard let saltData = salt.decomposedStringWithCompatibilityMapping.data(using: .utf8) else {return nil} - guard let seedArray = try? PKCS5.PBKDF2(password: mnemData.bytes, salt: saltData.bytes, iterations: 2048, keyLength: 64, variant: HMAC.Variant.sha2(.sha512)).calculate() else {return nil} + guard let saltData = salt.decomposedStringWithCompatibilityMapping.data(using: .utf8) else { return nil } + guard let seedArray = try? PKCS5.PBKDF2(password: mnemData.bytes, salt: saltData.bytes, iterations: 2048, keyLength: 64, variant: HMAC.Variant.sha2(.sha512)).calculate() else { return nil } let seed = Data(seedArray) return seed } diff --git a/Sources/Web3Core/KeystoreManager/IBAN.swift b/Sources/Web3Core/KeystoreManager/IBAN.swift index 164ff319f..84a46b1c2 100755 --- a/Sources/Web3Core/KeystoreManager/IBAN.swift +++ b/Sources/Web3Core/KeystoreManager/IBAN.swift @@ -111,15 +111,15 @@ public struct IBAN { public init?(_ ibanString: String) { let matched = ibanString.replacingOccurrences(of: " ", with: "").uppercased() - guard IBAN.isValidIBANaddress(matched) else {return nil} + guard IBAN.isValidIBANaddress(matched) else { return nil } self.iban = matched } public init?(_ address: EthereumAddress) { let addressString = address.address.lowercased().stripHexPrefix() - guard let bigNumber = BigUInt(addressString, radix: 16) else {return nil} + guard let bigNumber = BigUInt(addressString, radix: 16) else { return nil } let base36EncodedString = String(bigNumber, radix: 36) - guard base36EncodedString.count <= 30 else {return nil} + guard base36EncodedString.count <= 30 else { return nil } let padded = base36EncodedString.leftPadding(toLength: 30, withPad: "0") let prefix = "XE" let remainder = IBAN.calculateChecksumMod97(IBAN.decodeToInts(prefix + "00" + padded)) diff --git a/Sources/Web3Core/KeystoreManager/PlainKeystore.swift b/Sources/Web3Core/KeystoreManager/PlainKeystore.swift index 5150149a2..1e43ff3af 100755 --- a/Sources/Web3Core/KeystoreManager/PlainKeystore.swift +++ b/Sources/Web3Core/KeystoreManager/PlainKeystore.swift @@ -19,14 +19,14 @@ public class PlainKeystore: AbstractKeystore { } public convenience init?(privateKey: String) { - guard let privateKeyData = Data.fromHex(privateKey) else {return nil} + guard let privateKeyData = Data.fromHex(privateKey) else { return nil } self.init(privateKey: privateKeyData) } public init?(privateKey: Data) { - guard SECP256K1.verifyPrivateKey(privateKey: privateKey) else {return nil} - guard let publicKey = Utilities.privateToPublic(privateKey, compressed: false) else {return nil} - guard let address = Utilities.publicToAddress(publicKey) else {return nil} + guard SECP256K1.verifyPrivateKey(privateKey: privateKey) else { return nil } + guard let publicKey = Utilities.privateToPublic(privateKey, compressed: false) else { return nil } + guard let address = Utilities.publicToAddress(publicKey) else { return nil } self.addresses = [address] self.privateKey = privateKey } diff --git a/Sources/Web3Core/RLP/RLP.swift b/Sources/Web3Core/RLP/RLP.swift index af5d8b29e..b565bb3fa 100755 --- a/Sources/Web3Core/RLP/RLP.swift +++ b/Sources/Web3Core/RLP/RLP.swift @@ -33,12 +33,12 @@ public struct RLP { if let hexData = Data.fromHex(string) { return encode(hexData) } - guard let data = string.data(using: .utf8) else {return nil} + guard let data = string.data(using: .utf8) else { return nil } return encode(data) } internal static func encode(_ number: Int) -> Data? { - guard number >= 0 else {return nil} + guard number >= 0 else { return nil } let uint = UInt(number) return encode(uint) } @@ -57,7 +57,7 @@ public struct RLP { if data.count == 1 && data.bytes[0] < UInt8(0x80) { return data } else { - guard let length = encodeLength(data.count, offset: UInt8(0x80)) else {return nil} + guard let length = encodeLength(data.count, offset: UInt8(0x80)) else { return nil } var encoded = Data() encoded.append(length) encoded.append(data) @@ -76,12 +76,12 @@ public struct RLP { internal static func encodeLength(_ length: BigUInt, offset: UInt8) -> Data? { if length < length56 { let encodedLength = length + BigUInt(UInt(offset)) - guard encodedLength.bitWidth <= 8 else {return nil} + guard encodedLength.bitWidth <= 8 else { return nil } return encodedLength.serialize() } else if length < lengthMax { let encodedLength = length.serialize() let len = BigUInt(UInt(encodedLength.count)) - guard let prefix = lengthToBinary(len) else {return nil} + guard let prefix = lengthToBinary(len) else { return nil } let lengthPrefix = prefix + offset + UInt8(55) var encoded = Data([lengthPrefix]) encoded.append(encodedLength) @@ -96,7 +96,7 @@ public struct RLP { } let divisor = BigUInt(256) var encoded = Data() - guard let prefix = lengthToBinary(length/divisor) else {return nil} + guard let prefix = lengthToBinary(length/divisor) else { return nil } let suffix = length % divisor var prefixData = Data([prefix]) @@ -107,7 +107,7 @@ public struct RLP { encoded.append(prefixData) encoded.append(suffixData) - guard encoded.count == 1 else {return nil} + guard encoded.count == 1 else { return nil } return encoded.bytes[0] } @@ -117,12 +117,12 @@ public struct RLP { if let encoded = encode(element: e) { encodedData.append(encoded) } else { - guard let asArray = e as? [Any] else {return nil} - guard let encoded = encode(asArray) else {return nil} + guard let asArray = e as? [Any] else { return nil } + guard let encoded = encode(asArray) else { return nil } encodedData.append(encoded) } } - guard var encodedLength = encodeLength(encodedData.count, offset: UInt8(0xc0)) else {return nil} + guard var encodedLength = encodeLength(encodedData.count, offset: UInt8(0xc0)) else { return nil } if encodedLength != Data() { encodedLength.append(encodedData) } @@ -130,7 +130,7 @@ public struct RLP { } internal static func decode(_ raw: String) -> RLPItem? { - guard let rawData = Data.fromHex(raw) else {return nil} + guard let rawData = Data.fromHex(raw) else { return nil } return decode(rawData) } @@ -142,18 +142,18 @@ public struct RLP { var bytesToParse = Data(raw) while bytesToParse.count != 0 { let (of, dl, t) = decodeLength(bytesToParse) - guard let offset = of, let dataLength = dl, let type = t else {return nil} + guard let offset = of, let dataLength = dl, let type = t else { return nil } switch type { case .empty: break case .data: - guard let slice = try? slice(data: bytesToParse, offset: offset, length: dataLength) else {return nil} + guard let slice = try? slice(data: bytesToParse, offset: offset, length: dataLength) else { return nil } let data = Data(slice) let rlpItem = RLPItem.init(content: .data(data)) outputArray.append(rlpItem) case .list: - guard let slice = try? slice(data: bytesToParse, offset: offset, length: dataLength) else {return nil} - guard let inside = decode(Data(slice)) else {return nil} + guard let slice = try? slice(data: bytesToParse, offset: offset, length: dataLength) else { return nil } + guard let inside = decode(Data(slice)) else { return nil } switch inside.content { case .data: return nil @@ -161,7 +161,7 @@ public struct RLP { outputArray.append(inside) } } - guard let tail = try? slice(data: bytesToParse, start: offset + dataLength) else {return nil} + guard let tail = try? slice(data: bytesToParse, start: offset + dataLength) else { return nil } bytesToParse = tail } return RLPItem.init(content: .list(outputArray, 0, Data(raw))) @@ -217,7 +217,7 @@ public struct RLP { public subscript(index: Int) -> RLPItem? { get { - guard case .list(let list, _, _) = self.content else {return nil} + guard case .list(let list, _, _) = self.content else { return nil } let item = list[index] return item } @@ -229,10 +229,10 @@ public struct RLP { public func getData() -> Data? { if self.isList { - guard case .list(_, _, let rawContent) = self.content else {return nil} + guard case .list(_, _, let rawContent) = self.content else { return nil } return rawContent } - guard case .data(let data) = self.content else {return nil} + guard case .data(let data) = self.content else { return nil } return data } diff --git a/Sources/Web3Core/Transaction/EthereumBloomFilter.swift b/Sources/Web3Core/Transaction/EthereumBloomFilter.swift index c55998270..30bff1f78 100755 --- a/Sources/Web3Core/Transaction/EthereumBloomFilter.swift +++ b/Sources/Web3Core/Transaction/EthereumBloomFilter.swift @@ -22,7 +22,7 @@ public struct EthereumBloomFilter { /// Bloom filter. public var bytes = Data(repeatElement(UInt8(0), count: 256)) public init?(_ biguint: BigUInt) { - guard let data = biguint.serialize().setLengthLeft(256) else {return nil} + guard let data = biguint.serialize().setLengthLeft(256) else { return nil } bytes = data } public init() {} diff --git a/Sources/Web3Core/Utility/BigUInt+Extension.swift b/Sources/Web3Core/Utility/BigUInt+Extension.swift index 743e92fbc..6144b6247 100755 --- a/Sources/Web3Core/Utility/BigUInt+Extension.swift +++ b/Sources/Web3Core/Utility/BigUInt+Extension.swift @@ -9,7 +9,7 @@ import struct BigInt.BigUInt public extension BigUInt { init?(_ naturalUnits: String, _ ethereumUnits: Utilities.Units) { - guard let value = Utilities.parseToBigUInt(naturalUnits, units: ethereumUnits) else {return nil} + guard let value = Utilities.parseToBigUInt(naturalUnits, units: ethereumUnits) else { return nil } self = value } } diff --git a/Sources/Web3Core/Utility/CryptoExtension.swift b/Sources/Web3Core/Utility/CryptoExtension.swift index 6c270ee1b..39d107a2d 100755 --- a/Sources/Web3Core/Utility/CryptoExtension.swift +++ b/Sources/Web3Core/Utility/CryptoExtension.swift @@ -12,8 +12,8 @@ func toByteArray(_ value: T) -> [UInt8] { } func scrypt (password: String, salt: Data, length: Int, N: Int, R: Int, P: Int) -> Data? { - guard let passwordData = password.data(using: .utf8) else {return nil} - guard let deriver = try? Scrypt(password: passwordData.bytes, salt: salt.bytes, dkLen: length, N: N, r: R, p: P) else {return nil} - guard let result = try? deriver.calculate() else {return nil} + guard let passwordData = password.data(using: .utf8) else { return nil } + guard let deriver = try? Scrypt(password: passwordData.bytes, salt: salt.bytes, dkLen: length, N: N, r: R, p: P) else { return nil } + guard let result = try? deriver.calculate() else { return nil } return Data(result) } diff --git a/Sources/Web3Core/Utility/Data+Extension.swift b/Sources/Web3Core/Utility/Data+Extension.swift index 6949f91be..448728f1a 100755 --- a/Sources/Web3Core/Utility/Data+Extension.swift +++ b/Sources/Web3Core/Utility/Data+Extension.swift @@ -59,15 +59,15 @@ extension Data { } public func bitsInRange(_ startingBit: Int, _ length: Int) -> UInt64? { // return max of 8 bytes for simplicity, non-public - if startingBit + length / 8 > self.count, length > 64, startingBit > 0, length >= 1 {return nil} + if startingBit + length / 8 > self.count, length > 64, startingBit > 0, length >= 1 { return nil } let bytes = self[(startingBit/8) ..< (startingBit+length+7)/8] let padding = Data(repeating: 0, count: 8 - bytes.count) let padded = bytes + padding - guard padded.count == 8 else {return nil} + guard padded.count == 8 else { return nil } let pointee = padded.withUnsafeBytes { (body: UnsafeRawBufferPointer) in body.baseAddress?.assumingMemoryBound(to: UInt64.self).pointee } - guard let ptee = pointee else {return nil} + guard let ptee = pointee else { return nil } var uintRepresentation = UInt64(bigEndian: ptee) uintRepresentation = uintRepresentation << (startingBit % 8) uintRepresentation = uintRepresentation >> UInt64(64 - length) diff --git a/Sources/Web3Core/Utility/Utilities.swift b/Sources/Web3Core/Utility/Utilities.swift index 3d347e79a..4524bcd98 100644 --- a/Sources/Web3Core/Utility/Utilities.swift +++ b/Sources/Web3Core/Utility/Utilities.swift @@ -44,14 +44,14 @@ public struct Utilities { /// - Parameter publicKey: compressed 33, non-compressed (65 bytes) or non-compressed without prefix (64 bytes) /// - Returns: `EthereumAddress` object. public static func publicToAddress(_ publicKey: Data) -> EthereumAddress? { - guard let addressData = publicToAddressData(publicKey) else {return nil} + guard let addressData = publicToAddressData(publicKey) else { return nil } let address = addressData.toHexString().addHexPrefix().lowercased() return EthereumAddress(address) } /// Convert the private key (32 bytes of Data) to compressed (33 bytes) or non-compressed (65 bytes) public key. public static func privateToPublic(_ privateKey: Data, compressed: Bool = false) -> Data? { - guard let publicKey = SECP256K1.privateToPublic(privateKey: privateKey, compressed: compressed) else {return nil} + guard let publicKey = SECP256K1.privateToPublic(privateKey: privateKey, compressed: compressed) else { return nil } return publicKey } @@ -61,14 +61,14 @@ public struct Utilities { /// - Parameter publicKey: compressed 33, non-compressed (65 bytes) or non-compressed without prefix (64 bytes) /// - Returns: `0x` prefixed hex string. public static func publicToAddressString(_ publicKey: Data) -> String? { - guard let addressData = Utilities.publicToAddressData(publicKey) else {return nil} + guard let addressData = Utilities.publicToAddressData(publicKey) else { return nil } let address = addressData.toHexString().addHexPrefix().lowercased() return address } /// Converts address data (20 bytes) to the 0x prefixed hex string. Does not perform checksumming. static func addressDataToString(_ addressData: Data) -> String? { - guard addressData.count == 20 else {return nil} + guard addressData.count == 20 else { return nil } return addressData.toHexString().addHexPrefix().lowercased() } @@ -78,7 +78,7 @@ public struct Utilities { public static func hashPersonalMessage(_ personalMessage: Data) -> Data? { var prefix = "\u{19}Ethereum Signed Message:\n" prefix += String(personalMessage.count) - guard let prefixData = prefix.data(using: .ascii) else {return nil} + guard let prefixData = prefix.data(using: .ascii) else { return nil } var data = Data() if personalMessage.count >= prefixData.count && prefixData == personalMessage[0 ..< prefixData.count] { data.append(personalMessage) @@ -104,14 +104,14 @@ public struct Utilities { public static func parseToBigUInt(_ amount: String, decimals: Int = 18) -> BigUInt? { let separators = CharacterSet(charactersIn: ".,") let components = amount.trimmingCharacters(in: .whitespacesAndNewlines).components(separatedBy: separators) - guard components.count == 1 || components.count == 2 else {return nil} + guard components.count == 1 || components.count == 2 else { return nil } let unitDecimals = decimals - guard let beforeDecPoint = BigUInt(components[0], radix: 10) else {return nil} + guard let beforeDecPoint = BigUInt(components[0], radix: 10) else { return nil } var mainPart = beforeDecPoint*BigUInt(10).power(unitDecimals) if components.count == 2 { let numDigits = components[1].count - guard numDigits <= unitDecimals else {return nil} - guard let afterDecPoint = BigUInt(components[1], radix: 10) else {return nil} + guard numDigits <= unitDecimals else { return nil } + guard let afterDecPoint = BigUInt(components[1], radix: 10) else { return nil } let extraPart = afterDecPoint*BigUInt(10).power(unitDecimals-numDigits) mainPart = mainPart + extraPart } @@ -196,8 +196,8 @@ public struct Utilities { /// /// Input parameters should be hex Strings. static func personalECRecover(_ personalMessage: String, signature: String) -> EthereumAddress? { - guard let data = Data.fromHex(personalMessage) else {return nil} - guard let sig = Data.fromHex(signature) else {return nil} + guard let data = Data.fromHex(personalMessage) else { return nil } + guard let sig = Data.fromHex(signature) else { return nil } return Utilities.personalECRecover(data, signature: sig) } @@ -218,9 +218,9 @@ public struct Utilities { vData -= 35 } - guard let signatureData = SECP256K1.marshalSignature(v: vData, r: rData, s: sData) else {return nil} - guard let hash = Utilities.hashPersonalMessage(personalMessage) else {return nil} - guard let publicKey = SECP256K1.recoverPublicKey(hash: hash, signature: signatureData) else {return nil} + guard let signatureData = SECP256K1.marshalSignature(v: vData, r: rData, s: sData) else { return nil } + guard let hash = Utilities.hashPersonalMessage(personalMessage) else { return nil } + guard let publicKey = SECP256K1.recoverPublicKey(hash: hash, signature: signatureData) else { return nil } return Utilities.publicToAddress(publicKey) } @@ -240,32 +240,32 @@ public struct Utilities { } else if vData >= 35 && vData <= 38 { vData -= 35 } - guard let signatureData = SECP256K1.marshalSignature(v: vData, r: rData, s: sData) else {return nil} - guard let publicKey = SECP256K1.recoverPublicKey(hash: hash, signature: signatureData) else {return nil} + guard let signatureData = SECP256K1.marshalSignature(v: vData, r: rData, s: sData) else { return nil } + guard let publicKey = SECP256K1.recoverPublicKey(hash: hash, signature: signatureData) else { return nil } return Utilities.publicToAddress(publicKey) } /// returns Ethereum variant of sha3 (keccak256) of data. Returns nil is data is empty static func keccak256(_ data: Data) -> Data? { - if data.count == 0 {return nil} + if data.count == 0 { return nil } return data.sha3(.keccak256) } /// returns Ethereum variant of sha3 (keccak256) of data. Returns nil is data is empty static func sha3(_ data: Data) -> Data? { - if data.count == 0 {return nil} + if data.count == 0 { return nil } return data.sha3(.keccak256) } /// returns sha256 of data. Returns nil is data is empty static func sha256(_ data: Data) -> Data? { - if data.count == 0 {return nil} + if data.count == 0 { return nil } return data.sha256() } /// Unmarshals a 65 byte recoverable EC signature into internal structure. static func unmarshalSignature(signatureData: Data) -> SECP256K1.UnmarshaledSignature? { - if signatureData.count != 65 {return nil} + if signatureData.count != 65 { return nil } let bytes = signatureData.bytes let r = Array(bytes[0..<32]) let s = Array(bytes[32..<64]) @@ -274,7 +274,7 @@ public struct Utilities { /// Marshals the V, R and S signature parameters into a 65 byte recoverable EC signature. static func marshalSignature(v: UInt8, r: [UInt8], s: [UInt8]) -> Data? { - guard r.count == 32, s.count == 32 else {return nil} + guard r.count == 32, s.count == 32 else { return nil } var completeSignature = Data(r) completeSignature.append(Data(s)) completeSignature.append(Data([v])) diff --git a/Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift b/Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift index 46b64c006..88e9d52d0 100755 --- a/Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift +++ b/Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift @@ -19,8 +19,8 @@ extension Web3.BrowserFunctions { } public func getCoinbase() async -> String? { - guard let addresses = await self.getAccounts() else {return nil} - guard addresses.count > 0 else {return nil} + guard let addresses = await self.getAccounts() else { return nil } + guard addresses.count > 0 else { return nil } return addresses[0] } @@ -29,15 +29,15 @@ extension Web3.BrowserFunctions { } public func sign(_ personalMessage: String, account: String, password: String ) -> String? { - guard let data = Data.fromHex(personalMessage) else {return nil} + guard let data = Data.fromHex(personalMessage) else { return nil } return self.sign(data, account: account, password: password) } public func sign(_ personalMessage: Data, account: String, password: String ) -> String? { do { - guard let keystoreManager = self.web3.provider.attachedKeystoreManager else {return nil} - guard let from = EthereumAddress(account, ignoreChecksum: true) else {return nil} - guard let signature = try Web3Signer.signPersonalMessage(personalMessage, keystore: keystoreManager, account: from, password: password) else {return nil} + guard let keystoreManager = self.web3.provider.attachedKeystoreManager else { return nil } + guard let from = EthereumAddress(account, ignoreChecksum: true) else { return nil } + guard let signature = try Web3Signer.signPersonalMessage(personalMessage, keystore: keystoreManager, account: from, password: password) else { return nil } return signature.toHexString().addHexPrefix() } catch { print(error) @@ -46,8 +46,8 @@ extension Web3.BrowserFunctions { } public func personalECRecover(_ personalMessage: String, signature: String) -> String? { - guard let data = Data.fromHex(personalMessage) else {return nil} - guard let sig = Data.fromHex(signature) else {return nil} + guard let data = Data.fromHex(personalMessage) else { return nil } + guard let sig = Data.fromHex(signature) else { return nil } return self.personalECRecover(data, signature: sig) } @@ -63,9 +63,9 @@ extension Web3.BrowserFunctions { } else if vData >= 35 && vData <= 38 { vData -= 35 } - guard let signatureData = SECP256K1.marshalSignature(v: vData, r: rData, s: sData) else {return nil} - guard let hash = Utilities.hashPersonalMessage(personalMessage) else {return nil} - guard let publicKey = SECP256K1.recoverPublicKey(hash: hash, signature: signatureData) else {return nil} + guard let signatureData = SECP256K1.marshalSignature(v: vData, r: rData, s: sData) else { return nil } + guard let hash = Utilities.hashPersonalMessage(personalMessage) else { return nil } + guard let publicKey = SECP256K1.recoverPublicKey(hash: hash, signature: signatureData) else { return nil } return Utilities.publicToAddressString(publicKey) } @@ -167,11 +167,11 @@ extension Web3.BrowserFunctions { // public func signTransaction(_ trans: EthereumTransaction, transaction: TransactionOptions, password: String ) async -> String? { // do { // var transaction = trans -// guard let from = transaction.from else {return nil} -// guard let keystoreManager = self.web3.provider.attachedKeystoreManager else {return nil} -// guard let gasPricePolicy = transaction.gasPrice else {return nil} -// guard let gasLimitPolicy = transaction.gasLimit else {return nil} -// guard let noncePolicy = transaction.nonce else {return nil} +// guard let from = transaction.from else { return nil } +// guard let keystoreManager = self.web3.provider.attachedKeystoreManager else { return nil } +// guard let gasPricePolicy = transaction.gasPrice else { return nil } +// guard let gasLimitPolicy = transaction.gasLimit else { return nil } +// guard let noncePolicy = transaction.nonce else { return nil } // switch gasPricePolicy { // case .manual(let gasPrice): // transaction.parameters.gasPrice = gasPrice @@ -200,7 +200,7 @@ extension Web3.BrowserFunctions { // transaction.chainID = self.web3.provider.network?.chainID // } // -// guard let keystore = keystoreManager.walletForAddress(from) else {return nil} +// guard let keystore = keystoreManager.walletForAddress(from) else { return nil } // try Web3Signer.signTX(transaction: &transaction, keystore: keystore, account: from, password: password) // print(transaction) // let signedData = transaction.encode(for: .transaction)?.toHexString().addHexPrefix() diff --git a/Sources/web3swift/Utils/EIP/EIP67Code.swift b/Sources/web3swift/Utils/EIP/EIP67Code.swift index 38e95b112..f18ad2f15 100755 --- a/Sources/web3swift/Utils/EIP/EIP67Code.swift +++ b/Sources/web3swift/Utils/EIP/EIP67Code.swift @@ -46,7 +46,7 @@ extension Web3 { } public init? (address: String) { - guard let addr = EthereumAddress(address) else {return nil} + guard let addr = EthereumAddress(address) else { return nil } self.address = addr } @@ -97,32 +97,32 @@ extension Web3 { public struct EIP67CodeParser { public static func parse(_ data: Data) -> EIP67Code? { - guard let string = String(data: data, encoding: .utf8) else {return nil} + guard let string = String(data: data, encoding: .utf8) else { return nil } return parse(string) } public static func parse(_ string: String) -> EIP67Code? { - guard string.hasPrefix("ethereum:") else {return nil} + guard string.hasPrefix("ethereum:") else { return nil } let striped = string.components(separatedBy: "ethereum:") - guard striped.count == 2 else {return nil} - guard let encoding = striped[1].removingPercentEncoding else {return nil} - guard let url = URL.init(string: encoding) else {return nil} - guard let address = EthereumAddress(url.lastPathComponent) else {return nil} + guard striped.count == 2 else { return nil } + guard let encoding = striped[1].removingPercentEncoding else { return nil } + guard let url = URL.init(string: encoding) else { return nil } + guard let address = EthereumAddress(url.lastPathComponent) else { return nil } var code = EIP67Code(address: address) guard let components = URLComponents(string: encoding)?.queryItems else {return code} for comp in components { switch comp.name { case "value": - guard let value = comp.value else {return nil} - guard let val = BigUInt(value, radix: 10) else {return nil} + guard let value = comp.value else { return nil } + guard let val = BigUInt(value, radix: 10) else { return nil } code.amount = val case "gas": - guard let value = comp.value else {return nil} - guard let val = BigUInt(value, radix: 10) else {return nil} + guard let value = comp.value else { return nil } + guard let val = BigUInt(value, radix: 10) else { return nil } code.gasLimit = val case "data": - guard let value = comp.value else {return nil} - guard let data = Data.fromHex(value) else {return nil} + guard let value = comp.value else { return nil } + guard let data = Data.fromHex(value) else { return nil } code.data = EIP67Code.DataType.data(data) case "function": continue diff --git a/Sources/web3swift/Utils/ENS/NameHash.swift b/Sources/web3swift/Utils/ENS/NameHash.swift index 8e82eb2f8..9c6654a58 100755 --- a/Sources/web3swift/Utils/ENS/NameHash.swift +++ b/Sources/web3swift/Utils/ENS/NameHash.swift @@ -14,7 +14,7 @@ public struct NameHash { } public static func nameHash(_ domain: String) -> Data? { - guard let normalized = NameHash.normalizeDomainName(domain) else {return nil} + guard let normalized = NameHash.normalizeDomainName(domain) else { return nil } return namehash(normalized) } diff --git a/Sources/web3swift/Web3/Web3+Contract.swift b/Sources/web3swift/Web3/Web3+Contract.swift index 7ac561d66..7bf192710 100755 --- a/Sources/web3swift/Web3/Web3+Contract.swift +++ b/Sources/web3swift/Web3/Web3+Contract.swift @@ -33,7 +33,7 @@ extension Web3 { return nil case 2: // TODO: should throw - guard let contract = try? EthereumContract(abiString, at: at) else {return nil} + guard let contract = try? EthereumContract(abiString, at: at) else { return nil } self.contract = contract default: return nil diff --git a/Sources/web3swift/Web3/Web3+EventParser.swift b/Sources/web3swift/Web3/Web3+EventParser.swift index cc4eaa285..8053ec765 100755 --- a/Sources/web3swift/Web3/Web3+EventParser.swift +++ b/Sources/web3swift/Web3/Web3+EventParser.swift @@ -205,7 +205,7 @@ import Web3Core // // let decodedLogs = response.result.compactMap { (log) -> EventParserResult? in // let (n, d) = self.contract.parseEvent(log) -// guard let evName = n, let evData = d else {return nil} +// guard let evName = n, let evData = d else { return nil } // var res = EventParserResult(eventName: evName, transactionReceipt: nil, contractAddress: log.address, decodedResult: evData) // res.eventLog = log // return res diff --git a/Tests/web3swiftTests/localTests/UserCases.swift b/Tests/web3swiftTests/localTests/UserCases.swift index 0fb8ef47b..faa903d4d 100755 --- a/Tests/web3swiftTests/localTests/UserCases.swift +++ b/Tests/web3swiftTests/localTests/UserCases.swift @@ -13,8 +13,8 @@ class UserCases: XCTestCase { func getKeystoreData() -> Data? { let bundle = Bundle(for: type(of: self)) - guard let path = bundle.path(forResource: "key", ofType: "json") else {return nil} - guard let data = NSData(contentsOfFile: path) else {return nil} + guard let path = bundle.path(forResource: "key", ofType: "json") else { return nil } + guard let data = NSData(contentsOfFile: path) else { return nil } return data as Data } From 14ffe586ebddcf9a3711f1bb24944b5da32bd57a Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 3 Feb 2023 22:01:41 +0200 Subject: [PATCH 081/210] fix: EIP67Code swiftlint issues --- Sources/web3swift/Utils/EIP/EIP67Code.swift | 29 +++++++++++---------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Sources/web3swift/Utils/EIP/EIP67Code.swift b/Sources/web3swift/Utils/EIP/EIP67Code.swift index f18ad2f15..204dcfcdb 100755 --- a/Sources/web3swift/Utils/EIP/EIP67Code.swift +++ b/Sources/web3swift/Utils/EIP/EIP67Code.swift @@ -25,7 +25,7 @@ extension Web3 { public var parameters: [(ABI.Element.ParameterType, Any)] public func toString() -> String? { - let encoding = method + "(" + parameters.map({ el -> String in + let encoding = method + "(" + parameters.map { el -> String in if let string = el.1 as? String { return el.0.abiRepresentation + " " + string } else if let number = el.1 as? BigUInt { @@ -36,7 +36,7 @@ extension Web3 { return el.0.abiRepresentation + " " + data.toHexString().addHexPrefix() } return "" - }).joined(separator: ", ") + ")" + }.joined(separator: ", ") + ")" return encoding } } @@ -104,25 +104,27 @@ extension Web3 { public static func parse(_ string: String) -> EIP67Code? { guard string.hasPrefix("ethereum:") else { return nil } let striped = string.components(separatedBy: "ethereum:") - guard striped.count == 2 else { return nil } - guard let encoding = striped[1].removingPercentEncoding else { return nil } - guard let url = URL.init(string: encoding) else { return nil } - guard let address = EthereumAddress(url.lastPathComponent) else { return nil } + guard striped.count == 2, + let encoding = striped[1].removingPercentEncoding, + let url = URL.init(string: encoding), + let address = EthereumAddress(url.lastPathComponent) else { return nil } var code = EIP67Code(address: address) - guard let components = URLComponents(string: encoding)?.queryItems else {return code} + parseEncodingComponents(&code, encoding) + return code + } + + private static func parseEncodingComponents(_ code: inout EIP67Code, _ encoding: ) { + guard let components = URLComponents(string: encoding)?.queryItems else { return code } for comp in components { switch comp.name { case "value": - guard let value = comp.value else { return nil } - guard let val = BigUInt(value, radix: 10) else { return nil } + guard let value = comp.value, let val = BigUInt(value, radix: 10) else { return nil } code.amount = val case "gas": - guard let value = comp.value else { return nil } - guard let val = BigUInt(value, radix: 10) else { return nil } + guard let value = comp.value, let val = BigUInt(value, radix: 10) else { return nil } code.gasLimit = val case "data": - guard let value = comp.value else { return nil } - guard let data = Data.fromHex(value) else { return nil } + guard let value = comp.value, let data = Data.fromHex(value) else { return nil } code.data = EIP67Code.DataType.data(data) case "function": continue @@ -130,7 +132,6 @@ extension Web3 { continue } } - return code } } } From 7da547789cae35b9277ed930ddb548474c5ea3a0 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 4 Feb 2023 00:41:22 +0200 Subject: [PATCH 082/210] fix: SECP256K1.swift more swiflint fixes --- Sources/Web3Core/Structure/SECP256k1.swift | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index c01e6fd44..f4fbbe325 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -86,19 +86,19 @@ extension SECP256K1 { internal static func recoverPublicKey(hash: Data, recoverableSignature: inout secp256k1_ecdsa_recoverable_signature) -> secp256k1_pubkey? { guard let context = context, hash.count == 32 else { return nil } var publicKey: secp256k1_pubkey = secp256k1_pubkey() - let result = hash.withUnsafeBytes({ (hashRawBufferPointer: UnsafeRawBufferPointer) -> Int32? in + let result = hash.withUnsafeBytes { (hashRawBufferPointer: UnsafeRawBufferPointer) -> Int32? in if let hashRawPointer = hashRawBufferPointer.baseAddress, hashRawBufferPointer.count > 0 { let hashPointer = hashRawPointer.assumingMemoryBound(to: UInt8.self) - return withUnsafePointer(to: &recoverableSignature, { (signaturePointer: UnsafePointer) -> Int32 in - withUnsafeMutablePointer(to: &publicKey, { (pubKeyPtr: UnsafeMutablePointer) -> Int32 in + return withUnsafePointer(to: &recoverableSignature) { (signaturePointer: UnsafePointer) -> Int32 in + withUnsafeMutablePointer(to: &publicKey) { (pubKeyPtr: UnsafeMutablePointer) -> Int32 in let res = secp256k1_ecdsa_recover(context, pubKeyPtr, signaturePointer, hashPointer) return res - }) - }) + } + } } else { return nil } - }) + } guard let res = result, res != 0 else { return nil } @@ -131,16 +131,16 @@ extension SECP256K1 { let result = serializedPubkey.withUnsafeMutableBytes { serializedPubkeyRawBuffPointer -> Int32? in if let serializedPkRawPointer = serializedPubkeyRawBuffPointer.baseAddress, serializedPubkeyRawBuffPointer.count > 0 { let serializedPubkeyPointer = serializedPkRawPointer.assumingMemoryBound(to: UInt8.self) - return withUnsafeMutablePointer(to: &keyLength, { (keyPtr: UnsafeMutablePointer) -> Int32 in - withUnsafeMutablePointer(to: &publicKey, { (pubKeyPtr: UnsafeMutablePointer) -> Int32 in + return withUnsafeMutablePointer(to: &keyLength) { (keyPtr: UnsafeMutablePointer) -> Int32 in + withUnsafeMutablePointer(to: &publicKey) { (pubKeyPtr: UnsafeMutablePointer) -> Int32 in let res = secp256k1_ec_pubkey_serialize(context, serializedPubkeyPointer, keyPtr, pubKeyPtr, UInt32(compressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED)) return res - }) - }) + } + } } else { return nil } @@ -188,10 +188,10 @@ extension SECP256K1 { let result = serializedSignature.withUnsafeBytes { (serRawBufferPtr: UnsafeRawBufferPointer) -> Int32? in if let serRawPtr = serRawBufferPtr.baseAddress, serRawBufferPtr.count > 0 { let serPtr = serRawPtr.assumingMemoryBound(to: UInt8.self) - return withUnsafeMutablePointer(to: &recoverableSignature, { (signaturePointer: UnsafeMutablePointer) -> Int32 in + return withUnsafeMutablePointer(to: &recoverableSignature) { (signaturePointer: UnsafeMutablePointer) -> Int32 in let res = secp256k1_ecdsa_recoverable_signature_parse_compact(context, signaturePointer, serPtr, v) return res - }) + } } else { return nil } @@ -210,10 +210,10 @@ extension SECP256K1 { if let serSignatureRawPointer = serSignatureRawBufferPointer.baseAddress, serSignatureRawBufferPointer.count > 0 { let serSignaturePointer = serSignatureRawPointer.assumingMemoryBound(to: UInt8.self) return withUnsafePointer(to: &recoverableSignature) { (signaturePointer: UnsafePointer) -> Int32 in - withUnsafeMutablePointer(to: &v, { (vPtr: UnsafeMutablePointer) -> Int32 in + withUnsafeMutablePointer(to: &v) { (vPtr: UnsafeMutablePointer) -> Int32 in let res = secp256k1_ecdsa_recoverable_signature_serialize_compact(context, serSignaturePointer, vPtr, signaturePointer) return res - }) + } } } else { return nil @@ -244,24 +244,24 @@ extension SECP256K1 { let result = hash.withUnsafeBytes { hashRBPointer -> Int32? in if let hashRPointer = hashRBPointer.baseAddress, hashRBPointer.count > 0 { let hashPointer = hashRPointer.assumingMemoryBound(to: UInt8.self) - return privateKey.withUnsafeBytes({ privateKeyRBPointer -> Int32? in + return privateKey.withUnsafeBytes { privateKeyRBPointer -> Int32? in if let privateKeyRPointer = privateKeyRBPointer.baseAddress, privateKeyRBPointer.count > 0 { let privateKeyPointer = privateKeyRPointer.assumingMemoryBound(to: UInt8.self) - return extraEntropy.withUnsafeBytes({ extraEntropyRBPointer -> Int32? in + return extraEntropy.withUnsafeBytes { extraEntropyRBPointer -> Int32? in if let extraEntropyRPointer = extraEntropyRBPointer.baseAddress, extraEntropyRBPointer.count > 0 { let extraEntropyPointer = extraEntropyRPointer.assumingMemoryBound(to: UInt8.self) - return withUnsafeMutablePointer(to: &recoverableSignature, { (recSignaturePtr: UnsafeMutablePointer) -> Int32 in + return withUnsafeMutablePointer(to: &recoverableSignature) { (recSignaturePtr: UnsafeMutablePointer) -> Int32 in let res = secp256k1_ecdsa_sign_recoverable(context, recSignaturePtr, hashPointer, privateKeyPointer, nil, useExtraEntropy ? extraEntropyPointer : nil) return res - }) + } } else { return nil } - }) + } } else { return nil } - }) + } } else { return nil } From 93bdc1cb9e397f9162d5944fe7010928c10786ed Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 4 Feb 2023 12:24:03 +0200 Subject: [PATCH 083/210] fix: commited incomplete swiftlint fix (broken Swift code) --- Sources/web3swift/Utils/EIP/EIP67Code.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/web3swift/Utils/EIP/EIP67Code.swift b/Sources/web3swift/Utils/EIP/EIP67Code.swift index 204dcfcdb..9bc7aa013 100755 --- a/Sources/web3swift/Utils/EIP/EIP67Code.swift +++ b/Sources/web3swift/Utils/EIP/EIP67Code.swift @@ -113,18 +113,18 @@ extension Web3 { return code } - private static func parseEncodingComponents(_ code: inout EIP67Code, _ encoding: ) { - guard let components = URLComponents(string: encoding)?.queryItems else { return code } + private static func parseEncodingComponents(_ code: inout EIP67Code, _ encoding: String) { + guard let components = URLComponents(string: encoding)?.queryItems else { return } for comp in components { switch comp.name { case "value": - guard let value = comp.value, let val = BigUInt(value, radix: 10) else { return nil } + guard let value = comp.value, let val = BigUInt(value, radix: 10) else { return } code.amount = val case "gas": - guard let value = comp.value, let val = BigUInt(value, radix: 10) else { return nil } + guard let value = comp.value, let val = BigUInt(value, radix: 10) else { return } code.gasLimit = val case "data": - guard let value = comp.value, let data = Data.fromHex(value) else { return nil } + guard let value = comp.value, let data = Data.fromHex(value) else { return } code.data = EIP67Code.DataType.data(data) case "function": continue From 52919e7b0348a8c5fe389c0c2c24b9f38d0dc102 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 5 Feb 2023 15:45:47 +0200 Subject: [PATCH 084/210] fix: re-enabled indentation_width; fixed SECP256K1.swift indentation_width issues. --- .swiftlint.yml | 4 ++-- Sources/Web3Core/Structure/SECP256k1.swift | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index 97f0123e5..c0ec7c117 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -10,8 +10,7 @@ disabled_rules: - identifier_name - line_length - multiple_closures_with_trailing_closure - - todo - - indentation_width + - todo - function_parameter_count - nesting @@ -29,6 +28,7 @@ opt_in_rules: - empty_string - closure_body_length - fallthrough + - indentation_width # force warnings force_cast: error diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index f4fbbe325..f67e69d77 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -133,11 +133,13 @@ extension SECP256K1 { let serializedPubkeyPointer = serializedPkRawPointer.assumingMemoryBound(to: UInt8.self) return withUnsafeMutablePointer(to: &keyLength) { (keyPtr: UnsafeMutablePointer) -> Int32 in withUnsafeMutablePointer(to: &publicKey) { (pubKeyPtr: UnsafeMutablePointer) -> Int32 in - let res = secp256k1_ec_pubkey_serialize(context, - serializedPubkeyPointer, - keyPtr, - pubKeyPtr, - UInt32(compressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED)) + let res = secp256k1_ec_pubkey_serialize( + context, + serializedPubkeyPointer, + keyPtr, + pubKeyPtr, + UInt32(compressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED) + ) return res } } @@ -152,8 +154,10 @@ extension SECP256K1 { } internal static func parsePublicKey(serializedKey: Data) -> secp256k1_pubkey? { - guard let context = context, - serializedKey.count == 33 || serializedKey.count == 65 else { + guard + let context = context, + (serializedKey.count == 33 || serializedKey.count == 65) + else { return nil } let keyLen: Int = Int(serializedKey.count) From 06b67c3cd7000059773cff2b304d6565e2005121 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 5 Feb 2023 16:54:35 +0200 Subject: [PATCH 085/210] chore: spacing fix --- Sources/Web3Core/Utility/Utilities.swift | 4 ++-- Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Web3Core/Utility/Utilities.swift b/Sources/Web3Core/Utility/Utilities.swift index 4524bcd98..a1aed1b2a 100644 --- a/Sources/Web3Core/Utility/Utilities.swift +++ b/Sources/Web3Core/Utility/Utilities.swift @@ -206,7 +206,7 @@ public struct Utilities { /// /// Input parameters should be Data objects. public static func personalECRecover(_ personalMessage: Data, signature: Data) -> EthereumAddress? { - if signature.count != 65 { return nil} + if signature.count != 65 { return nil } let rData = signature[0..<32].bytes let sData = signature[32..<64].bytes var vData = signature[64] @@ -229,7 +229,7 @@ public struct Utilities { /// /// Input parameters should be Data objects. public static func hashECRecover(hash: Data, signature: Data) -> EthereumAddress? { - if signature.count != 65 { return nil} + if signature.count != 65 { return nil } let rData = signature[0..<32].bytes let sData = signature[32..<64].bytes var vData = signature[64] diff --git a/Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift b/Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift index 88e9d52d0..c903a6af4 100755 --- a/Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift +++ b/Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift @@ -52,7 +52,7 @@ extension Web3.BrowserFunctions { } public func personalECRecover(_ personalMessage: Data, signature: Data) -> String? { - if signature.count != 65 { return nil} + if signature.count != 65 { return nil } let rData = signature[0..<32].bytes let sData = signature[32..<64].bytes var vData = signature[64] From 2c171a9e51d7893b69c3964102975222772b1763 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 5 Feb 2023 16:55:06 +0200 Subject: [PATCH 086/210] fix: BIP32HDNode.swift refactoring to fix swiftlint issues --- .../KeystoreManager/BIP32HDNode.swift | 312 +++++++++--------- 1 file changed, 161 insertions(+), 151 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift index ca9a205b9..6a57a8e43 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift @@ -9,8 +9,7 @@ import CryptoSwift extension UInt32 { public func serialize32() -> Data { - let uint32 = UInt32(self) - var bigEndian = uint32.bigEndian + var bigEndian = self.bigEndian let count = MemoryLayout.size let bytePtr = withUnsafePointer(to: &bigEndian) { $0.withMemoryRebound(to: UInt8.self, capacity: count) { @@ -24,11 +23,11 @@ extension UInt32 { public class HDNode { public struct HDversion { + // swiftlint:disable force_unwrapping public var privatePrefix: Data = Data.fromHex("0x0488ADE4")! public var publicPrefix: Data = Data.fromHex("0x0488B21E")! - public init() { - - } + // swiftlint:enable force_unwrapping + public init() {} } public var path: String? = "m" public var privateKey: Data? @@ -38,23 +37,17 @@ public class HDNode { public var parentFingerprint: Data = Data(repeating: 0, count: 4) public var childNumber: UInt32 = UInt32(0) public var isHardened: Bool { - get { - return self.childNumber >= (UInt32(1) << 31) - } + childNumber >= (UInt32(1) << 31) } public var index: UInt32 { - get { if self.isHardened { - return self.childNumber - (UInt32(1) << 31) + return childNumber - (UInt32(1) << 31) } else { - return self.childNumber + return childNumber } - } } public var hasPrivate: Bool { - get { - return privateKey != nil - } + privateKey != nil } init() { @@ -81,8 +74,11 @@ public class HDNode { chaincode = data[13..<45] if serializePrivate { privateKey = data[46..<78] - guard let pubKey = Utilities.privateToPublic(privateKey!, compressed: true) else { return nil } - if pubKey[0] != 0x02 && pubKey[0] != 0x03 { return nil } + guard + let privateKey = privateKey, + let pubKey = Utilities.privateToPublic(privateKey, compressed: true), + (pubKey[0] == 0x02 || pubKey[0] == 0x03) + else { return nil } publicKey = pubKey } else { publicKey = data[45..<78] @@ -94,10 +90,10 @@ public class HDNode { public init?(seed: Data) { guard seed.count >= 16 else { return nil } + // swiftlint:disable force_unwrapping let hmacKey = "Bitcoin seed".data(using: .ascii)! - let hmac: Authenticator = HMAC(key: hmacKey.bytes, variant: HMAC.Variant.sha2(.sha512)) - guard let entropy = try? hmac.authenticate(seed.bytes) else { return nil } - guard entropy.count == 64 else { return nil} + let hmac = HMAC(key: hmacKey.bytes, variant: HMAC.Variant.sha2(.sha512)) + guard let entropy = try? hmac.authenticate(seed.bytes), entropy.count == 64 else { return nil } let I_L = entropy[0..<32] let I_R = entropy[32..<64] chaincode = Data(I_R) @@ -112,6 +108,7 @@ public class HDNode { } private static var curveOrder = BigUInt("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", radix: 16)! + // swiftlint:enable force_unwrapping public static var defaultPath: String = "m/44'/60'/0'/0" public static var defaultPathPrefix: String = "m/44'/60'/0'" public static var defaultPathMetamask: String = "m/44'/60'/0'/0/0" @@ -120,130 +117,15 @@ public class HDNode { } extension HDNode { - public func derive (index: UInt32, derivePrivateKey: Bool, hardened: Bool = false) -> HDNode? { + public func derive(index: UInt32, derivePrivateKey: Bool, hardened: Bool = false) -> HDNode? { if derivePrivateKey { - if self.hasPrivate { // derive private key when is itself extended private key - var entropy: [UInt8] - var trueIndex: UInt32 - if index >= (UInt32(1) << 31) || hardened { - trueIndex = index - if trueIndex < (UInt32(1) << 31) { - trueIndex = trueIndex + (UInt32(1) << 31) - } - let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) - var inputForHMAC = Data() - inputForHMAC.append(Data([UInt8(0x00)])) - inputForHMAC.append(self.privateKey!) - inputForHMAC.append(trueIndex.serialize32()) - guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else {return nil } - guard ent.count == 64 else { return nil } - entropy = ent - } else { - trueIndex = index - let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) - var inputForHMAC = Data() - inputForHMAC.append(self.publicKey) - inputForHMAC.append(trueIndex.serialize32()) - guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else {return nil } - guard ent.count == 64 else { return nil } - entropy = ent - } - let I_L = entropy[0..<32] - let I_R = entropy[32..<64] - let cc = Data(I_R) - let bn = BigUInt(Data(I_L)) - if bn > HDNode.curveOrder { - if trueIndex < UInt32.max { - return self.derive(index: index+1, derivePrivateKey: derivePrivateKey, hardened: hardened) - } - return nil - } - let newPK = (bn + BigUInt(self.privateKey!)) % HDNode.curveOrder - if newPK == BigUInt(0) { - if trueIndex < UInt32.max { - return self.derive(index: index+1, derivePrivateKey: derivePrivateKey, hardened: hardened) - } - return nil - } - guard let privKeyCandidate = newPK.serialize().setLengthLeft(32) else { return nil } - guard SECP256K1.verifyPrivateKey(privateKey: privKeyCandidate) else {return nil } - guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: privKeyCandidate, compressed: true) else { return nil } - guard pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03 else { return nil } - guard self.depth < UInt8.max else { return nil } - let newNode = HDNode() - newNode.chaincode = cc - newNode.depth = self.depth + 1 - newNode.publicKey = pubKeyCandidate - newNode.privateKey = privKeyCandidate - newNode.childNumber = trueIndex - guard let fprint = try? RIPEMD160.hash(message: self.publicKey.sha256())[0..<4] else { - return nil - } - newNode.parentFingerprint = fprint - var newPath = String() - if newNode.isHardened { - newPath = self.path! + "/" - newPath += String(newNode.index % HDNode.hardenedIndexPrefix) + "'" - } else { - newPath = self.path! + "/" + String(newNode.index) - } - newNode.path = newPath - return newNode - } else { - return nil // derive private key when is itself extended public key (impossible) - } - } else { // deriving only the public key - var entropy: [UInt8] // derive public key when is itself public key - if index >= (UInt32(1) << 31) || hardened { - return nil // no derivation of hardened public key from extended public key - } else { - let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) - var inputForHMAC = Data() - inputForHMAC.append(self.publicKey) - inputForHMAC.append(index.serialize32()) - guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else {return nil } - guard ent.count == 64 else { return nil } - entropy = ent - } - let I_L = entropy[0..<32] - let I_R = entropy[32..<64] - let cc = Data(I_R) - let bn = BigUInt(Data(I_L)) - if bn > HDNode.curveOrder { - if index < UInt32.max { - return self.derive(index: index+1, derivePrivateKey: derivePrivateKey, hardened: hardened) - } - return nil - } - guard let tempKey = bn.serialize().setLengthLeft(32) else { return nil } - guard SECP256K1.verifyPrivateKey(privateKey: tempKey) else {return nil } - guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: tempKey, compressed: true) else { return nil } - guard pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03 else { return nil } - guard let newPublicKey = SECP256K1.combineSerializedPublicKeys(keys: [self.publicKey, pubKeyCandidate], outputCompressed: true) else { return nil } - guard newPublicKey.bytes[0] == 0x02 || newPublicKey.bytes[0] == 0x03 else { return nil } - guard self.depth < UInt8.max else { return nil } - let newNode = HDNode() - newNode.chaincode = cc - newNode.depth = self.depth + 1 - newNode.publicKey = newPublicKey - newNode.childNumber = index - guard let fprint = try? RIPEMD160.hash(message: self.publicKey.sha256())[0..<4] else { - return nil - } - newNode.parentFingerprint = fprint - var newPath = String() - if newNode.isHardened { - newPath = self.path! + "/" - newPath += String(newNode.index % HDNode.hardenedIndexPrefix) + "'" - } else { - newPath = self.path! + "/" + String(newNode.index) - } - newNode.path = newPath - return newNode + return self.derivePrivateKey(index: index, hardened: hardened) + } else { + return derivePublicKey(index: index, hardened: hardened) } } - public func derive (path: String, derivePrivateKey: Bool = true) -> HDNode? { + public func derive(path: String, derivePrivateKey: Bool = true) -> HDNode? { let components = path.components(separatedBy: "/") var currentNode: HDNode = self var firstComponent = 0 @@ -262,30 +144,158 @@ extension HDNode { return currentNode } + /// Derive public key when is itself private key. + /// Derivation of private key when is itself extended public key is impossible and will return `nil`. + private func derivePrivateKey(index: UInt32, hardened: Bool) -> HDNode? { + guard let privateKey = privateKey else { + // derive private key when is itself extended public key (impossible) + return nil + } + + var trueIndex = index + if trueIndex < (UInt32(1) << 31) && hardened { + trueIndex += (UInt32(1) << 31) + } + + guard let entropy = calculateEntropy(index: trueIndex, privateKey: privateKey, hardened: hardened) else { return nil } + + let I_L = entropy[0..<32] + let I_R = entropy[32..<64] + let chainCode = Data(I_R) + let bn = BigUInt(Data(I_L)) + if bn > HDNode.curveOrder { + if trueIndex < UInt32.max { + return self.derive(index: index + 1, derivePrivateKey: true, hardened: hardened) + } + return nil + } + let newPK = (bn + BigUInt(privateKey)) % HDNode.curveOrder + if newPK == BigUInt(0) { + if trueIndex < UInt32.max { + return self.derive(index: index + 1, derivePrivateKey: true, hardened: hardened) + } + return nil + } + + guard + let newPrivateKey = newPK.serialize().setLengthLeft(32), + SECP256K1.verifyPrivateKey(privateKey: newPrivateKey), + let newPublicKey = SECP256K1.privateToPublic(privateKey: newPrivateKey, compressed: true), + (newPublicKey.bytes[0] == 0x02 || newPublicKey.bytes[0] == 0x03), + self.depth < UInt8.max + else { return nil } + return createNode(chainCode: chainCode, depth: depth + 1, publicKey: newPublicKey, privateKey: newPrivateKey, childNumber: trueIndex) + } + + /// Derive public key when is itself public key. + /// No derivation of hardened public key from extended public key is allowed. + private func derivePublicKey(index: UInt32, hardened: Bool) -> HDNode? { + if index >= (UInt32(1) << 31) || hardened { + // no derivation of hardened public key from extended public key + return nil + } + + guard let entropy = calculateEntropy(index: index, hardened: hardened) else { return nil } + + let I_L = entropy[0..<32] + let I_R = entropy[32..<64] + let chainCode = Data(I_R) + let bn = BigUInt(Data(I_L)) + if bn > HDNode.curveOrder { + if index < UInt32.max { + return self.derive(index: index+1, derivePrivateKey: false, hardened: hardened) + } + return nil + } + + guard + let tempKey = bn.serialize().setLengthLeft(32), + SECP256K1.verifyPrivateKey(privateKey: tempKey), + let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: tempKey, compressed: true), + (pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03), + let newPublicKey = SECP256K1.combineSerializedPublicKeys(keys: [self.publicKey, pubKeyCandidate], outputCompressed: true), + (newPublicKey.bytes[0] == 0x02 || newPublicKey.bytes[0] == 0x03), + self.depth < UInt8.max + else { return nil } + + return createNode(chainCode: chainCode, depth: depth + 1, publicKey: newPublicKey, childNumber: index) + } + + private func createNode(chainCode: Data, depth: UInt8, publicKey: Data, privateKey: Data? = nil, childNumber: UInt32) -> HDNode? { + let newNode = HDNode() + newNode.chaincode = chainCode + newNode.depth = depth + newNode.publicKey = publicKey + newNode.privateKey = privateKey + newNode.childNumber = childNumber + guard + let fprint = try? RIPEMD160.hash(message: self.publicKey.sha256())[0..<4], + let path = path + else { return nil } + newNode.parentFingerprint = fprint + var newPath = String() + if newNode.isHardened { + newPath = path + "/" + newPath += String(newNode.index % HDNode.hardenedIndexPrefix) + "'" + } else { + newPath = path + "/" + String(newNode.index) + } + newNode.path = newPath + return newNode + } + + private func calculateHMACInput(_ index: UInt32, privateKey: Data? = nil, hardened: Bool) -> Data { + var inputForHMAC = Data() + + if let privateKey = privateKey, (index >= (UInt32(1) << 31) || hardened) { + inputForHMAC.append(Data([UInt8(0x00)])) + inputForHMAC.append(privateKey) + } else { + inputForHMAC.append(self.publicKey) + } + + inputForHMAC.append(index.serialize32()) + return inputForHMAC + } + + /// Calculates entropy used for private or public key derivation. + /// - Parameters: + /// - index: index + /// - privateKey: private key data or `nil` if entropy is calculated for a public key; + /// - hardened: is hardened key + /// - Returns: 64 bytes entropy or `nil`. + private func calculateEntropy(index: UInt32, privateKey: Data? = nil, hardened: Bool) -> [UInt8]? { + let inputForHMAC = calculateHMACInput(index, privateKey: privateKey, hardened: hardened) + let hmac = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) + guard let entropy = try? hmac.authenticate(inputForHMAC.bytes), entropy.count == 64 else { return nil } + return entropy + } + public func serializeToString(serializePublic: Bool = true, version: HDversion = HDversion()) -> String? { guard let data = self.serialize(serializePublic: serializePublic, version: version) else { return nil } - let encoded = Base58.base58FromBytes(data.bytes) - return encoded + return Base58.base58FromBytes(data.bytes) } public func serialize(serializePublic: Bool = true, version: HDversion = HDversion()) -> Data? { var data = Data() - if !serializePublic && !self.hasPrivate { return nil } + /// Public or private key + let keyData: Data if serializePublic { + keyData = publicKey data.append(version.publicPrefix) } else { + guard let privateKey = privateKey else { return nil } + keyData = privateKey data.append(version.privatePrefix) } - data.append(contentsOf: [self.depth]) - data.append(self.parentFingerprint) - data.append(self.childNumber.serialize32()) - data.append(self.chaincode) - if serializePublic { - data.append(self.publicKey) - } else { + data.append(contentsOf: [depth]) + data.append(parentFingerprint) + data.append(childNumber.serialize32()) + data.append(chaincode) + if !serializePublic { data.append(contentsOf: [0x00]) - data.append(self.privateKey!) } + data.append(keyData) let hashedData = data.sha256().sha256() let checksum = hashedData[0..<4] data.append(checksum) From d37280f0d4b2c9a874ea7b1488dc8c156531a401 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 5 Feb 2023 17:46:55 +0200 Subject: [PATCH 087/210] fix: swiftlint configuration file --- .swiftlint.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index a0d7900d6..c0ec7c117 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -10,7 +10,9 @@ disabled_rules: - identifier_name - line_length - multiple_closures_with_trailing_closure - - todo + - todo + - function_parameter_count + - nesting opt_in_rules: - weak_delegate @@ -34,12 +36,12 @@ force_try: error custom_rules: commented_out_code: - included: ".*\\.swift" # regex that defines paths to include during linting. optional. - excluded: ".*Test(s)?\\.swift" # regex that defines paths to exclude during linting. optional - name: "Commented out code" # rule name. optional. - regex: "^\\/\\/\\s*(@|\\.?([a-z]|(\\})))" # matching pattern + included: .*\.swift # regex that defines paths to include during linting. optional. + excluded: .*Test(s)?\.swift # regex that defines paths to exclude during linting. optional + name: Commented out code # rule name. optional. + regex: ^\s*(\/\/(?!\s*swiftlint:).*|\/\*[\s\S]*?\*\/) # matching pattern capture_group: 0 # number of regex capture group to highlight the rule violation at. optional. match_kinds: # SyntaxKinds to match. optional. - comment - message: "No commented code in devel branch allowed." # violation message. optional. + message: No commented code in devel branch allowed. # violation message. optional. severity: warning # violation severity. optional. From d1d2d9a70f120c0cae44de6a9b733d560a3deabb Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 5 Feb 2023 17:47:48 +0200 Subject: [PATCH 088/210] fix: ran swiflint --fix --- .../Appdelegate/AppDelegate.swift | 4 - .../Appdelegate/SceneDelegate.swift | 3 - .../myWeb3Wallet/ViewController.swift | 2 - .../DashboardViewController.swift | 1 - .../SplashViewController.swift | 7 +- .../WalletViewController.swift | 46 ++-- .../Web3Core/EthereumABI/ABIElements.swift | 52 ++-- .../Transaction/CodableTransaction.swift | 2 +- .../Ethereum/IEth+Defaults.swift | 2 +- .../Tokens/ERC1376/Web3+ERC1376.swift | 1 - .../Tokens/ERC1400/Web3+ERC1400.swift | 258 +++++++++--------- .../Tokens/ERC1410/Web3+ERC1410.swift | 178 ++++++------ .../Tokens/ERC1594/Web3+ERC1594.swift | 104 +++---- .../Tokens/ERC1633/Web3+ERC1633.swift | 62 ++--- .../Tokens/ERC1643/Web3+ERC1643.swift | 61 ++--- .../Tokens/ERC1644/Web3+ERC1644.swift | 64 ++--- .../web3swift/Tokens/ERC777/Web3+ERC777.swift | 1 - Sources/web3swift/Tokens/ST20/Web3+ST20.swift | 74 ++--- .../Utils/ENS/ETHRegistrarController.swift | 20 +- .../web3swift/Web3/Web3+HttpProvider.swift | 2 +- Sources/web3swift/Web3/Web3+Signing.swift | 6 +- .../ABIElementErrorDecodingTest.swift | 8 +- .../localTests/ABIEncoderTest.swift | 8 +- .../localTests/AdvancedABIv2Tests.swift | 15 +- .../localTests/BasicLocalNodeTests.swift | 6 - .../localTests/DataConversionTests.swift | 11 - .../localTests/EIP1559BlockTests.swift | 1 - .../localTests/EIP67Tests.swift | 2 +- .../localTests/EventloopTests.swift | 2 +- .../localTests/KeystoresTests.swift | 9 +- .../NumberFormattingUtilTests.swift | 2 +- .../localTests/PersonalSignatureTests.swift | 6 +- .../web3swiftTests/localTests/RLPTests.swift | 2 +- .../ST20AndSecurityTokenTests.swift | 2 +- .../localTests/TestHelpers.swift | 1 - .../localTests/TransactionsTests.swift | 35 ++- .../localTests/UncategorizedTests.swift | 9 +- .../web3swiftTests/localTests/UserCases.swift | 8 +- .../localTests/UtilitiesTests.swift | 8 +- .../localTests/Web3ErrorTests.swift | 1 - .../web3swiftTests/remoteTests/ENSTests.swift | 2 +- .../EtherscanTransactionCheckerTests.swift | 2 +- .../remoteTests/PolicyResolverTests.swift | 6 +- 43 files changed, 523 insertions(+), 573 deletions(-) diff --git a/Example/myWeb3Wallet/myWeb3Wallet/Appdelegate/AppDelegate.swift b/Example/myWeb3Wallet/myWeb3Wallet/Appdelegate/AppDelegate.swift index d4f88c2b0..855876d1c 100644 --- a/Example/myWeb3Wallet/myWeb3Wallet/Appdelegate/AppDelegate.swift +++ b/Example/myWeb3Wallet/myWeb3Wallet/Appdelegate/AppDelegate.swift @@ -10,8 +10,6 @@ import UIKit @main class AppDelegate: UIResponder, UIApplicationDelegate { - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true @@ -31,6 +29,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // Use this method to release any resources that were specific to the discarded scenes, as they will not return. } - } - diff --git a/Example/myWeb3Wallet/myWeb3Wallet/Appdelegate/SceneDelegate.swift b/Example/myWeb3Wallet/myWeb3Wallet/Appdelegate/SceneDelegate.swift index 3182cf687..4134b433b 100644 --- a/Example/myWeb3Wallet/myWeb3Wallet/Appdelegate/SceneDelegate.swift +++ b/Example/myWeb3Wallet/myWeb3Wallet/Appdelegate/SceneDelegate.swift @@ -11,7 +11,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? - func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. @@ -47,6 +46,4 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // to restore the scene back to its current state. } - } - diff --git a/Example/myWeb3Wallet/myWeb3Wallet/ViewController.swift b/Example/myWeb3Wallet/myWeb3Wallet/ViewController.swift index de12eaa06..cdaa670f8 100644 --- a/Example/myWeb3Wallet/myWeb3Wallet/ViewController.swift +++ b/Example/myWeb3Wallet/myWeb3Wallet/ViewController.swift @@ -14,6 +14,4 @@ class ViewController: UIViewController { // Do any additional setup after loading the view. } - } - diff --git a/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/DashboardViewController.swift b/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/DashboardViewController.swift index fc4a8b585..cb99dd8e8 100644 --- a/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/DashboardViewController.swift +++ b/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/DashboardViewController.swift @@ -19,7 +19,6 @@ class DashboardViewController: UIViewController { } } - /* // MARK: - Navigation diff --git a/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/SplashViewController.swift b/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/SplashViewController.swift index 6c8eef804..593b1281e 100644 --- a/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/SplashViewController.swift +++ b/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/SplashViewController.swift @@ -10,7 +10,7 @@ import UIKit class SplashViewController: UIViewController { @IBOutlet weak var logoView: UIImageView! - + override func viewDidLoad() { super.viewDidLoad() UIView.animate(withDuration: 0.9) { @@ -18,12 +18,11 @@ class SplashViewController: UIViewController { Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(self.moveToWalletView), userInfo: nil, repeats: false) } - // Do any additional setup after loading the view. } - @objc func moveToWalletView(){ - + @objc func moveToWalletView() { + guard let walletScreen = self.storyboard?.instantiateViewController(withIdentifier: "WalletViewController") as? WalletViewController else { #if DEBUG printContent("Unable to get Wallet controller") diff --git a/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift b/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift index c766c5758..640ce697b 100644 --- a/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift +++ b/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift @@ -8,13 +8,13 @@ import UIKit import web3swift class WalletViewController: UIViewController { - + @IBOutlet weak var continueButton: UIButton! @IBOutlet weak var walletAddressLabel: UILabel! @IBOutlet weak var importWalletButton: UIButton! @IBOutlet weak var createWalletButton: UIButton! var _walletAddress: String { - set{ + set { self.continueButton.isHidden = false self.walletAddressLabel.text = newValue } @@ -27,23 +27,22 @@ class WalletViewController: UIViewController { super.viewDidLoad() self.createWalletButton.layer.cornerRadius = 5.0 self.importWalletButton.layer.cornerRadius = 5.0 - + // Do any additional setup after loading the view. } - - + @IBAction func onClickCreateWallet(_ sender: UIButton) { #if DEBUG print("Clicked on Create Wallet Option") #endif self.createMnemonics() - + } @IBAction func onClickImportWalletButton(_ sender: UIButton) { print("Clicked on import Wallet Option") self.showImportALert() } - + @IBAction func onClickContinueButton(_ sender: UIButton) { print("Clicked on COntinue button") guard let dashboardScreen = self.storyboard?.instantiateViewController(withIdentifier: "DashboardViewController") as? DashboardViewController else { @@ -54,7 +53,7 @@ class WalletViewController: UIViewController { } self.navigationController?.pushViewController(dashboardScreen, animated: true) } - fileprivate func showImportALert(){ + fileprivate func showImportALert() { let alert = UIAlertController(title: "MyWeb3Wallet", message: "", preferredStyle: .alert) alert.addTextField { textfied in textfied.placeholder = "Enter mnemonics/private Key" @@ -69,7 +68,7 @@ class WalletViewController: UIViewController { guard let privateKey = alert.textFields?[0].text else { return } print(privateKey) self.importWalletWith(privateKey: privateKey) - + } let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) alert.addAction(mnemonicsAction) @@ -77,7 +76,7 @@ class WalletViewController: UIViewController { alert.addAction(cancelAction) self.present(alert, animated: true, completion: nil) } - func importWalletWith(privateKey: String){ + func importWalletWith(privateKey: String) { let formattedKey = privateKey.trimmingCharacters(in: .whitespacesAndNewlines) guard let dataKey = Data.fromHex(formattedKey) else { self.showAlertMessage(title: "Error", message: "Please enter a valid Private key ", actionName: "Ok") @@ -94,7 +93,7 @@ class WalletViewController: UIViewController { #endif let walletAddress = manager.addresses?.first?.address self.walletAddressLabel.text = walletAddress ?? "0x" - + print(walletAddress) } else { print("error") @@ -109,26 +108,23 @@ class WalletViewController: UIViewController { alert.addAction(okAction) self.present(alert, animated: true) } - - - + } func importWalletWith(mnemonics: String) { - let walletAddress = try? BIP32Keystore(mnemonics: mnemonics , prefixPath: "m/44'/77777'/0'/0") + let walletAddress = try? BIP32Keystore(mnemonics: mnemonics, prefixPath: "m/44'/77777'/0'/0") print(walletAddress?.addresses) self.walletAddressLabel.text = "\(walletAddress?.addresses?.first?.address ?? "0x")" - + } - - + } extension WalletViewController { - - fileprivate func createMnemonics(){ + + fileprivate func createMnemonics() { let userDir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] let web3KeystoreManager = KeystoreManager.managerForPath(userDir + "/keystore") do { - if (web3KeystoreManager?.addresses?.count ?? 0 >= 0) { + if web3KeystoreManager?.addresses?.count ?? 0 >= 0 { let tempMnemonics = try? BIP39.generateMnemonics(bitsOfEntropy: 256, language: .english) guard let tMnemonics = tempMnemonics else { self.showAlertMessage(title: "", message: "We are unable to create wallet", actionName: "Ok") @@ -136,7 +132,7 @@ extension WalletViewController { } self._mnemonics = tMnemonics print(_mnemonics) - let tempWalletAddress = try? BIP32Keystore(mnemonics: self._mnemonics , prefixPath: "m/44'/77777'/0'/0") + let tempWalletAddress = try? BIP32Keystore(mnemonics: self._mnemonics, prefixPath: "m/44'/77777'/0'/0") print(tempWalletAddress?.addresses?.first?.address) guard let walletAddress = tempWalletAddress?.addresses?.first else { self.showAlertMessage(title: "", message: "We are unable to create wallet", actionName: "Ok") @@ -151,9 +147,9 @@ extension WalletViewController { FileManager.default.createFile(atPath: userDir + "/keystore"+"/key.json", contents: keyData, attributes: nil) } } catch { - + } - + } } extension UIViewController { @@ -163,5 +159,5 @@ extension UIViewController { alertController.addAction(action) self.present(alertController, animated: true) } - + } diff --git a/Sources/Web3Core/EthereumABI/ABIElements.swift b/Sources/Web3Core/EthereumABI/ABIElements.swift index 7db0ca31a..a9a28bcd0 100755 --- a/Sources/Web3Core/EthereumABI/ABIElements.swift +++ b/Sources/Web3Core/EthereumABI/ABIElements.swift @@ -274,35 +274,35 @@ extension ABI.Element.Function { /// /// Return cases: /// - when no `outputs` declared and `data` is not an error response: - ///```swift - ///["_success": true] - ///``` + /// ```swift + /// ["_success": true] + /// ``` /// - when `outputs` declared and decoding completed successfully: - ///```swift - ///["_success": true, "0": value_1, "1": value_2, ...] - ///``` - ///Additionally this dictionary will have mappings to output names if these names are specified in the ABI; + /// ```swift + /// ["_success": true, "0": value_1, "1": value_2, ...] + /// ``` + /// Additionally this dictionary will have mappings to output names if these names are specified in the ABI; /// - function call was aborted using `revert(message)` or `require(expression, message)`: - ///```swift - ///["_success": false, "_abortedByRevertOrRequire": true, "_errorMessage": message]` - ///``` + /// ```swift + /// ["_success": false, "_abortedByRevertOrRequire": true, "_errorMessage": message]` + /// ``` /// - function call was aborted using `revert CustomMessage()` and `errors` argument contains the ABI of that custom error type: - ///```swift - ///["_success": false, - ///"_abortedByRevertOrRequire": true, - ///"_error": error_name_and_types, // e.g. `MyCustomError(uint256, address senderAddress)` - ///"0": error_arg1, - ///"1": error_arg2, - ///..., - ///"error_arg1_name": error_arg1, // Only named arguments will be mapped to their names, e.g. `"senderAddress": EthereumAddress` - ///"error_arg2_name": error_arg2, // Otherwise, you can query them by position index. - ///...] - ///``` - ///- in case of any error: - ///```swift - ///["_success": false, "_failureReason": String] - ///``` - ///Error reasons include: + /// ```swift + /// ["_success": false, + /// "_abortedByRevertOrRequire": true, + /// "_error": error_name_and_types, // e.g. `MyCustomError(uint256, address senderAddress)` + /// "0": error_arg1, + /// "1": error_arg2, + /// ..., + /// "error_arg1_name": error_arg1, // Only named arguments will be mapped to their names, e.g. `"senderAddress": EthereumAddress` + /// "error_arg2_name": error_arg2, // Otherwise, you can query them by position index. + /// ...] + /// ``` + /// - in case of any error: + /// ```swift + /// ["_success": false, "_failureReason": String] + /// ``` + /// Error reasons include: /// - `outputs` declared but at least one value failed to be decoded; /// - `data.count` is less than `outputs.count * 32`; /// - `outputs` defined and `data` is empty; diff --git a/Sources/Web3Core/Transaction/CodableTransaction.swift b/Sources/Web3Core/Transaction/CodableTransaction.swift index b478dc0f0..af407e00f 100644 --- a/Sources/Web3Core/Transaction/CodableTransaction.swift +++ b/Sources/Web3Core/Transaction/CodableTransaction.swift @@ -54,7 +54,7 @@ public struct CodableTransaction { set { envelope.value = newValue } } - public var data: Data { + public var data: Data { get { return envelope.data } set { envelope.data = newValue } } diff --git a/Sources/web3swift/EthereumAPICalls/Ethereum/IEth+Defaults.swift b/Sources/web3swift/EthereumAPICalls/Ethereum/IEth+Defaults.swift index 6c5424689..c2732c66e 100644 --- a/Sources/web3swift/EthereumAPICalls/Ethereum/IEth+Defaults.swift +++ b/Sources/web3swift/EthereumAPICalls/Ethereum/IEth+Defaults.swift @@ -19,7 +19,7 @@ public extension IEth { func estimateGas(for transaction: CodableTransaction) async throws -> BigUInt { try await estimateGas(for: transaction, onBlock: .latest) } - + func estimateGas(for transaction: CodableTransaction, onBlock: BlockNumber) async throws -> BigUInt { let request = APIRequest.estimateGas(transaction, onBlock) return try await APIRequest.sendRequest(with: provider, for: request).result diff --git a/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift b/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift index 80a4f796b..91fa18f31 100644 --- a/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift +++ b/Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift @@ -365,4 +365,3 @@ extension ERC1376 { } } - diff --git a/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift b/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift index df0874a93..b800f70bd 100644 --- a/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift +++ b/Sources/web3swift/Tokens/ERC1400/Web3+ERC1400.swift @@ -10,49 +10,49 @@ import Web3Core // Security Token Standard protocol IERC1400: IERC20 { - + // Document Management func getDocument(name: Data) async throws -> (String, Data) func setDocument(from: EthereumAddress, name: Data, uri: String, documentHash: Data) async throws -> WriteOperation - + // Token Information func balanceOfByPartition(partition: Data, tokenHolder: EthereumAddress) async throws -> BigUInt func partitionsOf(tokenHolder: EthereumAddress) async throws -> [Data] - + // Transfers func transferWithData(from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func transferFromWithData(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation - + // Partition Token Transfers func transferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func operatorTransferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation - + // Controller Operation func isControllable() async throws -> Bool func controllerTransfer(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation func controllerRedeem(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation - + // Operator Management func authorizeOperator(from: EthereumAddress, operator user: EthereumAddress) async throws -> WriteOperation func revokeOperator(from: EthereumAddress, operator user: EthereumAddress) async throws -> WriteOperation func authorizeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) async throws -> WriteOperation func revokeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) async throws -> WriteOperation - + // Operator Information func isOperator(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool func isOperatorForPartition(partition: Data, operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool - + // Token Issuance func isIssuable() async throws -> Bool func issue(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func issueByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation - + // Token Redemption func redeem(from: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func redeemFrom(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func redeemByPartition(from: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> WriteOperation func operatorRedeemByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, operatorData: [UInt8]) async throws -> WriteOperation - + // Transfer Validity func canTransfer(to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) func canTransferFrom(originalOwner: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) @@ -70,9 +70,9 @@ public class ERC1400: IERC1400, ERC20BaseProperties { public var provider: Web3Provider public var address: EthereumAddress public var abi: String - + public let contract: Web3.Contract - + public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.erc1400ABI, transaction: CodableTransaction = .emptyTransaction) { self.web3 = web3 self.provider = provider @@ -84,21 +84,21 @@ public class ERC1400: IERC1400, ERC20BaseProperties { contract = web3.contract(abi, at: address)! basePropertiesProvider = ERC20BasePropertiesProvider(contract: contract) } - + public func getBalance(account: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOf", parameters: [account])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -108,16 +108,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } - + public func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -127,16 +127,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } - + public func setAllowance(from: EthereumAddress, to: EthereumAddress, newAmount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -146,23 +146,23 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(newAmount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } - + public func totalSupply() async throws -> BigUInt { let result = try await contract.createReadOperation("totalSupply")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -172,44 +172,44 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } - + // ERC1400 methods public func getDocument(name: Data) async throws -> (String, Data) { let result = try await contract.createReadOperation("getDocument", parameters: [name])!.callContractMethod() - + guard let res = result["0"] as? (String, Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func setDocument(from: EthereumAddress, name: Data, uri: String, documentHash: Data) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("setDocument", parameters: [name, uri, documentHash])! return tx } - + public func balanceOfByPartition(partition: Data, tokenHolder: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOfByPartition", parameters: [partition, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func partitionsOf(tokenHolder: EthereumAddress) async throws -> [Data] { let result = try await contract.createReadOperation("partitionsOf", parameters: [tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? [Data] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transferWithData(from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -219,16 +219,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferWithData", parameters: [to, value, data])! return tx } - + public func transferFromWithData(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -238,16 +238,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFromWithData", parameters: [originalOwner, to, value, data])! return tx } - + public func transferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -257,16 +257,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferByPartition", parameters: [partition, to, value, data])! return tx } - + public func operatorTransferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -276,23 +276,23 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("operatorTransferByPartition", parameters: [partition, originalOwner, to, value, data, operatorData])! return tx } - + public func isControllable() async throws -> Bool { let result = try await contract.createReadOperation("isControllable")!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func controllerTransfer(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -302,16 +302,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("controllerTransfer", parameters: [originalOwner, to, value, data, operatorData])! return tx } - + public func controllerRedeem(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -321,61 +321,61 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("controllerRedeem", parameters: [tokenHolder, value, data, operatorData])! return tx } - + public func authorizeOperator(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("authorizeOperator", parameters: [user])! return tx } - + public func revokeOperator(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("revokeOperator", parameters: [user])! return tx } - + public func authorizeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("authorizeOperatorByPartition", parameters: [partition, user])! return tx } - + public func revokeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("revokeOperatorByPartition", parameters: [partition, user])! return tx } - + public func isOperator(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let result = try await contract.createReadOperation("isOperator", parameters: [user, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func isOperatorForPartition(partition: Data, operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let result = try await contract.createReadOperation("isOperatorForPartition", parameters: [partition, user, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func isIssuable() async throws -> Bool { let result = try await contract.createReadOperation("isIssuable")!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func issue(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -385,16 +385,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("issue", parameters: [tokenHolder, value, data])! return tx } - + public func issueByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -404,16 +404,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("issueByPartition", parameters: [partition, tokenHolder, value, data])! return tx } - + public func redeem(from: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -423,16 +423,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("redeem", parameters: [value, data])! return tx } - + public func redeemFrom(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -442,16 +442,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("redeemFrom", parameters: [tokenHolder, value, data])! return tx } - + public func redeemByPartition(from: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -461,16 +461,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("redeemByPartition", parameters: [partition, value, data])! return tx } - + public func operatorRedeemByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -480,16 +480,16 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("operatorRedeemByPartition", parameters: [partition, tokenHolder, value, operatorData])! return tx } - + public func canTransfer(to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) { // get the decimals manually let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() @@ -497,18 +497,18 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let result = try await contract.createReadOperation("canTransfer", parameters: [to, value, data])!.callContractMethod() - + guard let res = result["0"] as? ([UInt8], Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func canTransferFrom(originalOwner: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) { // get the decimals manually let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() @@ -516,18 +516,18 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, value, data])!.callContractMethod() - + guard let res = result["0"] as? ([UInt8], Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func canTransferByPartition(originalOwner: EthereumAddress, to: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> ([UInt8], Data, Data) { // get the decimals manually let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() @@ -535,14 +535,14 @@ public class ERC1400: IERC1400, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, partition, value, data])!.callContractMethod() - + guard let res = result["0"] as? ([UInt8], Data, Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -551,85 +551,85 @@ public class ERC1400: IERC1400, ERC20BaseProperties { extension ERC1400: IERC777 { public func canImplementInterfaceForAddress(interfaceHash: Data, addr: EthereumAddress) async throws -> Data { let result = try await contract.createReadOperation("canImplementInterfaceForAddress", parameters: [interfaceHash, addr])!.callContractMethod() - + guard let res = result["0"] as? Data else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getInterfaceImplementer(addr: EthereumAddress, interfaceHash: Data) async throws -> EthereumAddress { let result = try await contract.createReadOperation("getInterfaceImplementer", parameters: [addr, interfaceHash])!.callContractMethod() - + guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func setInterfaceImplementer(from: EthereumAddress, addr: EthereumAddress, interfaceHash: Data, implementer: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer])! return tx } - + public func setManager(from: EthereumAddress, addr: EthereumAddress, newManager: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager])! return tx } - + public func interfaceHash(interfaceName: String) async throws -> Data { let result = try await contract.createReadOperation("interfaceHash", parameters: [interfaceName])!.callContractMethod() - + guard let res = result["0"] as? Data else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func updateERC165Cache(from: EthereumAddress, contract: EthereumAddress, interfaceId: [UInt8]) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = self.contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId])! return tx } - + public func supportsInterface(interfaceID: String) async throws -> Bool { let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getGranularity() async throws -> BigUInt { let result = try await contract.createReadOperation("granularity")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getDefaultOperators() async throws -> [EthereumAddress] { let result = try await contract.createReadOperation("defaultOperators")!.callContractMethod() - + guard let res = result["0"] as? [EthereumAddress] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func authorize(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("authorizeOperator", parameters: [user])! return tx } - + public func revoke(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("revokeOperator", parameters: [user])! return tx } - + public func isOperatorFor(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let result = try await contract.createReadOperation("isOperatorFor", parameters: [user, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func send(from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -639,16 +639,16 @@ extension ERC1400: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("send", parameters: [to, value, data])! return tx } - + public func operatorSend(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -658,16 +658,16 @@ extension ERC1400: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData])! return tx } - + public func burn(from: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -677,16 +677,16 @@ extension ERC1400: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("burn", parameters: [value, data])! return tx } - + public func operatorBurn(from: EthereumAddress, amount: String, originalOwner: EthereumAddress, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -696,12 +696,12 @@ extension ERC1400: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData])! return tx } @@ -710,11 +710,11 @@ extension ERC1400: IERC777 { // MARK: - Private extension ERC1400 { - + private func updateTransactionAndContract(from: EthereumAddress) { transaction.from = from transaction.to = address contract.transaction = transaction } - + } diff --git a/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift b/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift index ed947f435..ad4ae54b0 100644 --- a/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift +++ b/Sources/web3swift/Tokens/ERC1410/Web3+ERC1410.swift @@ -11,33 +11,33 @@ import Web3Core // Partially Fungible Token Standard protocol IERC1410: IERC20 { - + // Token Information func getBalance(account: EthereumAddress) async throws -> BigUInt func balanceOfByPartition(partition: Data, tokenHolder: EthereumAddress) async throws -> BigUInt func partitionsOf(tokenHolder: EthereumAddress) async throws -> [Data] func totalSupply() async throws -> BigUInt - + // Token Transfers func transferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func operatorTransferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation func canTransferByPartition(originalOwner: EthereumAddress, to: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> ([UInt8], Data, Data) - + // Operator Information func isOperator(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool func isOperatorForPartition(partition: Data, operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool - + // Operator Management func authorizeOperator(from: EthereumAddress, operator user: EthereumAddress) async throws -> WriteOperation func revokeOperator(from: EthereumAddress, operator user: EthereumAddress) async throws -> WriteOperation func authorizeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) async throws -> WriteOperation func revokeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) async throws -> WriteOperation - + // Issuance / Redemption func issueByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func redeemByPartition(from: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> WriteOperation func operatorRedeemByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, operatorData: [UInt8]) async throws -> WriteOperation - + } // FIXME: Rewrite this to CodableTransaction @@ -48,9 +48,9 @@ public class ERC1410: IERC1410, ERC20BaseProperties { public var provider: Web3Provider public var address: EthereumAddress public var abi: String - + public let contract: Web3.Contract - + public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.erc1410ABI, transaction: CodableTransaction = .emptyTransaction) { self.web3 = web3 self.provider = provider @@ -62,21 +62,21 @@ public class ERC1410: IERC1410, ERC20BaseProperties { contract = web3.contract(abi, at: address)! basePropertiesProvider = ERC20BasePropertiesProvider(contract: contract) } - + public func getBalance(account: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOf", parameters: [account])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -86,16 +86,16 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } - + public func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -105,16 +105,16 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } - + public func setAllowance(from: EthereumAddress, to: EthereumAddress, newAmount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -124,23 +124,23 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(newAmount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } - + public func totalSupply() async throws -> BigUInt { let result = try await contract.createReadOperation("totalSupply")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -150,31 +150,31 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } - + // ERC1410 methods public func balanceOfByPartition(partition: Data, tokenHolder: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOfByPartition", parameters: [partition, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func partitionsOf(tokenHolder: EthereumAddress) async throws -> [Data] { let result = try await contract.createReadOperation("partitionsOf", parameters: [tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? [Data] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -184,16 +184,16 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferByPartition", parameters: [partition, to, value, data])! return tx } - + public func operatorTransferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -203,16 +203,16 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("operatorTransferByPartition", parameters: [partition, originalOwner, to, value, data, operatorData])! return tx } - + public func canTransferByPartition(originalOwner: EthereumAddress, to: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> ([UInt8], Data, Data) { // get the decimals manually let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() @@ -220,56 +220,56 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, partition, value, data])!.callContractMethod() - + guard let res = result["0"] as? ([UInt8], Data, Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func isOperator(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let result = try await contract.createReadOperation("isOperator", parameters: [user, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func isOperatorForPartition(partition: Data, operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let result = try await contract.createReadOperation("isOperatorForPartition", parameters: [partition, user, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func authorizeOperator(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("authorizeOperator", parameters: [user])! return tx } - + public func revokeOperator(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("revokeOperator", parameters: [user])! return tx } - + public func authorizeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("authorizeOperatorByPartition", parameters: [partition, user])! return tx } - + public func revokeOperatorByPartition(from: EthereumAddress, partition: Data, operator user: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("revokeOperatorByPartition", parameters: [partition, user])! return tx } - + public func issueByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -279,16 +279,16 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("issueByPartition", parameters: [partition, tokenHolder, value, data])! return tx } - + public func redeemByPartition(from: EthereumAddress, partition: Data, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -298,16 +298,16 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("redeemByPartition", parameters: [partition, value, data])! return tx } - + public func operatorRedeemByPartition(from: EthereumAddress, partition: Data, tokenHolder: EthereumAddress, amount: String, operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -317,12 +317,12 @@ public class ERC1410: IERC1410, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("operatorRedeemByPartition", parameters: [partition, tokenHolder, value, operatorData])! return tx } @@ -331,72 +331,72 @@ public class ERC1410: IERC1410, ERC20BaseProperties { extension ERC1410: IERC777 { public func canImplementInterfaceForAddress(interfaceHash: Data, addr: EthereumAddress) async throws -> Data { let result = try await contract.createReadOperation("canImplementInterfaceForAddress", parameters: [interfaceHash, addr])!.callContractMethod() - + guard let res = result["0"] as? Data else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getInterfaceImplementer(addr: EthereumAddress, interfaceHash: Data) async throws -> EthereumAddress { let result = try await contract.createReadOperation("getInterfaceImplementer", parameters: [addr, interfaceHash])!.callContractMethod() - + guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func setInterfaceImplementer(from: EthereumAddress, addr: EthereumAddress, interfaceHash: Data, implementer: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("setInterfaceImplementer", parameters: [addr, interfaceHash, implementer])! return tx } - + public func setManager(from: EthereumAddress, addr: EthereumAddress, newManager: EthereumAddress) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("setManager", parameters: [addr, newManager])! return tx } - + public func interfaceHash(interfaceName: String) async throws -> Data { let result = try await contract.createReadOperation("interfaceHash", parameters: [interfaceName])!.callContractMethod() - + guard let res = result["0"] as? Data else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func updateERC165Cache(from: EthereumAddress, contract: EthereumAddress, interfaceId: [UInt8]) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = self.contract.createWriteOperation("updateERC165Cache", parameters: [contract, interfaceId])! return tx } - + public func supportsInterface(interfaceID: String) async throws -> Bool { transaction.callOnBlock = .latest let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func authorize(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("authorizeOperator", parameters: [user])! return tx } - + public func revoke(from: EthereumAddress, operator user: EthereumAddress) throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("revokeOperator", parameters: [user])! return tx } - + public func isOperatorFor(operator user: EthereumAddress, tokenHolder: EthereumAddress) async throws -> Bool { let result = try await contract.createReadOperation("isOperatorFor", parameters: [user, tokenHolder])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func send(from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -406,16 +406,16 @@ extension ERC1410: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("send", parameters: [to, value, data])! return tx } - + public func operatorSend(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -425,16 +425,16 @@ extension ERC1410: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("operatorSend", parameters: [originalOwner, to, value, data, operatorData])! return tx } - + public func burn(from: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -444,16 +444,16 @@ extension ERC1410: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("burn", parameters: [value, data])! return tx } - + public func operatorBurn(from: EthereumAddress, amount: String, originalOwner: EthereumAddress, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -463,26 +463,26 @@ extension ERC1410: IERC777 { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("burn", parameters: [originalOwner, value, data, operatorData])! return tx } - + public func getGranularity() async throws -> BigUInt { let result = try await contract.createReadOperation("granularity")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getDefaultOperators() async throws -> [EthereumAddress] { let result = try await contract.createReadOperation("defaultOperators")!.callContractMethod() - + guard let res = result["0"] as? [EthereumAddress] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -491,11 +491,11 @@ extension ERC1410: IERC777 { // MARK: - Private extension ERC1410 { - + private func updateTransactionAndContract(from: EthereumAddress) { transaction.from = from transaction.to = address contract.transaction = transaction } - + } diff --git a/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift b/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift index 3e83074d8..07dba9fc7 100644 --- a/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift +++ b/Sources/web3swift/Tokens/ERC1594/Web3+ERC1594.swift @@ -11,23 +11,23 @@ import Web3Core // Core Security Token Standard protocol IERC1594: IERC20 { - + // Transfers func transferWithData(from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func transferFromWithData(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation - + // Token Issuance func isIssuable() async throws -> Bool func issue(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation - + // Token Redemption func redeem(from: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation func redeemFrom(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation - + // Transfer Validity func canTransfer(to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) func canTransferFrom(originalOwner: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) - + } // FIXME: Rewrite this to CodableTransaction @@ -38,9 +38,9 @@ public class ERC1594: IERC1594, ERC20BaseProperties { public var provider: Web3Provider public var address: EthereumAddress public var abi: String - + public let contract: Web3.Contract - + public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.erc1594ABI, transaction: CodableTransaction = .emptyTransaction) { self.web3 = web3 self.provider = provider @@ -52,21 +52,21 @@ public class ERC1594: IERC1594, ERC20BaseProperties { contract = web3.contract(abi, at: address)! basePropertiesProvider = ERC20BasePropertiesProvider(contract: contract) } - + public func getBalance(account: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOf", parameters: [account])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { updateTransactionAndContract(from: from) // get the decimals manually @@ -75,16 +75,16 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } - + public func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -94,16 +94,16 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } - + public func setAllowance(from: EthereumAddress, to: EthereumAddress, newAmount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -113,23 +113,23 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(newAmount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } - + public func totalSupply() async throws -> BigUInt { let result = try await contract.createReadOperation("totalSupply")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -139,16 +139,16 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } - + // ERC1594 public func transferWithData(from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest @@ -159,16 +159,16 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferWithData", parameters: [to, value, data])! return tx } - + public func transferFromWithData(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -178,23 +178,23 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFromWithData", parameters: [originalOwner, to, value, data])! return tx } - + public func isIssuable() async throws -> Bool { let result = try await contract.createReadOperation("isIssuable")!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func issue(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -204,16 +204,16 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("issue", parameters: [tokenHolder, value, data])! return tx } - + public func redeem(from: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -223,16 +223,16 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("redeem", parameters: [value, data])! return tx } - + public func redeemFrom(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -242,16 +242,16 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("redeemFrom", parameters: [tokenHolder, value, data])! return tx } - + public func canTransfer(to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) { // get the decimals manually let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() @@ -259,18 +259,18 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let result = try await contract.createReadOperation("canTransfer", parameters: [to, value, data])!.callContractMethod() - + guard let res = result["0"] as? ([UInt8], Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func canTransferFrom(originalOwner: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) async throws -> ([UInt8], Data) { // get the decimals manually let callResult = try await contract.createReadOperation("decimals")!.callContractMethod() @@ -278,14 +278,14 @@ public class ERC1594: IERC1594, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let result = try await contract.createReadOperation("canTransfer", parameters: [originalOwner, to, value, data])!.callContractMethod() - + guard let res = result["0"] as? ([UInt8], Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -294,11 +294,11 @@ public class ERC1594: IERC1594, ERC20BaseProperties { // MARK: - Private extension ERC1594 { - + private func updateTransactionAndContract(from: EthereumAddress) { transaction.from = from transaction.to = address contract.transaction = transaction } - + } diff --git a/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift b/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift index e7551fce1..dfc2ed271 100644 --- a/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift +++ b/Sources/web3swift/Tokens/ERC1633/Web3+ERC1633.swift @@ -12,10 +12,10 @@ import Web3Core // Re-Fungible Token Standard (RFT) // FIXME: Rewrite this to CodableTransaction protocol IERC1633: IERC20, IERC165 { - + func parentToken() async throws -> EthereumAddress func parentTokenId() async throws -> BigUInt - + } public class ERC1633: IERC1633, ERC20BaseProperties { @@ -25,9 +25,9 @@ public class ERC1633: IERC1633, ERC20BaseProperties { public var provider: Web3Provider public var address: EthereumAddress public var abi: String - + public let contract: Web3.Contract - + public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.erc1633ABI, transaction: CodableTransaction = .emptyTransaction) { self.web3 = web3 self.provider = provider @@ -39,21 +39,21 @@ public class ERC1633: IERC1633, ERC20BaseProperties { contract = web3.contract(abi, at: address)! basePropertiesProvider = ERC20BasePropertiesProvider(contract: contract) } - + public func getBalance(account: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOf", parameters: [account])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -63,16 +63,16 @@ public class ERC1633: IERC1633, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } - + public func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -82,16 +82,16 @@ public class ERC1633: IERC1633, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } - + public func setAllowance(from: EthereumAddress, to: EthereumAddress, newAmount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -101,23 +101,23 @@ public class ERC1633: IERC1633, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(newAmount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } - + public func totalSupply() async throws -> BigUInt { let result = try await contract.createReadOperation("totalSupply")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -127,47 +127,47 @@ public class ERC1633: IERC1633, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } - + func parentToken() async throws -> EthereumAddress { let result = try await contract.createReadOperation("parentToken")!.callContractMethod() - + guard let res = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + func parentTokenId() async throws -> BigUInt { let result = try await contract.createReadOperation("parentTokenId")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func supportsInterface(interfaceID: String) async throws -> Bool { let result = try await contract.createReadOperation("supportsInterface", parameters: [interfaceID])!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + } // MARK: - Private extension ERC1633 { - + private func updateTransactionAndContract(from: EthereumAddress) { transaction.from = from transaction.to = address contract.transaction = transaction } - + } diff --git a/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift b/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift index 9e0c3fdec..c70ae346d 100644 --- a/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift +++ b/Sources/web3swift/Tokens/ERC1643/Web3+ERC1643.swift @@ -11,13 +11,13 @@ import Web3Core // Document Management Standard protocol IERC1643: IERC20 { - + // Document Management func getDocument(name: Data) async throws -> (String, Data) func setDocument(from: EthereumAddress, name: Data, uri: String, documentHash: Data) async throws -> WriteOperation func removeDocument(from: EthereumAddress, name: Data) async throws -> WriteOperation func getAllDocuments() async throws -> [Data] - + } // FIXME: Rewrite this to CodableTransaction @@ -28,9 +28,9 @@ public class ERC1643: IERC1643, ERC20BaseProperties { public var provider: Web3Provider public var address: EthereumAddress public var abi: String - + public let contract: Web3.Contract - + public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.erc1643ABI, transaction: CodableTransaction = .emptyTransaction) { self.web3 = web3 self.provider = provider @@ -42,21 +42,21 @@ public class ERC1643: IERC1643, ERC20BaseProperties { contract = web3.contract(abi, at: address)! basePropertiesProvider = ERC20BasePropertiesProvider(contract: contract) } - + public func getBalance(account: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOf", parameters: [account])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -66,16 +66,16 @@ public class ERC1643: IERC1643, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } - + public func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -85,16 +85,16 @@ public class ERC1643: IERC1643, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } - + public func setAllowance(from: EthereumAddress, to: EthereumAddress, newAmount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -104,23 +104,23 @@ public class ERC1643: IERC1643, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(newAmount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } - + public func totalSupply() async throws -> BigUInt { let result = try await contract.createReadOperation("totalSupply")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -130,39 +130,39 @@ public class ERC1643: IERC1643, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } - + // ERC1643 methods public func getDocument(name: Data) async throws -> (String, Data) { let result = try await contract.createReadOperation("getDocument", parameters: [name])!.callContractMethod() - + guard let res = result["0"] as? (String, Data) else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func setDocument(from: EthereumAddress, name: Data, uri: String, documentHash: Data) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("setDocument", parameters: [name, uri, documentHash])! return tx } - + public func removeDocument(from: EthereumAddress, name: Data) throws -> WriteOperation { updateTransactionAndContract(from: from) let tx = contract.createWriteOperation("removeDocument", parameters: [name])! return tx } - + public func getAllDocuments() async throws -> [Data] { let result = try await contract.createReadOperation("getAllDocuments")!.callContractMethod() - + guard let res = result["0"] as? [Data] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } @@ -171,12 +171,11 @@ public class ERC1643: IERC1643, ERC20BaseProperties { // MARK: - Private extension ERC1643 { - + private func updateTransactionAndContract(from: EthereumAddress) { transaction.from = from transaction.to = address contract.transaction = transaction } - -} +} diff --git a/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift b/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift index 1acaf69a1..31e5795d8 100644 --- a/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift +++ b/Sources/web3swift/Tokens/ERC1644/Web3+ERC1644.swift @@ -11,12 +11,12 @@ import Web3Core // Controller Token Operation Standard protocol IERC1644: IERC20 { - + // Controller Operation func isControllable() async throws -> Bool func controllerTransfer(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation func controllerRedeem(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation - + } // FIXME: Rewrite this to CodableTransaction @@ -27,9 +27,9 @@ public class ERC1644: IERC1644, ERC20BaseProperties { public var provider: Web3Provider public var address: EthereumAddress public var abi: String - + public let contract: Web3.Contract - + public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.erc1644ABI, transaction: CodableTransaction = .emptyTransaction) { self.web3 = web3 self.provider = provider @@ -41,21 +41,21 @@ public class ERC1644: IERC1644, ERC20BaseProperties { contract = web3.contract(abi, at: address)! basePropertiesProvider = ERC20BasePropertiesProvider(contract: contract) } - + public func getBalance(account: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOf", parameters: [account])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -65,16 +65,16 @@ public class ERC1644: IERC1644, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } - + public func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -84,16 +84,16 @@ public class ERC1644: IERC1644, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } - + public func setAllowance(from: EthereumAddress, to: EthereumAddress, newAmount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -103,23 +103,23 @@ public class ERC1644: IERC1644, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(newAmount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } - + public func totalSupply() async throws -> BigUInt { let result = try await contract.createReadOperation("totalSupply")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -129,24 +129,24 @@ public class ERC1644: IERC1644, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } - + // ERC1644 public func isControllable() async throws -> Bool { let result = try await contract.createReadOperation("isControllable")!.callContractMethod() - + guard let res = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func controllerTransfer(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -156,16 +156,16 @@ public class ERC1644: IERC1644, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("controllerTransfer", parameters: [originalOwner, to, value, data, operatorData])! return tx } - + public func controllerRedeem(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -175,12 +175,12 @@ public class ERC1644: IERC1644, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("controllerRedeem", parameters: [tokenHolder, value, data, operatorData])! return tx } @@ -189,11 +189,11 @@ public class ERC1644: IERC1644, ERC20BaseProperties { // MARK: - Private extension ERC1644 { - + private func updateTransactionAndContract(from: EthereumAddress) { transaction.from = from transaction.to = address contract.transaction = transaction } - + } diff --git a/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift b/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift index f7360d913..c5a428c53 100644 --- a/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift +++ b/Sources/web3swift/Tokens/ERC777/Web3+ERC777.swift @@ -318,4 +318,3 @@ extension ERC777 { } } - diff --git a/Sources/web3swift/Tokens/ST20/Web3+ST20.swift b/Sources/web3swift/Tokens/ST20/Web3+ST20.swift index 52f603380..b3688bd9e 100644 --- a/Sources/web3swift/Tokens/ST20/Web3+ST20.swift +++ b/Sources/web3swift/Tokens/ST20/Web3+ST20.swift @@ -13,13 +13,13 @@ import Web3Core protocol IST20: IERC20 { // off-chain hash func tokenDetails() async throws -> [UInt32] - + // transfer, transferFrom must respect the result of verifyTransfer func verifyTransfer(from: EthereumAddress, originalOwner: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation - + // used to create tokens func mint(from: EthereumAddress, investor: EthereumAddress, amount: String) async throws -> WriteOperation - + // Burn function used to burn the securityToken func burn(from: EthereumAddress, amount: String) async throws -> WriteOperation } @@ -34,9 +34,9 @@ public class ST20: IST20, ERC20BaseProperties { public var provider: Web3Provider public var address: EthereumAddress public var abi: String - + public let contract: Web3.Contract - + public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.st20ABI, transaction: CodableTransaction = .emptyTransaction) { self.web3 = web3 self.provider = provider @@ -48,14 +48,14 @@ public class ST20: IST20, ERC20BaseProperties { contract = web3.contract(abi, at: address)! basePropertiesProvider = ERC20BasePropertiesProvider(contract: contract) } - + func tokenDetails() async throws -> [UInt32] { let result = try await contract.createReadOperation("tokenDetails")!.callContractMethod() - + guard let res = result["0"] as? [UInt32] else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + func verifyTransfer(from: EthereumAddress, originalOwner: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -65,16 +65,16 @@ public class ST20: IST20, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("verifyTransfer", parameters: [originalOwner, to, value])! return tx } - + func mint(from: EthereumAddress, investor: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -84,16 +84,16 @@ public class ST20: IST20, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("mint", parameters: [investor, value])! return tx } - + public func burn(from: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -103,30 +103,30 @@ public class ST20: IST20, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("burn", parameters: [value])! return tx } - + public func getBalance(account: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("balanceOf", parameters: [account])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) async throws -> BigUInt { let result = try await contract.createReadOperation("allowance", parameters: [originalOwner, delegate])!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + public func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -136,16 +136,16 @@ public class ST20: IST20, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transfer", parameters: [to, value])! return tx } - + public func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -155,16 +155,16 @@ public class ST20: IST20, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("transferFrom", parameters: [originalOwner, to, value])! return tx } - + public func setAllowance(from: EthereumAddress, to: EthereumAddress, newAmount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -174,16 +174,16 @@ public class ST20: IST20, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(newAmount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("setAllowance", parameters: [to, value])! return tx } - + public func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) async throws -> WriteOperation { transaction.callOnBlock = .latest updateTransactionAndContract(from: from) @@ -193,33 +193,33 @@ public class ST20: IST20, ERC20BaseProperties { guard let dec = callResult["0"], let decTyped = dec as? BigUInt else { throw Web3Error.inputError(desc: "Contract may be not ERC20 compatible, can not get decimals")} decimals = decTyped - + let intDecimals = Int(decimals) guard let value = Utilities.parseToBigUInt(amount, decimals: intDecimals) else { throw Web3Error.inputError(desc: "Can not parse inputted amount") } - + let tx = contract.createWriteOperation("approve", parameters: [spender, value])! return tx } - + public func totalSupply() async throws -> BigUInt { let result = try await contract.createReadOperation("totalSupply")!.callContractMethod() - + guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")} return res } - + } // MARK: - Private extension ST20 { - + private func updateTransactionAndContract(from: EthereumAddress) { transaction.from = from transaction.to = address contract.transaction = transaction } - + } diff --git a/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift b/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift index 8802d5c33..6fdda1e12 100644 --- a/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift +++ b/Sources/web3swift/Utils/ENS/ETHRegistrarController.swift @@ -13,7 +13,7 @@ public extension ENS { class ETHRegistrarController { public let web3: Web3 public let address: EthereumAddress - + lazy var contract: Web3.Contract = { let contract = self.web3.contract(Web3.Utils.ethRegistrarControllerABI, at: self.address, abiVersion: 2) precondition(contract != nil) @@ -23,47 +23,47 @@ public extension ENS { lazy var defaultTransaction: CodableTransaction = { return CodableTransaction.emptyTransaction }() - + public init(web3: Web3, address: EthereumAddress) { self.web3 = web3 self.address = address } - + public func getRentPrice(name: String, duration: UInt) async throws -> BigUInt { guard let transaction = self.contract.createReadOperation("rentPrice", parameters: [name, duration]) else { throw Web3Error.transactionSerializationError } guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let price = result["0"] as? BigUInt else { throw Web3Error.processingError(desc: "Can't get answer") } return price } - + public func checkNameValidity(name: String) async throws -> Bool { guard let transaction = self.contract.createReadOperation("valid", parameters: [name]) else { throw Web3Error.transactionSerializationError } guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let valid = result["0"] as? Bool else { throw Web3Error.processingError(desc: "Can't get answer") } return valid } - + public func isNameAvailable(name: String) async throws -> Bool { guard let transaction = self.contract.createReadOperation("available", parameters: [name]) else { throw Web3Error.transactionSerializationError } guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let available = result["0"] as? Bool else { throw Web3Error.processingError(desc: "Can't get answer") } return available } - + public func calculateCommitmentHash(name: String, owner: EthereumAddress, secret: String) async throws -> Data { guard let transaction = self.contract.createReadOperation("makeCommitment", parameters: [name, owner.address, secret]) else { throw Web3Error.transactionSerializationError } guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")} guard let hash = result["0"] as? Data else { throw Web3Error.processingError(desc: "Can't get answer") } return hash } - + public func sumbitCommitment(from: EthereumAddress, commitment: Data) throws -> WriteOperation { defaultTransaction.from = from defaultTransaction.to = self.address guard let transaction = self.contract.createWriteOperation("commit", parameters: [commitment]) else { throw Web3Error.transactionSerializationError } return transaction } - + public func registerName(from: EthereumAddress, name: String, owner: EthereumAddress, duration: UInt, secret: String, price: String) throws -> WriteOperation { guard let amount = Utilities.parseToBigUInt(price, units: .ether) else {throw Web3Error.inputError(desc: "Wrong price: no way for parsing to ether units")} defaultTransaction.value = amount @@ -72,7 +72,7 @@ public extension ENS { guard let transaction = self.contract.createWriteOperation("register", parameters: [name, owner.address, duration, secret]) else { throw Web3Error.transactionSerializationError } return transaction } - + public func extendNameRegistration(from: EthereumAddress, name: String, duration: UInt32, price: String) throws -> WriteOperation { guard let amount = Utilities.parseToBigUInt(price, units: .ether) else {throw Web3Error.inputError(desc: "Wrong price: no way for parsing to ether units")} defaultTransaction.value = amount @@ -81,7 +81,7 @@ public extension ENS { guard let transaction = self.contract.createWriteOperation("renew", parameters: [name, duration]) else { throw Web3Error.transactionSerializationError } return transaction } - + @available(*, message: "Available for only owner") public func withdraw(from: EthereumAddress) throws -> WriteOperation { defaultTransaction.from = from diff --git a/Sources/web3swift/Web3/Web3+HttpProvider.swift b/Sources/web3swift/Web3/Web3+HttpProvider.swift index e56243740..29ad59831 100755 --- a/Sources/web3swift/Web3/Web3+HttpProvider.swift +++ b/Sources/web3swift/Web3/Web3+HttpProvider.swift @@ -39,7 +39,7 @@ public class Web3HttpProvider: Web3Provider { } attachedKeystoreManager = manager } - + public init(url: URL, network: Networks, keystoreManager: KeystoreManager? = nil) { self.url = url self.network = network diff --git a/Sources/web3swift/Web3/Web3+Signing.swift b/Sources/web3swift/Web3/Web3+Signing.swift index d1b57f270..2e135c6c0 100755 --- a/Sources/web3swift/Web3/Web3+Signing.swift +++ b/Sources/web3swift/Web3/Web3+Signing.swift @@ -18,7 +18,7 @@ public struct Web3Signer { defer { Data.zero(&privateKey) } try transaction.sign(privateKey: privateKey, useExtraEntropy: useExtraEntropy) } - + public static func signPersonalMessage(_ personalMessage: Data, keystore: T, account: EthereumAddress, @@ -32,14 +32,14 @@ public struct Web3Signer { useExtraEntropy: useExtraEntropy) return compressedSignature } - + public static func signEIP712(_ eip712Hashable: EIP712Hashable, keystore: BIP32Keystore, verifyingContract: EthereumAddress, account: EthereumAddress, password: String? = nil, chainId: BigUInt? = nil) throws -> Data { - + let domainSeparator: EIP712Hashable = EIP712Domain(chainId: chainId, verifyingContract: verifyingContract) let hash = try eip712encode(domainSeparator: domainSeparator, message: eip712Hashable) guard let signature = try Web3Signer.signPersonalMessage(hash, diff --git a/Tests/web3swiftTests/localTests/ABIElementErrorDecodingTest.swift b/Tests/web3swiftTests/localTests/ABIElementErrorDecodingTest.swift index 9c7d238f9..181337d19 100644 --- a/Tests/web3swiftTests/localTests/ABIElementErrorDecodingTest.swift +++ b/Tests/web3swiftTests/localTests/ABIElementErrorDecodingTest.swift @@ -51,7 +51,7 @@ class ABIElementErrorDecodingTest: XCTestCase { .init(name: "rand_bytes", type: .bytes(length: 123)), .init(name: "", type: .dynamicBytes), .init(name: "arrarrarray123", type: .array(type: .bool, length: 0)), - .init(name: "error_message_maybe", type: .string), + .init(name: "error_message_maybe", type: .string) ] XCTAssertEqual(EthError(name: "VeryCustomErrorName", inputs: allTypesNamedAndNot).errorDeclaration, @@ -113,7 +113,7 @@ class ABIElementErrorDecodingTest: XCTestCase { /// 82b42900 - Unauthorized() function selector /// 00000000000000000000000000000000000000000000000000000000 - padding bytes let errorResponse = Data.fromHex("82b4290000000000000000000000000000000000000000000000000000000000")! - let errors: [String: EthError] = ["82b42900" : .init(name: "Unauthorized", inputs: [])] + let errors: [String: EthError] = ["82b42900": .init(name: "Unauthorized", inputs: [])] guard let errorData = emptyFunction.decodeErrorResponse(errorResponse, errors: errors) else { XCTFail("Data must be decoded as a `revert(\"Not enough Ether provided.\")` or `require(false, \"Not enough Ether provided.\")` but decoding failed completely.") return @@ -136,7 +136,7 @@ class ABIElementErrorDecodingTest: XCTestCase { /// 82b42900 - Unauthorized() function selector /// 00000000000000000000000000000000000000000000000000000000 - padding bytes let errorResponse = Data.fromHex("82b4290000000000000000000000000000000000000000000000000000000000")! - let errors: [String: EthError] = ["82b42900" : .init(name: "Unauthorized", inputs: [.init(name: "", type: .string)])] + let errors: [String: EthError] = ["82b42900": .init(name: "Unauthorized", inputs: [.init(name: "", type: .string)])] guard let errorData = emptyFunction.decodeErrorResponse(errorResponse, errors: errors) else { XCTFail("Data must be decoded as a `revert(\"Not enough Ether provided.\")` or `require(false, \"Not enough Ether provided.\")` but decoding failed completely.") return @@ -164,7 +164,7 @@ class ABIElementErrorDecodingTest: XCTestCase { /// 526561736f6e0000000000000000000000000000000000000000000000000000 - first custom argument bytes + 0 bytes padding /// 0000... - some more 0 bytes padding to make the number of bytes match 32 bytes chunks let errorResponse = Data.fromHex("973d02cb00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000006526561736f6e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")! - let errors: [String: EthError] = ["973d02cb" : .init(name: "Unauthorized", inputs: [.init(name: "message_arg", type: .string)])] + let errors: [String: EthError] = ["973d02cb": .init(name: "Unauthorized", inputs: [.init(name: "message_arg", type: .string)])] guard let errorData = emptyFunction.decodeErrorResponse(errorResponse, errors: errors) else { XCTFail("Data must be decoded as a `revert(\"Not enough Ether provided.\")` or `require(false, \"Not enough Ether provided.\")` but decoding failed completely.") return diff --git a/Tests/web3swiftTests/localTests/ABIEncoderTest.swift b/Tests/web3swiftTests/localTests/ABIEncoderTest.swift index c6e6057f7..2e13e4334 100644 --- a/Tests/web3swiftTests/localTests/ABIEncoderTest.swift +++ b/Tests/web3swiftTests/localTests/ABIEncoderTest.swift @@ -200,12 +200,12 @@ class ABIEncoderTest: XCTestCase { var hexData = ABIEncoder.encode(types: [.string], values: ["test"])?.toHexString() XCTAssertEqual(hexData?[0..<64], "0000000000000000000000000000000000000000000000000000000000000020") XCTAssertEqual(hexData, "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000047465737400000000000000000000000000000000000000000000000000000000") - hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 0)], values: [[1,2,3,4]])?.toHexString() + hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 0)], values: [[1, 2, 3, 4]])?.toHexString() XCTAssertEqual(hexData?[0..<64], "0000000000000000000000000000000000000000000000000000000000000020") XCTAssertEqual(hexData, "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004") // This one shouldn't have data offset - hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 4)], values: [[1,2,3,4]])?.toHexString() + hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 4)], values: [[1, 2, 3, 4]])?.toHexString() // First 32 bytes are the first value from the array XCTAssertEqual(hexData?[0..<64], "0000000000000000000000000000000000000000000000000000000000000001") XCTAssertEqual(hexData, "0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004") @@ -214,7 +214,7 @@ class ABIEncoderTest: XCTestCase { .bool, .array(type: .uint(bits: 8), length: 0), .bytes(length: 2)] - let values: [Any] = [10, false, [1,2,3,4], Data(count: 2)] + let values: [Any] = [10, false, [1, 2, 3, 4], Data(count: 2)] hexData = ABIEncoder.encode(types: types, values: values)?.toHexString() XCTAssertEqual(hexData?[128..<192], "0000000000000000000000000000000000000000000000000000000000000080") XCTAssertEqual(hexData, "000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004") @@ -230,7 +230,7 @@ class ABIEncoderTest: XCTestCase { encodedValue = ABIEncoder.encode(types: [.dynamicBytes], values: [Data.fromHex("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1")!])!.toHexString() XCTAssertEqual(encodedValue, "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000009ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff100") - + encodedValue = ABIEncoder.encode(types: [.dynamicBytes], values: [Data.fromHex("c3a40000c3a4")!])!.toHexString() XCTAssertEqual(encodedValue, "00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000006c3a40000c3a40000000000000000000000000000000000000000000000000000") diff --git a/Tests/web3swiftTests/localTests/AdvancedABIv2Tests.swift b/Tests/web3swiftTests/localTests/AdvancedABIv2Tests.swift index 7f174b784..066a1b7a8 100755 --- a/Tests/web3swiftTests/localTests/AdvancedABIv2Tests.swift +++ b/Tests/web3swiftTests/localTests/AdvancedABIv2Tests.swift @@ -31,7 +31,6 @@ class AdvancedABIv2Tests: LocalTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(Data.fromHex(txHash)!) - switch receipt.status { case .notYetProcessed: @@ -44,7 +43,7 @@ class AdvancedABIv2Tests: LocalTestCase { // MARK: Read data from ABI flow // MARK: - Encoding ABI Data flow let tx = contract.createReadOperation("testSingle") - let _ = try await tx!.callContractMethod() + _ = try await tx!.callContractMethod() } func testAdvancedABIv2staticArray() async throws { @@ -66,7 +65,6 @@ class AdvancedABIv2Tests: LocalTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(Data.fromHex(txHash)!) - switch receipt.status { case .notYetProcessed: @@ -79,7 +77,7 @@ class AdvancedABIv2Tests: LocalTestCase { // MARK: Read data from ABI flow // MARK: - Encoding ABI Data flow let tx = contract.createReadOperation("testStaticArray") - let _ = try await tx!.callContractMethod() + _ = try await tx!.callContractMethod() } func testAdvancedABIv2dynamicArray() async throws { @@ -101,7 +99,6 @@ class AdvancedABIv2Tests: LocalTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(Data.fromHex(txHash)!) - switch receipt.status { case .notYetProcessed: @@ -113,7 +110,7 @@ class AdvancedABIv2Tests: LocalTestCase { contract = web3.contract(abiString, at: receipt.contractAddress, abiVersion: 2)! let tx = contract.createReadOperation("testDynArray") - let _ = try await tx!.callContractMethod() + _ = try await tx!.callContractMethod() } func testAdvancedABIv2dynamicArrayOfStrings() async throws { @@ -135,7 +132,6 @@ class AdvancedABIv2Tests: LocalTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(Data.fromHex(txHash)!) - switch receipt.status { case .notYetProcessed: @@ -148,7 +144,7 @@ class AdvancedABIv2Tests: LocalTestCase { // MARK: Read data from ABI flow // MARK: - Encoding ABI Data flow let tx = contract.createReadOperation("testDynOfDyn") - let _ = try await tx!.callContractMethod() + _ = try await tx!.callContractMethod() } func testAdvancedABIv2staticArrayOfStrings() async throws { @@ -170,7 +166,6 @@ class AdvancedABIv2Tests: LocalTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(Data.fromHex(txHash)!) - switch receipt.status { case .notYetProcessed: @@ -183,7 +178,7 @@ class AdvancedABIv2Tests: LocalTestCase { // MARK: Read data from ABI flow // MARK: - Encoding ABI Data flow let tx = contract.createReadOperation("testStOfDyn") - let _ = try await tx!.callContractMethod() + _ = try await tx!.callContractMethod() } func testEmptyArrayDecoding() async throws { diff --git a/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift b/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift index 4ad43fc53..822d90c9b 100755 --- a/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift +++ b/Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift @@ -57,8 +57,6 @@ class BasicLocalNodeTests: LocalTestCase { let balanceBeforeTo = try await web3.eth.getBalance(for: sendToAddress) let balanceBeforeFrom = try await web3.eth.getBalance(for: allAddresses[0]) - - let result = try await sendTx.writeToChain(password: "web3swift", sendRaw: false) let txHash = Data.fromHex(result.hash.stripHexPrefix())! @@ -66,7 +64,6 @@ class BasicLocalNodeTests: LocalTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(txHash) - switch receipt.status { case .notYetProcessed: @@ -76,12 +73,9 @@ class BasicLocalNodeTests: LocalTestCase { } let details = try await web3.eth.transactionDetails(txHash) - let balanceAfterTo = try await web3.eth.getBalance(for: sendToAddress) let balanceAfterFrom = try await web3.eth.getBalance(for: allAddresses[0]) - - XCTAssertEqual(balanceAfterTo - balanceBeforeTo, valueToSend) let txnGasPrice = details.transaction.meta?.gasPrice ?? 0 diff --git a/Tests/web3swiftTests/localTests/DataConversionTests.swift b/Tests/web3swiftTests/localTests/DataConversionTests.swift index 62211ec88..bba7db52d 100644 --- a/Tests/web3swiftTests/localTests/DataConversionTests.swift +++ b/Tests/web3swiftTests/localTests/DataConversionTests.swift @@ -22,15 +22,12 @@ class DataConversionTests: LocalTestCase { func testBase58() throws { let vector = "" - guard let resultDecoded = vector.base58DecodedData else { return XCTFail("base58 decode unexpectedly returned nil") } XCTAssert(resultDecoded.count == 0) - let resultEncoded1 = vector.base58EncodedString XCTAssert(resultEncoded1 == vector) - let arr = resultDecoded.withUnsafeBytes { Array($0) } let resultEncoded2 = arr.base58EncodedString XCTAssert(resultEncoded2 == vector) @@ -41,13 +38,11 @@ class DataConversionTests: LocalTestCase { let vector = "2NEpo7TZRRrLZSi2U" let expected = "Hello World!" - guard let resultDecoded = vector.base58DecodedData else { return XCTFail("base58 decode unexpectedly returned nil") } let arr = resultDecoded.withUnsafeBytes { Array($0) } let str = String(bytes: arr, encoding: .utf8) XCTAssert(str == expected) - let resultEncoded = expected.base58EncodedString XCTAssert(resultEncoded == vector) } @@ -57,13 +52,11 @@ class DataConversionTests: LocalTestCase { let vector = "USm3fpXnKG5EUBx2ndxBDMPVciP5hGey2Jh4NDv6gmeo1LkMeiKrLJUUBk6Z" let expected = "The quick brown fox jumps over the lazy dog." - guard let resultDecoded = vector.base58DecodedData else { return XCTFail("base58 decode unexpectedly returned nil") } let arr = resultDecoded.withUnsafeBytes { Array($0) } let str = String(bytes: arr, encoding: .utf8) XCTAssert(str == expected) - let resultEncoded = expected.base58EncodedString XCTAssert(resultEncoded == vector) } @@ -73,12 +66,10 @@ class DataConversionTests: LocalTestCase { let vector = "111233QC4" let expected = "0x000000287fb4cd" - guard let resultDecoded = vector.base58DecodedData else { return XCTFail("base58 decode unexpectedly returned nil") } let str = resultDecoded.toHexString().addHexPrefix() XCTAssert(str == expected) - let arr = resultDecoded.withUnsafeBytes { Array($0) } let resultEncoded = arr.base58EncodedString XCTAssert(resultEncoded == vector) @@ -89,12 +80,10 @@ class DataConversionTests: LocalTestCase { let vector = "11111111111111111111111111111111" let expected = "0x0000000000000000000000000000000000000000000000000000000000000000" - guard let resultDecoded = vector.base58DecodedData else { return XCTFail("base58 decode unexpectedly returned nil") } let str = resultDecoded.toHexString().addHexPrefix() XCTAssert(str == expected) - let arr = resultDecoded.withUnsafeBytes { Array($0) } let resultEncoded = arr.base58EncodedString XCTAssert(resultEncoded == vector) diff --git a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift index d9c0aeaee..2287b4683 100644 --- a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift +++ b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift @@ -4,7 +4,6 @@ import BigInt @testable import web3swift -@testable import Web3Core class EIP1559BlockTests: LocalTestCase { diff --git a/Tests/web3swiftTests/localTests/EIP67Tests.swift b/Tests/web3swiftTests/localTests/EIP67Tests.swift index 9a105e5b5..de9f694d1 100755 --- a/Tests/web3swiftTests/localTests/EIP67Tests.swift +++ b/Tests/web3swiftTests/localTests/EIP67Tests.swift @@ -18,7 +18,7 @@ class EIP67Tests: LocalTestCase { eip67Data.amount = BigUInt("1000000000000000000") // eip67Data.data = let encoding = eip67Data.toString() - + } func testEIP67codeGeneration() throws { diff --git a/Tests/web3swiftTests/localTests/EventloopTests.swift b/Tests/web3swiftTests/localTests/EventloopTests.swift index 923aaf774..2e8b0df25 100755 --- a/Tests/web3swiftTests/localTests/EventloopTests.swift +++ b/Tests/web3swiftTests/localTests/EventloopTests.swift @@ -21,7 +21,7 @@ class EventloopTests: XCTestCase { expectation.fulfill() } } catch { - + } } diff --git a/Tests/web3swiftTests/localTests/KeystoresTests.swift b/Tests/web3swiftTests/localTests/KeystoresTests.swift index 3348ac9c9..cab2dae5f 100755 --- a/Tests/web3swiftTests/localTests/KeystoresTests.swift +++ b/Tests/web3swiftTests/localTests/KeystoresTests.swift @@ -81,7 +81,7 @@ class KeystoresTests: LocalTestCase { let keystore = try! EthereumKeystoreV3(password: "") XCTAssertNotNil(keystore) let account = keystore!.addresses![0] - + let data = try! keystore!.serialize() let key = try! keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) XCTAssertNotNil(key) @@ -172,7 +172,7 @@ class KeystoresTests: LocalTestCase { let account = keystore!.addresses![1] let key = try! keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) XCTAssertNotNil(key) - + } func testByBIP32keystoreSaveAndDeriva() throws { @@ -186,10 +186,7 @@ class KeystoresTests: LocalTestCase { let recreatedStore = BIP32Keystore.init(data!) XCTAssert(keystore?.addresses?.count == recreatedStore?.addresses?.count) XCTAssert(keystore?.rootPrefix == recreatedStore?.rootPrefix) - - - - + XCTAssert(keystore?.addresses![0] == recreatedStore?.addresses![0]) XCTAssert(keystore?.addresses![1] == recreatedStore?.addresses![1]) } diff --git a/Tests/web3swiftTests/localTests/NumberFormattingUtilTests.swift b/Tests/web3swiftTests/localTests/NumberFormattingUtilTests.swift index e8a95463d..676eb533c 100755 --- a/Tests/web3swiftTests/localTests/NumberFormattingUtilTests.swift +++ b/Tests/web3swiftTests/localTests/NumberFormattingUtilTests.swift @@ -65,7 +65,7 @@ class NumberFormattingUtilTests: LocalTestCase { let formatted = Utilities.formatToPrecision(balance, units: .ether, formattingDecimals: 4, decimalSeparator: ",", fallbackToScientific: true) XCTAssert(formatted == "1,0000e-12") } - + func testFormatPreccissionFallbacksToUnitsDecimals() throws { let bInt = BigInt(1_700_000_000_000_000_000) let result = Utilities.formatToPrecision(bInt, units: .ether, formattingDecimals: Utilities.Units.ether.decimals + 1, decimalSeparator: ",") diff --git a/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift b/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift index 407115b08..d9027b6e4 100755 --- a/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift +++ b/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift @@ -19,7 +19,7 @@ class PersonalSignatureTests: XCTestCase { web3.addKeystoreManager(keystoreManager) let message = "Hello World" let expectedAddress = keystoreManager.addresses![0] - + let signature = try await web3.personal.signPersonalMessage(message: message.data(using: .utf8)!, from: expectedAddress, password: "") let unmarshalledSignature = SECP256K1.unmarshalSignature(signatureData: signature)! let signer = try web3.personal.ecrecover(personalMessage: message.data(using: .utf8)!, signature: signature) @@ -44,7 +44,7 @@ class PersonalSignatureTests: XCTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(txHash) - + switch receipt.status { case .notYetProcessed: return @@ -58,7 +58,7 @@ class PersonalSignatureTests: XCTestCase { web3.addKeystoreManager(keystoreManager) let message = "Hello World" let expectedAddress = keystoreManager.addresses![0] - + let signature = try await web3.personal.signPersonalMessage(message: message.data(using: .utf8)!, from: expectedAddress, password: "") let unmarshalledSignature = SECP256K1.unmarshalSignature(signatureData: signature)! diff --git a/Tests/web3swiftTests/localTests/RLPTests.swift b/Tests/web3swiftTests/localTests/RLPTests.swift index a17e41300..e6fa28cc9 100755 --- a/Tests/web3swiftTests/localTests/RLPTests.swift +++ b/Tests/web3swiftTests/localTests/RLPTests.swift @@ -14,6 +14,6 @@ class RLPTests: LocalTestCase { func testRLPdecodeTransaction() throws { let input = Data.fromHex("0xf90890558504e3b292008309153a8080b9083d6060604052336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550341561004f57600080fd5b60405160208061081d83398101604052808051906020019091905050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156100a757600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610725806100f86000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638da5cb5b14610067578063b2b2c008146100bc578063d59ba0df146101eb578063d8ffdcc414610247575b600080fd5b341561007257600080fd5b61007a61029c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156100c757600080fd5b61019460048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919050506102c1565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156101d75780820151818401526020810190506101bc565b505050509050019250505060405180910390f35b34156101f657600080fd5b61022d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080351515906020019091905050610601565b604051808215151515815260200191505060405180910390f35b341561025257600080fd5b61025a6106bf565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6102c96106e5565b6102d16106e5565b6000806000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561032e57600080fd5b8651885114151561033e57600080fd5b875160405180591061034d5750595b9080825280602002602001820160405250935060009250600091505b87518210156105f357600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd87848151811015156103be57fe5b906020019060200201518a858151811015156103d657fe5b906020019060200201518a868151811015156103ee57fe5b906020019060200201516000604051602001526040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15156104b857600080fd5b6102c65a03f115156104c957600080fd5b50505060405180519050905080156105e65787828151811015156104e957fe5b90602001906020020151848481518110151561050157fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508280600101935050868281518110151561055357fe5b90602001906020020151888381518110151561056b57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff16878481518110151561059957fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff167f334b3b1d4ad406523ee8e24beb689f5adbe99883a662c37d43275de52389da1460405160405180910390a45b8180600101925050610369565b839450505050509392505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561065e57600080fd5b81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001905092915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6020604051908101604052806000815250905600a165627a7a723058200618093d895b780d4616f24638637da0e0f9767e6d3675a9525fee1d6ed7f431002900000000000000000000000045245bc59219eeaaf6cd3f382e078a461ff9de7b25a0d1efc3c97d1aa9053aa0f59bf148d73f59764343bf3cae576c8769a14866948da0613d0265634fddd436397bc858e2672653833b57a05cfc8b93c14a6c05166e4a")! let transaction = CodableTransaction(rawValue: input) - + } } diff --git a/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift b/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift index 285b2641f..ca30a8d94 100644 --- a/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift +++ b/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift @@ -111,7 +111,7 @@ class ST20AndSecurityTokenTests: XCTestCase { func testSecurityTokenGranularity() async throws { let expectedGranularity = BigUInt.randomInteger(lessThan: BigUInt(10000000000)) - + ethMock.onCallTransaction = { transaction in guard let function = self.securityToken.contract.contract.getFunctionCalled(transaction.data) else { XCTFail("Failed to decode function call to determine what shall be returned") diff --git a/Tests/web3swiftTests/localTests/TestHelpers.swift b/Tests/web3swiftTests/localTests/TestHelpers.swift index ce049fce4..9f3a49860 100644 --- a/Tests/web3swiftTests/localTests/TestHelpers.swift +++ b/Tests/web3swiftTests/localTests/TestHelpers.swift @@ -39,7 +39,6 @@ class TestHelpers { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(txHash) - switch receipt.status { case .notYetProcessed: diff --git a/Tests/web3swiftTests/localTests/TransactionsTests.swift b/Tests/web3swiftTests/localTests/TransactionsTests.swift index 1a39e3bf3..4af0c4fa9 100755 --- a/Tests/web3swiftTests/localTests/TransactionsTests.swift +++ b/Tests/web3swiftTests/localTests/TransactionsTests.swift @@ -195,7 +195,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -243,7 +243,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -264,7 +264,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -312,7 +312,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -333,7 +333,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -381,7 +381,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -402,7 +402,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -450,7 +450,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -518,7 +518,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -539,7 +539,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -587,7 +587,7 @@ class TransactionsTests: XCTestCase { // check that we recovered the address correctly XCTAssertEqual(jsonTxn.sender!.address, expectedAddress.address, "Recovered Address Mismatch") } catch { - + return XCTFail(String(describing: error)) } } @@ -611,16 +611,16 @@ class TransactionsTests: XCTestCase { let publicKey = Utilities.privateToPublic(privateKeyData, compressed: false) let sender = Utilities.publicToAddress(publicKey!) transaction.chainID = 1 - + let hash = transaction.hashForSignature() let expectedHash = "0xdaf5a779ae972f972197303d7b574746c7ef83eadac0f2791ad23db92e4c8e53".stripHexPrefix() XCTAssertEqual(hash!.toHexString(), expectedHash, "Transaction signature failed") try transaction.sign(privateKey: privateKeyData, useExtraEntropy: false) - + XCTAssertEqual(transaction.v, 37, "Transaction signature failed") XCTAssertEqual(sender, transaction.sender) } catch { - + XCTFail() } } @@ -639,12 +639,11 @@ class TransactionsTests: XCTestCase { let policies = Policies(gasLimitPolicy: .manual(78423)) let result = try await writeTX.writeToChain(password: "", policies: policies, sendRaw: false) let txHash = Data.fromHex(result.hash.stripHexPrefix())! - Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(txHash) - + XCTAssert(receipt.status == .ok) switch receipt.status { @@ -655,13 +654,13 @@ class TransactionsTests: XCTestCase { } let details = try await web3.eth.transactionDetails(txHash) - + // FIXME: Re-enable this test. // XCTAssertEqual(details.transaction.gasLimit, BigUInt(78423)) } catch Web3Error.nodeError(let descr) { guard descr == "insufficient funds for gas * price + value" else {return XCTFail()} } catch { - + XCTFail() } } diff --git a/Tests/web3swiftTests/localTests/UncategorizedTests.swift b/Tests/web3swiftTests/localTests/UncategorizedTests.swift index ccd1056b1..f47ccdeec 100755 --- a/Tests/web3swiftTests/localTests/UncategorizedTests.swift +++ b/Tests/web3swiftTests/localTests/UncategorizedTests.swift @@ -69,7 +69,7 @@ class UncategorizedTests: XCTestCase { bloom.add(BigUInt(data)) let newBytes = bloom.bytes if newBytes != oldBytes { - + } } for str in positive { @@ -118,16 +118,15 @@ class UncategorizedTests: XCTestCase { let userDeviceCount = try await contract! .createReadOperation("userDeviceCount", parameters: [addr])? .callContractMethod() - + let totalUsers = try await contract! .createReadOperation("totalUsers")? .callContractMethod() - + let user = try await contract! .createReadOperation("users", parameters: [0])? .callContractMethod() - - + } func testBloomFilterPerformance() throws { diff --git a/Tests/web3swiftTests/localTests/UserCases.swift b/Tests/web3swiftTests/localTests/UserCases.swift index c6377dda9..0fb8ef47b 100755 --- a/Tests/web3swiftTests/localTests/UserCases.swift +++ b/Tests/web3swiftTests/localTests/UserCases.swift @@ -26,7 +26,7 @@ class UserCases: XCTestCase { readTransaction.transaction.from = account let response = try await readTransaction.callContractMethod() let balance = response["0"] as? BigUInt - + } func testUserCase2() async { @@ -86,7 +86,7 @@ class UserCases: XCTestCase { Thread.sleep(forTimeInterval: 1.0) let receipt = try await web3.eth.transactionReceipt(txHash) - + XCTAssert(receipt.contractAddress != nil) switch receipt.status { @@ -97,7 +97,7 @@ class UserCases: XCTestCase { } let details = try await web3.eth.transactionDetails(txHash) - + XCTAssert(details.transaction.to == .contractDeploymentAddress()) } @@ -105,6 +105,6 @@ class UserCases: XCTestCase { let web3 = try await Web3.new(LocalTestCase.url) let address = EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")! let balanceResult = try await web3.eth.getBalance(for: address) - + } } diff --git a/Tests/web3swiftTests/localTests/UtilitiesTests.swift b/Tests/web3swiftTests/localTests/UtilitiesTests.swift index 5751afde0..4780805b0 100644 --- a/Tests/web3swiftTests/localTests/UtilitiesTests.swift +++ b/Tests/web3swiftTests/localTests/UtilitiesTests.swift @@ -10,14 +10,14 @@ import Web3Core @testable import web3swift -class UtilitiesTests: XCTestCase { +class UtilitiesTests: XCTestCase { // MARK: - units - + struct Test { let input: Utilities.Units let output: Int } - + func testUnitsDecimals() throws { let units: [Test] = [.init(input: .wei, output: 0), .init(input: .kwei, output: 3), @@ -41,7 +41,7 @@ class UtilitiesTests: XCTestCase { .init(input: .grand, output: 21), .init(input: .mether, output: 24), .init(input: .gether, output: 27), - .init(input: .tether, output: 30), + .init(input: .tether, output: 30) ] units.forEach { test in XCTAssertEqual(test.input.decimals, test.output) diff --git a/Tests/web3swiftTests/localTests/Web3ErrorTests.swift b/Tests/web3swiftTests/localTests/Web3ErrorTests.swift index c66ff9012..7eba7b8eb 100644 --- a/Tests/web3swiftTests/localTests/Web3ErrorTests.swift +++ b/Tests/web3swiftTests/localTests/Web3ErrorTests.swift @@ -22,4 +22,3 @@ class Web3ErrorTests: XCTestCase { } } - diff --git a/Tests/web3swiftTests/remoteTests/ENSTests.swift b/Tests/web3swiftTests/remoteTests/ENSTests.swift index 052142bd9..55a254848 100755 --- a/Tests/web3swiftTests/remoteTests/ENSTests.swift +++ b/Tests/web3swiftTests/remoteTests/ENSTests.swift @@ -27,7 +27,7 @@ class ENSTests: XCTestCase { let ens = ENS(web3: web3) let domain = "somename.eth" let address = try await ens?.registry.getResolver(forDomain: domain).resolverContractAddress - + XCTAssertEqual(address?.address.lowercased(), "0x4976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41") } diff --git a/Tests/web3swiftTests/remoteTests/EtherscanTransactionCheckerTests.swift b/Tests/web3swiftTests/remoteTests/EtherscanTransactionCheckerTests.swift index c58d2fa44..88de5f92b 100644 --- a/Tests/web3swiftTests/remoteTests/EtherscanTransactionCheckerTests.swift +++ b/Tests/web3swiftTests/remoteTests/EtherscanTransactionCheckerTests.swift @@ -13,7 +13,7 @@ final class EtherscanTransactionCheckerTests: XCTestCase { func testHasTransactions() async throws { let sut = EtherscanTransactionChecker(urlSession: URLSession.shared, apiKey: testApiKey) - + let result = try await sut.hasTransactions(ethereumAddress: try XCTUnwrap(EthereumAddress(vitaliksAddress))) XCTAssertTrue(result) diff --git a/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift b/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift index 7e10946a5..f84324794 100644 --- a/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift +++ b/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift @@ -27,8 +27,7 @@ final class PolicyResolverTests: XCTestCase { tx.from = EthereumAddress("0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B")! let policies = Policies(gasLimitPolicy: .manual(21_000)) try await resolver.resolveAll(for: &tx, with: policies) - - + XCTAssertGreaterThan(tx.gasLimit, 0) XCTAssertGreaterThan(tx.maxFeePerGas ?? 0, 0) XCTAssertGreaterThan(tx.maxPriorityFeePerGas ?? 0, 0) @@ -49,8 +48,7 @@ final class PolicyResolverTests: XCTestCase { tx.from = EthereumAddress("0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B")! let policies = Policies(gasLimitPolicy: .manual(21_000)) try await resolver.resolveAll(for: &tx, with: policies) - - + XCTAssertGreaterThan(tx.gasLimit, 0) XCTAssertGreaterThan(tx.gasPrice ?? 0, 0) XCTAssertGreaterThan(tx.nonce, 0) From 87f8aa25e5a456162a8eda7c9f2638ddbf0a11a9 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 5 Feb 2023 18:05:28 +0200 Subject: [PATCH 089/210] fix: EIP1559BlockTests import of Web3Core --- Tests/web3swiftTests/localTests/EIP1559BlockTests.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift index 2287b4683..d9c0aeaee 100644 --- a/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift +++ b/Tests/web3swiftTests/localTests/EIP1559BlockTests.swift @@ -4,6 +4,7 @@ import BigInt @testable import web3swift +@testable import Web3Core class EIP1559BlockTests: LocalTestCase { From 61a8f6cbaec1cc237cc79daf58373e505ee55ed5 Mon Sep 17 00:00:00 2001 From: Vaishali Desai Date: Sun, 5 Feb 2023 20:55:33 +0000 Subject: [PATCH 090/210] swapped the order of spm and cocoapods --- README.md | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index ad57bfe93..dad6960ea 100755 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ - [Core features](#core-features) - [Installation](#installation) - - [CocoaPods](#cocoapods) - [Swift Package](#swift-package) + - [CocoaPods](#cocoapods) - [Example usage](#example-usage) - [Send Ether](#send-ether) - [Contract read method](#contract-read-method) @@ -66,6 +66,24 @@ ## Installation +### Swift Package +The [Swift Package Manager](https://swift.org/package-manager/ "") is a tool for automating the distribution of Swift code and is integrated into the swift compiler. + +Once you have your Swift package set up, adding Alamofire as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. +```swift +dependencies: [ + .package(url: "https://github.com/web3swift-team/web3swift.git", .upToNextMajor(from: "3.0.0")) +] +``` + +## Example usage +In the imports section: + +```swift +import web3swift +import Web3Core +``` + ### CocoaPods [CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: @@ -91,23 +109,6 @@ Then, run the following command: $ pod install ``` -### Swift Package -The [Swift Package Manager](https://swift.org/package-manager/ "") is a tool for automating the distribution of Swift code and is integrated into the swift compiler. - -Once you have your Swift package set up, adding Alamofire as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. -```swift -dependencies: [ - .package(url: "https://github.com/web3swift-team/web3swift.git", .upToNextMajor(from: "3.0.0")) -] -``` - -## Example usage -In the imports section: - -```swift -import web3swift -import Web3Core -``` ### Send Ether ```swift From 6d226237f673aec9bdf9aeae81aebc192257cd1d Mon Sep 17 00:00:00 2001 From: Vaishali Desai Date: Sun, 5 Feb 2023 20:55:42 +0000 Subject: [PATCH 091/210] added warning for cocoapods --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index dad6960ea..4d47fde1c 100755 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ Then, run the following command: $ pod install ``` +> **WARNING**: CocoaPods is a powerful tool for managing dependencies in iOS development, but it also has some limitations that need to be considered such as its limited control over dependencies, lack of transparency, complex setup and slow performance. ### Send Ether ```swift From 66558d3e640243b9d94456b72f97483d3e34fb60 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Mon, 6 Feb 2023 00:21:04 +0200 Subject: [PATCH 092/210] fix: README SPM - mention web3swift instead of Alamofire --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d47fde1c..72583cfee 100755 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ ### Swift Package The [Swift Package Manager](https://swift.org/package-manager/ "") is a tool for automating the distribution of Swift code and is integrated into the swift compiler. -Once you have your Swift package set up, adding Alamofire as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. +Once you have your Swift package set up, adding `web3swift` as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. ```swift dependencies: [ .package(url: "https://github.com/web3swift-team/web3swift.git", .upToNextMajor(from: "3.0.0")) From 1978d3ba23cf1175383343d7623a685eba9daea6 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Mon, 6 Feb 2023 17:42:27 +0200 Subject: [PATCH 093/210] chore: alphabetical order for rules and excluded files + alignment of opt_in_rules --- .swiftlint.yml | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index c0ec7c117..4bd79d7b4 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,34 +1,34 @@ excluded: - - Carthage - - Pods - .build - Build + - Carthage - DerivedData + - Pods disabled_rules: - - type_name + - function_parameter_count - identifier_name - line_length - multiple_closures_with_trailing_closure - - todo - - function_parameter_count - nesting + - todo + - type_name opt_in_rules: - - weak_delegate - - unused_import - - unneeded_parentheses_in_closure_argument - - trailing_closure - - static_operator - - redundant_nil_coalescing - - override_in_extension - - legacy_objc_type - - implicitly_unwrapped_optional - - force_unwrapping - - empty_string - - closure_body_length - - fallthrough - - indentation_width + - closure_body_length + - empty_string + - fallthrough + - force_unwrapping + - implicitly_unwrapped_optional + - indentation_width + - legacy_objc_type + - override_in_extension + - redundant_nil_coalescing + - static_operator + - trailing_closure + - unneeded_parentheses_in_closure_argument + - unused_import + - weak_delegate # force warnings force_cast: error From d1ba3706b73542fb395ef6ca65760a4883a66492 Mon Sep 17 00:00:00 2001 From: Vaishali Desai Date: Mon, 6 Feb 2023 19:12:17 +0000 Subject: [PATCH 094/210] Updated recommended words --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 72583cfee..e5b0d26dd 100755 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ ## Installation -### Swift Package +### Swift Package (Recommended) The [Swift Package Manager](https://swift.org/package-manager/ "") is a tool for automating the distribution of Swift code and is integrated into the swift compiler. Once you have your Swift package set up, adding `web3swift` as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. @@ -109,7 +109,7 @@ Then, run the following command: $ pod install ``` -> **WARNING**: CocoaPods is a powerful tool for managing dependencies in iOS development, but it also has some limitations that need to be considered such as its limited control over dependencies, lack of transparency, complex setup and slow performance. +> **WARNING**: CocoaPods is a powerful tool for managing dependencies in iOS development, but it also has some limitations that need to be considered such as its limited control over dependencies, lack of transparency, complex setup and slow performance. We highly recommend using SPM first as using CocoaPods will delay new updates and bug fixes being delivered to you. ### Send Ether ```swift From 61e2f01c88677bea04a49309eececd8692e73520 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Mon, 6 Feb 2023 21:49:09 +0200 Subject: [PATCH 095/210] chore: a few clarifications --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e5b0d26dd..5b4cf4c5d 100755 --- a/README.md +++ b/README.md @@ -67,9 +67,9 @@ ## Installation ### Swift Package (Recommended) -The [Swift Package Manager](https://swift.org/package-manager/ "") is a tool for automating the distribution of Swift code and is integrated into the swift compiler. +The [Swift Package Manager](https://swift.org/package-manager/ "") is a tool for automating the distribution of Swift code that is well integrated with Swift build system. -Once you have your Swift package set up, adding `web3swift` as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. +Once you have your Swift project set up, adding `web3swift` as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. ```swift dependencies: [ .package(url: "https://github.com/web3swift-team/web3swift.git", .upToNextMajor(from: "3.0.0")) From 592d6ce616c7418abb28f3d1ab69c9137110acc3 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Mon, 6 Feb 2023 21:54:35 +0200 Subject: [PATCH 096/210] chore: fixed wrong update; added explanation reference about adding packages --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b4cf4c5d..ed5d31cb8 100755 --- a/README.md +++ b/README.md @@ -69,13 +69,16 @@ ### Swift Package (Recommended) The [Swift Package Manager](https://swift.org/package-manager/ "") is a tool for automating the distribution of Swift code that is well integrated with Swift build system. -Once you have your Swift project set up, adding `web3swift` as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. +Once you have your Swift package set up, adding `web3swift` as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. ```swift dependencies: [ .package(url: "https://github.com/web3swift-team/web3swift.git", .upToNextMajor(from: "3.0.0")) ] ``` +Or if your project is not a package follow these guidelines on [how to add a Swift Package to your Xcode project](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app). + + ## Example usage In the imports section: From ce274a273303377146d743300f05e9fc98d7c973 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Mon, 6 Feb 2023 21:58:28 +0200 Subject: [PATCH 097/210] chore: swiftlint will run with --fix by default --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9dcbbe83d..d923d7bc9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,4 +22,4 @@ repos: # rev: 0.50.3 # hooks: # - id: swiftlint -# args: [Sources, Tests] +# args: [--fix, Sources, Tests] From 61b9f1bfa0c9088945b92b9398a811cfb75be6d9 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Mon, 6 Feb 2023 22:20:58 +0200 Subject: [PATCH 098/210] fix: web3 wallet example --- Example/myWeb3Wallet/Podfile | 30 ---- Example/myWeb3Wallet/Podfile.lock | 53 ------ .../myWeb3Wallet.xcodeproj/project.pbxproj | 167 +++--------------- .../myWeb3Wallet/ViewController.swift | 2 - .../WalletViewController.swift | 23 ++- 5 files changed, 38 insertions(+), 237 deletions(-) delete mode 100644 Example/myWeb3Wallet/Podfile delete mode 100644 Example/myWeb3Wallet/Podfile.lock diff --git a/Example/myWeb3Wallet/Podfile b/Example/myWeb3Wallet/Podfile deleted file mode 100644 index 9dea1b01f..000000000 --- a/Example/myWeb3Wallet/Podfile +++ /dev/null @@ -1,30 +0,0 @@ -# Uncomment the next line to define a global platform for your project -platform :ios, '15.0' - -target 'myWeb3Wallet' do - # Comment the next line if you don't want to use dynamic frameworks - use_frameworks! - - # Pods for myWeb3Wallet -pod 'web3swift', :git => 'https://github.com/veerChauhan/web3swift.git', :branch => 'develop' - - - target 'myWeb3WalletTests' do - inherit! :search_paths - # Pods for testing - end - - target 'myWeb3WalletUITests' do - # Pods for testing - end - -end - -# set iOS deployment target for every pod to avoid warnings -post_install do |installer| - installer.pods_project.targets.each do |target| - target.build_configurations.each do |config| - config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0' - end - end -end diff --git a/Example/myWeb3Wallet/Podfile.lock b/Example/myWeb3Wallet/Podfile.lock deleted file mode 100644 index 5fd352276..000000000 --- a/Example/myWeb3Wallet/Podfile.lock +++ /dev/null @@ -1,53 +0,0 @@ -PODS: - - BigInt (5.2.0) - - CryptoSwift (1.4.2) - - PromiseKit (6.15.3): - - PromiseKit/CorePromise (= 6.15.3) - - PromiseKit/Foundation (= 6.15.3) - - PromiseKit/UIKit (= 6.15.3) - - PromiseKit/CorePromise (6.15.3) - - PromiseKit/Foundation (6.15.3): - - PromiseKit/CorePromise - - PromiseKit/UIKit (6.15.3): - - PromiseKit/CorePromise - - secp256k1.c (0.1.2) - - Starscream (4.0.4) - - web3swift (2.3.0): - - BigInt (~> 5.2) - - CryptoSwift (~> 1.4.0) - - PromiseKit (~> 6.15.3) - - secp256k1.c (~> 0.1) - - Starscream (~> 4.0.4) - -DEPENDENCIES: - - web3swift (from `https://github.com/veerChauhan/web3swift.git`, branch `develop`) - -SPEC REPOS: - trunk: - - BigInt - - CryptoSwift - - PromiseKit - - secp256k1.c - - Starscream - -EXTERNAL SOURCES: - web3swift: - :branch: develop - :git: https://github.com/veerChauhan/web3swift.git - -CHECKOUT OPTIONS: - web3swift: - :commit: d05a569a1dbb43b3770832cfa2be703ec26ca894 - :git: https://github.com/veerChauhan/web3swift.git - -SPEC CHECKSUMS: - BigInt: f668a80089607f521586bbe29513d708491ef2f7 - CryptoSwift: a532e74ed010f8c95f611d00b8bbae42e9fe7c17 - PromiseKit: 3b2b6995e51a954c46dbc550ce3da44fbfb563c5 - secp256k1.c: db47b726585d80f027423682eb369729e61b3b20 - Starscream: 5178aed56b316f13fa3bc55694e583d35dd414d9 - web3swift: dcc8da6f0944a062faa381869ce64114ddb5f8d3 - -PODFILE CHECKSUM: 53e3e6ef11ba247d3bee3e2fa1580cb90296aef2 - -COCOAPODS: 1.11.2 diff --git a/Example/myWeb3Wallet/myWeb3Wallet.xcodeproj/project.pbxproj b/Example/myWeb3Wallet/myWeb3Wallet.xcodeproj/project.pbxproj index 2c39452c9..224ad4a5b 100644 --- a/Example/myWeb3Wallet/myWeb3Wallet.xcodeproj/project.pbxproj +++ b/Example/myWeb3Wallet/myWeb3Wallet.xcodeproj/project.pbxproj @@ -7,9 +7,7 @@ objects = { /* Begin PBXBuildFile section */ - 08D762AA7F8C96F1FEC2BDDA /* Pods_myWeb3Wallet.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6EB035B54D0DDFE25556549 /* Pods_myWeb3Wallet.framework */; }; - 1A3D2B3177B96101E5BA3A86 /* Pods_myWeb3WalletTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4590F35DEE4A4CA41141602 /* Pods_myWeb3WalletTests.framework */; }; - ADDA7950DDF6B6F2FFB1F198 /* Pods_myWeb3Wallet_myWeb3WalletUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2DEF494BADF9FD39D553B87D /* Pods_myWeb3Wallet_myWeb3WalletUITests.framework */; }; + D6DD90D22991966100EE140E /* web3swift in Frameworks */ = {isa = PBXBuildFile; productRef = D6DD90D12991966100EE140E /* web3swift */; }; FA5308212721D59B002C1F06 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA5308202721D59B002C1F06 /* AppDelegate.swift */; }; FA5308232721D59B002C1F06 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA5308222721D59B002C1F06 /* SceneDelegate.swift */; }; FA5308252721D59B002C1F06 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA5308242721D59B002C1F06 /* ViewController.swift */; }; @@ -47,14 +45,8 @@ /* Begin PBXFileReference section */ 2DEF494BADF9FD39D553B87D /* Pods_myWeb3Wallet_myWeb3WalletUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_myWeb3Wallet_myWeb3WalletUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 5B0E97C0C8FE51D0241E7D19 /* Pods-myWeb3Wallet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-myWeb3Wallet.release.xcconfig"; path = "Target Support Files/Pods-myWeb3Wallet/Pods-myWeb3Wallet.release.xcconfig"; sourceTree = ""; }; - 600772647D45BC0D702D4137 /* Pods-myWeb3Wallet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-myWeb3Wallet.debug.xcconfig"; path = "Target Support Files/Pods-myWeb3Wallet/Pods-myWeb3Wallet.debug.xcconfig"; sourceTree = ""; }; - 7574A738941D92CC94F93A9E /* Pods-myWeb3Wallet-myWeb3WalletUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-myWeb3Wallet-myWeb3WalletUITests.release.xcconfig"; path = "Target Support Files/Pods-myWeb3Wallet-myWeb3WalletUITests/Pods-myWeb3Wallet-myWeb3WalletUITests.release.xcconfig"; sourceTree = ""; }; - A87A2F63C4B3084139E790F5 /* Pods-myWeb3WalletTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-myWeb3WalletTests.debug.xcconfig"; path = "Target Support Files/Pods-myWeb3WalletTests/Pods-myWeb3WalletTests.debug.xcconfig"; sourceTree = ""; }; D4590F35DEE4A4CA41141602 /* Pods_myWeb3WalletTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_myWeb3WalletTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - D6018FABA256C0117F85A829 /* Pods-myWeb3Wallet-myWeb3WalletUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-myWeb3Wallet-myWeb3WalletUITests.debug.xcconfig"; path = "Target Support Files/Pods-myWeb3Wallet-myWeb3WalletUITests/Pods-myWeb3Wallet-myWeb3WalletUITests.debug.xcconfig"; sourceTree = ""; }; D6EB035B54D0DDFE25556549 /* Pods_myWeb3Wallet.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_myWeb3Wallet.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - E41A5A8BF0A312348D3C52FD /* Pods-myWeb3WalletTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-myWeb3WalletTests.release.xcconfig"; path = "Target Support Files/Pods-myWeb3WalletTests/Pods-myWeb3WalletTests.release.xcconfig"; sourceTree = ""; }; FA53081D2721D59B002C1F06 /* myWeb3Wallet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = myWeb3Wallet.app; sourceTree = BUILT_PRODUCTS_DIR; }; FA5308202721D59B002C1F06 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; FA5308222721D59B002C1F06 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -82,7 +74,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 08D762AA7F8C96F1FEC2BDDA /* Pods_myWeb3Wallet.framework in Frameworks */, + D6DD90D22991966100EE140E /* web3swift in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -90,7 +82,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1A3D2B3177B96101E5BA3A86 /* Pods_myWeb3WalletTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -98,26 +89,12 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - ADDA7950DDF6B6F2FFB1F198 /* Pods_myWeb3Wallet_myWeb3WalletUITests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 40AC3854191B335F2FCA6C71 /* Pods */ = { - isa = PBXGroup; - children = ( - 600772647D45BC0D702D4137 /* Pods-myWeb3Wallet.debug.xcconfig */, - 5B0E97C0C8FE51D0241E7D19 /* Pods-myWeb3Wallet.release.xcconfig */, - D6018FABA256C0117F85A829 /* Pods-myWeb3Wallet-myWeb3WalletUITests.debug.xcconfig */, - 7574A738941D92CC94F93A9E /* Pods-myWeb3Wallet-myWeb3WalletUITests.release.xcconfig */, - A87A2F63C4B3084139E790F5 /* Pods-myWeb3WalletTests.debug.xcconfig */, - E41A5A8BF0A312348D3C52FD /* Pods-myWeb3WalletTests.release.xcconfig */, - ); - path = Pods; - sourceTree = ""; - }; B67819FA7D92C1562AFD65A8 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -135,7 +112,6 @@ FA5308362721D59D002C1F06 /* myWeb3WalletTests */, FA5308402721D59D002C1F06 /* myWeb3WalletUITests */, FA53081E2721D59B002C1F06 /* Products */, - 40AC3854191B335F2FCA6C71 /* Pods */, B67819FA7D92C1562AFD65A8 /* Frameworks */, ); sourceTree = ""; @@ -227,17 +203,18 @@ isa = PBXNativeTarget; buildConfigurationList = FA5308472721D59D002C1F06 /* Build configuration list for PBXNativeTarget "myWeb3Wallet" */; buildPhases = ( - 2C189F9EA9914E3A42777867 /* [CP] Check Pods Manifest.lock */, FA5308192721D59B002C1F06 /* Sources */, FA53081A2721D59B002C1F06 /* Frameworks */, FA53081B2721D59B002C1F06 /* Resources */, - 5E0CBD27780EAD115251C9AC /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); dependencies = ( ); name = myWeb3Wallet; + packageProductDependencies = ( + D6DD90D12991966100EE140E /* web3swift */, + ); productName = myWeb3Wallet; productReference = FA53081D2721D59B002C1F06 /* myWeb3Wallet.app */; productType = "com.apple.product-type.application"; @@ -246,7 +223,6 @@ isa = PBXNativeTarget; buildConfigurationList = FA53084A2721D59D002C1F06 /* Build configuration list for PBXNativeTarget "myWeb3WalletTests" */; buildPhases = ( - 342829194E3F4C74B29C947B /* [CP] Check Pods Manifest.lock */, FA53082F2721D59D002C1F06 /* Sources */, FA5308302721D59D002C1F06 /* Frameworks */, FA5308312721D59D002C1F06 /* Resources */, @@ -265,11 +241,9 @@ isa = PBXNativeTarget; buildConfigurationList = FA53084D2721D59D002C1F06 /* Build configuration list for PBXNativeTarget "myWeb3WalletUITests" */; buildPhases = ( - 5F33F7D7F77389C37C4F1656 /* [CP] Check Pods Manifest.lock */, FA5308392721D59D002C1F06 /* Sources */, FA53083A2721D59D002C1F06 /* Frameworks */, FA53083B2721D59D002C1F06 /* Resources */, - AAF75ECFD98859A6D0818BB6 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -313,6 +287,9 @@ Base, ); mainGroup = FA5308142721D59B002C1F06; + packageReferences = ( + D6DD90D02991966100EE140E /* XCRemoteSwiftPackageReference "web3swift" */, + ); productRefGroup = FA53081E2721D59B002C1F06 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -355,109 +332,6 @@ }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - 2C189F9EA9914E3A42777867 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-myWeb3Wallet-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 342829194E3F4C74B29C947B /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-myWeb3WalletTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 5E0CBD27780EAD115251C9AC /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-myWeb3Wallet/Pods-myWeb3Wallet-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-myWeb3Wallet/Pods-myWeb3Wallet-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-myWeb3Wallet/Pods-myWeb3Wallet-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - 5F33F7D7F77389C37C4F1656 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-myWeb3Wallet-myWeb3WalletUITests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - AAF75ECFD98859A6D0818BB6 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-myWeb3Wallet-myWeb3WalletUITests/Pods-myWeb3Wallet-myWeb3WalletUITests-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-myWeb3Wallet-myWeb3WalletUITests/Pods-myWeb3Wallet-myWeb3WalletUITests-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-myWeb3Wallet-myWeb3WalletUITests/Pods-myWeb3Wallet-myWeb3WalletUITests-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ FA5308192721D59B002C1F06 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -642,7 +516,6 @@ }; FA5308482721D59D002C1F06 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 600772647D45BC0D702D4137 /* Pods-myWeb3Wallet.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; @@ -671,7 +544,6 @@ }; FA5308492721D59D002C1F06 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5B0E97C0C8FE51D0241E7D19 /* Pods-myWeb3Wallet.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; @@ -700,7 +572,6 @@ }; FA53084B2721D59D002C1F06 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = A87A2F63C4B3084139E790F5 /* Pods-myWeb3WalletTests.debug.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -726,7 +597,6 @@ }; FA53084C2721D59D002C1F06 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = E41A5A8BF0A312348D3C52FD /* Pods-myWeb3WalletTests.release.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -752,7 +622,6 @@ }; FA53084E2721D59D002C1F06 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = D6018FABA256C0117F85A829 /* Pods-myWeb3Wallet-myWeb3WalletUITests.debug.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; CODE_SIGN_STYLE = Automatic; @@ -776,7 +645,6 @@ }; FA53084F2721D59D002C1F06 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7574A738941D92CC94F93A9E /* Pods-myWeb3Wallet-myWeb3WalletUITests.release.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; CODE_SIGN_STYLE = Automatic; @@ -838,6 +706,25 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + D6DD90D02991966100EE140E /* XCRemoteSwiftPackageReference "web3swift" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/web3swift-team/web3swift"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 3.0.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + D6DD90D12991966100EE140E /* web3swift */ = { + isa = XCSwiftPackageProductDependency; + package = D6DD90D02991966100EE140E /* XCRemoteSwiftPackageReference "web3swift" */; + productName = web3swift; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = FA5308152721D59B002C1F06 /* Project object */; } diff --git a/Example/myWeb3Wallet/myWeb3Wallet/ViewController.swift b/Example/myWeb3Wallet/myWeb3Wallet/ViewController.swift index de12eaa06..cdaa670f8 100644 --- a/Example/myWeb3Wallet/myWeb3Wallet/ViewController.swift +++ b/Example/myWeb3Wallet/myWeb3Wallet/ViewController.swift @@ -14,6 +14,4 @@ class ViewController: UIViewController { // Do any additional setup after loading the view. } - } - diff --git a/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift b/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift index c766c5758..78940f394 100644 --- a/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift +++ b/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift @@ -7,6 +7,8 @@ import UIKit import web3swift +import Web3Core + class WalletViewController: UIViewController { @IBOutlet weak var continueButton: UIButton! @@ -47,9 +49,9 @@ class WalletViewController: UIViewController { @IBAction func onClickContinueButton(_ sender: UIButton) { print("Clicked on COntinue button") guard let dashboardScreen = self.storyboard?.instantiateViewController(withIdentifier: "DashboardViewController") as? DashboardViewController else { - #if DEBUG +#if DEBUG printContent("Unable to get Wallet controller") - #endif +#endif return } self.navigationController?.pushViewController(dashboardScreen, animated: true) @@ -84,7 +86,7 @@ class WalletViewController: UIViewController { return } do { - let keystore = try EthereumKeystoreV3(privateKey: dataKey) + let keystore = try EthereumKeystoreV3(privateKey: dataKey, password: "") if let myWeb3KeyStore = keystore { let manager = KeystoreManager([myWeb3KeyStore]) let address = keystore?.addresses?.first @@ -113,15 +115,13 @@ class WalletViewController: UIViewController { } + func importWalletWith(mnemonics: String) { - let walletAddress = try? BIP32Keystore(mnemonics: mnemonics , prefixPath: "m/44'/77777'/0'/0") - print(walletAddress?.addresses) + let walletAddress = try? BIP32Keystore(mnemonics: mnemonics, password: "", prefixPath: "m/44'/77777'/0'/0") self.walletAddressLabel.text = "\(walletAddress?.addresses?.first?.address ?? "0x")" - } - - } + extension WalletViewController { fileprivate func createMnemonics(){ @@ -136,10 +136,9 @@ extension WalletViewController { } self._mnemonics = tMnemonics print(_mnemonics) - let tempWalletAddress = try? BIP32Keystore(mnemonics: self._mnemonics , prefixPath: "m/44'/77777'/0'/0") - print(tempWalletAddress?.addresses?.first?.address) + let tempWalletAddress = try? BIP32Keystore(mnemonics: self._mnemonics, password: "", prefixPath: "m/44'/77777'/0'/0") guard let walletAddress = tempWalletAddress?.addresses?.first else { - self.showAlertMessage(title: "", message: "We are unable to create wallet", actionName: "Ok") + self.showAlertMessage(title: "", message: "Unable to create wallet", actionName: "Ok") return } self._walletAddress = walletAddress.address @@ -148,7 +147,7 @@ extension WalletViewController { print(privateKey, "Is the private key") #endif let keyData = try? JSONEncoder().encode(tempWalletAddress?.keystoreParams) - FileManager.default.createFile(atPath: userDir + "/keystore"+"/key.json", contents: keyData, attributes: nil) + FileManager.default.createFile(atPath: userDir + "/keystore" + "/key.json", contents: keyData, attributes: nil) } } catch { From 081a552887850ab1883a33e112fdb70eaa0adb0b Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Tue, 7 Feb 2023 19:23:48 +0700 Subject: [PATCH 099/210] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ed5d31cb8..f7f7187be 100755 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ Then, run the following command: $ pod install ``` -> **WARNING**: CocoaPods is a powerful tool for managing dependencies in iOS development, but it also has some limitations that need to be considered such as its limited control over dependencies, lack of transparency, complex setup and slow performance. We highly recommend using SPM first as using CocoaPods will delay new updates and bug fixes being delivered to you. +> **WARNING**: CocoaPods is a powerful tool for managing dependencies in iOS development, but it also has some limitations that preventing us of providing first class support there. We highly recommend using SPM first as using CocoaPods will delay new updates and bug fixes being delivered to you. ### Send Ether ```swift From b0425af20ff307c0e0784b0ff56dad154d444d5c Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Tue, 7 Feb 2023 20:08:03 +0700 Subject: [PATCH 100/210] Moved the `decodeInputData(:methodEncoding:inputs)` method into `ABI.Element` type thus it prevents Cocoapods to build. --- .../Web3Core/EthereumABI/ABIElements.swift | 102 +++++++++--------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/Sources/Web3Core/EthereumABI/ABIElements.swift b/Sources/Web3Core/EthereumABI/ABIElements.swift index 7db0ca31a..1b04d0f23 100755 --- a/Sources/Web3Core/EthereumABI/ABIElements.swift +++ b/Sources/Web3Core/EthereumABI/ABIElements.swift @@ -262,7 +262,7 @@ extension ABI.Element { extension ABI.Element.Function { public func decodeInputData(_ rawData: Data) -> [String: Any]? { - return Web3Core.decodeInputData(rawData, methodEncoding: methodEncoding, inputs: inputs) + return ABI.Element.decodeInputData(rawData, methodEncoding: methodEncoding, inputs: inputs) } /// Decodes data returned by a function call. Able to decode `revert(string)`, `revert CustomError(...)` and `require(expression, string)` calls. @@ -432,61 +432,63 @@ extension ABI.Element.Function { extension ABI.Element.Constructor { public func decodeInputData(_ rawData: Data) -> [String: Any]? { - return Web3Core.decodeInputData(rawData, inputs: inputs) + return ABI.Element.decodeInputData(rawData, inputs: inputs) } } -/// Generic input decoding function. -/// - Parameters: -/// - rawData: data to decode. Must match the following criteria: `data.count == 0 || data.count % 32 == 4`. -/// - methodEncoding: 4 bytes representing method signature like `0xFFffFFff`. Can be omitted to avoid checking method encoding. -/// - inputs: expected input types. Order must be the same as in function declaration. -/// - Returns: decoded dictionary of input arguments mapped to their indices and arguments' names if these are not empty. -/// If decoding of at least one argument fails, `rawData` size is invalid or `methodEncoding` doesn't match - `nil` is returned. -private func decodeInputData(_ rawData: Data, - methodEncoding: Data? = nil, - inputs: [ABI.Element.InOut]) -> [String: Any]? { - let data: Data - let sig: Data? - - switch rawData.count % 32 { - case 0: - sig = nil - data = Data() - break - case 4: - sig = rawData[0 ..< 4] - data = Data(rawData[4 ..< rawData.count]) - default: - return nil - } +extension ABI.Element { + /// Generic input decoding function. + /// - Parameters: + /// - rawData: data to decode. Must match the following criteria: `data.count == 0 || data.count % 32 == 4`. + /// - methodEncoding: 4 bytes representing method signature like `0xFFffFFff`. Can be omitted to avoid checking method encoding. + /// - inputs: expected input types. Order must be the same as in function declaration. + /// - Returns: decoded dictionary of input arguments mapped to their indices and arguments' names if these are not empty. + /// If decoding of at least one argument fails, `rawData` size is invalid or `methodEncoding` doesn't match - `nil` is returned. + static private func decodeInputData(_ rawData: Data, + methodEncoding: Data? = nil, + inputs: [ABI.Element.InOut]) -> [String: Any]? { + let data: Data + let sig: Data? + + switch rawData.count % 32 { + case 0: + sig = nil + data = Data() + break + case 4: + sig = rawData[0 ..< 4] + data = Data(rawData[4 ..< rawData.count]) + default: + return nil + } - if methodEncoding != nil && sig != nil && sig != methodEncoding { - return nil - } + if methodEncoding != nil && sig != nil && sig != methodEncoding { + return nil + } - var returnArray = [String: Any]() + var returnArray = [String: Any]() - if data.count == 0 && inputs.count == 1 { - let name = "0" - let value = inputs[0].type.emptyValue - returnArray[name] = value - if inputs[0].name != "" { - returnArray[inputs[0].name] = value - } - } else { - guard inputs.count * 32 <= data.count else { return nil } - - var i = 0 - guard let values = ABIDecoder.decode(types: inputs, data: data) else {return nil} - for input in inputs { - let name = "\(i)" - returnArray[name] = values[i] - if input.name != "" { - returnArray[input.name] = values[i] + if data.count == 0 && inputs.count == 1 { + let name = "0" + let value = inputs[0].type.emptyValue + returnArray[name] = value + if inputs[0].name != "" { + returnArray[inputs[0].name] = value + } + } else { + guard inputs.count * 32 <= data.count else { return nil } + + var i = 0 + guard let values = ABIDecoder.decode(types: inputs, data: data) else {return nil} + for input in inputs { + let name = "\(i)" + returnArray[name] = values[i] + if input.name != "" { + returnArray[input.name] = values[i] + } + i = i + 1 } - i = i + 1 } + return returnArray } - return returnArray -} +} \ No newline at end of file From ae022a758b54970da0af8769417445b9f119949e Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Tue, 7 Feb 2023 20:44:39 +0700 Subject: [PATCH 101/210] Fixes due to PR review. --- Sources/Web3Core/EthereumABI/ABIElements.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Web3Core/EthereumABI/ABIElements.swift b/Sources/Web3Core/EthereumABI/ABIElements.swift index 1b04d0f23..e2ca9202b 100755 --- a/Sources/Web3Core/EthereumABI/ABIElements.swift +++ b/Sources/Web3Core/EthereumABI/ABIElements.swift @@ -262,7 +262,7 @@ extension ABI.Element { extension ABI.Element.Function { public func decodeInputData(_ rawData: Data) -> [String: Any]? { - return ABI.Element.decodeInputData(rawData, methodEncoding: methodEncoding, inputs: inputs) + return ABIDecoder.decodeInputData(rawData, methodEncoding: methodEncoding, inputs: inputs) } /// Decodes data returned by a function call. Able to decode `revert(string)`, `revert CustomError(...)` and `require(expression, string)` calls. @@ -432,11 +432,11 @@ extension ABI.Element.Function { extension ABI.Element.Constructor { public func decodeInputData(_ rawData: Data) -> [String: Any]? { - return ABI.Element.decodeInputData(rawData, inputs: inputs) + return ABIDecoder.decodeInputData(rawData, inputs: inputs) } } -extension ABI.Element { +extension ABIDecoder { /// Generic input decoding function. /// - Parameters: /// - rawData: data to decode. Must match the following criteria: `data.count == 0 || data.count % 32 == 4`. @@ -444,7 +444,7 @@ extension ABI.Element { /// - inputs: expected input types. Order must be the same as in function declaration. /// - Returns: decoded dictionary of input arguments mapped to their indices and arguments' names if these are not empty. /// If decoding of at least one argument fails, `rawData` size is invalid or `methodEncoding` doesn't match - `nil` is returned. - static private func decodeInputData(_ rawData: Data, + static func decodeInputData(_ rawData: Data, methodEncoding: Data? = nil, inputs: [ABI.Element.InOut]) -> [String: Any]? { let data: Data From 1c226f0b4ceacc0cbed92aa2c9d93d626553b89f Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Tue, 7 Feb 2023 23:16:04 +0200 Subject: [PATCH 102/210] chore: web3swift.podspec - version set to 3.1.1 --- web3swift.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web3swift.podspec b/web3swift.podspec index 475718533..50da01f53 100755 --- a/web3swift.podspec +++ b/web3swift.podspec @@ -1,4 +1,4 @@ -WEB3CORE_VERSION ||= '3.1.0' +WEB3CORE_VERSION ||= '3.1.1' Pod::Spec.new do |spec| spec.name = 'web3swift' From c09e631f815524ee8bfd1769e8be9bfac53db5b0 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Tue, 7 Feb 2023 23:16:07 +0200 Subject: [PATCH 103/210] chore: Web3Core.podspec - version set to 3.1.1 --- Web3Core.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Web3Core.podspec b/Web3Core.podspec index df71e5207..0da2cabc9 100644 --- a/Web3Core.podspec +++ b/Web3Core.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |spec| spec.compiler_flags = '-DCOCOAPODS' spec.name = 'Web3Core' - spec.version = '3.1.0' + spec.version = '3.1.1' spec.ios.deployment_target = "13.0" spec.osx.deployment_target = "10.15" spec.license = { :type => 'Apache License 2.0', :file => 'LICENSE.md' } From efe14a3f38a67ae9b9c8b540e83fbffca8740310 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 10 Feb 2023 15:31:31 +0200 Subject: [PATCH 104/210] fix: web3 infura and http provider alternative throwing initalizers --- .../web3swift/Web3/Web3+HttpProvider.swift | 24 ++++++---- .../web3swift/Web3/Web3+InfuraProviders.swift | 12 +++-- Sources/web3swift/Web3/Web3.swift | 25 +++++----- .../ST20AndSecurityTokenTests.swift | 2 +- .../remoteTests/EIP1559Tests.swift | 12 +---- .../web3swiftTests/remoteTests/ENSTests.swift | 48 ++++--------------- .../remoteTests/GasOracleTests.swift | 26 +++------- .../remoteTests/InfuraTests.swift | 46 ++++-------------- .../remoteTests/PolicyResolverTests.swift | 18 ++----- .../remoteTests/RemoteParsingTests.swift | 4 +- 10 files changed, 66 insertions(+), 151 deletions(-) diff --git a/Sources/web3swift/Web3/Web3+HttpProvider.swift b/Sources/web3swift/Web3/Web3+HttpProvider.swift index 29ad59831..a6411552d 100755 --- a/Sources/web3swift/Web3/Web3+HttpProvider.swift +++ b/Sources/web3swift/Web3/Web3+HttpProvider.swift @@ -18,9 +18,18 @@ public class Web3HttpProvider: Web3Provider { let urlSession = URLSession(configuration: config) return urlSession }() - public init?(_ httpProviderURL: URL, network net: Networks?, keystoreManager manager: KeystoreManager? = nil) async { - guard httpProviderURL.scheme == "http" || httpProviderURL.scheme == "https" else { return nil } - url = httpProviderURL + + @available(*, deprecated, message: "Will be removed in Web3Swift v4. Please use `init(url: URL, network: Networks?, keystoreManager: KeystoreManager?)` instead as it will throw an error instead of returning `nil` value.") + public convenience init?(_ httpProviderURL: URL, network net: Networks?, keystoreManager manager: KeystoreManager? = nil) async { + try? await self.init(url: httpProviderURL, network: net, keystoreManager: manager) + } + + public init(url: URL, network net: Networks?, keystoreManager manager: KeystoreManager? = nil) async throws { + guard url.scheme == "http" || url.scheme == "https" else { + throw Web3Error.inputError(desc: "Web3HttpProvider endpoint must have scheme http or https. Given scheme \(url.scheme ?? "none"). \(url.absoluteString)") + } + + self.url = url if let net = net { network = net } else { @@ -29,13 +38,8 @@ public class Web3HttpProvider: Web3Provider { urlRequest.setValue("application/json", forHTTPHeaderField: "Accept") urlRequest.httpMethod = APIRequest.getNetwork.call urlRequest.httpBody = APIRequest.getNetwork.encodedBody - do { - let response: APIResponse = try await APIRequest.send(uRLRequest: urlRequest, with: session) - let network = Networks.fromInt(response.result) - self.network = network - } catch { - return nil - } + let response: APIResponse = try await APIRequest.send(uRLRequest: urlRequest, with: session) + self.network = Networks.fromInt(response.result) } attachedKeystoreManager = manager } diff --git a/Sources/web3swift/Web3/Web3+InfuraProviders.swift b/Sources/web3swift/Web3/Web3+InfuraProviders.swift index 18e71d3ec..7d3d5040f 100755 --- a/Sources/web3swift/Web3/Web3+InfuraProviders.swift +++ b/Sources/web3swift/Web3/Web3+InfuraProviders.swift @@ -8,12 +8,18 @@ import Web3Core /// Custom Web3 HTTP provider of Infura nodes. public final class InfuraProvider: Web3HttpProvider { - public init?(_ net: Networks, accessToken token: String? = nil, keystoreManager manager: KeystoreManager? = nil) async { + + @available(*, deprecated, message: "Will be removed in Web3Swift v4. Please use `init(net: Networks, accessToken: String?, keystoreManager: KeystoreManager?)` instead as it will throw an error instead of returning `nil`.") + public convenience init?(_ net: Networks, accessToken token: String? = nil, keystoreManager manager: KeystoreManager? = nil) async { + try? await self.init(net: net, accessToken: token, keystoreManager: manager) + } + + public init(net: Networks, accessToken token: String? = nil, keystoreManager manager: KeystoreManager? = nil) async throws { var requestURLstring = "https://" + net.name + Constants.infuraHttpScheme requestURLstring += token ?? Constants.infuraToken guard let providerURL = URL(string: requestURLstring) else { - return nil + throw Web3Error.inputError(desc: "URL created with token \(token ?? "Default token - \(Constants.infuraToken)") is not a valid URL: \(requestURLstring)") } - await super.init(providerURL, network: net, keystoreManager: manager) + try await super.init(url: providerURL, network: net, keystoreManager: manager) } } diff --git a/Sources/web3swift/Web3/Web3.swift b/Sources/web3swift/Web3/Web3.swift index d5c543946..8b5dfc792 100755 --- a/Sources/web3swift/Web3/Web3.swift +++ b/Sources/web3swift/Web3/Web3.swift @@ -13,43 +13,40 @@ extension Web3 { /// Initialized provider-bound Web3 instance using a provider's URL. Under the hood it performs a synchronous call to get /// the Network ID for EIP155 purposes public static func new(_ providerURL: URL, network: Networks = .Mainnet) async throws -> Web3 { - // FIXME: Change this hardcoded value to dynamically fethed from a Node - guard let provider = await Web3HttpProvider(providerURL, network: network) else { - throw Web3Error.inputError(desc: "Wrong provider - should be Web3HttpProvider with endpoint scheme http or https") - } + let provider = try await Web3HttpProvider(url: providerURL, network: network) return Web3(provider: provider) } /// Initialized Web3 instance bound to Infura's mainnet provider. - public static func InfuraMainnetWeb3(accessToken: String? = nil) async -> Web3? { - guard let infura = await InfuraProvider(Networks.Mainnet, accessToken: accessToken) else { return nil } + public static func InfuraMainnetWeb3(accessToken: String? = nil) async throws -> Web3 { + let infura = try await InfuraProvider(net: Networks.Mainnet, accessToken: accessToken) return Web3(provider: infura) } /// Initialized Web3 instance bound to Infura's goerli provider. - public static func InfuraGoerliWeb3(accessToken: String? = nil) async -> Web3? { - guard let infura = await InfuraProvider(Networks.Goerli, accessToken: accessToken) else { return nil } + public static func InfuraGoerliWeb3(accessToken: String? = nil) async throws -> Web3 { + let infura = try await InfuraProvider(net: Networks.Goerli, accessToken: accessToken) return Web3(provider: infura) } /// Initialized Web3 instance bound to Infura's rinkeby provider. @available(*, deprecated, message: "This network support was deprecated by Infura") - public static func InfuraRinkebyWeb3(accessToken: String? = nil) async -> Web3? { - guard let infura = await InfuraProvider(Networks.Rinkeby, accessToken: accessToken) else { return nil } + public static func InfuraRinkebyWeb3(accessToken: String? = nil) async throws -> Web3 { + let infura = try await InfuraProvider(net: Networks.Rinkeby, accessToken: accessToken) return Web3(provider: infura) } /// Initialized Web3 instance bound to Infura's ropsten provider. @available(*, deprecated, message: "This network support was deprecated by Infura") - public static func InfuraRopstenWeb3(accessToken: String? = nil) async -> Web3? { - guard let infura = await InfuraProvider(Networks.Ropsten, accessToken: accessToken) else { return nil } + public static func InfuraRopstenWeb3(accessToken: String? = nil) async throws -> Web3 { + let infura = try await InfuraProvider(net: Networks.Ropsten, accessToken: accessToken) return Web3(provider: infura) } /// Initialized Web3 instance bound to Infura's kovan provider. @available(*, deprecated, message: "This network support was deprecated by Infura") - public static func InfuraKovanWeb3(accessToken: String? = nil) async -> Web3? { - guard let infura = await InfuraProvider(Networks.Kovan, accessToken: accessToken) else { return nil } + public static func InfuraKovanWeb3(accessToken: String? = nil) async throws -> Web3 { + let infura = try await InfuraProvider(net: Networks.Kovan, accessToken: accessToken) return Web3(provider: infura) } diff --git a/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift b/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift index ca30a8d94..ebf9193a1 100644 --- a/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift +++ b/Tests/web3swiftTests/localTests/ST20AndSecurityTokenTests.swift @@ -18,7 +18,7 @@ class ST20AndSecurityTokenTests: XCTestCase { var securityToken: SecurityToken! override func setUp() async throws { - web3 = await Web3.InfuraGoerliWeb3(accessToken: Constants.infuraToken) + web3 = try await Web3.InfuraGoerliWeb3(accessToken: Constants.infuraToken) ethMock = Web3EthMock(provider: web3.provider) web3.ethInstance = ethMock st20token = ST20.init(web3: web3, provider: web3.provider, address: .contractDeploymentAddress()) diff --git a/Tests/web3swiftTests/remoteTests/EIP1559Tests.swift b/Tests/web3swiftTests/remoteTests/EIP1559Tests.swift index e493edace..f1e0904c0 100644 --- a/Tests/web3swiftTests/remoteTests/EIP1559Tests.swift +++ b/Tests/web3swiftTests/remoteTests/EIP1559Tests.swift @@ -14,11 +14,7 @@ import Web3Core final class EIP1559Tests: XCTestCase { func testEIP1159MainnetTransaction() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) var tx = CodableTransaction( type: .eip1559, to: EthereumAddress("0xb47292B7bBedA4447564B8336E4eD1f93735e7C7")!, @@ -34,11 +30,7 @@ final class EIP1559Tests: XCTestCase { } func testEIP1159GoerliTransaction() async throws { - guard let web3 = await Web3.InfuraGoerliWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraGoerli using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraGoerliWeb3(accessToken: Constants.infuraToken) var tx = CodableTransaction( type: .eip1559, to: EthereumAddress("0xeBec795c9c8bBD61FFc14A6662944748F299cAcf")!, diff --git a/Tests/web3swiftTests/remoteTests/ENSTests.swift b/Tests/web3swiftTests/remoteTests/ENSTests.swift index 1a9872ccb..a21c5f848 100755 --- a/Tests/web3swiftTests/remoteTests/ENSTests.swift +++ b/Tests/web3swiftTests/remoteTests/ENSTests.swift @@ -23,11 +23,7 @@ class ENSTests: XCTestCase { } func testResolverAddress() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) let ens = ENS(web3: web3) let domain = "somename.eth" let address = try await ens?.registry.getResolver(forDomain: domain).resolverContractAddress @@ -36,11 +32,7 @@ class ENSTests: XCTestCase { } func testResolver() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) let ens = ENS(web3: web3) let domain = "somename.eth" let address = try await ens?.getAddress(forNode: domain) @@ -48,11 +40,7 @@ class ENSTests: XCTestCase { } func testSupportsInterface() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) let ens = ENS(web3: web3) let domain = "somename.eth" let resolver = try await ens?.registry.getResolver(forDomain: domain) @@ -67,11 +55,7 @@ class ENSTests: XCTestCase { } func testABI() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) let ens = ENS(web3: web3) let domain = "somename.eth" let resolver = try await ens?.registry.getResolver(forDomain: domain) @@ -86,11 +70,7 @@ class ENSTests: XCTestCase { } func testOwner() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) let ens = ENS(web3: web3) let domain = "somename.eth" let owner = try await ens?.registry.getOwner(node: domain) @@ -98,11 +78,7 @@ class ENSTests: XCTestCase { } func testTTL() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) let ens = try XCTUnwrap(ENS(web3: web3)) let domain = "somename.eth" let ttl = try await ens.registry.getTTL(node: domain) @@ -110,11 +86,7 @@ class ENSTests: XCTestCase { } func testGetAddress() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) let ens = ENS(web3: web3) let domain = "somename.eth" let resolver = try await ens?.registry.getResolver(forDomain: domain) @@ -123,11 +95,7 @@ class ENSTests: XCTestCase { } func testGetPubkey() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) let ens = ENS(web3: web3) let domain = "somename.eth" let resolver = try await ens?.registry.getResolver(forDomain: domain) diff --git a/Tests/web3swiftTests/remoteTests/GasOracleTests.swift b/Tests/web3swiftTests/remoteTests/GasOracleTests.swift index 9b7769b82..89b782fb6 100644 --- a/Tests/web3swiftTests/remoteTests/GasOracleTests.swift +++ b/Tests/web3swiftTests/remoteTests/GasOracleTests.swift @@ -16,11 +16,7 @@ class GasOracleTests: XCTestCase { let blockNumber: BigUInt = 14571792 func testPretictBaseFee() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) lazy var oracle: Oracle = .init(web3.provider, block: .exact(blockNumber), blockCount: 20, percentiles: [10, 40, 60, 90]) let etalonPercentiles: [BigUInt] = [ 94217344703, // 10 percentile @@ -34,11 +30,7 @@ class GasOracleTests: XCTestCase { } func testPredictTip() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) lazy var oracle: Oracle = .init(web3.provider, block: .exact(blockNumber), blockCount: 20, percentiles: [10, 40, 60, 90]) let etalonPercentiles: [BigUInt] = [ 1217066957, // 10 percentile @@ -52,11 +44,7 @@ class GasOracleTests: XCTestCase { } func testPredictBothFee() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) lazy var oracle: Oracle = .init(web3.provider, block: .exact(blockNumber), blockCount: 20, percentiles: [10, 40, 60, 90]) let etalonPercentiles: ([BigUInt], [BigUInt]) = ( baseFee: [ @@ -79,7 +67,7 @@ class GasOracleTests: XCTestCase { } // func testPredictLegacyGasPrice() async throws { -// let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) +// let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) // lazy var oracle: Web3.Oracle = .init(web3, block: .exact(blockNumber), blockCount: 20, percentiles: [10, 40, 60, 90]) // let etalonPercentiles: [BigUInt] = [ // 93253857566, // 10 percentile @@ -93,7 +81,7 @@ class GasOracleTests: XCTestCase { // } // // func testAllTransactionInBlockDecodesWell() async throws { -// let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) +// let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) // lazy var oracle: Web3.Oracle = .init(web3, block: .exact(blockNumber), blockCount: 20, percentiles: [10, 40, 60, 90]) // let blockWithTransaction = try await web3.eth.getBlockByNumber(blockNumber, fullTransactions: true) // @@ -107,13 +95,13 @@ class GasOracleTests: XCTestCase { // FIXME: Move it to external test suit. // func testBlockNumber() async throws { -// let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) +// let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) // let latestBlockNumber = try await web3.eth.getBlockNumber() // // } // // func testgetAccounts() async throws { -// let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) +// let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) // let accounts = try await web3.eth.getAccounts() // // } diff --git a/Tests/web3swiftTests/remoteTests/InfuraTests.swift b/Tests/web3swiftTests/remoteTests/InfuraTests.swift index 8de339cdd..8f5b04af2 100755 --- a/Tests/web3swiftTests/remoteTests/InfuraTests.swift +++ b/Tests/web3swiftTests/remoteTests/InfuraTests.swift @@ -12,11 +12,7 @@ import Web3Core class InfuraTests: XCTestCase { func testGetBalance() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) let address = EthereumAddress("0xd61b5ca425F8C8775882d4defefC68A6979DBbce")! let balance = try await web3.eth.getBalance(for: address) let balString = Utilities.formatToPrecision(balance, units: .ether, formattingDecimals: 3) @@ -24,50 +20,30 @@ class InfuraTests: XCTestCase { } func testGetBlockByHash() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) let result = try await web3.eth.block(by: "0x6d05ba24da6b7a1af22dc6cc2a1fe42f58b2a5ea4c406b19c8cf672ed8ec0695", fullTransactions: false) XCTAssertEqual(result.number, 5184323) } func testGetBlockByHash_hashAsData() async throws { let blockHash = Data.fromHex("6d05ba24da6b7a1af22dc6cc2a1fe42f58b2a5ea4c406b19c8cf672ed8ec0695")! - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) let result = try await web3.eth.block(by: blockHash, fullTransactions: false) XCTAssertEqual(result.number, 5184323) } func testGetBlockByNumber1() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) _ = try await web3.eth.block(by: .latest, fullTransactions: false) } func testGetBlockByNumber2() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) _ = try await web3.eth.block(by: .exact(5184323), fullTransactions: true) } - func testGetBlockByNumber3() async { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + func testGetBlockByNumber3() async throws { + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) do { _ = try await web3.eth.block(by: .exact(10000000000000), fullTransactions: true) XCTFail("The expression above must throw DecodingError.") @@ -78,17 +54,13 @@ class InfuraTests: XCTestCase { } func testGasPrice() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) _ = try await web3.eth.gasPrice() } // func testGetIndexedEventsPromise() async throws { // let jsonString = "[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"version\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"balance\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"},{\"name\":\"_extraData\",\"type\":\"bytes\"}],\"name\":\"approveAndCall\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"remaining\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"_initialAmount\",\"type\":\"uint256\"},{\"name\":\"_tokenName\",\"type\":\"string\"},{\"name\":\"_decimalUnits\",\"type\":\"uint8\"},{\"name\":\"_tokenSymbol\",\"type\":\"string\"}],\"type\":\"constructor\"},{\"payable\":false,\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_spender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},]" -// let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) +// let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) // let contract = web3.contract(jsonString, at: nil, abiVersion: 2) // var filter = EventFilterParameters() // filter.fromBlock = .exact(5200120) diff --git a/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift b/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift index 84db3b8df..8f92327f7 100644 --- a/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift +++ b/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift @@ -15,11 +15,7 @@ import Web3Core final class PolicyResolverTests: XCTestCase { func testResolveAllForEIP1159Transaction() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) let resolver = PolicyResolver(provider: web3.provider) var tx = CodableTransaction( type: .eip1559, @@ -40,11 +36,7 @@ final class PolicyResolverTests: XCTestCase { } func testResolveAllForLegacyTransaction() async throws { - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) let resolver = PolicyResolver(provider: web3.provider) var tx = CodableTransaction( type: .legacy, @@ -68,11 +60,7 @@ final class PolicyResolverTests: XCTestCase { let expectedGasLimit = BigUInt(22_000) let expectedBaseFee = BigUInt(20) let expectedPriorityFee = BigUInt(9) - guard let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) - else { - XCTFail("Failed to connect to InfuraMainnet using token \(Constants.infuraToken)") - return - } + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) let resolver = PolicyResolver(provider: web3.provider) var tx = CodableTransaction( type: .eip1559, diff --git a/Tests/web3swiftTests/remoteTests/RemoteParsingTests.swift b/Tests/web3swiftTests/remoteTests/RemoteParsingTests.swift index b4b272b20..7f3ad7c82 100755 --- a/Tests/web3swiftTests/remoteTests/RemoteParsingTests.swift +++ b/Tests/web3swiftTests/remoteTests/RemoteParsingTests.swift @@ -91,7 +91,7 @@ class RemoteParsingTests: XCTestCase { // func testEventParsing5usingABIv2() async throws { // let jsonString = "[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"version\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"balance\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"},{\"name\":\"_extraData\",\"type\":\"bytes\"}],\"name\":\"approveAndCall\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"remaining\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"_initialAmount\",\"type\":\"uint256\"},{\"name\":\"_tokenName\",\"type\":\"string\"},{\"name\":\"_decimalUnits\",\"type\":\"uint8\"},{\"name\":\"_tokenSymbol\",\"type\":\"string\"}],\"type\":\"constructor\"},{\"payable\":false,\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_spender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},]" -// let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) +// let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) // let contract = web3.contract(jsonString, at: nil, abiVersion: 2) // var filter = EventFilter() // filter.fromBlock = .exact(5200120) @@ -104,7 +104,7 @@ class RemoteParsingTests: XCTestCase { // func testEventParsing6usingABIv2() async throws { // let jsonString = "[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"version\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"balance\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"},{\"name\":\"_extraData\",\"type\":\"bytes\"}],\"name\":\"approveAndCall\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"remaining\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"_initialAmount\",\"type\":\"uint256\"},{\"name\":\"_tokenName\",\"type\":\"string\"},{\"name\":\"_decimalUnits\",\"type\":\"uint8\"},{\"name\":\"_tokenSymbol\",\"type\":\"string\"}],\"type\":\"constructor\"},{\"payable\":false,\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_spender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},]" -// let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) +// let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) // let contract = web3.contract(jsonString, at: nil, abiVersion: 2) // var filter = EventFilter() // filter.fromBlock = .exact(5200120) From 1c0f2f75973ad0854e29f18a6aa6fc02fe88ed3f Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 11 Feb 2023 18:06:58 +0200 Subject: [PATCH 105/210] fix: docs fix in Web3.Personal --- Sources/web3swift/Web3/Web3+Personal.swift | 95 ++++++++-------------- 1 file changed, 33 insertions(+), 62 deletions(-) diff --git a/Sources/web3swift/Web3/Web3+Personal.swift b/Sources/web3swift/Web3/Web3+Personal.swift index 6a7882849..e2755d770 100755 --- a/Sources/web3swift/Web3/Web3+Personal.swift +++ b/Sources/web3swift/Web3/Web3+Personal.swift @@ -9,77 +9,48 @@ import Web3Core extension Web3.Personal { - /** - *Locally or remotely sign a message (arbitrary data) with the private key. To avoid potential signing of a transaction the message is first prepended by a special header and then hashed.* - - - parameters: - - message: Message Data - - from: Use a private key that corresponds to this account - - password: Password for account if signing locally - - - returns: - - Result object - - - important: This call is synchronous - - */ + /// Locally or remotely sign a message (arbitrary data) with the private key. + /// To avoid potential signing of a transaction the message is first prepended by a special header and then hashed. + /// - Parameters: + /// - message: raw message as bytes (e.g. UTF-8 bytes of a string); + /// - from: an account whose private key will be used; + /// - password: password to extract private key; + /// - Returns: signed personal message public func signPersonalMessage(message: Data, from: EthereumAddress, password: String) async throws -> Data { - let result = try await self.signPersonal(message: message, from: from, password: password) + let result = try await signPersonal(message: message, from: from, password: password) return result } - /** - *Unlock an account on the remote node to be able to send transactions and sign messages.* - - - parameters: - - account: EthereumAddress of the account to unlock - - password: Password to use for the account - - seconds: Time interval before automatic account lock by Ethereum node - - - returns: - - Result object - - - important: This call is synchronous. Does nothing if private keys are stored locally. - - */ + /// Unlock an account on the remote node to be able to send transactions and sign messages. + /// - Parameters: + /// - account: EthereumAddress of the account to unlock + /// - password: Password for the account + /// - seconds: Time interval before automatic account lock by Ethereum node. Default 300 + /// - Returns: `true` if account was unlocked. public func unlockAccount(account: EthereumAddress, password: String, seconds: UInt = 300) async throws -> Bool { - let result = try await self.unlock(account: account, password: password) + let result = try await unlock(account: account, password: password) return result } - /** - *Recovers a signer of some message. Message is first prepended by special prefix (check the "signPersonalMessage" method description) and then hashed.* - - - parameters: - - personalMessage: Message Data - - signature: Serialized signature, 65 bytes - - - returns: - - Result object - - */ - public func ecrecover(personalMessage: Data, signature: Data) throws -> EthereumAddress { - guard let recovered = Utilities.personalECRecover(personalMessage, signature: signature) else { - throw Web3Error.dataError - } - return recovered + /// Recovers a signer of some personal message. Message will be first prepended by special prefix + /// (check the "signPersonalMessage" method description) and then hashed before the recovery attempt. + /// + /// If you have a hash instead of a message use ``Web3/Personal/ecrecover(hash:signature:)`` + /// + /// - Parameters: + /// - personalMessage: raw message as bytes (e.g. UTF-8 bytes of a string); + /// - signature: signature that is the result of signing the `personalMessage`; + /// - Returns: address of the signer or `nil`. + public func ecrecover(personalMessage: Data, signature: Data) -> EthereumAddress? { + Utilities.personalECRecover(personalMessage, signature: signature) } - /** - *Recovers a signer of some hash. Checking what is under this hash is on behalf of the user.* - - - parameters: - - hash: Signed hash - - signature: Serialized signature, 65 bytes - - - returns: - - Result object - - */ - public func ecrecover(hash: Data, signature: Data) throws -> EthereumAddress { - guard let recovered = Utilities.hashECRecover(hash: hash, signature: signature) else { - throw Web3Error.dataError - } - return recovered + /// Recovers a signer of some hash. + /// - Parameters: + /// - hash: some hash, e.g. hashed personal message; + /// - signature: 65 bytes serialized signature; + /// - Returns: address of the signer or `nil`. + public func ecrecover(hash: Data, signature: Data) -> EthereumAddress { + Utilities.hashECRecover(hash: hash, signature: signature) } } From 85f7261accc1a95755d94023957b8562f7676e1e Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 11 Feb 2023 18:09:22 +0200 Subject: [PATCH 106/210] chore: spacing + removed redundant comments --- Sources/Web3Core/KeystoreManager/BIP32HDNode.swift | 2 +- Sources/Web3Core/Utility/Utilities.swift | 10 +++------- .../HookedFunctions/Web3+BrowserFunctions.swift | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift index db7c868fb..55a366f79 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift @@ -97,7 +97,7 @@ public class HDNode { let hmacKey = "Bitcoin seed".data(using: .ascii)! let hmac: Authenticator = HMAC(key: hmacKey.bytes, variant: HMAC.Variant.sha2(.sha512)) guard let entropy = try? hmac.authenticate(seed.bytes) else { return nil } - guard entropy.count == 64 else { return nil} + guard entropy.count == 64 else { return nil } let I_L = entropy[0..<32] let I_R = entropy[32..<64] chaincode = Data(I_R) diff --git a/Sources/Web3Core/Utility/Utilities.swift b/Sources/Web3Core/Utility/Utilities.swift index 4524bcd98..a626c3ef6 100644 --- a/Sources/Web3Core/Utility/Utilities.swift +++ b/Sources/Web3Core/Utility/Utilities.swift @@ -202,11 +202,9 @@ public struct Utilities { } /// Recover the Ethereum address from recoverable secp256k1 signature. Message is first hashed using the "personal hash" protocol. - /// BE WARNED - changing a message will result in different Ethereum address, but not in error. - /// - /// Input parameters should be Data objects. + /// BE WARNED - changing a message will result in different Ethereum address, but not in an error. public static func personalECRecover(_ personalMessage: Data, signature: Data) -> EthereumAddress? { - if signature.count != 65 { return nil} + if signature.count != 65 { return nil } let rData = signature[0..<32].bytes let sData = signature[32..<64].bytes var vData = signature[64] @@ -226,10 +224,8 @@ public struct Utilities { /// Recover the Ethereum address from recoverable secp256k1 signature. /// Takes a hash of some message. What message is hashed should be checked by user separately. - /// - /// Input parameters should be Data objects. public static func hashECRecover(hash: Data, signature: Data) -> EthereumAddress? { - if signature.count != 65 { return nil} + if signature.count != 65 { return nil } let rData = signature[0..<32].bytes let sData = signature[32..<64].bytes var vData = signature[64] diff --git a/Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift b/Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift index 88e9d52d0..c903a6af4 100755 --- a/Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift +++ b/Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift @@ -52,7 +52,7 @@ extension Web3.BrowserFunctions { } public func personalECRecover(_ personalMessage: Data, signature: Data) -> String? { - if signature.count != 65 { return nil} + if signature.count != 65 { return nil } let rData = signature[0..<32].bytes let sData = signature[32..<64].bytes var vData = signature[64] From 0a40422a7796dc59c700741b8641a2cf4f2eaf3d Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 11 Feb 2023 18:19:04 +0200 Subject: [PATCH 107/210] chore: some more docs updates --- .../RequestParameter+Encodable.swift | 9 +++++---- .../RequestParameter+RawRepresentable.swift | 1 + Sources/Web3Core/KeystoreManager/BIP44.swift | 20 +++++++++---------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+Encodable.swift b/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+Encodable.swift index a683d5fdc..107c1bffb 100644 --- a/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+Encodable.swift +++ b/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+Encodable.swift @@ -15,15 +15,16 @@ extension RequestParameter: Encodable { ```swift let someArray: [RequestParameter] = [ - .init(rawValue: 12)!, - .init(rawValue: "this")!, - .init(rawValue: 12.2)!, - .init(rawValue: [12.2, 12.4])! + .init(rawValue: 12)!, + .init(rawValue: "this")!, + .init(rawValue: 12.2)!, + .init(rawValue: [12.2, 12.4])! ] let encoded = try JSONEncoder().encode(someArray) print(String(data: encoded, encoding: .utf8)!) //> [12,\"this\",12.2,[12.2,12.4]]` ``` + - Parameter encoder: encoder */ func encode(to encoder: Encoder) throws { var enumContainer = encoder.singleValueContainer() diff --git a/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+RawRepresentable.swift b/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+RawRepresentable.swift index 5cdad289f..10ee683a6 100644 --- a/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+RawRepresentable.swift +++ b/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+RawRepresentable.swift @@ -15,6 +15,7 @@ extension RequestParameter: RawRepresentable { which encodes an array of self-assosiated values. You're totally free to use explicit and more convenience member init as `RequestParameter.int(12)` in your code. + - Parameter rawValue: one of the supported types like `Int`, `UInt` etc. */ init?(rawValue: APIRequestParameterType) { /// force casting in this switch is safe because diff --git a/Sources/Web3Core/KeystoreManager/BIP44.swift b/Sources/Web3Core/KeystoreManager/BIP44.swift index 9a80a396c..bb1da0a87 100644 --- a/Sources/Web3Core/KeystoreManager/BIP44.swift +++ b/Sources/Web3Core/KeystoreManager/BIP44.swift @@ -36,11 +36,11 @@ public enum BIP44Error: LocalizedError, Equatable { public protocol TransactionChecker { /** - It verifies if the provided address has at least one transaction - - Parameter address: to be queried - - Throws: any error related to query the blockchain provider - - Returns: `true` if the address has at least one transaction, `false` otherwise - */ + It verifies if the provided address has at least one transaction + - Parameter ethereumAddress: to be queried + - Throws: any error related to query the blockchain provider + - Returns: `true` if the address has at least one transaction, `false` otherwise + */ func hasTransactions(ethereumAddress: EthereumAddress) async throws -> Bool } @@ -105,11 +105,11 @@ extension String { } /** - Transforms a bip44 path into a new one changing account & index. The resulting one will have the change value equal to `0` to represent the external chain. The format will be `m/44'/coin_type'/account'/change/address_index` - - Parameter account: the new account to use - - Parameter addressIndex: the new addressIndex to use - - Returns: a valid bip44 path with the provided account, addressIndex and external change or `nil` otherwise - */ + Transforms a bip44 path into a new one changing account & index. The resulting one will have the change value equal to `0` to represent the external chain. The format will be `m/44'/coin_type'/account'/change/address_index` + - Parameter account: the new account to use + - Parameter addressIndex: the new addressIndex to use + - Returns: a valid bip44 path with the provided account, addressIndex and external change or `nil` otherwise + */ func newPath(account: Int, addressIndex: Int) -> String? { guard isBip44Path else { return nil From 2a155d371993826ddd077436b1345c8dd8424549 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 11 Feb 2023 18:22:30 +0200 Subject: [PATCH 108/210] chore: hashECRecover and personalECRecover are identical except 1 line --- Sources/Web3Core/Utility/Utilities.swift | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Sources/Web3Core/Utility/Utilities.swift b/Sources/Web3Core/Utility/Utilities.swift index 4524bcd98..310a8e26e 100644 --- a/Sources/Web3Core/Utility/Utilities.swift +++ b/Sources/Web3Core/Utility/Utilities.swift @@ -206,22 +206,8 @@ public struct Utilities { /// /// Input parameters should be Data objects. public static func personalECRecover(_ personalMessage: Data, signature: Data) -> EthereumAddress? { - if signature.count != 65 { return nil} - let rData = signature[0..<32].bytes - let sData = signature[32..<64].bytes - var vData = signature[64] - if vData >= 27 && vData <= 30 { - vData -= 27 - } else if vData >= 31 && vData <= 34 { - vData -= 31 - } else if vData >= 35 && vData <= 38 { - vData -= 35 - } - - guard let signatureData = SECP256K1.marshalSignature(v: vData, r: rData, s: sData) else { return nil } guard let hash = Utilities.hashPersonalMessage(personalMessage) else { return nil } - guard let publicKey = SECP256K1.recoverPublicKey(hash: hash, signature: signatureData) else { return nil } - return Utilities.publicToAddress(publicKey) + return hashECRecover(hash: hash, signature: signature) } /// Recover the Ethereum address from recoverable secp256k1 signature. From 7b2e03a6b751766151fcb79dcea45e5ba1913449 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 11 Feb 2023 18:40:46 +0200 Subject: [PATCH 109/210] chore: multiline docs update --- .../RequestParameter+Encodable.swift | 35 +++++---- .../RequestParameter+RawRepresentable.swift | 16 ++-- .../RequestParameter/RequestParameter.swift | 58 ++++++++------- Sources/Web3Core/KeystoreManager/BIP44.swift | 46 ++++++------ .../Transaction/EventfilterParameters.swift | 74 +++++++++---------- Sources/web3swift/Web3/Web3+Personal.swift | 18 ++++- 6 files changed, 129 insertions(+), 118 deletions(-) diff --git a/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+Encodable.swift b/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+Encodable.swift index 107c1bffb..835048fbf 100644 --- a/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+Encodable.swift +++ b/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+Encodable.swift @@ -8,24 +8,23 @@ import Foundation extension RequestParameter: Encodable { - /** - This encoder encodes `RequestParameter` associated value ignoring self value - - This is required to encode mixed types array, like - - ```swift - let someArray: [RequestParameter] = [ - .init(rawValue: 12)!, - .init(rawValue: "this")!, - .init(rawValue: 12.2)!, - .init(rawValue: [12.2, 12.4])! - ] - let encoded = try JSONEncoder().encode(someArray) - print(String(data: encoded, encoding: .utf8)!) - //> [12,\"this\",12.2,[12.2,12.4]]` - ``` - - Parameter encoder: encoder - */ + + /// This encoder encodes `RequestParameter` associated value ignoring self value + /// + /// This is required to encode mixed types array, like + /// + /// ```swift + /// let someArray: [RequestParameter] = [ + /// .init(rawValue: 12)!, + /// .init(rawValue: "this")!, + /// .init(rawValue: 12.2)!, + /// .init(rawValue: [12.2, 12.4])! + /// ] + /// let encoded = try JSONEncoder().encode(someArray) + /// print(String(data: encoded, encoding: .utf8)!) + /// //> [12,\"this\",12.2,[12.2,12.4]]` + /// ``` + /// - Parameter encoder: The encoder to write data to. func encode(to encoder: Encoder) throws { var enumContainer = encoder.singleValueContainer() /// force casting in this switch is safe because diff --git a/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+RawRepresentable.swift b/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+RawRepresentable.swift index 10ee683a6..ef04032ba 100644 --- a/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+RawRepresentable.swift +++ b/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+RawRepresentable.swift @@ -8,15 +8,15 @@ import Foundation extension RequestParameter: RawRepresentable { - /** - This init is required by ``RawRepresentable`` protocol, which is required to encode mixed type values array in JSON. - This protocol is used to implement custom `encode` method for that enum, - which encodes an array of self-assosiated values. - - You're totally free to use explicit and more convenience member init as `RequestParameter.int(12)` in your code. - - Parameter rawValue: one of the supported types like `Int`, `UInt` etc. - */ + /// This init is required by ``RawRepresentable`` protocol, which is required + /// to encode mixed type values array in JSON. + /// + /// This protocol is used to implement custom `encode` method for that enum, + /// which encodes an array of self-assosiated values. + /// + /// You're totally free to use explicit and more convenience member init as `RequestParameter.int(12)` in your code. + /// - Parameter rawValue: one of the supported types like `Int`, `UInt` etc. init?(rawValue: APIRequestParameterType) { /// force casting in this switch is safe because /// each `rawValue` forced to casts only in exact case which is runs based on `rawValues` type diff --git a/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter.swift b/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter.swift index 65c3059fa..ff0d526a6 100644 --- a/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter.swift +++ b/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter.swift @@ -1,39 +1,41 @@ // // RequestParameter.swift -// +// // // Created by Yaroslav Yashin on 12.07.2022. // import Foundation -/** - Enum to compose request to the node params. - - In most cases request params are passed to Ethereum JSON RPC request as array of mixed type values, such as `[12,"this",true]`. - - Meanwhile swift don't provide strict way to compose such array it gives some hacks to solve this task - and one of them is using `RawRepresentable` protocol. - - This protocol allows the designated type to represent itself in `String` representation. - - So in our case we're using it to implement custom `encode` method for all possible types used as request params. - - This `encode` method is required to encode array of `RequestParameter` to not to `[RequestParameter.int(1)]`, but to `[1]`. - - Here's an example of using this enum in field. - ```swift - let jsonRPCParams: [APIRequestParameterType] = [ - .init(rawValue: 12)!, - .init(rawValue: "this")!, - .init(rawValue: 12.2)!, - .init(rawValue: [12.2, 12.4])! - ] - let encoded = try JSONEncoder().encode(jsonRPCParams) - print(String(data: encoded, encoding: .utf8)!) - //> [12,\"this\",12.2,[12.2,12.4]]` - ``` - */ +/// Enum to compose request to the node params. +/// +/// In most cases request params are passed to Ethereum JSON RPC request as array of +/// mixed type values, such as `[12,"this",true]`. +/// +/// Meanwhile swift don't provide strict way to compose such array it gives +/// some hacks to solve this task +/// and one of them is using `RawRepresentable` protocol. +/// +/// This protocol allows the designated type to represent itself in `String` representation. +/// +/// So in our case we're using it to implement custom `encode` method for all possible +/// types used as request params. +/// +/// This `encode` method is required to encode array of `RequestParameter` +/// to not to `[RequestParameter.int(1)]`, but to `[1]`. +/// +/// Here's an example of using this enum in field. +/// ```swift +/// let jsonRPCParams: [APIRequestParameterType] = [ +/// .init(rawValue: 12)!, +/// .init(rawValue: "this")!, +/// .init(rawValue: 12.2)!, +/// .init(rawValue: [12.2, 12.4])! +/// ] +/// let encoded = try JSONEncoder().encode(jsonRPCParams) +/// print(String(data: encoded, encoding: .utf8)!) +/// //> [12,\"this\",12.2,[12.2,12.4]]` +/// ``` enum RequestParameter { case int(Int) case intArray([Int]) diff --git a/Sources/Web3Core/KeystoreManager/BIP44.swift b/Sources/Web3Core/KeystoreManager/BIP44.swift index bb1da0a87..d093115fc 100644 --- a/Sources/Web3Core/KeystoreManager/BIP44.swift +++ b/Sources/Web3Core/KeystoreManager/BIP44.swift @@ -6,19 +6,18 @@ import Foundation public protocol BIP44 { - /** - Derive an ``HDNode`` based on the provided path. The function will throw ``BIP44Error.warning`` if it was invoked with `throwOnWarning` equal to - `true` and the root key doesn't have a previous child with at least one transaction. If it is invoked with `throwOnWarning` equal to `false` the child node will be - derived directly using the derive function of ``HDNode``. This function needs to query the blockchain history when `throwOnWarning` is `true`, so it can throw - network errors. - - Parameter path: valid BIP44 path. - - Parameter throwOnWarning: `true` to use - [Account Discovery](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account-discovery) standard, - otherwise it will dervive the key using the derive function of ``HDNode``. - - Throws: ``BIP44Error.warning`` if the child key shouldn't be used according to - [Account Discovery](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account-discovery) standard. - - Returns: an ``HDNode`` child key for the provided `path` if it can be created, otherwise `nil` - */ + /// Derive an ``HDNode`` based on the provided path. The function will throw ``BIP44Error.warning`` + /// if it was invoked with `throwOnWarning` equal to `true` and the root key doesn't have a previous child + /// with at least one transaction. If it is invoked with `throwOnWarning` equal to `false` the child node will + /// be derived directly using the derive function of ``HDNode``. This function needs to query the blockchain + /// history when `throwOnWarning` is `true`, so it can throw network errors. + /// - Parameter path: valid BIP44 path. + /// - Parameter throwOnWarning: `true` to use + /// [Account Discovery](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account-discovery) standard, + /// otherwise it will dervive the key using the derive function of ``HDNode``. + /// - Throws: ``BIP44Error.warning`` if the child key shouldn't be used according to + /// [Account Discovery](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account-discovery) standard. + /// - Returns: an ``HDNode`` child key for the provided `path` if it can be created, otherwise `nil` func derive(path: String, throwOnWarning: Bool, transactionChecker: TransactionChecker) async throws -> HDNode? } @@ -35,12 +34,10 @@ public enum BIP44Error: LocalizedError, Equatable { } public protocol TransactionChecker { - /** - It verifies if the provided address has at least one transaction - - Parameter ethereumAddress: to be queried - - Throws: any error related to query the blockchain provider - - Returns: `true` if the address has at least one transaction, `false` otherwise - */ + /// It verifies if the provided address has at least one transaction + /// - Parameter ethereumAddress: to be queried + /// - Throws: any error related to query the blockchain provider + /// - Returns: `true` if the address has at least one transaction, `false` otherwise func hasTransactions(ethereumAddress: EthereumAddress) async throws -> Bool } @@ -104,12 +101,11 @@ extension String { return account } - /** - Transforms a bip44 path into a new one changing account & index. The resulting one will have the change value equal to `0` to represent the external chain. The format will be `m/44'/coin_type'/account'/change/address_index` - - Parameter account: the new account to use - - Parameter addressIndex: the new addressIndex to use - - Returns: a valid bip44 path with the provided account, addressIndex and external change or `nil` otherwise - */ + /// Transforms a bip44 path into a new one changing account & index. The resulting one will have the change value equal to `0` to + /// represent the external chain. The format will be `m/44'/coin_type'/account'/change/address_index` + /// - Parameter account: the new account to use + /// - Parameter addressIndex: the new addressIndex to use + /// - Returns: a valid bip44 path with the provided account, addressIndex and external change or `nil` otherwise func newPath(account: Int, addressIndex: Int) -> String? { guard isBip44Path else { return nil diff --git a/Sources/Web3Core/Transaction/EventfilterParameters.swift b/Sources/Web3Core/Transaction/EventfilterParameters.swift index 7459f2dda..9850feb72 100755 --- a/Sources/Web3Core/Transaction/EventfilterParameters.swift +++ b/Sources/Web3Core/Transaction/EventfilterParameters.swift @@ -56,44 +56,42 @@ extension EventFilterParameters { } extension EventFilterParameters { - /** - This enum covers the optional nested Arrays - - ``EventFilterParameters`` include ``topic`` property with is array of optional values, - and where `nil` value is a thing, and should be kept in server request. - - This is not a trivial case for swift lang or any other stricktly typed lang. - - So to make this possible ``Topic`` enum is provided. - - It handle two cases: ``.string(String?)`` and ``.strings([Topic?]?)``, - where former should be used to assign first demention value, - and the latter to assign second dimension value into ``EventFilterParameters.topics`` property. - - So to encode as a parameter follow JSON array: - ```JSON - [ - "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", - null, - [ - "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc" - ] - ] - ``` - - you have to pass to the ``topics`` property follow swift array: - ```swift - let topics: [Topic?] = [ - .string("0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"), - .string(nil), - .strings([ - .string("0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"), - .string("0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc"), - ]) - ] - ``` - */ + /// This enum covers the optional nested Arrays + /// + /// ``EventFilterParameters`` include ``topic`` property with is array of optional values, + /// and where `nil` value is a thing, and should be kept in server request. + /// + /// This is not a trivial case for swift lang or any other stricktly typed lang. + /// + /// So to make this possible ``Topic`` enum is provided. + /// + /// It handle two cases: ``.string(String?)`` and ``.strings([Topic?]?)``, + /// where former should be used to assign first demention value, + /// and the latter to assign second dimension value into ``EventFilterParameters.topics`` property. + /// + /// So to encode as a parameter follow JSON array: + /// ```JSON + /// [ + /// "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", + /// null, + /// [ + /// "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", + /// "0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc" + /// ] + /// ] + /// ``` + /// + /// you have to pass to the ``topics`` property follow swift array: + /// ```swift + /// let topics: [Topic?] = [ + /// .string("0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"), + /// .string(nil), + /// .strings([ + /// .string("0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"), + /// .string("0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc"), + /// ]) + /// ] + /// ``` public enum Topic: Encodable { case string(String?) case strings([Topic?]?) diff --git a/Sources/web3swift/Web3/Web3+Personal.swift b/Sources/web3swift/Web3/Web3+Personal.swift index e2755d770..7729ec4af 100755 --- a/Sources/web3swift/Web3/Web3+Personal.swift +++ b/Sources/web3swift/Web3/Web3+Personal.swift @@ -45,12 +45,28 @@ extension Web3.Personal { Utilities.personalECRecover(personalMessage, signature: signature) } + @available(*, deprecated, message: "Will be removed in Web3Swift v4. Please, use `func ecrecover(personalMessage: Data, signature: Data) -> EthereumAddress?` instead.") + public func ecrecover(personalMessage: Data, signature: Data) throws -> EthereumAddress { + if let address = ecrecover(personalMessage: personalMessage, signature: signature) { + return address + } + throw Web3Error.dataError + } + /// Recovers a signer of some hash. /// - Parameters: /// - hash: some hash, e.g. hashed personal message; /// - signature: 65 bytes serialized signature; /// - Returns: address of the signer or `nil`. - public func ecrecover(hash: Data, signature: Data) -> EthereumAddress { + public func ecrecover(hash: Data, signature: Data) -> EthereumAddress? { Utilities.hashECRecover(hash: hash, signature: signature) } + + @available(*, deprecated, message: "Will be removed in Web3Swift v4. Please, use `func ecrecover(hash: Data, signature: Data) -> EthereumAddress?` instead.") + public func ecrecover(hash: Data, signature: Data) throws -> EthereumAddress { + if let address = ecrecover(hash: hash, signature: signature) { + return address + } + throw Web3Error.dataError + } } From 82a90896f2b91a0a6f85cd8314f3781e25b502e3 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 12 Feb 2023 22:19:48 +0200 Subject: [PATCH 110/210] fix: renamed new functions from ecrecover to recoverAddress --- Sources/web3swift/Web3/Web3+Personal.swift | 18 +++++++++--------- .../localTests/PersonalSignatureTests.swift | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Sources/web3swift/Web3/Web3+Personal.swift b/Sources/web3swift/Web3/Web3+Personal.swift index 7729ec4af..42e21f6f6 100755 --- a/Sources/web3swift/Web3/Web3+Personal.swift +++ b/Sources/web3swift/Web3/Web3+Personal.swift @@ -35,19 +35,19 @@ extension Web3.Personal { /// Recovers a signer of some personal message. Message will be first prepended by special prefix /// (check the "signPersonalMessage" method description) and then hashed before the recovery attempt. /// - /// If you have a hash instead of a message use ``Web3/Personal/ecrecover(hash:signature:)`` + /// If you have a hash instead of a message use ``Web3/Personal/recoverAddress(hash:signature:)`` /// /// - Parameters: - /// - personalMessage: raw message as bytes (e.g. UTF-8 bytes of a string); + /// - message: raw personal message as bytes (e.g. UTF-8 bytes of a string); /// - signature: signature that is the result of signing the `personalMessage`; /// - Returns: address of the signer or `nil`. - public func ecrecover(personalMessage: Data, signature: Data) -> EthereumAddress? { - Utilities.personalECRecover(personalMessage, signature: signature) + public func recoverAddress(message: Data, signature: Data) -> EthereumAddress? { + Utilities.personalECRecover(message, signature: signature) } - @available(*, deprecated, message: "Will be removed in Web3Swift v4. Please, use `func ecrecover(personalMessage: Data, signature: Data) -> EthereumAddress?` instead.") + @available(*, deprecated, message: "Will be removed in Web3Swift v4. Please, use `func recoverAddress(message: Data, signature: Data) -> EthereumAddress?` instead.") public func ecrecover(personalMessage: Data, signature: Data) throws -> EthereumAddress { - if let address = ecrecover(personalMessage: personalMessage, signature: signature) { + if let address = recoverAddress(message: personalMessage, signature: signature) { return address } throw Web3Error.dataError @@ -58,13 +58,13 @@ extension Web3.Personal { /// - hash: some hash, e.g. hashed personal message; /// - signature: 65 bytes serialized signature; /// - Returns: address of the signer or `nil`. - public func ecrecover(hash: Data, signature: Data) -> EthereumAddress? { + public func recoverAddress(hash: Data, signature: Data) -> EthereumAddress? { Utilities.hashECRecover(hash: hash, signature: signature) } - @available(*, deprecated, message: "Will be removed in Web3Swift v4. Please, use `func ecrecover(hash: Data, signature: Data) -> EthereumAddress?` instead.") + @available(*, deprecated, message: "Will be removed in Web3Swift v4. Please, use `func recoverAddress(hash: Data, signature: Data) -> EthereumAddress?` instead.") public func ecrecover(hash: Data, signature: Data) throws -> EthereumAddress { - if let address = ecrecover(hash: hash, signature: signature) { + if let address = recoverAddress(hash: hash, signature: signature) { return address } throw Web3Error.dataError diff --git a/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift b/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift index d9027b6e4..e8cd5e1ff 100755 --- a/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift +++ b/Tests/web3swiftTests/localTests/PersonalSignatureTests.swift @@ -22,7 +22,7 @@ class PersonalSignatureTests: XCTestCase { let signature = try await web3.personal.signPersonalMessage(message: message.data(using: .utf8)!, from: expectedAddress, password: "") let unmarshalledSignature = SECP256K1.unmarshalSignature(signatureData: signature)! - let signer = try web3.personal.ecrecover(personalMessage: message.data(using: .utf8)!, signature: signature) + let signer = web3.personal.recoverAddress(message: message.data(using: .utf8)!, signature: signature) XCTAssert(expectedAddress == signer, "Failed to sign personal message") } From 141ab590a7c4f9655e25f5a66d44299d11b987e4 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Mon, 13 Feb 2023 13:43:33 +0200 Subject: [PATCH 111/210] fix: swiftlint issues in Utilities.swift --- Sources/Web3Core/Utility/Utilities.swift | 121 +++++++++++------- .../NumberFormattingUtilTests.swift | 18 +-- 2 files changed, 83 insertions(+), 56 deletions(-) diff --git a/Sources/Web3Core/Utility/Utilities.swift b/Sources/Web3Core/Utility/Utilities.swift index 4524bcd98..955e36d15 100644 --- a/Sources/Web3Core/Utility/Utilities.swift +++ b/Sources/Web3Core/Utility/Utilities.swift @@ -18,8 +18,10 @@ public struct Utilities { static func publicToAddressData(_ publicKey: Data) -> Data? { var publicKey = publicKey if publicKey.count == 33 { - guard (publicKey[0] == 2 || publicKey[0] == 3), - let decompressedKey = SECP256K1.combineSerializedPublicKeys(keys: [publicKey], outputCompressed: false) else { + guard + (publicKey[0] == 2 || publicKey[0] == 3), + let decompressedKey = SECP256K1.combineSerializedPublicKeys(keys: [publicKey], outputCompressed: false) + else { return nil } publicKey = decompressedKey @@ -98,7 +100,7 @@ public struct Utilities { return parseToBigUInt(amount, decimals: unitDecimals) } - /// Parse a user-supplied string using the number of decimals. + /// Parse a string using the number of decimals. /// If input is non-numeric or precision is not sufficient - returns nil. /// Allowed decimal separators are ".", ",". public static func parseToBigUInt(_ amount: String, decimals: Int = 18) -> BigUInt? { @@ -107,22 +109,28 @@ public struct Utilities { guard components.count == 1 || components.count == 2 else { return nil } let unitDecimals = decimals guard let beforeDecPoint = BigUInt(components[0], radix: 10) else { return nil } - var mainPart = beforeDecPoint*BigUInt(10).power(unitDecimals) + var mainPart = beforeDecPoint * BigUInt(10).power(unitDecimals) if components.count == 2 { let numDigits = components[1].count guard numDigits <= unitDecimals else { return nil } guard let afterDecPoint = BigUInt(components[1], radix: 10) else { return nil } - let extraPart = afterDecPoint*BigUInt(10).power(unitDecimals-numDigits) - mainPart = mainPart + extraPart + let extraPart = afterDecPoint * BigUInt(10).power(unitDecimals-numDigits) + mainPart += extraPart } return mainPart } - /// Formats a BigInt object to String. The supplied number is first divided into integer and decimal part based on "units", - /// then limit the decimal part to "decimals" symbols and uses a "decimalSeparator" as a separator. + /// Formats a `BigInt` object to `String`. The supplied number is first divided into integer and decimal part based on `units` value, + /// then limits the decimal part to `formattingDecimals` symbols and uses a `decimalSeparator` as a separator. /// Fallbacks to scientific format if higher precision is required. /// - /// Returns nil of formatting is not possible to satisfy. + /// - Parameters: + /// - bigNumber: number to format; + /// - units: unit to format number to; + /// - formattingDecimals: the number of decimals that should be in the final formatted number; + /// - decimalSeparator: decimals separator; + /// - fallbackToScientific: if should fallback to scienctific representation like `1.23e-10`. + /// - Returns: formatted number or `nil` if formatting was not possible. public static func formatToPrecision(_ bigNumber: BigInt, units: Utilities.Units = .ether, formattingDecimals: Int = 4, decimalSeparator: String = ".", fallbackToScientific: Bool = false) -> String { let magnitude = bigNumber.magnitude let formatted = formatToPrecision(magnitude, units: units, formattingDecimals: formattingDecimals, decimalSeparator: decimalSeparator, fallbackToScientific: fallbackToScientific) @@ -134,13 +142,19 @@ public struct Utilities { } } - /// Formats a BigUInt object to String. The supplied number is first divided into integer and decimal part based on "units", - /// then limits the decimal part to "formattingDecimals" symbols and uses a "decimalSeparator" as a separator. + /// Formats a `BigUInt` object to `String`. The supplied number is first divided into integer and decimal part based on `units` value, + /// then limits the decimal part to `formattingDecimals` symbols and uses a `decimalSeparator` as a separator. /// Fallbacks to scientific format if higher precision is required. /// - /// Returns nil of formatting is not possible to satisfy. + /// - Parameters: + /// - bigNumber: number to format; + /// - units: unit to format number to; + /// - formattingDecimals: the number of decimals that should be in the final formatted number; + /// - decimalSeparator: decimals separator; + /// - fallbackToScientific: if should fallback to scienctific representation like `1.23e-10`. + /// - Returns: formatted number or `nil` if formatting was not possible. public static func formatToPrecision(_ bigNumber: BigUInt, units: Utilities.Units = .ether, formattingDecimals: Int = 4, decimalSeparator: String = ".", fallbackToScientific: Bool = false) -> String { - if bigNumber == 0 { + guard bigNumber != 0 else { return "0" } let unitDecimals = units.decimals @@ -150,47 +164,60 @@ public struct Utilities { } let divisor = BigUInt(10).power(unitDecimals) let (quotient, remainder) = bigNumber.quotientAndRemainder(dividingBy: divisor) - var fullRemainder = "\(remainder)" - let fullPaddedRemainder = fullRemainder.leftPadding(toLength: unitDecimals, withPad: "0") + + guard toDecimals != 0 else { + return "\(quotient)" + } + + let remainderStr = "\(remainder)" + let fullPaddedRemainder = remainderStr.leftPadding(toLength: unitDecimals, withPad: "0") let remainderPadded = fullPaddedRemainder[0.. formattingDecimals { - let end = firstDigit+1+formattingDecimals > fullPaddedRemainder.count ? fullPaddedRemainder.count: firstDigit+1+formattingDecimals - remainingDigits = String(fullPaddedRemainder[firstDigit+1 ..< end]) - } else { - remainingDigits = String(fullPaddedRemainder[firstDigit+1 ..< fullPaddedRemainder.count]) - } - if remainingDigits != "" { - fullRemainder = firstDecimalUnit + decimalSeparator + remainingDigits - } else { - fullRemainder = firstDecimalUnit - } - firstDigit = firstDigit + 1 - break - } - } - return fullRemainder + "e-" + String(firstDigit) - } + + guard remainderPadded == String(repeating: "0", count: toDecimals) else { + return "\(quotient)" + decimalSeparator + remainderPadded + } + + if fallbackToScientific { + return formatToScientificRepresentation(remainderStr, remainder: fullPaddedRemainder, decimals: formattingDecimals, decimalSeparator: decimalSeparator) } - if toDecimals == 0 { + + guard quotient == 0 else { return "\(quotient)" } + return "\(quotient)" + decimalSeparator + remainderPadded } + private static func formatToScientificRepresentation(_ remainder: String, remainder fullPaddedRemainder: String, decimals: Int, decimalSeparator: String) -> String { + var remainder = remainder + var firstDigit = 0 + for char in fullPaddedRemainder { + if char == "0" { + firstDigit += 1 + } else { + let firstDecimalUnit = String(fullPaddedRemainder[firstDigit ..< firstDigit + 1]) + var remainingDigits = "" + let numOfRemainingDecimals = fullPaddedRemainder.count - firstDigit - 1 + if numOfRemainingDecimals <= 0 { + remainingDigits = "" + } else if numOfRemainingDecimals > decimals { + let end = firstDigit + 1 + decimals > fullPaddedRemainder.count ? fullPaddedRemainder.count : firstDigit + 1 + decimals + remainingDigits = String(fullPaddedRemainder[firstDigit + 1 ..< end]) + } else { + remainingDigits = String(fullPaddedRemainder[firstDigit + 1 ..< fullPaddedRemainder.count]) + } + if !remainingDigits.isEmpty { + remainder = firstDecimalUnit + decimalSeparator + remainingDigits + } else { + remainder = firstDecimalUnit + } + firstDigit += 1 + break + } + } + return remainder + "e-" + String(firstDigit) + } + /// Recover the Ethereum address from recoverable secp256k1 signature. Message is first hashed using the "personal hash" protocol. /// BE WARNED - changing a message will result in different Ethereum address, but not in error. /// diff --git a/Tests/web3swiftTests/localTests/NumberFormattingUtilTests.swift b/Tests/web3swiftTests/localTests/NumberFormattingUtilTests.swift index 676eb533c..9929130a9 100755 --- a/Tests/web3swiftTests/localTests/NumberFormattingUtilTests.swift +++ b/Tests/web3swiftTests/localTests/NumberFormattingUtilTests.swift @@ -15,55 +15,55 @@ class NumberFormattingUtilTests: LocalTestCase { func testNumberFormattingUtil() throws { let balance = BigInt("-1000000000000000000") let formatted = Utilities.formatToPrecision(balance, units: .ether, formattingDecimals: 4, decimalSeparator: ",") - XCTAssert(formatted == "-1") + XCTAssertEqual(formatted, "-1") } func testNumberFormattingUtil2() throws { let balance = BigInt("-1000000000000000") let formatted = Utilities.formatToPrecision(balance, units: .ether, formattingDecimals: 4, decimalSeparator: ",") - XCTAssert(formatted == "-0,0010") + XCTAssertEqual(formatted, "-0,0010") } func testNumberFormattingUtil3() throws { let balance = BigInt("-1000000000000") let formatted = Utilities.formatToPrecision(balance, units: .ether, formattingDecimals: 4, decimalSeparator: ",") - XCTAssert(formatted == "-0,0000") + XCTAssertEqual(formatted, "-0,0000") } func testNumberFormattingUtil4() throws { let balance = BigInt("-1000000000000") let formatted = Utilities.formatToPrecision(balance, units: .ether, formattingDecimals: 9, decimalSeparator: ",") - XCTAssert(formatted == "-0,000001000") + XCTAssertEqual(formatted, "-0,000001000") } func testNumberFormattingUtil5() throws { let balance = BigInt("-1") let formatted = Utilities.formatToPrecision(balance, units: .ether, formattingDecimals: 9, decimalSeparator: ",", fallbackToScientific: true) - XCTAssert(formatted == "-1e-18") + XCTAssertEqual(formatted, "-1e-18") } func testNumberFormattingUtil6() throws { let balance = BigInt("0") let formatted = Utilities.formatToPrecision(balance, units: .ether, formattingDecimals: 9, decimalSeparator: ",") - XCTAssert(formatted == "0") + XCTAssertEqual(formatted, "0") } func testNumberFormattingUtil7() throws { let balance = BigInt("-1100000000000000000") let formatted = Utilities.formatToPrecision(balance, units: .ether, formattingDecimals: 4, decimalSeparator: ",") - XCTAssert(formatted == "-1,1000") + XCTAssertEqual(formatted, "-1,1000") } func testNumberFormattingUtil8() throws { let balance = BigInt("100") let formatted = Utilities.formatToPrecision(balance, units: .ether, formattingDecimals: 4, decimalSeparator: ",", fallbackToScientific: true) - XCTAssert(formatted == "1,00e-16") + XCTAssertEqual(formatted, "1,00e-16") } func testNumberFormattingUtil9() throws { let balance = BigInt("1000000") let formatted = Utilities.formatToPrecision(balance, units: .ether, formattingDecimals: 4, decimalSeparator: ",", fallbackToScientific: true) - XCTAssert(formatted == "1,0000e-12") + XCTAssertEqual(formatted, "1,0000e-12") } func testFormatPreccissionFallbacksToUnitsDecimals() throws { From 0c314e2898ee33728465d46c8aefadbd1fe9c7a9 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 15 Feb 2023 10:22:46 +0100 Subject: [PATCH 112/210] pre-commit: SwiftLint: Disable failing tests --- .codespellrc | 4 + .github/workflows/macOS-tests.yml | 6 +- .github/workflows/pre-commit.yml | 22 + .pre-commit-config.yaml | 15 +- .swiftlint.yml | 36 +- CONTRIBUTION.md | 4 +- README.md | 8 +- .../APIRequest+ComputedProperties.swift | 2 +- .../Request/APIRequest+Methods.swift | 2 +- .../Request/APIRequest+UtilityTypes.swift | 2 +- .../Utility/Async+BackwardCapability.swift | 2 +- .../Utility/HexDecodable+Extensions.swift | 2 +- .../Utility/IntegerInitableWithRadix.swift | 2 +- .../Structure/Block/BlockNumber.swift | 2 +- .../Structure/Web3ProviderProtocol.swift | 2 +- .../Envelope/AbstractEnvelope.swift | 2 +- Sources/Web3Core/Transaction/Policies.swift | 2 +- .../Transaction/TransactionMetadata.swift | 4 +- Sources/Web3Core/Web3Error/Web3Error.swift | 2 +- Sources/secp256k1/ecmult_impl.h | 2 +- Sources/secp256k1/include/secp256k1.h | 16 +- Sources/web3swift/Browser/browser.js | 19198 ++++++++-------- .../web3swift/Operations/WriteOperation.swift | 4 +- .../Tokens/ERC20/ERC20BaseProperties.swift | 2 +- .../ERC20/ERC20BasePropertiesProvider.swift | 4 +- Sources/web3swift/Web3/Web3+Resolver.swift | 2 +- TestToken/Helpers/TokenBasics/ERC20.sol | 2 +- TestToken/Helpers/TokenBasics/IERC20.sol | 2 +- TestToken/Token/Web3SwiftToken.sol | 1 - .../localTests/EthereumAddressTest.swift | 2 +- .../localTests/PromisesTests.swift | 14 +- .../remoteTests/EIP1559Tests.swift | 2 +- .../remoteTests/GasOracleTests.swift | 6 +- .../remoteTests/InfuraTests.swift | 6 +- .../remoteTests/PolicyResolverTests.swift | 2 +- .../remoteTests/RemoteParsingTests.swift | 20 +- 36 files changed, 9731 insertions(+), 9675 deletions(-) create mode 100644 .codespellrc create mode 100644 .github/workflows/pre-commit.yml diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 000000000..96f480b57 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,4 @@ +[codespell] +count = True +ignore-words-list = ans,deriver,inout,packag +skip = *.js,*WordLists.swift,.git,Carthage,.build,build diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index 9c842cd4f..7ea285b9d 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -29,7 +29,7 @@ jobs: spm: name: Swift Package Manager 5.7 runs-on: macOS-12 - concurrency: + concurrency: group: spm-${{ github.run_id }} cancel-in-progress: false steps: @@ -39,6 +39,10 @@ jobs: pip3 install --upgrade pip pip3 install codespell codespell --count --ignore-words-list=ans,deriver,inout,packag --skip="*.js,*WordLists.swift" + - name: SwiftLint + run: | + swiftlint --fix + # swiftlint analyze - name: Resolve dependencies run: swift package resolve - name: Build diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000..65fec63f9 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,22 @@ +# https://pre-commit.com +# This GitHub Action assumes that the repo contains a valid .pre-commit-config.yaml file. +# Using pre-commit.ci is even better that using GitHub Actions for pre-commit. +name: pre-commit +on: + pull_request: + branches: [develop] + push: + branches: [develop] + workflow_dispatch: +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: 3.x + - run: pip install pre-commit + - run: pre-commit --version + - run: pre-commit install + - run: pre-commit run --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d923d7bc9..0b19196c4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,12 +14,9 @@ repos: - repo: https://github.com/codespell-project/codespell rev: v2.2.2 hooks: - - id: codespell - args: ["--count --ignore-words-list=ans,deriver,inout,packag --skip=\"*.js,*WordLists.swift,.git,Carthage,.build,build\""] -# SwiftLint is commented out until we fix all SwiftLint warnings and errors. -# https://github.com/web3swift-team/web3swift/pull/756 -#- repo: https://github.com/realm/SwiftLint -# rev: 0.50.3 -# hooks: -# - id: swiftlint -# args: [--fix, Sources, Tests] + - id: codespell # See .codespellrc for args +# - repo: https://github.com/realm/SwiftLint # Too slow in pre-commit +# rev: 0.50.3 +# hooks: +# - id: swiftlint +# args: [--fix, Sources, Tests] diff --git a/.swiftlint.yml b/.swiftlint.yml index 4bd79d7b4..a794f4992 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -5,14 +5,45 @@ excluded: - DerivedData - Pods +analyzer_rules: + - unused_import + disabled_rules: + - block_based_kvo + - closure_body_length + - computed_accessors_order + - cyclomatic_complexity + - duplicate_imports + - empty_enum_arguments + - empty_string + - file_length + - for_where + - force_cast + - force_try + - force_unwrapping + - function_body_length - function_parameter_count - identifier_name + - implicit_getter + - implicitly_unwrapped_optional + - indentation_width + - large_tuple + - legacy_objc_type - line_length - multiple_closures_with_trailing_closure - nesting + - orphaned_doc_comment + - operator_whitespace + - return_arrow_whitespace + - shorthand_operator - todo + - trailing_closure + - type_body_length - type_name + - unneeded_break_in_switch + - unused_optional_binding + - vertical_parameter_alignment + - xctfail_message opt_in_rules: - closure_body_length @@ -27,15 +58,14 @@ opt_in_rules: - static_operator - trailing_closure - unneeded_parentheses_in_closure_argument - - unused_import - weak_delegate # force warnings force_cast: error -force_try: error +force_try: error custom_rules: - commented_out_code: + commented_out_code: included: .*\.swift # regex that defines paths to include during linting. optional. excluded: .*Test(s)?\.swift # regex that defines paths to exclude during linting. optional name: Commented out code # rule name. optional. diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md index 5edbe93d5..be8daa9de 100644 --- a/CONTRIBUTION.md +++ b/CONTRIBUTION.md @@ -17,7 +17,7 @@ Please take it from the [roadmap](https://hackmd.io/G5znP3xAQY-BVc1X8Y1jSg) or f ## Codestyle guideline - `swiftlint` check should goes with no warnings. -- Here’s some more detailed and human readable code style [guidelines](https://hackmd.io/8bACoAnTSsKc55Os596yCg "") (you can add there some suggestion if you’d like to). +- Here’s some more detailed and human readable code style [guidelines](https://hackmd.io/8bACoAnTSsKc55Os596yCg "") (you can add there some suggestion if you’d like to). - We use [swift](https://www.swift.org/documentation/api-design-guidelines/ "") name convention. ## Tests guideline 1. Cover each new public method with tests. @@ -67,4 +67,4 @@ on: - [ ] All public method have `///` styled comments. - [ ] All magic or nonintuitive internal code parts are clearly explained in inline comments. - [ ] `swiftlint` ran have no warnings. -- [ ] No commented out code lefts in PR. \ No newline at end of file +- [ ] No commented out code lefts in PR. diff --git a/README.md b/README.md index 89e69220e..e7bb7523d 100755 --- a/README.md +++ b/README.md @@ -44,13 +44,13 @@ ## Core features -- [x] :zap: Swift implementation of [web3.js](https://github.com/ethereum/web3.js/) functionality -- [x] :thought_balloon: Interaction with remote node via **JSON RPC** +- [x] :zap: Swift implementation of [web3.js](https://github.com/ethereum/web3.js/) functionality +- [x] :thought_balloon: Interaction with remote node via **JSON RPC** - [x] 🔐 Local **keystore management** (`geth` compatible) -- [x] 🤖 Smart-contract **ABI parsing** +- [x] 🤖 Smart-contract **ABI parsing** - [x] 🔓**ABI decoding** (V2 is supported with return of structures from public functions. Part of 0.4.22 Solidity compiler) - [x] 🕸Ethereum Name Service **(ENS) support** - a secure & decentralised way to address resources both on and off the blockchain using simple, human-readable names -- [x] :arrows_counterclockwise: **Smart contracts interactions** (read/write) +- [x] :arrows_counterclockwise: **Smart contracts interactions** (read/write) - [x] ⛩ **Infura support** - [x] ⚒ **Parsing TxPool** content into native values (ethereum addresses and transactions) - easy to get pending transactions - [x] 🖇 **Event loops** functionality diff --git a/Sources/Web3Core/EthereumNetwork/Request/APIRequest+ComputedProperties.swift b/Sources/Web3Core/EthereumNetwork/Request/APIRequest+ComputedProperties.swift index 1b53a2b8e..cfa7f5190 100644 --- a/Sources/Web3Core/EthereumNetwork/Request/APIRequest+ComputedProperties.swift +++ b/Sources/Web3Core/EthereumNetwork/Request/APIRequest+ComputedProperties.swift @@ -1,6 +1,6 @@ // // APIRequest+ComputedProperties.swift -// +// // // Created by Yaroslav Yashin on 12.07.2022. // diff --git a/Sources/Web3Core/EthereumNetwork/Request/APIRequest+Methods.swift b/Sources/Web3Core/EthereumNetwork/Request/APIRequest+Methods.swift index 463cd60d5..58e13aa0f 100644 --- a/Sources/Web3Core/EthereumNetwork/Request/APIRequest+Methods.swift +++ b/Sources/Web3Core/EthereumNetwork/Request/APIRequest+Methods.swift @@ -1,6 +1,6 @@ // // APIRequest+Methods.swift -// +// // // Created by Yaroslav Yashin on 12.07.2022. // diff --git a/Sources/Web3Core/EthereumNetwork/Request/APIRequest+UtilityTypes.swift b/Sources/Web3Core/EthereumNetwork/Request/APIRequest+UtilityTypes.swift index 6c54fb887..ca55d622f 100644 --- a/Sources/Web3Core/EthereumNetwork/Request/APIRequest+UtilityTypes.swift +++ b/Sources/Web3Core/EthereumNetwork/Request/APIRequest+UtilityTypes.swift @@ -1,6 +1,6 @@ // // APIRequest+UtilityTypes.swift -// +// // // Created by Yaroslav Yashin on 12.07.2022. // diff --git a/Sources/Web3Core/EthereumNetwork/Utility/Async+BackwardCapability.swift b/Sources/Web3Core/EthereumNetwork/Utility/Async+BackwardCapability.swift index 46658db72..e6b67ae83 100644 --- a/Sources/Web3Core/EthereumNetwork/Utility/Async+BackwardCapability.swift +++ b/Sources/Web3Core/EthereumNetwork/Utility/Async+BackwardCapability.swift @@ -1,6 +1,6 @@ // // Async+BackwardCapability.swift -// +// // // Created by Yaroslav Yashin on 05.06.2022. // diff --git a/Sources/Web3Core/EthereumNetwork/Utility/HexDecodable+Extensions.swift b/Sources/Web3Core/EthereumNetwork/Utility/HexDecodable+Extensions.swift index 27db82dee..d64bb9a09 100644 --- a/Sources/Web3Core/EthereumNetwork/Utility/HexDecodable+Extensions.swift +++ b/Sources/Web3Core/EthereumNetwork/Utility/HexDecodable+Extensions.swift @@ -1,6 +1,6 @@ // // HexDecodable+Extensions.swift -// +// // // Created by Yaroslav Yashin on 12.07.2022. // diff --git a/Sources/Web3Core/EthereumNetwork/Utility/IntegerInitableWithRadix.swift b/Sources/Web3Core/EthereumNetwork/Utility/IntegerInitableWithRadix.swift index c02e14650..299cdc276 100644 --- a/Sources/Web3Core/EthereumNetwork/Utility/IntegerInitableWithRadix.swift +++ b/Sources/Web3Core/EthereumNetwork/Utility/IntegerInitableWithRadix.swift @@ -1,6 +1,6 @@ // // IntegerInitableWithRadix.swift -// +// // // Created by Yaroslav Yashin on 12.07.2022. // diff --git a/Sources/Web3Core/Structure/Block/BlockNumber.swift b/Sources/Web3Core/Structure/Block/BlockNumber.swift index 983dd37bc..524f371e3 100644 --- a/Sources/Web3Core/Structure/Block/BlockNumber.swift +++ b/Sources/Web3Core/Structure/Block/BlockNumber.swift @@ -1,6 +1,6 @@ // // BlockNumber.swift -// +// // // Created by Yaroslav Yashin on 11.07.2022. // diff --git a/Sources/Web3Core/Structure/Web3ProviderProtocol.swift b/Sources/Web3Core/Structure/Web3ProviderProtocol.swift index 6af95e217..9dda5ebf5 100644 --- a/Sources/Web3Core/Structure/Web3ProviderProtocol.swift +++ b/Sources/Web3Core/Structure/Web3ProviderProtocol.swift @@ -1,6 +1,6 @@ // // Web3ProviderProtocol.swift -// +// // // Created by Yaroslav Yashin on 11.07.2022. // diff --git a/Sources/Web3Core/Transaction/Envelope/AbstractEnvelope.swift b/Sources/Web3Core/Transaction/Envelope/AbstractEnvelope.swift index 7986cddb1..0f75c75b7 100644 --- a/Sources/Web3Core/Transaction/Envelope/AbstractEnvelope.swift +++ b/Sources/Web3Core/Transaction/Envelope/AbstractEnvelope.swift @@ -16,7 +16,7 @@ import BigInt Adding a new transaction type in the future should be as straight forward as adding to the TransactionType enum here then creating a new struct that implements to `EIP2718Envelope`, and implementing the required elements for the type - Finally adding the type specific inits to the factory routines in `EnvelopeFactory` so that objectts of the new type + Finally adding the type specific inits to the factory routines in `EnvelopeFactory` so that objectts of the new type will get generated when `CodableTransaction` is being created with data for the new type */ diff --git a/Sources/Web3Core/Transaction/Policies.swift b/Sources/Web3Core/Transaction/Policies.swift index c2923405d..da9c55d50 100644 --- a/Sources/Web3Core/Transaction/Policies.swift +++ b/Sources/Web3Core/Transaction/Policies.swift @@ -1,6 +1,6 @@ // // Policies.swift -// +// // // Created by Jann Driessen on 01.11.22. // diff --git a/Sources/Web3Core/Transaction/TransactionMetadata.swift b/Sources/Web3Core/Transaction/TransactionMetadata.swift index f70334290..df95a84d7 100644 --- a/Sources/Web3Core/Transaction/TransactionMetadata.swift +++ b/Sources/Web3Core/Transaction/TransactionMetadata.swift @@ -9,7 +9,7 @@ import BigInt /// This structure holds additional data /// returned by nodes when reading a transaction -/// from the blockchain. The data here is not +/// from the blockchain. The data here is not /// part of the transaction itself public struct TransactionMetadata { @@ -29,7 +29,7 @@ public struct TransactionMetadata { /// gasPrice value returned by the node /// note this is a duplicate value for legacy and EIP-2930 transaction types - /// but is included here since EIP-1559 does not contain a `gasPrice`, but + /// but is included here since EIP-1559 does not contain a `gasPrice`, but /// nodes still report the value. public var gasPrice: BigUInt? } diff --git a/Sources/Web3Core/Web3Error/Web3Error.swift b/Sources/Web3Core/Web3Error/Web3Error.swift index 6a24b2456..a9e77a188 100644 --- a/Sources/Web3Core/Web3Error/Web3Error.swift +++ b/Sources/Web3Core/Web3Error/Web3Error.swift @@ -1,6 +1,6 @@ // // Web3Error.swift -// +// // // Created by Yaroslav Yashin on 11.07.2022. // diff --git a/Sources/secp256k1/ecmult_impl.h b/Sources/secp256k1/ecmult_impl.h index 61a5ffd23..fd847c8e6 100755 --- a/Sources/secp256k1/ecmult_impl.h +++ b/Sources/secp256k1/ecmult_impl.h @@ -306,7 +306,7 @@ static int secp256k1_ecmult_wnaf(int *wnaf, int len, const secp256k1_scalar *a, CHECK(carry == 0); while (bit < 256) { CHECK(secp256k1_scalar_get_bits(&s, bit++, 1) == 0); - } + } #endif return last_set_bit + 1; } diff --git a/Sources/secp256k1/include/secp256k1.h b/Sources/secp256k1/include/secp256k1.h index c1fc13fac..22a27e06f 100755 --- a/Sources/secp256k1/include/secp256k1.h +++ b/Sources/secp256k1/include/secp256k1.h @@ -646,7 +646,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine( const secp256k1_pubkey * const * ins, size_t n ) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); - + /** Opaque data structured that holds a parsed ECDSA signature, * supporting pubkey recovery. * @@ -664,7 +664,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine( typedef struct { unsigned char data[65]; } secp256k1_ecdsa_recoverable_signature; - + /** Parse a compact ECDSA signature (64 bytes + recovery id). * * Returns: 1 when the signature could be parsed, 0 otherwise @@ -679,7 +679,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine( const unsigned char *input64, int recid ) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); - + /** Convert a recoverable signature into a normal signature. * * Returns: 1 @@ -691,7 +691,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine( secp256k1_ecdsa_signature* sig, const secp256k1_ecdsa_recoverable_signature* sigin ) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); - + /** Serialize an ECDSA signature in compact format (64 bytes + recovery id). * * Returns: 1 @@ -706,7 +706,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine( int *recid, const secp256k1_ecdsa_recoverable_signature* sig ) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); - + /** Create a recoverable ECDSA signature. * * Returns: 1: signature created @@ -726,7 +726,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine( secp256k1_nonce_function noncefp, const void *ndata ) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); - + /** Recover an ECDSA public key from a signature. * * Returns: 1: public key successfully recovered (which guarantees a correct signature). @@ -758,8 +758,8 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine( const secp256k1_pubkey *pubkey, const unsigned char *privkey ) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); - - + + #ifdef __cplusplus } #endif diff --git a/Sources/web3swift/Browser/browser.js b/Sources/web3swift/Browser/browser.js index 8cffd18b1..d85214d3d 100644 --- a/Sources/web3swift/Browser/browser.js +++ b/Sources/web3swift/Browser/browser.js @@ -113,18 +113,18 @@ } }); }()); - + //# sourceURL=/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy/index.js },{"./wk.bridge":424,"web3":407,"web3-provider-engine/zero.js":397}],2:[function(require,module,exports){ module.exports = require('./register')().Promise - + },{"./register":4}],3:[function(require,module,exports){ "use strict" // global key for user preferred registration var REGISTRATION_KEY = '@@any-promise/REGISTRATION', // Prior registration (preferred or detected) registered = null - + /** * Registers the given implementation. An implementation must * be registered prior to any call to `require("any-promise")`, @@ -161,12 +161,12 @@ opts = opts || {} // global registration unless explicitly {global: false} in options (default true) var registerGlobal = opts.global !== false; - + // load any previous global registration if(registered === null && registerGlobal){ registered = root[REGISTRATION_KEY] || null } - + if(registered !== null && implementation !== null && registered.implementation !== implementation){ @@ -175,7 +175,7 @@ '". You can only register an implementation before the first '+ ' call to require("any-promise") and an implementation cannot be changed') } - + if(registered === null){ // use provided implementation if(implementation !== null && typeof opts.Promise !== 'undefined'){ @@ -187,21 +187,21 @@ // require implementation if implementation is specified but not provided registered = loadImplementation(implementation) } - + if(registerGlobal){ // register preference globally in case multiple installations root[REGISTRATION_KEY] = registered } } - + return registered } } - + },{}],4:[function(require,module,exports){ "use strict"; module.exports = require('./loader')(window, loadImplementation) - + /** * Browser specific loadImplementation. Always uses `window.Promise` * @@ -217,36 +217,36 @@ implementation: 'window.Promise' } } - + },{"./loader":3}],5:[function(require,module,exports){ var asn1 = exports; - + asn1.bignum = require('bn.js'); - + asn1.define = require('./asn1/api').define; asn1.base = require('./asn1/base'); asn1.constants = require('./asn1/constants'); asn1.decoders = require('./asn1/decoders'); asn1.encoders = require('./asn1/encoders'); - + },{"./asn1/api":6,"./asn1/base":8,"./asn1/constants":12,"./asn1/decoders":14,"./asn1/encoders":17,"bn.js":53}],6:[function(require,module,exports){ var asn1 = require('../asn1'); var inherits = require('inherits'); - + var api = exports; - + api.define = function define(name, body) { return new Entity(name, body); }; - + function Entity(name, body) { this.name = name; this.body = body; - + this.decoders = {}; this.encoders = {}; }; - + Entity.prototype._createNamed = function createNamed(base) { var named; try { @@ -264,10 +264,10 @@ named.prototype._initNamed = function initnamed(entity) { base.call(this, entity); }; - + return new named(this); }; - + Entity.prototype._getDecoder = function _getDecoder(enc) { enc = enc || 'der'; // Lazily create decoder @@ -275,11 +275,11 @@ this.decoders[enc] = this._createNamed(asn1.decoders[enc]); return this.decoders[enc]; }; - + Entity.prototype.decode = function decode(data, enc, options) { return this._getDecoder(enc).decode(data, options); }; - + Entity.prototype._getEncoder = function _getEncoder(enc) { enc = enc || 'der'; // Lazily create encoder @@ -287,76 +287,76 @@ this.encoders[enc] = this._createNamed(asn1.encoders[enc]); return this.encoders[enc]; }; - + Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) { return this._getEncoder(enc).encode(data, reporter); }; - + },{"../asn1":5,"inherits":180,"vm":334}],7:[function(require,module,exports){ var inherits = require('inherits'); var Reporter = require('../base').Reporter; var Buffer = require('buffer').Buffer; - + function DecoderBuffer(base, options) { Reporter.call(this, options); if (!Buffer.isBuffer(base)) { this.error('Input not Buffer'); return; } - + this.base = base; this.offset = 0; this.length = base.length; } inherits(DecoderBuffer, Reporter); exports.DecoderBuffer = DecoderBuffer; - + DecoderBuffer.prototype.save = function save() { return { offset: this.offset, reporter: Reporter.prototype.save.call(this) }; }; - + DecoderBuffer.prototype.restore = function restore(save) { // Return skipped data var res = new DecoderBuffer(this.base); res.offset = save.offset; res.length = this.offset; - + this.offset = save.offset; Reporter.prototype.restore.call(this, save.reporter); - + return res; }; - + DecoderBuffer.prototype.isEmpty = function isEmpty() { return this.offset === this.length; }; - + DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) { if (this.offset + 1 <= this.length) return this.base.readUInt8(this.offset++, true); else return this.error(fail || 'DecoderBuffer overrun'); } - + DecoderBuffer.prototype.skip = function skip(bytes, fail) { if (!(this.offset + bytes <= this.length)) return this.error(fail || 'DecoderBuffer overrun'); - + var res = new DecoderBuffer(this.base); - + // Share reporter state res._reporterState = this._reporterState; - + res.offset = this.offset; res.length = this.offset + bytes; this.offset += bytes; return res; } - + DecoderBuffer.prototype.raw = function raw(save) { return this.base.slice(save ? save.offset : this.offset, this.length); } - + function EncoderBuffer(value, reporter) { if (Array.isArray(value)) { this.length = 0; @@ -382,16 +382,16 @@ } } exports.EncoderBuffer = EncoderBuffer; - + EncoderBuffer.prototype.join = function join(out, offset) { if (!out) out = new Buffer(this.length); if (!offset) offset = 0; - + if (this.length === 0) return out; - + if (Array.isArray(this.value)) { this.value.forEach(function(item) { item.join(out, offset); @@ -406,24 +406,24 @@ this.value.copy(out, offset); offset += this.length; } - + return out; }; - + },{"../base":8,"buffer":84,"inherits":180}],8:[function(require,module,exports){ var base = exports; - + base.Reporter = require('./reporter').Reporter; base.DecoderBuffer = require('./buffer').DecoderBuffer; base.EncoderBuffer = require('./buffer').EncoderBuffer; base.Node = require('./node'); - + },{"./buffer":7,"./node":9,"./reporter":10}],9:[function(require,module,exports){ var Reporter = require('../base').Reporter; var EncoderBuffer = require('../base').EncoderBuffer; var DecoderBuffer = require('../base').DecoderBuffer; var assert = require('minimalistic-assert'); - + // Supported tags var tags = [ 'seq', 'seqof', 'set', 'setof', 'objid', 'bool', @@ -431,32 +431,32 @@ 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str', 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr' ]; - + // Public methods list var methods = [ 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice', 'any', 'contains' ].concat(tags); - + // Overrided methods list var overrided = [ '_peekTag', '_decodeTag', '_use', '_decodeStr', '_decodeObjid', '_decodeTime', '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList', - + '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime', '_encodeNull', '_encodeInt', '_encodeBool' ]; - + function Node(enc, parent) { var state = {}; this._baseState = state; - + state.enc = enc; - + state.parent = parent || null; state.children = null; - + // State state.tag = null; state.args = null; @@ -472,7 +472,7 @@ state.explicit = null; state.implicit = null; state.contains = null; - + // Should create new instance on each method if (!state.parent) { state.children = []; @@ -480,13 +480,13 @@ } } module.exports = Node; - + var stateProps = [ 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice', 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit', 'implicit', 'contains' ]; - + Node.prototype.clone = function clone() { var state = this._baseState; var cstate = {}; @@ -497,7 +497,7 @@ res._baseState = cstate; return res; }; - + Node.prototype._wrap = function wrap() { var state = this._baseState; methods.forEach(function(method) { @@ -508,23 +508,23 @@ }; }, this); }; - + Node.prototype._init = function init(body) { var state = this._baseState; - + assert(state.parent === null); body.call(this); - + // Filter children state.children = state.children.filter(function(child) { return child._baseState.parent === this; }, this); assert.equal(state.children.length, 1, 'Root node can have only one child'); }; - + Node.prototype._useArgs = function useArgs(args) { var state = this._baseState; - + // Filter children and args var children = args.filter(function(arg) { return arg instanceof this.constructor; @@ -532,11 +532,11 @@ args = args.filter(function(arg) { return !(arg instanceof this.constructor); }, this); - + if (children.length !== 0) { assert(state.children === null); state.children = children; - + // Replace parent to maintain backward link children.forEach(function(child) { child._baseState.parent = this; @@ -548,7 +548,7 @@ state.reverseArgs = args.map(function(arg) { if (typeof arg !== 'object' || arg.constructor !== Object) return arg; - + var res = {}; Object.keys(arg).forEach(function(key) { if (key == (key | 0)) @@ -560,150 +560,150 @@ }); } }; - + // // Overrided methods // - + overrided.forEach(function(method) { Node.prototype[method] = function _overrided() { var state = this._baseState; throw new Error(method + ' not implemented for encoding: ' + state.enc); }; }); - + // // Public methods // - + tags.forEach(function(tag) { Node.prototype[tag] = function _tagMethod() { var state = this._baseState; var args = Array.prototype.slice.call(arguments); - + assert(state.tag === null); state.tag = tag; - + this._useArgs(args); - + return this; }; }); - + Node.prototype.use = function use(item) { assert(item); var state = this._baseState; - + assert(state.use === null); state.use = item; - + return this; }; - + Node.prototype.optional = function optional() { var state = this._baseState; - + state.optional = true; - + return this; }; - + Node.prototype.def = function def(val) { var state = this._baseState; - + assert(state['default'] === null); state['default'] = val; state.optional = true; - + return this; }; - + Node.prototype.explicit = function explicit(num) { var state = this._baseState; - + assert(state.explicit === null && state.implicit === null); state.explicit = num; - + return this; }; - + Node.prototype.implicit = function implicit(num) { var state = this._baseState; - + assert(state.explicit === null && state.implicit === null); state.implicit = num; - + return this; }; - + Node.prototype.obj = function obj() { var state = this._baseState; var args = Array.prototype.slice.call(arguments); - + state.obj = true; - + if (args.length !== 0) this._useArgs(args); - + return this; }; - + Node.prototype.key = function key(newKey) { var state = this._baseState; - + assert(state.key === null); state.key = newKey; - + return this; }; - + Node.prototype.any = function any() { var state = this._baseState; - + state.any = true; - + return this; }; - + Node.prototype.choice = function choice(obj) { var state = this._baseState; - + assert(state.choice === null); state.choice = obj; this._useArgs(Object.keys(obj).map(function(key) { return obj[key]; })); - + return this; }; - + Node.prototype.contains = function contains(item) { var state = this._baseState; - + assert(state.use === null); state.contains = item; - + return this; }; - + // // Decoding // - + Node.prototype._decode = function decode(input, options) { var state = this._baseState; - + // Decode root node if (state.parent === null) return input.wrapResult(state.children[0]._decode(input, options)); - + var result = state['default']; var present = true; - + var prevKey = null; if (state.key !== null) prevKey = input.enterKey(state.key); - + // Check if tag is there if (state.optional) { var tag = null; @@ -713,7 +713,7 @@ tag = state.implicit; else if (state.tag !== null) tag = state.tag; - + if (tag === null && !state.any) { // Trial and Error var save = input.save(); @@ -729,17 +729,17 @@ input.restore(save); } else { present = this._peekTag(input, tag, state.any); - + if (input.isError(present)) return present; } } - + // Push object on stack var prevObj; if (state.obj && present) prevObj = input.enterObject(); - + if (present) { // Unwrap explicit values if (state.explicit !== null) { @@ -748,9 +748,9 @@ return explicit; input = explicit; } - + var start = input.offset; - + // Unwrap implicit and normal values if (state.use === null && state.choice === null) { if (state.any) @@ -762,19 +762,19 @@ ); if (input.isError(body)) return body; - + if (state.any) result = input.raw(save); else input = body; } - + if (options && options.track && state.tag !== null) options.track(input.path(), start, input.length, 'tagged'); - + if (options && options.track && state.tag !== null) options.track(input.path(), input.offset, input.length, 'content'); - + // Select proper method for tag if (state.any) result = result; @@ -782,10 +782,10 @@ result = this._decodeGeneric(state.tag, input, options); else result = this._decodeChoice(input, options); - + if (input.isError(result)) return result; - + // Decode children if (!state.any && state.choice === null && state.children !== null) { state.children.forEach(function decodeChildren(child) { @@ -794,7 +794,7 @@ child._decode(input, options); }); } - + // Decode contained/encoded by schema, only in bit or octet strings if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) { var data = new DecoderBuffer(result); @@ -802,23 +802,23 @@ ._decode(data, options); } } - + // Pop object if (state.obj && present) result = input.leaveObject(prevObj); - + // Set key if (state.key !== null && (result !== null || present === true)) input.leaveKey(prevKey, state.key, result); else if (prevKey !== null) input.exitKey(prevKey); - + return result; }; - + Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) { var state = this._baseState; - + if (tag === 'seq' || tag === 'set') return null; if (tag === 'seqof' || tag === 'setof') @@ -839,7 +839,7 @@ return this._decodeStr(input, tag, options); else if (tag === 'int' || tag === 'enum') return this._decodeInt(input, state.args && state.args[0], options); - + if (state.use !== null) { return this._getUse(state.use, input._reporterState.obj) ._decode(input, options); @@ -847,9 +847,9 @@ return input.error('unknown tag: ' + tag); } }; - + Node.prototype._getUse = function _getUse(entity, obj) { - + var state = this._baseState; // Create altered use decoder if implicit is set state.useDecoder = this._use(entity, obj); @@ -861,12 +861,12 @@ } return state.useDecoder; }; - + Node.prototype._decodeChoice = function decodeChoice(input, options) { var state = this._baseState; var result = null; var match = false; - + Object.keys(state.choice).some(function(key) { var save = input.save(); var node = state.choice[key]; @@ -874,7 +874,7 @@ var value = node._decode(input, options); if (input.isError(value)) return false; - + result = { type: key, value: value }; match = true; } catch (e) { @@ -883,48 +883,48 @@ } return true; }, this); - + if (!match) return input.error('Choice not matched'); - + return result; }; - + // // Encoding // - + Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) { return new EncoderBuffer(data, this.reporter); }; - + Node.prototype._encode = function encode(data, reporter, parent) { var state = this._baseState; if (state['default'] !== null && state['default'] === data) return; - + var result = this._encodeValue(data, reporter, parent); if (result === undefined) return; - + if (this._skipDefault(result, reporter, parent)) return; - + return result; }; - + Node.prototype._encodeValue = function encode(data, reporter, parent) { var state = this._baseState; - + // Decode root node if (state.parent === null) return state.children[0]._encode(data, reporter || new Reporter()); - + var result = null; - + // Set reporter to share it with a child class this.reporter = reporter; - + // Check if data is there if (state.optional && data === undefined) { if (state['default'] !== null) @@ -932,7 +932,7 @@ else return; } - + // Encode children first var content = null; var primitive = false; @@ -948,17 +948,17 @@ content = state.children.map(function(child) { if (child._baseState.tag === 'null_') return child._encode(null, reporter, data); - + if (child._baseState.key === null) return reporter.error('Child should have a key'); var prevKey = reporter.enterKey(child._baseState.key); - + if (typeof data !== 'object') return reporter.error('Child expected, but input is not object'); - + var res = child._encode(data[child._baseState.key], reporter, data); reporter.leaveKey(prevKey); - + return res; }, this).filter(function(child) { return child; @@ -969,15 +969,15 @@ // TODO(indutny): this should be thrown on DSL level if (!(state.args && state.args.length === 1)) return reporter.error('Too many args for : ' + state.tag); - + if (!Array.isArray(data)) return reporter.error('seqof/setof, but data is not Array'); - + var child = this.clone(); child._baseState.implicit = null; content = this._createEncoderBuffer(data.map(function(item) { var state = this._baseState; - + return this._getUse(state.args[0], data)._encode(item, reporter); }, child)); } else if (state.use !== null) { @@ -987,13 +987,13 @@ primitive = true; } } - + // Encode data itself var result; if (!state.any && state.choice === null) { var tag = state.implicit !== null ? state.implicit : state.tag; var cls = state.implicit === null ? 'universal' : 'context'; - + if (tag === null) { if (state.use === null) reporter.error('Tag could be omitted only for .use()'); @@ -1002,17 +1002,17 @@ result = this._encodeComposite(tag, primitive, cls, content); } } - + // Wrap in explicit if (state.explicit !== null) result = this._encodeComposite(state.explicit, false, 'context', result); - + return result; }; - + Node.prototype._encodeChoice = function encodeChoice(data, reporter) { var state = this._baseState; - + var node = state.choice[data.type]; if (!node) { assert( @@ -1022,10 +1022,10 @@ } return node._encode(data.value, reporter); }; - + Node.prototype._encodePrimitive = function encodePrimitive(tag, data) { var state = this._baseState; - + if (/str$/.test(tag)) return this._encodeStr(data, tag); else if (tag === 'objid' && state.args) @@ -1045,18 +1045,18 @@ else throw new Error('Unsupported tag: ' + tag); }; - + Node.prototype._isNumstr = function isNumstr(str) { return /^[0-9 ]*$/.test(str); }; - + Node.prototype._isPrintstr = function isPrintstr(str) { return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str); }; - + },{"../base":8,"minimalistic-assert":234}],10:[function(require,module,exports){ var inherits = require('inherits'); - + function Reporter(options) { this._reporterState = { obj: null, @@ -1066,66 +1066,66 @@ }; } exports.Reporter = Reporter; - + Reporter.prototype.isError = function isError(obj) { return obj instanceof ReporterError; }; - + Reporter.prototype.save = function save() { var state = this._reporterState; - + return { obj: state.obj, pathLen: state.path.length }; }; - + Reporter.prototype.restore = function restore(data) { var state = this._reporterState; - + state.obj = data.obj; state.path = state.path.slice(0, data.pathLen); }; - + Reporter.prototype.enterKey = function enterKey(key) { return this._reporterState.path.push(key); }; - + Reporter.prototype.exitKey = function exitKey(index) { var state = this._reporterState; - + state.path = state.path.slice(0, index - 1); }; - + Reporter.prototype.leaveKey = function leaveKey(index, key, value) { var state = this._reporterState; - + this.exitKey(index); if (state.obj !== null) state.obj[key] = value; }; - + Reporter.prototype.path = function path() { return this._reporterState.path.join('/'); }; - + Reporter.prototype.enterObject = function enterObject() { var state = this._reporterState; - + var prev = state.obj; state.obj = {}; return prev; }; - + Reporter.prototype.leaveObject = function leaveObject(prev) { var state = this._reporterState; - + var now = state.obj; state.obj = prev; return now; }; - + Reporter.prototype.error = function error(msg) { var err; var state = this._reporterState; - + var inherited = msg instanceof ReporterError; if (inherited) { err = msg; @@ -1134,38 +1134,38 @@ return '[' + JSON.stringify(elem) + ']'; }).join(''), msg.message || msg, msg.stack); } - + if (!state.options.partial) throw err; - + if (!inherited) state.errors.push(err); - + return err; }; - + Reporter.prototype.wrapResult = function wrapResult(result) { var state = this._reporterState; if (!state.options.partial) return result; - + return { result: this.isError(result) ? null : result, errors: state.errors }; }; - + function ReporterError(path, msg) { this.path = path; this.rethrow(msg); }; inherits(ReporterError, Error); - + ReporterError.prototype.rethrow = function rethrow(msg) { this.message = msg + ' at: ' + (this.path || '(shallow)'); if (Error.captureStackTrace) Error.captureStackTrace(this, ReporterError); - + if (!this.stack) { try { // IE only adds stack when thrown @@ -1176,10 +1176,10 @@ } return this; }; - + },{"inherits":180}],11:[function(require,module,exports){ var constants = require('../constants'); - + exports.tagClass = { 0: 'universal', 1: 'application', @@ -1187,7 +1187,7 @@ 3: 'private' }; exports.tagClassByName = constants._reverse(exports.tagClass); - + exports.tag = { 0x00: 'end', 0x01: 'bool', @@ -1220,102 +1220,102 @@ 0x1e: 'bmpstr' }; exports.tagByName = constants._reverse(exports.tag); - + },{"../constants":12}],12:[function(require,module,exports){ var constants = exports; - + // Helper constants._reverse = function reverse(map) { var res = {}; - + Object.keys(map).forEach(function(key) { // Convert key to integer if it is stringified if ((key | 0) == key) key = key | 0; - + var value = map[key]; res[value] = key; }); - + return res; }; - + constants.der = require('./der'); - + },{"./der":11}],13:[function(require,module,exports){ var inherits = require('inherits'); - + var asn1 = require('../../asn1'); var base = asn1.base; var bignum = asn1.bignum; - + // Import DER constants var der = asn1.constants.der; - + function DERDecoder(entity) { this.enc = 'der'; this.name = entity.name; this.entity = entity; - + // Construct base tree this.tree = new DERNode(); this.tree._init(entity.body); }; module.exports = DERDecoder; - + DERDecoder.prototype.decode = function decode(data, options) { if (!(data instanceof base.DecoderBuffer)) data = new base.DecoderBuffer(data, options); - + return this.tree._decode(data, options); }; - + // Tree methods - + function DERNode(parent) { base.Node.call(this, 'der', parent); } inherits(DERNode, base.Node); - + DERNode.prototype._peekTag = function peekTag(buffer, tag, any) { if (buffer.isEmpty()) return false; - + var state = buffer.save(); var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"'); if (buffer.isError(decodedTag)) return decodedTag; - + buffer.restore(state); - + return decodedTag.tag === tag || decodedTag.tagStr === tag || (decodedTag.tagStr + 'of') === tag || any; }; - + DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) { var decodedTag = derDecodeTag(buffer, 'Failed to decode tag of "' + tag + '"'); if (buffer.isError(decodedTag)) return decodedTag; - + var len = derDecodeLen(buffer, decodedTag.primitive, 'Failed to get length of "' + tag + '"'); - + // Failure if (buffer.isError(len)) return len; - + if (!any && decodedTag.tag !== tag && decodedTag.tagStr !== tag && decodedTag.tagStr + 'of' !== tag) { return buffer.error('Failed to match tag: "' + tag + '"'); } - + if (decodedTag.primitive || len !== null) return buffer.skip(len, 'Failed to match body of: "' + tag + '"'); - + // Indefinite length... find END tag var state = buffer.save(); var res = this._skipUntilEnd( @@ -1323,12 +1323,12 @@ 'Failed to skip indefinite length body: "' + this.tag + '"'); if (buffer.isError(res)) return res; - + len = buffer.offset - state.offset; buffer.restore(state); return buffer.skip(len, 'Failed to match body of: "' + tag + '"'); }; - + DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) { while (true) { var tag = derDecodeTag(buffer, fail); @@ -1337,22 +1337,22 @@ var len = derDecodeLen(buffer, tag.primitive, fail); if (buffer.isError(len)) return len; - + var res; if (tag.primitive || len !== null) res = buffer.skip(len) else res = this._skipUntilEnd(buffer, fail); - + // Failure if (buffer.isError(res)) return res; - + if (tag.tagStr === 'end') break; } }; - + DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder, options) { var result = []; @@ -1360,7 +1360,7 @@ var possibleEnd = this._peekTag(buffer, 'end'); if (buffer.isError(possibleEnd)) return possibleEnd; - + var res = decoder.decode(buffer, 'der', options); if (buffer.isError(res) && possibleEnd) break; @@ -1368,7 +1368,7 @@ } return result; }; - + DERNode.prototype._decodeStr = function decodeStr(buffer, tag) { if (tag === 'bitstr') { var unused = buffer.readUInt8(); @@ -1379,7 +1379,7 @@ var raw = buffer.raw(); if (raw.length % 2 === 1) return buffer.error('Decoding of string type: bmpstr length mismatch'); - + var str = ''; for (var i = 0; i < raw.length / 2; i++) { str += String.fromCharCode(raw.readUInt16BE(i * 2)); @@ -1409,7 +1409,7 @@ return buffer.error('Decoding of string type: ' + tag + ' unsupported'); } }; - + DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) { var result; var identifiers = []; @@ -1425,15 +1425,15 @@ } if (subident & 0x80) identifiers.push(ident); - + var first = (identifiers[0] / 40) | 0; var second = identifiers[0] % 40; - + if (relative) result = identifiers; else result = [first, second].concat(identifiers.slice(1)); - + if (values) { var tmp = values[result.join(' ')]; if (tmp === undefined) @@ -1441,10 +1441,10 @@ if (tmp !== undefined) result = tmp; } - + return result; }; - + DERNode.prototype._decodeTime = function decodeTime(buffer, tag) { var str = buffer.raw().toString(); if (tag === 'gentime') { @@ -1468,14 +1468,14 @@ } else { return buffer.error('Decoding ' + tag + ' time is not supported yet'); } - + return Date.UTC(year, mon - 1, day, hour, min, sec, 0); }; - + DERNode.prototype._decodeNull = function decodeNull(buffer) { return null; }; - + DERNode.prototype._decodeBool = function decodeBool(buffer) { var res = buffer.readUInt8(); if (buffer.isError(res)) @@ -1483,34 +1483,34 @@ else return res !== 0; }; - + DERNode.prototype._decodeInt = function decodeInt(buffer, values) { // Bigint, return as it is (assume big endian) var raw = buffer.raw(); var res = new bignum(raw); - + if (values) res = values[res.toString(10)] || res; - + return res; }; - + DERNode.prototype._use = function use(entity, obj) { if (typeof entity === 'function') entity = entity(obj); return entity._getDecoder('der').tree; }; - + // Utility methods - + function derDecodeTag(buf, fail) { var tag = buf.readUInt8(fail); if (buf.isError(tag)) return tag; - + var cls = der.tagClass[tag >> 6]; var primitive = (tag & 0x20) === 0; - + // Multi-octet tag - load if ((tag & 0x1f) === 0x1f) { var oct = tag; @@ -1519,7 +1519,7 @@ oct = buf.readUInt8(fail); if (buf.isError(oct)) return oct; - + tag <<= 7; tag |= oct & 0x7f; } @@ -1527,7 +1527,7 @@ tag &= 0x1f; } var tagStr = der.tag[tag]; - + return { cls: cls, primitive: primitive, @@ -1535,27 +1535,27 @@ tagStr: tagStr }; } - + function derDecodeLen(buf, primitive, fail) { var len = buf.readUInt8(fail); if (buf.isError(len)) return len; - + // Indefinite form if (!primitive && len === 0x80) return null; - + // Definite form if ((len & 0x80) === 0) { // Short form return len; } - + // Long form var num = len & 0x7f; if (num > 4) return buf.error('length octect is too long'); - + len = 0; for (var i = 0; i < num; i++) { len <<= 8; @@ -1564,34 +1564,34 @@ return j; len |= j; } - + return len; } - + },{"../../asn1":5,"inherits":180}],14:[function(require,module,exports){ var decoders = exports; - + decoders.der = require('./der'); decoders.pem = require('./pem'); - + },{"./der":13,"./pem":15}],15:[function(require,module,exports){ var inherits = require('inherits'); var Buffer = require('buffer').Buffer; - + var DERDecoder = require('./der'); - + function PEMDecoder(entity) { DERDecoder.call(this, entity); this.enc = 'pem'; }; inherits(PEMDecoder, DERDecoder); module.exports = PEMDecoder; - + PEMDecoder.prototype.decode = function decode(data, options) { var lines = data.toString().split(/[\r\n]+/g); - + var label = options.label.toUpperCase(); - + var re = /^-----(BEGIN|END) ([^-]+)-----$/; var start = -1; var end = -1; @@ -1599,10 +1599,10 @@ var match = lines[i].match(re); if (match === null) continue; - + if (match[2] !== label) continue; - + if (start === -1) { if (match[1] !== 'BEGIN') break; @@ -1616,53 +1616,53 @@ } if (start === -1 || end === -1) throw new Error('PEM section not found for: ' + label); - + var base64 = lines.slice(start + 1, end).join(''); // Remove excessive symbols base64.replace(/[^a-z0-9\+\/=]+/gi, ''); - + var input = new Buffer(base64, 'base64'); return DERDecoder.prototype.decode.call(this, input, options); }; - + },{"./der":13,"buffer":84,"inherits":180}],16:[function(require,module,exports){ var inherits = require('inherits'); var Buffer = require('buffer').Buffer; - + var asn1 = require('../../asn1'); var base = asn1.base; - + // Import DER constants var der = asn1.constants.der; - + function DEREncoder(entity) { this.enc = 'der'; this.name = entity.name; this.entity = entity; - + // Construct base tree this.tree = new DERNode(); this.tree._init(entity.body); }; module.exports = DEREncoder; - + DEREncoder.prototype.encode = function encode(data, reporter) { return this.tree._encode(data, reporter).join(); }; - + // Tree methods - + function DERNode(parent) { base.Node.call(this, 'der', parent); } inherits(DERNode, base.Node); - + DERNode.prototype._encodeComposite = function encodeComposite(tag, primitive, cls, content) { var encodedTag = encodeTag(tag, primitive, cls, this.reporter); - + // Short form if (content.length < 0x80) { var header = new Buffer(2); @@ -1670,23 +1670,23 @@ header[1] = content.length; return this._createEncoderBuffer([ header, content ]); } - + // Long form // Count octets required to store length var lenOctets = 1; for (var i = content.length; i >= 0x100; i >>= 8) lenOctets++; - + var header = new Buffer(1 + 1 + lenOctets); header[0] = encodedTag; header[1] = 0x80 | lenOctets; - + for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8) header[i] = j & 0xff; - + return this._createEncoderBuffer([ header, content ]); }; - + DERNode.prototype._encodeStr = function encodeStr(str, tag) { if (tag === 'bitstr') { return this._createEncoderBuffer([ str.unused | 0, str.data ]); @@ -1721,7 +1721,7 @@ ' unsupported'); } }; - + DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) { if (typeof id === 'string') { if (!values) @@ -1736,18 +1736,18 @@ for (var i = 0; i < id.length; i++) id[i] |= 0; } - + if (!Array.isArray(id)) { return this.reporter.error('objid() should be either array or string, ' + 'got: ' + JSON.stringify(id)); } - + if (!relative) { if (id[1] >= 40) return this.reporter.error('Second objid identifier OOB'); id.splice(0, 2, id[0] * 40 + id[1]); } - + // Count number of octets var size = 0; for (var i = 0; i < id.length; i++) { @@ -1755,7 +1755,7 @@ for (size++; ident >= 0x80; ident >>= 7) size++; } - + var objid = new Buffer(size); var offset = objid.length - 1; for (var i = id.length - 1; i >= 0; i--) { @@ -1764,21 +1764,21 @@ while ((ident >>= 7) > 0) objid[offset--] = 0x80 | (ident & 0x7f); } - + return this._createEncoderBuffer(objid); }; - + function two(num) { if (num < 10) return '0' + num; else return num; } - + DERNode.prototype._encodeTime = function encodeTime(time, tag) { var str; var date = new Date(time); - + if (tag === 'gentime') { str = [ two(date.getFullYear()), @@ -1802,14 +1802,14 @@ } else { this.reporter.error('Encoding ' + tag + ' time is not supported yet'); } - + return this._encodeStr(str, 'octstr'); }; - + DERNode.prototype._encodeNull = function encodeNull() { return this._createEncoderBuffer(''); }; - + DERNode.prototype._encodeInt = function encodeInt(num, values) { if (typeof num === 'string') { if (!values) @@ -1820,7 +1820,7 @@ } num = values[num]; } - + // Bignum, assume big endian if (typeof num !== 'number' && !Buffer.isBuffer(num)) { var numArray = num.toArray(); @@ -1829,29 +1829,29 @@ } num = new Buffer(numArray); } - + if (Buffer.isBuffer(num)) { var size = num.length; if (num.length === 0) size++; - + var out = new Buffer(size); num.copy(out); if (num.length === 0) out[0] = 0 return this._createEncoderBuffer(out); } - + if (num < 0x80) return this._createEncoderBuffer(num); - + if (num < 0x100) return this._createEncoderBuffer([0, num]); - + var size = 1; for (var i = num; i >= 0x100; i >>= 8) size++; - + var out = new Array(size); for (var i = out.length - 1; i >= 0; i--) { out[i] = num & 0xff; @@ -1860,89 +1860,89 @@ if(out[0] & 0x80) { out.unshift(0); } - + return this._createEncoderBuffer(new Buffer(out)); }; - + DERNode.prototype._encodeBool = function encodeBool(value) { return this._createEncoderBuffer(value ? 0xff : 0); }; - + DERNode.prototype._use = function use(entity, obj) { if (typeof entity === 'function') entity = entity(obj); return entity._getEncoder('der').tree; }; - + DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) { var state = this._baseState; var i; if (state['default'] === null) return false; - + var data = dataBuffer.join(); if (state.defaultBuffer === undefined) state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join(); - + if (data.length !== state.defaultBuffer.length) return false; - + for (i=0; i < data.length; i++) if (data[i] !== state.defaultBuffer[i]) return false; - + return true; }; - + // Utility methods - + function encodeTag(tag, primitive, cls, reporter) { var res; - + if (tag === 'seqof') tag = 'seq'; else if (tag === 'setof') tag = 'set'; - + if (der.tagByName.hasOwnProperty(tag)) res = der.tagByName[tag]; else if (typeof tag === 'number' && (tag | 0) === tag) res = tag; else return reporter.error('Unknown tag: ' + tag); - + if (res >= 0x1f) return reporter.error('Multi-octet tag encoding unsupported'); - + if (!primitive) res |= 0x20; - + res |= (der.tagClassByName[cls || 'universal'] << 6); - + return res; } - + },{"../../asn1":5,"buffer":84,"inherits":180}],17:[function(require,module,exports){ var encoders = exports; - + encoders.der = require('./der'); encoders.pem = require('./pem'); - + },{"./der":16,"./pem":18}],18:[function(require,module,exports){ var inherits = require('inherits'); - + var DEREncoder = require('./der'); - + function PEMEncoder(entity) { DEREncoder.call(this, entity); this.enc = 'pem'; }; inherits(PEMEncoder, DEREncoder); module.exports = PEMEncoder; - + PEMEncoder.prototype.encode = function encode(data, options) { var buf = DEREncoder.prototype.encode.call(this, data); - + var p = buf.toString('base64'); var out = [ '-----BEGIN ' + options.label + '-----' ]; for (var i = 0; i < p.length; i += 64) @@ -1950,14 +1950,14 @@ out.push('-----END ' + options.label + '-----'); return out.join('\n'); }; - + },{"./der":16,"inherits":180}],19:[function(require,module,exports){ (function (global){ 'use strict'; - + // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js // original notice: - + /*! * The buffer module from node.js, for the browser. * @@ -1968,10 +1968,10 @@ if (a === b) { return 0; } - + var x = a.length; var y = b.length; - + for (var i = 0, len = Math.min(x, y); i < len; ++i) { if (a[i] !== b[i]) { x = a[i]; @@ -1979,7 +1979,7 @@ break; } } - + if (x < y) { return -1; } @@ -1994,9 +1994,9 @@ } return !!(b != null && b._isBuffer); } - + // based on node assert, original notice: - + // http://wiki.commonjs.org/wiki/Unit_Testing/1.0 // // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! @@ -2020,7 +2020,7 @@ // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - + var util = require('util/'); var hasOwn = Object.prototype.hasOwnProperty; var pSlice = Array.prototype.slice; @@ -2054,14 +2054,14 @@ // 1. The assert module provides functions that throw // AssertionError's when particular conditions are not met. The // assert module must conform to the following interface. - + var assert = module.exports = ok; - + // 2. The AssertionError is defined in assert. // new assert.AssertionError({ message: message, // actual: actual, // expected: expected }) - + var regex = /\s*function\s+([^\(\s]*)\s*/; // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js function getName(func) { @@ -2095,7 +2095,7 @@ var err = new Error(); if (err.stack) { var out = err.stack; - + // try to strip useless frames var fn_name = getName(stackStartFunction); var idx = out.indexOf('\n' + fn_name); @@ -2105,15 +2105,15 @@ var next_line = out.indexOf('\n', idx + 1); out = out.substring(next_line + 1); } - + this.stack = out; } } }; - + // assert.AssertionError instanceof Error util.inherits(assert.AssertionError, Error); - + function truncate(s, n) { if (typeof s === 'string') { return s.length < n ? s : s.slice(0, n); @@ -2134,18 +2134,18 @@ self.operator + ' ' + truncate(inspect(self.expected), 128); } - + // At present only the three keys mentioned above are used and // understood by the spec. Implementations or sub modules can pass // other keys to the AssertionError's constructor - they will be // ignored. - + // 3. All of the following functions must throw an AssertionError // when a corresponding condition is not met, with a message that // may be undefined if not provided. All assertion methods provide // both the actual and expected values to the assertion error for // display purposes. - + function fail(actual, expected, message, operator, stackStartFunction) { throw new assert.AssertionError({ message: message, @@ -2155,66 +2155,66 @@ stackStartFunction: stackStartFunction }); } - + // EXTENSION! allows for well behaved errors defined elsewhere. assert.fail = fail; - + // 4. Pure assertion tests whether a value is truthy, as determined // by !!guard. // assert.ok(guard, message_opt); // This statement is equivalent to assert.equal(true, !!guard, // message_opt);. To test strictly for the value true, use // assert.strictEqual(true, guard, message_opt);. - + function ok(value, message) { if (!value) fail(value, true, message, '==', assert.ok); } assert.ok = ok; - + // 5. The equality assertion tests shallow, coercive equality with // ==. // assert.equal(actual, expected, message_opt); - + assert.equal = function equal(actual, expected, message) { if (actual != expected) fail(actual, expected, message, '==', assert.equal); }; - + // 6. The non-equality assertion tests for whether two objects are not equal // with != assert.notEqual(actual, expected, message_opt); - + assert.notEqual = function notEqual(actual, expected, message) { if (actual == expected) { fail(actual, expected, message, '!=', assert.notEqual); } }; - + // 7. The equivalence assertion tests a deep equality relation. // assert.deepEqual(actual, expected, message_opt); - + assert.deepEqual = function deepEqual(actual, expected, message) { if (!_deepEqual(actual, expected, false)) { fail(actual, expected, message, 'deepEqual', assert.deepEqual); } }; - + assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { if (!_deepEqual(actual, expected, true)) { fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual); } }; - + function _deepEqual(actual, expected, strict, memos) { // 7.1. All identical values are equivalent, as determined by ===. if (actual === expected) { return true; } else if (isBuffer(actual) && isBuffer(expected)) { return compare(actual, expected) === 0; - + // 7.2. If the expected value is a Date object, the actual value is // equivalent if it is also a Date object that refers to the same time. } else if (util.isDate(actual) && util.isDate(expected)) { return actual.getTime() === expected.getTime(); - + // 7.3 If the expected value is a RegExp object, the actual value is // equivalent if it is also a RegExp object with the same source and // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`). @@ -2224,13 +2224,13 @@ actual.multiline === expected.multiline && actual.lastIndex === expected.lastIndex && actual.ignoreCase === expected.ignoreCase; - + // 7.4. Other pairs that do not both pass typeof value == 'object', // equivalence is determined by ==. } else if ((actual === null || typeof actual !== 'object') && (expected === null || typeof expected !== 'object')) { return strict ? actual === expected : actual == expected; - + // If both values are instances of typed arrays, wrap their underlying // ArrayBuffers in a Buffer each to increase performance // This optimization requires the arrays to have the same type as checked by @@ -2243,7 +2243,7 @@ actual instanceof Float64Array)) { return compare(new Uint8Array(actual.buffer), new Uint8Array(expected.buffer)) === 0; - + // 7.5 For all other Object pairs, including Array objects, equivalence is // determined by having the same number of owned properties (as verified // with Object.prototype.hasOwnProperty.call), the same set of keys @@ -2254,25 +2254,25 @@ return false; } else { memos = memos || {actual: [], expected: []}; - + var actualIndex = memos.actual.indexOf(actual); if (actualIndex !== -1) { if (actualIndex === memos.expected.indexOf(expected)) { return true; } } - + memos.actual.push(actual); memos.expected.push(expected); - + return objEquiv(actual, expected, strict, memos); } } - + function isArguments(object) { return Object.prototype.toString.call(object) == '[object Arguments]'; } - + function objEquiv(a, b, strict, actualVisitedObjects) { if (a === null || a === undefined || b === null || b === undefined) return false; @@ -2314,51 +2314,51 @@ } return true; } - + // 8. The non-equivalence assertion tests for any deep inequality. // assert.notDeepEqual(actual, expected, message_opt); - + assert.notDeepEqual = function notDeepEqual(actual, expected, message) { if (_deepEqual(actual, expected, false)) { fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); } }; - + assert.notDeepStrictEqual = notDeepStrictEqual; function notDeepStrictEqual(actual, expected, message) { if (_deepEqual(actual, expected, true)) { fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual); } } - - + + // 9. The strict equality assertion tests strict equality, as determined by ===. // assert.strictEqual(actual, expected, message_opt); - + assert.strictEqual = function strictEqual(actual, expected, message) { if (actual !== expected) { fail(actual, expected, message, '===', assert.strictEqual); } }; - + // 10. The strict non-equality assertion tests for strict inequality, as // determined by !==. assert.notStrictEqual(actual, expected, message_opt); - + assert.notStrictEqual = function notStrictEqual(actual, expected, message) { if (actual === expected) { fail(actual, expected, message, '!==', assert.notStrictEqual); } }; - + function expectedException(actual, expected) { if (!actual || !expected) { return false; } - + if (Object.prototype.toString.call(expected) == '[object RegExp]') { return expected.test(actual); } - + try { if (actual instanceof expected) { return true; @@ -2366,14 +2366,14 @@ } catch (e) { // Ignore. The instanceof check doesn't work for arrow functions. } - + if (Error.isPrototypeOf(expected)) { return false; } - + return expected.call({}, actual) === true; } - + function _tryBlock(block) { var error; try { @@ -2383,59 +2383,59 @@ } return error; } - + function _throws(shouldThrow, block, expected, message) { var actual; - + if (typeof block !== 'function') { throw new TypeError('"block" argument must be a function'); } - + if (typeof expected === 'string') { message = expected; expected = null; } - + actual = _tryBlock(block); - + message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + (message ? ' ' + message : '.'); - + if (shouldThrow && !actual) { fail(actual, expected, 'Missing expected exception' + message); } - + var userProvidedMessage = typeof message === 'string'; var isUnwantedException = !shouldThrow && util.isError(actual); var isUnexpectedException = !shouldThrow && actual && !expected; - + if ((isUnwantedException && userProvidedMessage && expectedException(actual, expected)) || isUnexpectedException) { fail(actual, expected, 'Got unwanted exception' + message); } - + if ((shouldThrow && actual && expected && !expectedException(actual, expected)) || (!shouldThrow && actual)) { throw actual; } } - + // 11. Expected to throw an error: // assert.throws(block, Error_opt, message_opt); - + assert.throws = function(block, /*optional*/error, /*optional*/message) { _throws(true, block, error, message); }; - + // EXTENSION! This is annoying to write outside this module. assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { _throws(false, block, error, message); }; - + assert.ifError = function(err) { if (err) throw err; }; - + var objectKeys = Object.keys || function (obj) { var keys = []; for (var key in obj) { @@ -2443,30 +2443,30 @@ } return keys; }; - + }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"util/":333}],20:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = asyncify; - + var _isObject = require('lodash/isObject'); - + var _isObject2 = _interopRequireDefault(_isObject); - + var _initialParams = require('./internal/initialParams'); - + var _initialParams2 = _interopRequireDefault(_initialParams); - + var _setImmediate = require('./internal/setImmediate'); - + var _setImmediate2 = _interopRequireDefault(_setImmediate); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + /** * Take a sync function and make it async, passing its return value to a * callback. This is useful for plugging sync functions into a waterfall, @@ -2543,7 +2543,7 @@ } }); } - + function invokeCallback(callback, error, value) { try { callback(error, value); @@ -2551,7 +2551,7 @@ (0, _setImmediate2.default)(rethrow, e); } } - + function rethrow(error) { throw error; } @@ -2563,7 +2563,7 @@ typeof define === 'function' && define.amd ? define(['exports'], factory) : (factory((global.async = global.async || {}))); }(this, (function (exports) { 'use strict'; - + function slice(arrayLike, start) { start = start|0; var newLen = Math.max(arrayLike.length - start, 0); @@ -2573,7 +2573,7 @@ } return newArr; } - + /** * Creates a continuation function with some arguments already applied. * @@ -2626,7 +2626,7 @@ return fn.apply(null, args.concat(callArgs)); }; }; - + var initialParams = function (fn) { return function (/*...args, callback*/) { var args = slice(arguments); @@ -2634,7 +2634,7 @@ fn.call(this, args, callback); }; }; - + /** * Checks if `value` is the * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) @@ -2664,14 +2664,14 @@ var type = typeof value; return value != null && (type == 'object' || type == 'function'); } - + var hasSetImmediate = typeof setImmediate === 'function' && setImmediate; var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function'; - + function fallback(fn) { setTimeout(fn, 0); } - + function wrap(defer) { return function (fn/*, ...args*/) { var args = slice(arguments, 1); @@ -2680,9 +2680,9 @@ }); }; } - + var _defer; - + if (hasSetImmediate) { _defer = setImmediate; } else if (hasNextTick) { @@ -2690,9 +2690,9 @@ } else { _defer = fallback; } - + var setImmediate$1 = wrap(_defer); - + /** * Take a sync function and make it async, passing its return value to a * callback. This is useful for plugging sync functions into a waterfall, @@ -2769,7 +2769,7 @@ } }); } - + function invokeCallback(callback, error, value) { try { callback(error, value); @@ -2777,21 +2777,21 @@ setImmediate$1(rethrow, e); } } - + function rethrow(error) { throw error; } - + var supportsSymbol = typeof Symbol === 'function'; - + function isAsync(fn) { return supportsSymbol && fn[Symbol.toStringTag] === 'AsyncFunction'; } - + function wrapAsync(asyncFn) { return isAsync(asyncFn) ? asyncify(asyncFn) : asyncFn; } - + function applyEach$1(eachfn) { return function(fns/*, ...args*/) { var args = slice(arguments, 1); @@ -2809,35 +2809,35 @@ } }; } - + /** Detect free variable `global` from Node.js. */ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - + /** Detect free variable `self`. */ var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - + /** Used as a reference to the global object. */ var root = freeGlobal || freeSelf || Function('return this')(); - + /** Built-in value references. */ var Symbol$1 = root.Symbol; - + /** Used for built-in method references. */ var objectProto = Object.prototype; - + /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; - + /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var nativeObjectToString = objectProto.toString; - + /** Built-in value references. */ var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined; - + /** * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. * @@ -2848,12 +2848,12 @@ function getRawTag(value) { var isOwn = hasOwnProperty.call(value, symToStringTag$1), tag = value[symToStringTag$1]; - + try { value[symToStringTag$1] = undefined; var unmasked = true; } catch (e) {} - + var result = nativeObjectToString.call(value); if (unmasked) { if (isOwn) { @@ -2864,17 +2864,17 @@ } return result; } - + /** Used for built-in method references. */ var objectProto$1 = Object.prototype; - + /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var nativeObjectToString$1 = objectProto$1.toString; - + /** * Converts `value` to a string using `Object.prototype.toString`. * @@ -2885,14 +2885,14 @@ function objectToString(value) { return nativeObjectToString$1.call(value); } - + /** `Object#toString` result references. */ var nullTag = '[object Null]'; var undefinedTag = '[object Undefined]'; - + /** Built-in value references. */ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined; - + /** * The base implementation of `getTag` without fallbacks for buggy environments. * @@ -2908,13 +2908,13 @@ ? getRawTag(value) : objectToString(value); } - + /** `Object#toString` result references. */ var asyncTag = '[object AsyncFunction]'; var funcTag = '[object Function]'; var genTag = '[object GeneratorFunction]'; var proxyTag = '[object Proxy]'; - + /** * Checks if `value` is classified as a `Function` object. * @@ -2941,10 +2941,10 @@ var tag = baseGetTag(value); return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; } - + /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; - + /** * Checks if `value` is a valid array-like length. * @@ -2975,7 +2975,7 @@ return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; } - + /** * Checks if `value` is array-like. A value is considered array-like if it's * not a function and has a `value.length` that's an integer greater than or @@ -3004,11 +3004,11 @@ function isArrayLike(value) { return value != null && isLength(value.length) && !isFunction(value); } - + // A temporary value used to identify if the loop should be broken. // See #1064, #1293 var breakLoop = {}; - + /** * This method returns `undefined`. * @@ -3024,7 +3024,7 @@ function noop() { // No operation performed. } - + function once(fn) { return function () { if (fn === null) return; @@ -3033,13 +3033,13 @@ callFn.apply(this, arguments); }; } - + var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator; - + var getIterator = function (coll) { return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol](); }; - + /** * The base implementation of `_.times` without support for iteratee shorthands * or max array length checks. @@ -3052,13 +3052,13 @@ function baseTimes(n, iteratee) { var index = -1, result = Array(n); - + while (++index < n) { result[index] = iteratee(index); } return result; } - + /** * Checks if `value` is object-like. A value is object-like if it's not `null` * and has a `typeof` result of "object". @@ -3086,10 +3086,10 @@ function isObjectLike(value) { return value != null && typeof value == 'object'; } - + /** `Object#toString` result references. */ var argsTag = '[object Arguments]'; - + /** * The base implementation of `_.isArguments`. * @@ -3100,16 +3100,16 @@ function baseIsArguments(value) { return isObjectLike(value) && baseGetTag(value) == argsTag; } - + /** Used for built-in method references. */ var objectProto$3 = Object.prototype; - + /** Used to check objects for own properties. */ var hasOwnProperty$2 = objectProto$3.hasOwnProperty; - + /** Built-in value references. */ var propertyIsEnumerable = objectProto$3.propertyIsEnumerable; - + /** * Checks if `value` is likely an `arguments` object. * @@ -3132,7 +3132,7 @@ return isObjectLike(value) && hasOwnProperty$2.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); }; - + /** * Checks if `value` is classified as an `Array` object. * @@ -3157,7 +3157,7 @@ * // => false */ var isArray = Array.isArray; - + /** * This method returns `false`. * @@ -3174,22 +3174,22 @@ function stubFalse() { return false; } - + /** Detect free variable `exports`. */ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; - + /** Detect free variable `module`. */ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; - + /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; - + /** Built-in value references. */ var Buffer = moduleExports ? root.Buffer : undefined; - + /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; - + /** * Checks if `value` is a buffer. * @@ -3208,13 +3208,13 @@ * // => false */ var isBuffer = nativeIsBuffer || stubFalse; - + /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER$1 = 9007199254740991; - + /** Used to detect unsigned integer values. */ var reIsUint = /^(?:0|[1-9]\d*)$/; - + /** * Checks if `value` is a valid array-like index. * @@ -3229,7 +3229,7 @@ (typeof value == 'number' || reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length); } - + /** `Object#toString` result references. */ var argsTag$1 = '[object Arguments]'; var arrayTag = '[object Array]'; @@ -3244,7 +3244,7 @@ var setTag = '[object Set]'; var stringTag = '[object String]'; var weakMapTag = '[object WeakMap]'; - + var arrayBufferTag = '[object ArrayBuffer]'; var dataViewTag = '[object DataView]'; var float32Tag = '[object Float32Array]'; @@ -3256,7 +3256,7 @@ var uint8ClampedTag = '[object Uint8ClampedArray]'; var uint16Tag = '[object Uint16Array]'; var uint32Tag = '[object Uint32Array]'; - + /** Used to identify `toStringTag` values of typed arrays. */ var typedArrayTags = {}; typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = @@ -3272,7 +3272,7 @@ typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; - + /** * The base implementation of `_.isTypedArray` without Node.js optimizations. * @@ -3284,7 +3284,7 @@ return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; } - + /** * The base implementation of `_.unary` without support for storing metadata. * @@ -3297,29 +3297,29 @@ return func(value); }; } - + /** Detect free variable `exports`. */ var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports; - + /** Detect free variable `module`. */ var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module; - + /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1; - + /** Detect free variable `process` from Node.js. */ var freeProcess = moduleExports$1 && freeGlobal.process; - + /** Used to access faster Node.js helpers. */ var nodeUtil = (function() { try { return freeProcess && freeProcess.binding && freeProcess.binding('util'); } catch (e) {} }()); - + /* Node.js helper references. */ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; - + /** * Checks if `value` is classified as a typed array. * @@ -3338,13 +3338,13 @@ * // => false */ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; - + /** Used for built-in method references. */ var objectProto$2 = Object.prototype; - + /** Used to check objects for own properties. */ var hasOwnProperty$1 = objectProto$2.hasOwnProperty; - + /** * Creates an array of the enumerable property names of the array-like `value`. * @@ -3361,7 +3361,7 @@ skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; - + for (var key in value) { if ((inherited || hasOwnProperty$1.call(value, key)) && !(skipIndexes && ( @@ -3379,10 +3379,10 @@ } return result; } - + /** Used for built-in method references. */ var objectProto$5 = Object.prototype; - + /** * Checks if `value` is likely a prototype object. * @@ -3393,10 +3393,10 @@ function isPrototype(value) { var Ctor = value && value.constructor, proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5; - + return value === proto; } - + /** * Creates a unary function that invokes `func` with its argument transformed. * @@ -3410,16 +3410,16 @@ return func(transform(arg)); }; } - + /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeKeys = overArg(Object.keys, Object); - + /** Used for built-in method references. */ var objectProto$4 = Object.prototype; - + /** Used to check objects for own properties. */ var hasOwnProperty$3 = objectProto$4.hasOwnProperty; - + /** * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. * @@ -3439,7 +3439,7 @@ } return result; } - + /** * Creates an array of the own enumerable property names of `object`. * @@ -3471,7 +3471,7 @@ function keys(object) { return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); } - + function createArrayIterator(coll) { var i = -1; var len = coll.length; @@ -3479,7 +3479,7 @@ return ++i < len ? {value: coll[i], key: i} : null; } } - + function createES2015Iterator(iterator) { var i = -1; return function next() { @@ -3490,7 +3490,7 @@ return {value: item.value, key: i}; } } - + function createObjectIterator(obj) { var okeys = keys(obj); var i = -1; @@ -3500,16 +3500,16 @@ return i < len ? {value: obj[key], key: key} : null; }; } - + function iterator(coll) { if (isArrayLike(coll)) { return createArrayIterator(coll); } - + var iterator = getIterator(coll); return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll); } - + function onlyOnce(fn) { return function() { if (fn === null) throw new Error("Callback was already called."); @@ -3518,7 +3518,7 @@ callFn.apply(this, arguments); }; } - + function _eachOfLimit(limit) { return function (obj, iteratee, callback) { callback = once(callback || noop); @@ -3528,7 +3528,7 @@ var nextElem = iterator(obj); var done = false; var running = 0; - + function iterateeCallback(err, value) { running -= 1; if (err) { @@ -3543,7 +3543,7 @@ replenish(); } } - + function replenish () { while (running < limit && !done) { var elem = nextElem(); @@ -3558,11 +3558,11 @@ iteratee(elem.value, elem.key, onlyOnce(iterateeCallback)); } } - + replenish(); }; } - + /** * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a * time. @@ -3586,13 +3586,13 @@ function eachOfLimit(coll, limit, iteratee, callback) { _eachOfLimit(limit)(coll, wrapAsync(iteratee), callback); } - + function doLimit(fn, limit) { return function (iterable, iteratee, callback) { return fn(iterable, limit, iteratee, callback); }; } - + // eachOf implementation optimized for array-likes function eachOfArrayLike(coll, iteratee, callback) { callback = once(callback || noop); @@ -3602,7 +3602,7 @@ if (length === 0) { callback(null); } - + function iteratorCallback(err, value) { if (err) { callback(err); @@ -3610,15 +3610,15 @@ callback(null); } } - + for (; index < length; index++) { iteratee(coll[index], index, onlyOnce(iteratorCallback)); } } - + // a generic version of eachOf which can handle array, object, and iterator cases. var eachOfGeneric = doLimit(eachOfLimit, Infinity); - + /** * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument * to the iteratee. @@ -3662,20 +3662,20 @@ var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric; eachOfImplementation(coll, wrapAsync(iteratee), callback); }; - + function doParallel(fn) { return function (obj, iteratee, callback) { return fn(eachOf, obj, wrapAsync(iteratee), callback); }; } - + function _asyncMap(eachfn, arr, iteratee, callback) { callback = callback || noop; arr = arr || []; var results = []; var counter = 0; var _iteratee = wrapAsync(iteratee); - + eachfn(arr, function (value, _, callback) { var index = counter++; _iteratee(value, function (err, v) { @@ -3686,7 +3686,7 @@ callback(err, results); }); } - + /** * Produces a new collection of values by mapping each value in `coll` through * the `iteratee` function. The `iteratee` is called with an item from `coll` @@ -3724,7 +3724,7 @@ * }); */ var map = doParallel(_asyncMap); - + /** * Applies the provided arguments to each function in the array, calling * `callback` after all functions have completed. If you only provide the first @@ -3759,13 +3759,13 @@ * ); */ var applyEach = applyEach$1(map); - + function doParallelLimit(fn) { return function (obj, limit, iteratee, callback) { return fn(_eachOfLimit(limit), obj, wrapAsync(iteratee), callback); }; } - + /** * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time. * @@ -3786,7 +3786,7 @@ * transformed items from the `coll`. Invoked with (err, results). */ var mapLimit = doParallelLimit(_asyncMap); - + /** * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time. * @@ -3806,7 +3806,7 @@ * transformed items from the `coll`. Invoked with (err, results). */ var mapSeries = doLimit(mapLimit, 1); - + /** * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time. * @@ -3827,7 +3827,7 @@ * function call. */ var applyEachSeries = applyEach$1(mapSeries); - + /** * A specialized version of `_.forEach` for arrays without support for * iteratee shorthands. @@ -3840,7 +3840,7 @@ function arrayEach(array, iteratee) { var index = -1, length = array == null ? 0 : array.length; - + while (++index < length) { if (iteratee(array[index], index, array) === false) { break; @@ -3848,7 +3848,7 @@ } return array; } - + /** * Creates a base function for methods like `_.forIn` and `_.forOwn`. * @@ -3862,7 +3862,7 @@ iterable = Object(object), props = keysFunc(object), length = props.length; - + while (length--) { var key = props[fromRight ? length : ++index]; if (iteratee(iterable[key], key, iterable) === false) { @@ -3872,7 +3872,7 @@ return object; }; } - + /** * The base implementation of `baseForOwn` which iterates over `object` * properties returned by `keysFunc` and invokes `iteratee` for each property. @@ -3885,7 +3885,7 @@ * @returns {Object} Returns `object`. */ var baseFor = createBaseFor(); - + /** * The base implementation of `_.forOwn` without support for iteratee shorthands. * @@ -3897,7 +3897,7 @@ function baseForOwn(object, iteratee) { return object && baseFor(object, iteratee, keys); } - + /** * The base implementation of `_.findIndex` and `_.findLastIndex` without * support for iteratee shorthands. @@ -3912,7 +3912,7 @@ function baseFindIndex(array, predicate, fromIndex, fromRight) { var length = array.length, index = fromIndex + (fromRight ? 1 : -1); - + while ((fromRight ? index-- : ++index < length)) { if (predicate(array[index], index, array)) { return index; @@ -3920,7 +3920,7 @@ } return -1; } - + /** * The base implementation of `_.isNaN` without support for number objects. * @@ -3931,7 +3931,7 @@ function baseIsNaN(value) { return value !== value; } - + /** * A specialized version of `_.indexOf` which performs strict equality * comparisons of values, i.e. `===`. @@ -3945,7 +3945,7 @@ function strictIndexOf(array, value, fromIndex) { var index = fromIndex - 1, length = array.length; - + while (++index < length) { if (array[index] === value) { return index; @@ -3953,7 +3953,7 @@ } return -1; } - + /** * The base implementation of `_.indexOf` without `fromIndex` bounds checks. * @@ -3968,7 +3968,7 @@ ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex); } - + /** * Determines the best order for running the {@link AsyncFunction}s in `tasks`, based on * their requirements. Each function can optionally depend on other functions @@ -4063,20 +4063,20 @@ if (!concurrency) { concurrency = numTasks; } - + var results = {}; var runningTasks = 0; var hasError = false; - + var listeners = Object.create(null); - + var readyTasks = []; - + // for cycle detection: var readyToCheck = []; // tasks that have been identified as reachable // without the possibility of returning to an ancestor task var uncheckedDependencies = {}; - + baseForOwn(tasks, function (task, key) { if (!isArray(task)) { // no dependencies @@ -4084,7 +4084,7 @@ readyToCheck.push(key); return; } - + var dependencies = task.slice(0, task.length - 1); var remainingDependencies = dependencies.length; if (remainingDependencies === 0) { @@ -4093,7 +4093,7 @@ return; } uncheckedDependencies[key] = remainingDependencies; - + arrayEach(dependencies, function (dependencyName) { if (!tasks[dependencyName]) { throw new Error('async.auto task `' + key + @@ -4109,16 +4109,16 @@ }); }); }); - + checkForDeadlocks(); processQueue(); - + function enqueueTask(key, task) { readyTasks.push(function () { runTask(key, task); }); } - + function processQueue() { if (readyTasks.length === 0 && runningTasks === 0) { return callback(null, results); @@ -4127,18 +4127,18 @@ var run = readyTasks.shift(); run(); } - + } - + function addListener(taskName, fn) { var taskListeners = listeners[taskName]; if (!taskListeners) { taskListeners = listeners[taskName] = []; } - + taskListeners.push(fn); } - + function taskComplete(taskName) { var taskListeners = listeners[taskName] || []; arrayEach(taskListeners, function (fn) { @@ -4146,11 +4146,11 @@ }); processQueue(); } - - + + function runTask(key, task) { if (hasError) return; - + var taskCallback = onlyOnce(function(err, result) { runningTasks--; if (arguments.length > 2) { @@ -4164,14 +4164,14 @@ safeResults[key] = result; hasError = true; listeners = Object.create(null); - + callback(err, safeResults); } else { results[key] = result; taskComplete(key); } }); - + runningTasks++; var taskFn = wrapAsync(task[task.length - 1]); if (task.length > 1) { @@ -4180,7 +4180,7 @@ taskFn(taskCallback); } } - + function checkForDeadlocks() { // Kahn's algorithm // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm @@ -4196,14 +4196,14 @@ } }); } - + if (counter !== numTasks) { throw new Error( 'async.auto cannot execute tasks due to a recursive dependency' ); } } - + function getDependents(taskName) { var result = []; baseForOwn(tasks, function (task, key) { @@ -4214,7 +4214,7 @@ return result; } }; - + /** * A specialized version of `_.map` for arrays without support for iteratee * shorthands. @@ -4228,16 +4228,16 @@ var index = -1, length = array == null ? 0 : array.length, result = Array(length); - + while (++index < length) { result[index] = iteratee(array[index], index, array); } return result; } - + /** `Object#toString` result references. */ var symbolTag = '[object Symbol]'; - + /** * Checks if `value` is classified as a `Symbol` primitive or object. * @@ -4259,14 +4259,14 @@ return typeof value == 'symbol' || (isObjectLike(value) && baseGetTag(value) == symbolTag); } - + /** Used as references for various `Number` constants. */ var INFINITY = 1 / 0; - + /** Used to convert symbols to primitives and strings. */ var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined; var symbolToString = symbolProto ? symbolProto.toString : undefined; - + /** * The base implementation of `_.toString` which doesn't convert nullish * values to empty strings. @@ -4290,7 +4290,7 @@ var result = (value + ''); return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; } - + /** * The base implementation of `_.slice` without an iteratee call guard. * @@ -4303,7 +4303,7 @@ function baseSlice(array, start, end) { var index = -1, length = array.length; - + if (start < 0) { start = -start > length ? 0 : (length + start); } @@ -4313,14 +4313,14 @@ } length = start > end ? 0 : ((end - start) >>> 0); start >>>= 0; - + var result = Array(length); while (++index < length) { result[index] = array[index + start]; } return result; } - + /** * Casts `array` to a slice if it's needed. * @@ -4335,7 +4335,7 @@ end = end === undefined ? length : end; return (!start && end >= length) ? array : baseSlice(array, start, end); } - + /** * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol * that is not found in the character symbols. @@ -4347,11 +4347,11 @@ */ function charsEndIndex(strSymbols, chrSymbols) { var index = strSymbols.length; - + while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} return index; } - + /** * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol * that is not found in the character symbols. @@ -4364,11 +4364,11 @@ function charsStartIndex(strSymbols, chrSymbols) { var index = -1, length = strSymbols.length; - + while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} return index; } - + /** * Converts an ASCII `string` to an array. * @@ -4379,7 +4379,7 @@ function asciiToArray(string) { return string.split(''); } - + /** Used to compose unicode character classes. */ var rsAstralRange = '\\ud800-\\udfff'; var rsComboMarksRange = '\\u0300-\\u036f'; @@ -4387,13 +4387,13 @@ var rsComboSymbolsRange = '\\u20d0-\\u20ff'; var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange; var rsVarRange = '\\ufe0e\\ufe0f'; - + /** Used to compose unicode capture groups. */ var rsZWJ = '\\u200d'; - + /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); - + /** * Checks if `string` contains Unicode symbols. * @@ -4404,7 +4404,7 @@ function hasUnicode(string) { return reHasUnicode.test(string); } - + /** Used to compose unicode character classes. */ var rsAstralRange$1 = '\\ud800-\\udfff'; var rsComboMarksRange$1 = '\\u0300-\\u036f'; @@ -4412,7 +4412,7 @@ var rsComboSymbolsRange$1 = '\\u20d0-\\u20ff'; var rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1; var rsVarRange$1 = '\\ufe0e\\ufe0f'; - + /** Used to compose unicode capture groups. */ var rsAstral = '[' + rsAstralRange$1 + ']'; var rsCombo = '[' + rsComboRange$1 + ']'; @@ -4422,17 +4422,17 @@ var rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}'; var rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]'; var rsZWJ$1 = '\\u200d'; - + /** Used to compose unicode regexes. */ var reOptMod = rsModifier + '?'; var rsOptVar = '[' + rsVarRange$1 + ']?'; var rsOptJoin = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*'; var rsSeq = rsOptVar + reOptMod + rsOptJoin; var rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; - + /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); - + /** * Converts a Unicode `string` to an array. * @@ -4443,7 +4443,7 @@ function unicodeToArray(string) { return string.match(reUnicode) || []; } - + /** * Converts `string` to an array. * @@ -4456,7 +4456,7 @@ ? unicodeToArray(string) : asciiToArray(string); } - + /** * Converts `value` to a string. An empty string is returned for `null` * and `undefined` values. The sign of `-0` is preserved. @@ -4481,10 +4481,10 @@ function toString(value) { return value == null ? '' : baseToString(value); } - + /** Used to match leading and trailing whitespace. */ var reTrim = /^\s+|\s+$/g; - + /** * Removes leading and trailing whitespace or specified characters from `string`. * @@ -4519,15 +4519,15 @@ chrSymbols = stringToArray(chars), start = charsStartIndex(strSymbols, chrSymbols), end = charsEndIndex(strSymbols, chrSymbols) + 1; - + return castSlice(strSymbols, start, end).join(''); } - + var FN_ARGS = /^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m; var FN_ARG_SPLIT = /,/; var FN_ARG = /(=.+)?(\s*)$/; var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; - + function parseParams(func) { func = func.toString().replace(STRIP_COMMENTS, ''); func = func.match(FN_ARGS)[2].replace(' ', ''); @@ -4537,7 +4537,7 @@ }); return func; } - + /** * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent * tasks are specified as parameters to the function, after the usual callback @@ -4622,18 +4622,18 @@ */ function autoInject(tasks, callback) { var newTasks = {}; - + baseForOwn(tasks, function (taskFn, key) { var params; var fnIsAsync = isAsync(taskFn); var hasNoDeps = (!fnIsAsync && taskFn.length === 1) || (fnIsAsync && taskFn.length === 0); - + if (isArray(taskFn)) { params = taskFn.slice(0, -1); taskFn = taskFn[taskFn.length - 1]; - + newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn); } else if (hasNoDeps) { // no dependencies, use the function as-is @@ -4643,13 +4643,13 @@ if (taskFn.length === 0 && !fnIsAsync && params.length === 0) { throw new Error("autoInject task functions require explicit parameters."); } - + // remove callback param if (!fnIsAsync) params.pop(); - + newTasks[key] = params.concat(newTask); } - + function newTask(results, taskCb) { var newArgs = arrayMap(params, function (name) { return results[name]; @@ -4658,10 +4658,10 @@ wrapAsync(taskFn).apply(null, newArgs); } }); - + auto(newTasks, callback); } - + // Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation // used for queues. This implementation assumes that the node provided by the user can be modified // to adjust the next and last properties. We implement only the minimal functionality @@ -4670,28 +4670,28 @@ this.head = this.tail = null; this.length = 0; } - + function setInitial(dll, node) { dll.length = 1; dll.head = dll.tail = node; } - + DLL.prototype.removeLink = function(node) { if (node.prev) node.prev.next = node.next; else this.head = node.next; if (node.next) node.next.prev = node.prev; else this.tail = node.prev; - + node.prev = node.next = null; this.length -= 1; return node; }; - + DLL.prototype.empty = function () { while(this.head) this.shift(); return this; }; - + DLL.prototype.insertAfter = function(node, newNode) { newNode.prev = node; newNode.next = node.next; @@ -4700,7 +4700,7 @@ node.next = newNode; this.length += 1; }; - + DLL.prototype.insertBefore = function(node, newNode) { newNode.prev = node.prev; newNode.next = node; @@ -4709,25 +4709,25 @@ node.prev = newNode; this.length += 1; }; - + DLL.prototype.unshift = function(node) { if (this.head) this.insertBefore(this.head, node); else setInitial(this, node); }; - + DLL.prototype.push = function(node) { if (this.tail) this.insertAfter(this.tail, node); else setInitial(this, node); }; - + DLL.prototype.shift = function() { return this.head && this.removeLink(this.head); }; - + DLL.prototype.pop = function() { return this.tail && this.removeLink(this.tail); }; - + DLL.prototype.toArray = function () { var arr = Array(this.length); var curr = this.head; @@ -4737,7 +4737,7 @@ } return arr; }; - + DLL.prototype.remove = function (testFn) { var curr = this.head; while(!!curr) { @@ -4749,7 +4749,7 @@ } return this; }; - + function queue(worker, concurrency, payload) { if (concurrency == null) { concurrency = 1; @@ -4757,11 +4757,11 @@ else if(concurrency === 0) { throw new Error('Concurrency must not be zero'); } - + var _worker = wrapAsync(worker); var numRunning = 0; var workersList = []; - + var processingScheduled = false; function _insert(data, insertAtFront, callback) { if (callback != null && typeof callback !== 'function') { @@ -4777,20 +4777,20 @@ q.drain(); }); } - + for (var i = 0, l = data.length; i < l; i++) { var item = { data: data[i], callback: callback || noop }; - + if (insertAtFront) { q._tasks.unshift(item); } else { q._tasks.push(item); } } - + if (!processingScheduled) { processingScheduled = true; setImmediate$1(function() { @@ -4799,39 +4799,39 @@ }); } } - + function _next(tasks) { return function(err){ numRunning -= 1; - + for (var i = 0, l = tasks.length; i < l; i++) { var task = tasks[i]; - + var index = baseIndexOf(workersList, task, 0); if (index === 0) { workersList.shift(); } else if (index > 0) { workersList.splice(index, 1); } - + task.callback.apply(task, arguments); - + if (err != null) { q.error(err, task.data); } } - + if (numRunning <= (q.concurrency - q.buffer) ) { q.unsaturated(); } - + if (q.idle()) { q.drain(); } q.process(); }; } - + var isProcessing = false; var q = { _tasks: new DLL(), @@ -4875,17 +4875,17 @@ workersList.push(node); data.push(node.data); } - + numRunning += 1; - + if (q._tasks.length === 0) { q.empty(); } - + if (numRunning === q.concurrency) { q.saturated(); } - + var cb = onlyOnce(_next(tasks)); _worker(data, cb); } @@ -4914,7 +4914,7 @@ }; return q; } - + /** * A cargo of tasks for the worker function to complete. Cargo inherits all of * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}. @@ -4944,7 +4944,7 @@ * @property {Function} kill - a function that removes the `drain` callback and * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`. */ - + /** * Creates a `cargo` object with the specified payload. Tasks added to the * cargo will be processed altogether (up to the `payload` limit). If the @@ -4995,7 +4995,7 @@ function cargo(worker, payload) { return queue(worker, 1, payload); } - + /** * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time. * @@ -5014,7 +5014,7 @@ * functions have finished, or an error occurs. Invoked with (err). */ var eachOfSeries = doLimit(eachOfLimit, 1); - + /** * Reduces `coll` into a single value using an async `iteratee` to return each * successive step. `memo` is the initial state of the reduction. This function @@ -5067,7 +5067,7 @@ callback(err, memo); }); } - + /** * Version of the compose function that is more natural to read. Each function * consumes the return value of the previous function. It is the equivalent of @@ -5111,14 +5111,14 @@ return function(/*...args*/) { var args = slice(arguments); var that = this; - + var cb = args[args.length - 1]; if (typeof cb == 'function') { args.pop(); } else { cb = noop; } - + reduce(_functions, args, function(newargs, fn, cb) { fn.apply(that, newargs.concat(function(err/*, ...nextargs*/) { var nextargs = slice(arguments, 1); @@ -5130,7 +5130,7 @@ }); }; } - + /** * Creates a function which is a composition of the passed asynchronous * functions. Each function consumes the return value of the function that @@ -5169,9 +5169,9 @@ var compose = function(/*...args*/) { return seq.apply(null, slice(arguments).reverse()); }; - + var _concat = Array.prototype.concat; - + /** * The same as [`concat`]{@link module:Collections.concat} but runs a maximum of `limit` async operations at a time. * @@ -5205,11 +5205,11 @@ result = _concat.apply(result, mapResults[i]); } } - + return callback(err, result); }); }; - + /** * Applies `iteratee` to each item in `coll`, concatenating the results. Returns * the concatenated list. The `iteratee`s are called in parallel, and the @@ -5236,7 +5236,7 @@ * }); */ var concat = doLimit(concatLimit, Infinity); - + /** * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time. * @@ -5256,7 +5256,7 @@ * (err, results). */ var concatSeries = doLimit(concatLimit, 1); - + /** * Returns a function that when called, calls-back with the values provided. * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to @@ -5307,7 +5307,7 @@ return callback.apply(this, args); }; }; - + /** * This method returns the first argument it receives. * @@ -5327,7 +5327,7 @@ function identity(value) { return value; } - + function _createTester(check, getResult) { return function(eachfn, arr, iteratee, cb) { cb = cb || noop; @@ -5354,18 +5354,18 @@ }); }; } - + function _findGetResult(v, x) { return x; } - + /** * Returns the first value in `coll` that passes an async truth test. The * `iteratee` is applied in parallel, meaning the first iteratee to return * `true` will fire the detect `callback` with that result. That means the * result might not be the first item in the original `coll` (in terms of order) * that passes the test. - + * If order within the original `coll` is important, then look at * [`detectSeries`]{@link module:Collections.detectSeries}. * @@ -5395,7 +5395,7 @@ * }); */ var detect = doParallel(_createTester(identity, _findGetResult)); - + /** * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a * time. @@ -5419,7 +5419,7 @@ * (err, result). */ var detectLimit = doParallelLimit(_createTester(identity, _findGetResult)); - + /** * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time. * @@ -5441,7 +5441,7 @@ * (err, result). */ var detectSeries = doLimit(detectLimit, 1); - + function consoleFunc(name) { return function (fn/*, ...args*/) { var args = slice(arguments, 1); @@ -5462,7 +5462,7 @@ wrapAsync(fn).apply(null, args); }; } - + /** * Logs the result of an [`async` function]{@link AsyncFunction} to the * `console` using `console.dir` to display the properties of the resulting object. @@ -5493,7 +5493,7 @@ * {hello: 'world'} */ var dir = consoleFunc('dir'); - + /** * The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in * the order of operations, the arguments `test` and `fn` are switched. @@ -5518,24 +5518,24 @@ callback = onlyOnce(callback || noop); var _fn = wrapAsync(fn); var _test = wrapAsync(test); - + function next(err/*, ...args*/) { if (err) return callback(err); var args = slice(arguments, 1); args.push(check); _test.apply(this, args); } - + function check(err, truth) { if (err) return callback(err); if (!truth) return callback(null); _fn(next); } - + check(null, true); - + } - + /** * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in * the order of operations, the arguments `test` and `iteratee` are switched. @@ -5569,7 +5569,7 @@ }; _iteratee(next); } - + /** * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the * argument ordering differs from `until`. @@ -5595,7 +5595,7 @@ return !test.apply(this, arguments); }, callback); } - + /** * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that * is passed a callback in the form of `function (err, truth)`. If error is @@ -5636,27 +5636,27 @@ callback = onlyOnce(callback || noop); var _fn = wrapAsync(fn); var _test = wrapAsync(test); - + function next(err) { if (err) return callback(err); _test(check); } - + function check(err, truth) { if (err) return callback(err); if (!truth) return callback(null); _fn(next); } - + _test(check); } - + function _withoutIndex(iteratee) { return function (value, index, callback) { return iteratee(value, callback); }; } - + /** * Applies the function `iteratee` to each item in `coll`, in parallel. * The `iteratee` is called with an item from the list, and a callback for when @@ -5717,7 +5717,7 @@ function eachLimit(coll, iteratee, callback) { eachOf(coll, _withoutIndex(wrapAsync(iteratee)), callback); } - + /** * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time. * @@ -5741,7 +5741,7 @@ function eachLimit$1(coll, limit, iteratee, callback) { _eachOfLimit(limit)(coll, _withoutIndex(wrapAsync(iteratee)), callback); } - + /** * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time. * @@ -5762,7 +5762,7 @@ * `iteratee` functions have finished, or an error occurs. Invoked with (err). */ var eachSeries = doLimit(eachLimit$1, 1); - + /** * Wrap an async function and ensure it calls its callback on a later tick of * the event loop. If the function already calls its callback on a next tick, @@ -5816,11 +5816,11 @@ sync = false; }); } - + function notId(v) { return !v; } - + /** * Returns `true` if every element in `coll` satisfies an async test. If any * iteratee call returns `false`, the main `callback` is immediately called. @@ -5850,7 +5850,7 @@ * }); */ var every = doParallel(_createTester(notId, notId)); - + /** * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time. * @@ -5872,7 +5872,7 @@ * depending on the values of the async tests. Invoked with (err, result). */ var everyLimit = doParallelLimit(_createTester(notId, notId)); - + /** * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time. * @@ -5893,7 +5893,7 @@ * depending on the values of the async tests. Invoked with (err, result). */ var everySeries = doLimit(everyLimit, 1); - + /** * The base implementation of `_.property` without support for deep paths. * @@ -5906,7 +5906,7 @@ return object == null ? undefined : object[key]; }; } - + function filterArray(eachfn, arr, iteratee, callback) { var truthValues = new Array(arr.length); eachfn(arr, function (x, index, callback) { @@ -5923,7 +5923,7 @@ callback(null, results); }); } - + function filterGeneric(eachfn, coll, iteratee, callback) { var results = []; eachfn(coll, function (x, index, callback) { @@ -5947,12 +5947,12 @@ } }); } - + function _filter(eachfn, coll, iteratee, callback) { var filter = isArrayLike(coll) ? filterArray : filterGeneric; filter(eachfn, coll, wrapAsync(iteratee), callback || noop); } - + /** * Returns a new array of all the values in `coll` which pass an async truth * test. This operation is performed in parallel, but the results array will be @@ -5981,7 +5981,7 @@ * }); */ var filter = doParallel(_filter); - + /** * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a * time. @@ -6002,7 +6002,7 @@ * `iteratee` functions have finished. Invoked with (err, results). */ var filterLimit = doParallelLimit(_filter); - + /** * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time. * @@ -6021,11 +6021,11 @@ * `iteratee` functions have finished. Invoked with (err, results) */ var filterSeries = doLimit(filterLimit, 1); - + /** * Calls the asynchronous function `fn` with a callback parameter that allows it * to call itself again, in series, indefinitely. - + * If an error is passed to the callback then `errback` is called with the * error, and execution stops, otherwise it will never be called. * @@ -6054,14 +6054,14 @@ function forever(fn, errback) { var done = onlyOnce(errback || noop); var task = wrapAsync(ensureAsync(fn)); - + function next(err) { if (err) return done(err); task(next); } next(); } - + /** * The same as [`groupBy`]{@link module:Collections.groupBy} but runs a maximum of `limit` async operations at a time. * @@ -6093,12 +6093,12 @@ var result = {}; // from MDN, handle object having an `hasOwnProperty` prop var hasOwnProperty = Object.prototype.hasOwnProperty; - + for (var i = 0; i < mapResults.length; i++) { if (mapResults[i]) { var key = mapResults[i].key; var val = mapResults[i].val; - + if (hasOwnProperty.call(result, key)) { result[key].push(val); } else { @@ -6106,11 +6106,11 @@ } } } - + return callback(err, result); }); }; - + /** * Returns a new object, where each value corresponds to an array of items, from * `coll`, that returned the corresponding key. That is, the keys of the object @@ -6148,7 +6148,7 @@ * }); */ var groupBy = doLimit(groupByLimit, Infinity); - + /** * The same as [`groupBy`]{@link module:Collections.groupBy} but runs only a single async operation at a time. * @@ -6169,7 +6169,7 @@ * properties are arrays of values which returned the corresponding key. */ var groupBySeries = doLimit(groupByLimit, 1); - + /** * Logs the result of an `async` function to the `console`. Only works in * Node.js or in browsers that support `console.log` and `console.error` (such @@ -6198,7 +6198,7 @@ * 'hello world' */ var log = consoleFunc('log'); - + /** * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a * time. @@ -6234,7 +6234,7 @@ callback(err, newObj); }); } - + /** * A relative of [`map`]{@link module:Collections.map}, designed for use with objects. * @@ -6279,9 +6279,9 @@ * // } * }); */ - + var mapValues = doLimit(mapValuesLimit, Infinity); - + /** * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time. * @@ -6302,11 +6302,11 @@ * Invoked with (err, result). */ var mapValuesSeries = doLimit(mapValuesLimit, 1); - + function has(obj, key) { return key in obj; } - + /** * Caches the results of an async function. When creating a hash to store * function results against, the callback is omitted from the hash and an @@ -6374,7 +6374,7 @@ memoized.unmemoized = fn; return memoized; } - + /** * Calls `callback` on a later loop around the event loop. In Node.js this just * calls `process.nextTicl`. In the browser it will use `setImmediate` if @@ -6407,7 +6407,7 @@ * }, 1, 2, 3); */ var _defer$1; - + if (hasNextTick) { _defer$1 = process.nextTick; } else if (hasSetImmediate) { @@ -6415,13 +6415,13 @@ } else { _defer$1 = fallback; } - + var nextTick = wrap(_defer$1); - + function _parallel(eachfn, tasks, callback) { callback = callback || noop; var results = isArrayLike(tasks) ? [] : {}; - + eachfn(tasks, function (task, key, callback) { wrapAsync(task)(function (err, result) { if (arguments.length > 2) { @@ -6434,7 +6434,7 @@ callback(err, results); }); } - + /** * Run the `tasks` collection of functions in parallel, without waiting until * the previous function has completed. If any of the functions pass an error to @@ -6507,7 +6507,7 @@ function parallelLimit(tasks, callback) { _parallel(eachOf, tasks, callback); } - + /** * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a * time. @@ -6530,7 +6530,7 @@ function parallelLimit$1(tasks, limit, callback) { _parallel(_eachOfLimit(limit), tasks, callback); } - + /** * A queue of tasks for the worker function to complete. * @typedef {Object} QueueObject @@ -6584,7 +6584,7 @@ * empties remaining tasks from the queue forcing it to go idle. No more tasks * should be pushed to the queue after calling this function. Invoke with `queue.kill()`. */ - + /** * Creates a `queue` object with the specified `concurrency`. Tasks added to the * `queue` are processed in parallel (up to the `concurrency` limit). If all @@ -6642,7 +6642,7 @@ _worker(items[0], cb); }, concurrency, 1); }; - + /** * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and * completed in ascending priority order. @@ -6669,7 +6669,7 @@ var priorityQueue = function(worker, concurrency) { // Start with a normal queue var q = queue$1(worker, concurrency); - + // Override push to accept second parameter representing priority q.push = function(data, priority, callback) { if (callback == null) callback = noop; @@ -6686,20 +6686,20 @@ q.drain(); }); } - + priority = priority || 0; var nextNode = q._tasks.head; while (nextNode && priority >= nextNode.priority) { nextNode = nextNode.next; } - + for (var i = 0, l = data.length; i < l; i++) { var item = { data: data[i], priority: priority, callback: callback }; - + if (nextNode) { q._tasks.insertBefore(nextNode, item); } else { @@ -6708,13 +6708,13 @@ } setImmediate$1(q.process); }; - + // Remove unshift function delete q.unshift; - + return q; }; - + /** * Runs the `tasks` array of functions in parallel, without waiting until the * previous function has completed. Once any of the `tasks` complete or pass an @@ -6759,7 +6759,7 @@ wrapAsync(tasks[i])(callback); } } - + /** * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order. * @@ -6786,7 +6786,7 @@ var reversed = slice(array).reverse(); reduce(reversed, memo, iteratee, callback); } - + /** * Wraps the async function in another function that always completes with a * result object, even when it errors. @@ -6842,11 +6842,11 @@ reflectCallback(null, { value: value }); } }); - + return _fn.apply(this, args); }); } - + /** * A helper function that wraps an array or an object of functions with `reflect`. * @@ -6926,7 +6926,7 @@ } return results; } - + function reject$1(eachfn, arr, iteratee, callback) { _filter(eachfn, arr, function(value, cb) { iteratee(value, function(err, v) { @@ -6934,7 +6934,7 @@ }); }, callback); } - + /** * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test. * @@ -6963,7 +6963,7 @@ * }); */ var reject = doParallel(reject$1); - + /** * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a * time. @@ -6984,7 +6984,7 @@ * `iteratee` functions have finished. Invoked with (err, results). */ var rejectLimit = doParallelLimit(reject$1); - + /** * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time. * @@ -7003,7 +7003,7 @@ * `iteratee` functions have finished. Invoked with (err, results). */ var rejectSeries = doLimit(rejectLimit, 1); - + /** * Creates a function that returns `value`. * @@ -7028,7 +7028,7 @@ return value; }; } - + /** * Attempts to get a successful response from `task` no more than `times` times * before returning an error. If the task is successful, the `callback` will be @@ -7116,20 +7116,20 @@ function retry(opts, task, callback) { var DEFAULT_TIMES = 5; var DEFAULT_INTERVAL = 0; - + var options = { times: DEFAULT_TIMES, intervalFunc: constant$1(DEFAULT_INTERVAL) }; - + function parseTimes(acc, t) { if (typeof t === 'object') { acc.times = +t.times || DEFAULT_TIMES; - + acc.intervalFunc = typeof t.interval === 'function' ? t.interval : constant$1(+t.interval || DEFAULT_INTERVAL); - + acc.errorFilter = t.errorFilter; } else if (typeof t === 'number' || typeof t === 'string') { acc.times = +t || DEFAULT_TIMES; @@ -7137,7 +7137,7 @@ throw new Error("Invalid arguments for async.retry"); } } - + if (arguments.length < 3 && typeof opts === 'function') { callback = task || noop; task = opts; @@ -7145,13 +7145,13 @@ parseTimes(options, opts); callback = callback || noop; } - + if (typeof task !== 'function') { throw new Error("Invalid arguments for async.retry"); } - + var _task = wrapAsync(task); - + var attempt = 1; function retryAttempt() { _task(function(err) { @@ -7164,10 +7164,10 @@ } }); } - + retryAttempt(); } - + /** * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method * wraps a task and makes it retryable, rather than immediately calling it @@ -7206,13 +7206,13 @@ function taskFn(cb) { _task.apply(null, args.concat(cb)); } - + if (opts) retry(opts, taskFn, callback); else retry(taskFn, callback); - + }); }; - + /** * Run the functions in the `tasks` collection in series, each one running once * the previous function has completed. If any functions in the series pass an @@ -7280,7 +7280,7 @@ function series(tasks, callback) { _parallel(eachOfSeries, tasks, callback); } - + /** * Returns `true` if at least one element in the `coll` satisfies an async test. * If any iteratee call returns `true`, the main `callback` is immediately @@ -7312,7 +7312,7 @@ * }); */ var some = doParallel(_createTester(Boolean, identity)); - + /** * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time. * @@ -7335,7 +7335,7 @@ * tests. Invoked with (err, result). */ var someLimit = doParallelLimit(_createTester(Boolean, identity)); - + /** * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time. * @@ -7357,7 +7357,7 @@ * tests. Invoked with (err, result). */ var someSeries = doLimit(someLimit, 1); - + /** * Sorts a list by the results of running each `coll` value through an async * `iteratee`. @@ -7416,13 +7416,13 @@ if (err) return callback(err); callback(null, arrayMap(results.sort(comparator), baseProperty('value'))); }); - + function comparator(left, right) { var a = left.criteria, b = right.criteria; return a < b ? -1 : a > b ? 1 : 0; } } - + /** * Sets a time limit on an asynchronous function. If the function does not call * its callback within the specified milliseconds, it will be called with a @@ -7466,11 +7466,11 @@ */ function timeout(asyncFn, milliseconds, info) { var fn = wrapAsync(asyncFn); - + return initialParams(function (args, callback) { var timedOut = false; var timer; - + function timeoutCallback() { var name = asyncFn.name || 'anonymous'; var error = new Error('Callback function "' + name + '" timed out.'); @@ -7481,24 +7481,24 @@ timedOut = true; callback(error); } - + args.push(function () { if (!timedOut) { callback.apply(null, arguments); clearTimeout(timer); } }); - + // setup timer and call original function timer = setTimeout(timeoutCallback, milliseconds); fn.apply(null, args); }); } - + /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeCeil = Math.ceil; var nativeMax = Math.max; - + /** * The base implementation of `_.range` and `_.rangeRight` which doesn't * coerce arguments. @@ -7514,14 +7514,14 @@ var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result = Array(length); - + while (length--) { result[fromRight ? length : ++index] = start; start += step; } return result; } - + /** * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a * time. @@ -7542,7 +7542,7 @@ var _iteratee = wrapAsync(iteratee); mapLimit(baseRange(0, count, 1), limit, _iteratee, callback); } - + /** * Calls the `iteratee` function `n` times, and accumulates results in the same * manner you would use with [map]{@link module:Collections.map}. @@ -7576,7 +7576,7 @@ * }); */ var times = doLimit(timeLimit, Infinity); - + /** * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time. * @@ -7592,7 +7592,7 @@ * @param {Function} callback - see {@link module:Collections.map}. */ var timesSeries = doLimit(timeLimit, 1); - + /** * A relative of `reduce`. Takes an Object or Array, and iterates over each * element in series, each step potentially mutating an `accumulator` value. @@ -7643,14 +7643,14 @@ } callback = once(callback || noop); var _iteratee = wrapAsync(iteratee); - + eachOf(coll, function(v, k, cb) { _iteratee(accumulator, v, k, cb); }, function(err) { callback(err, accumulator); }); } - + /** * It runs each task in series but stops whenever any of the functions were * successful. If one of the tasks were successful, the `callback` will be @@ -7706,7 +7706,7 @@ callback(error, result); }); } - + /** * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original, * unmemoized form. Handy for testing. @@ -7725,7 +7725,7 @@ return (fn.unmemoized || fn).apply(null, arguments); }; } - + /** * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when * stopped, or an error occurs. @@ -7772,7 +7772,7 @@ }; _iteratee(next); } - + /** * Repeatedly call `iteratee` until `test` returns `true`. Calls `callback` when * stopped, or an error occurs. `callback` will be passed an error and any @@ -7800,7 +7800,7 @@ return !test.apply(this, arguments); }, iteratee, callback); } - + /** * Runs the `tasks` array of functions in series, each passing their results to * the next in the array. However, if any of the `tasks` pass an error to their @@ -7863,23 +7863,23 @@ if (!isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions')); if (!tasks.length) return callback(); var taskIndex = 0; - + function nextTask(args) { var task = wrapAsync(tasks[taskIndex++]); args.push(onlyOnce(next)); task.apply(null, args); } - + function next(err/*, ...args*/) { if (err || taskIndex === tasks.length) { return callback.apply(null, arguments); } nextTask(slice(arguments, 1)); } - + nextTask([]); }; - + /** * An "async function" in the context of Async is an asynchronous function with * a variable number of parameters, with the final parameter being a callback. @@ -7918,7 +7918,7 @@ * @typedef {Function} AsyncFunction * @static */ - + /** * Async is a utility module which provides straight-forward, powerful functions * for working with asynchronous JavaScript. Although originally designed for @@ -7927,24 +7927,24 @@ * @module async * @see AsyncFunction */ - - + + /** * A collection of `async` functions for manipulating collections, such as * arrays and objects. * @module Collections */ - + /** * A collection of `async` functions for controlling the flow through a script. * @module ControlFlow */ - + /** * A collection of `async` utility functions. * @module Utils */ - + var index = { apply: apply, applyEach: applyEach, @@ -8023,7 +8023,7 @@ until: until, waterfall: waterfall, whilst: whilst, - + // aliases all: every, allLimit: everyLimit, @@ -8048,7 +8048,7 @@ selectSeries: filterSeries, wrapSync: asyncify }; - + exports['default'] = index; exports.apply = apply; exports.applyEach = applyEach; @@ -8149,34 +8149,34 @@ exports.selectLimit = filterLimit; exports.selectSeries = filterSeries; exports.wrapSync = asyncify; - + Object.defineProperty(exports, '__esModule', { value: true }); - + }))); - + }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"_process":257}],22:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = eachLimit; - + var _eachOfLimit = require('./internal/eachOfLimit'); - + var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit); - + var _withoutIndex = require('./internal/withoutIndex'); - + var _withoutIndex2 = _interopRequireDefault(_withoutIndex); - + var _wrapAsync = require('./internal/wrapAsync'); - + var _wrapAsync2 = _interopRequireDefault(_wrapAsync); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + /** * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time. * @@ -8203,50 +8203,50 @@ module.exports = exports['default']; },{"./internal/eachOfLimit":29,"./internal/withoutIndex":39,"./internal/wrapAsync":40}],23:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); - + exports.default = function (coll, iteratee, callback) { var eachOfImplementation = (0, _isArrayLike2.default)(coll) ? eachOfArrayLike : eachOfGeneric; eachOfImplementation(coll, (0, _wrapAsync2.default)(iteratee), callback); }; - + var _isArrayLike = require('lodash/isArrayLike'); - + var _isArrayLike2 = _interopRequireDefault(_isArrayLike); - + var _breakLoop = require('./internal/breakLoop'); - + var _breakLoop2 = _interopRequireDefault(_breakLoop); - + var _eachOfLimit = require('./eachOfLimit'); - + var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit); - + var _doLimit = require('./internal/doLimit'); - + var _doLimit2 = _interopRequireDefault(_doLimit); - + var _noop = require('lodash/noop'); - + var _noop2 = _interopRequireDefault(_noop); - + var _once = require('./internal/once'); - + var _once2 = _interopRequireDefault(_once); - + var _onlyOnce = require('./internal/onlyOnce'); - + var _onlyOnce2 = _interopRequireDefault(_onlyOnce); - + var _wrapAsync = require('./internal/wrapAsync'); - + var _wrapAsync2 = _interopRequireDefault(_wrapAsync); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + // eachOf implementation optimized for array-likes function eachOfArrayLike(coll, iteratee, callback) { callback = (0, _once2.default)(callback || _noop2.default); @@ -8256,7 +8256,7 @@ if (length === 0) { callback(null); } - + function iteratorCallback(err, value) { if (err) { callback(err); @@ -8264,15 +8264,15 @@ callback(null); } } - + for (; index < length; index++) { iteratee(coll[index], index, (0, _onlyOnce2.default)(iteratorCallback)); } } - + // a generic version of eachOf which can handle array, object, and iterator cases. var eachOfGeneric = (0, _doLimit2.default)(_eachOfLimit2.default, Infinity); - + /** * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument * to the iteratee. @@ -8315,22 +8315,22 @@ module.exports = exports['default']; },{"./eachOfLimit":24,"./internal/breakLoop":26,"./internal/doLimit":27,"./internal/once":34,"./internal/onlyOnce":35,"./internal/wrapAsync":40,"lodash/isArrayLike":221,"lodash/noop":229}],24:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = eachOfLimit; - + var _eachOfLimit2 = require('./internal/eachOfLimit'); - + var _eachOfLimit3 = _interopRequireDefault(_eachOfLimit2); - + var _wrapAsync = require('./internal/wrapAsync'); - + var _wrapAsync2 = _interopRequireDefault(_wrapAsync); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + /** * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a * time. @@ -8357,21 +8357,21 @@ module.exports = exports['default']; },{"./internal/eachOfLimit":29,"./internal/wrapAsync":40}],25:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); - + var _eachLimit = require('./eachLimit'); - + var _eachLimit2 = _interopRequireDefault(_eachLimit); - + var _doLimit = require('./internal/doLimit'); - + var _doLimit2 = _interopRequireDefault(_doLimit); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + /** * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time. * @@ -8395,7 +8395,7 @@ module.exports = exports['default']; },{"./eachLimit":22,"./internal/doLimit":27}],26:[function(require,module,exports){ "use strict"; - + Object.defineProperty(exports, "__esModule", { value: true }); @@ -8405,7 +8405,7 @@ module.exports = exports["default"]; },{}],27:[function(require,module,exports){ "use strict"; - + Object.defineProperty(exports, "__esModule", { value: true }); @@ -8418,22 +8418,22 @@ module.exports = exports["default"]; },{}],28:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = doParallel; - + var _eachOf = require('../eachOf'); - + var _eachOf2 = _interopRequireDefault(_eachOf); - + var _wrapAsync = require('./wrapAsync'); - + var _wrapAsync2 = _interopRequireDefault(_wrapAsync); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + function doParallel(fn) { return function (obj, iteratee, callback) { return fn(_eachOf2.default, obj, (0, _wrapAsync2.default)(iteratee), callback); @@ -8442,34 +8442,34 @@ module.exports = exports['default']; },{"../eachOf":23,"./wrapAsync":40}],29:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = _eachOfLimit; - + var _noop = require('lodash/noop'); - + var _noop2 = _interopRequireDefault(_noop); - + var _once = require('./once'); - + var _once2 = _interopRequireDefault(_once); - + var _iterator = require('./iterator'); - + var _iterator2 = _interopRequireDefault(_iterator); - + var _onlyOnce = require('./onlyOnce'); - + var _onlyOnce2 = _interopRequireDefault(_onlyOnce); - + var _breakLoop = require('./breakLoop'); - + var _breakLoop2 = _interopRequireDefault(_breakLoop); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + function _eachOfLimit(limit) { return function (obj, iteratee, callback) { callback = (0, _once2.default)(callback || _noop2.default); @@ -8479,7 +8479,7 @@ var nextElem = (0, _iterator2.default)(obj); var done = false; var running = 0; - + function iterateeCallback(err, value) { running -= 1; if (err) { @@ -8492,7 +8492,7 @@ replenish(); } } - + function replenish() { while (running < limit && !done) { var elem = nextElem(); @@ -8507,32 +8507,32 @@ iteratee(elem.value, elem.key, (0, _onlyOnce2.default)(iterateeCallback)); } } - + replenish(); }; } module.exports = exports['default']; },{"./breakLoop":26,"./iterator":32,"./once":34,"./onlyOnce":35,"lodash/noop":229}],30:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); - + exports.default = function (coll) { return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol](); }; - + var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator; - + module.exports = exports['default']; },{}],31:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); - + exports.default = function (fn) { return function () /*...args, callback*/{ var args = (0, _slice2.default)(arguments); @@ -8540,36 +8540,36 @@ fn.call(this, args, callback); }; }; - + var _slice = require('./slice'); - + var _slice2 = _interopRequireDefault(_slice); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + module.exports = exports['default']; },{"./slice":38}],32:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = iterator; - + var _isArrayLike = require('lodash/isArrayLike'); - + var _isArrayLike2 = _interopRequireDefault(_isArrayLike); - + var _getIterator = require('./getIterator'); - + var _getIterator2 = _interopRequireDefault(_getIterator); - + var _keys = require('lodash/keys'); - + var _keys2 = _interopRequireDefault(_keys); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + function createArrayIterator(coll) { var i = -1; var len = coll.length; @@ -8577,7 +8577,7 @@ return ++i < len ? { value: coll[i], key: i } : null; }; } - + function createES2015Iterator(iterator) { var i = -1; return function next() { @@ -8587,7 +8587,7 @@ return { value: item.value, key: i }; }; } - + function createObjectIterator(obj) { var okeys = (0, _keys2.default)(obj); var i = -1; @@ -8597,41 +8597,41 @@ return i < len ? { value: obj[key], key: key } : null; }; } - + function iterator(coll) { if ((0, _isArrayLike2.default)(coll)) { return createArrayIterator(coll); } - + var iterator = (0, _getIterator2.default)(coll); return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll); } module.exports = exports['default']; },{"./getIterator":30,"lodash/isArrayLike":221,"lodash/keys":228}],33:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = _asyncMap; - + var _noop = require('lodash/noop'); - + var _noop2 = _interopRequireDefault(_noop); - + var _wrapAsync = require('./wrapAsync'); - + var _wrapAsync2 = _interopRequireDefault(_wrapAsync); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + function _asyncMap(eachfn, arr, iteratee, callback) { callback = callback || _noop2.default; arr = arr || []; var results = []; var counter = 0; var _iteratee = (0, _wrapAsync2.default)(iteratee); - + eachfn(arr, function (value, _, callback) { var index = counter++; _iteratee(value, function (err, v) { @@ -8645,7 +8645,7 @@ module.exports = exports['default']; },{"./wrapAsync":40,"lodash/noop":229}],34:[function(require,module,exports){ "use strict"; - + Object.defineProperty(exports, "__esModule", { value: true }); @@ -8661,7 +8661,7 @@ module.exports = exports["default"]; },{}],35:[function(require,module,exports){ "use strict"; - + Object.defineProperty(exports, "__esModule", { value: true }); @@ -8677,34 +8677,34 @@ module.exports = exports["default"]; },{}],36:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = _parallel; - + var _noop = require('lodash/noop'); - + var _noop2 = _interopRequireDefault(_noop); - + var _isArrayLike = require('lodash/isArrayLike'); - + var _isArrayLike2 = _interopRequireDefault(_isArrayLike); - + var _slice = require('./slice'); - + var _slice2 = _interopRequireDefault(_slice); - + var _wrapAsync = require('./wrapAsync'); - + var _wrapAsync2 = _interopRequireDefault(_wrapAsync); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + function _parallel(eachfn, tasks, callback) { callback = callback || _noop2.default; var results = (0, _isArrayLike2.default)(tasks) ? [] : {}; - + eachfn(tasks, function (task, key, callback) { (0, _wrapAsync2.default)(task)(function (err, result) { if (arguments.length > 2) { @@ -8721,27 +8721,27 @@ },{"./slice":38,"./wrapAsync":40,"lodash/isArrayLike":221,"lodash/noop":229}],37:[function(require,module,exports){ (function (process){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); exports.hasNextTick = exports.hasSetImmediate = undefined; exports.fallback = fallback; exports.wrap = wrap; - + var _slice = require('./slice'); - + var _slice2 = _interopRequireDefault(_slice); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + var hasSetImmediate = exports.hasSetImmediate = typeof setImmediate === 'function' && setImmediate; var hasNextTick = exports.hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function'; - + function fallback(fn) { setTimeout(fn, 0); } - + function wrap(defer) { return function (fn /*, ...args*/) { var args = (0, _slice2.default)(arguments, 1); @@ -8750,9 +8750,9 @@ }); }; } - + var _defer; - + if (hasSetImmediate) { _defer = setImmediate; } else if (hasNextTick) { @@ -8760,12 +8760,12 @@ } else { _defer = fallback; } - + exports.default = wrap(_defer); }).call(this,require('_process')) },{"./slice":38,"_process":257}],38:[function(require,module,exports){ "use strict"; - + Object.defineProperty(exports, "__esModule", { value: true }); @@ -8782,7 +8782,7 @@ module.exports = exports["default"]; },{}],39:[function(require,module,exports){ "use strict"; - + Object.defineProperty(exports, "__esModule", { value: true }); @@ -8795,47 +8795,47 @@ module.exports = exports["default"]; },{}],40:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); exports.isAsync = undefined; - + var _asyncify = require('../asyncify'); - + var _asyncify2 = _interopRequireDefault(_asyncify); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + var supportsSymbol = typeof Symbol === 'function'; - + function isAsync(fn) { return supportsSymbol && fn[Symbol.toStringTag] === 'AsyncFunction'; } - + function wrapAsync(asyncFn) { return isAsync(asyncFn) ? (0, _asyncify2.default)(asyncFn) : asyncFn; } - + exports.default = wrapAsync; exports.isAsync = isAsync; },{"../asyncify":20}],41:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); - + var _doParallel = require('./internal/doParallel'); - + var _doParallel2 = _interopRequireDefault(_doParallel); - + var _map = require('./internal/map'); - + var _map2 = _interopRequireDefault(_map); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + /** * Produces a new collection of values by mapping each value in `coll` through * the `iteratee` function. The `iteratee` is called with an item from `coll` @@ -8876,22 +8876,22 @@ module.exports = exports['default']; },{"./internal/doParallel":28,"./internal/map":33}],42:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = parallelLimit; - + var _eachOf = require('./eachOf'); - + var _eachOf2 = _interopRequireDefault(_eachOf); - + var _parallel = require('./internal/parallel'); - + var _parallel2 = _interopRequireDefault(_parallel); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + /** * Run the `tasks` collection of functions in parallel, without waiting until * the previous function has completed. If any of the functions pass an error to @@ -8967,26 +8967,26 @@ module.exports = exports['default']; },{"./eachOf":23,"./internal/parallel":36}],43:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); exports.default = retry; - + var _noop = require('lodash/noop'); - + var _noop2 = _interopRequireDefault(_noop); - + var _constant = require('lodash/constant'); - + var _constant2 = _interopRequireDefault(_constant); - + var _wrapAsync = require('./internal/wrapAsync'); - + var _wrapAsync2 = _interopRequireDefault(_wrapAsync); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + /** * Attempts to get a successful response from `task` no more than `times` times * before returning an error. If the task is successful, the `callback` will be @@ -9074,18 +9074,18 @@ function retry(opts, task, callback) { var DEFAULT_TIMES = 5; var DEFAULT_INTERVAL = 0; - + var options = { times: DEFAULT_TIMES, intervalFunc: (0, _constant2.default)(DEFAULT_INTERVAL) }; - + function parseTimes(acc, t) { if (typeof t === 'object') { acc.times = +t.times || DEFAULT_TIMES; - + acc.intervalFunc = typeof t.interval === 'function' ? t.interval : (0, _constant2.default)(+t.interval || DEFAULT_INTERVAL); - + acc.errorFilter = t.errorFilter; } else if (typeof t === 'number' || typeof t === 'string') { acc.times = +t || DEFAULT_TIMES; @@ -9093,7 +9093,7 @@ throw new Error("Invalid arguments for async.retry"); } } - + if (arguments.length < 3 && typeof opts === 'function') { callback = task || _noop2.default; task = opts; @@ -9101,13 +9101,13 @@ parseTimes(options, opts); callback = callback || _noop2.default; } - + if (typeof task !== 'function') { throw new Error("Invalid arguments for async.retry"); } - + var _task = (0, _wrapAsync2.default)(task); - + var attempt = 1; function retryAttempt() { _task(function (err) { @@ -9118,67 +9118,67 @@ } }); } - + retryAttempt(); } module.exports = exports['default']; },{"./internal/wrapAsync":40,"lodash/constant":218,"lodash/noop":229}],44:[function(require,module,exports){ 'use strict'; - + Object.defineProperty(exports, "__esModule", { value: true }); - + exports.default = function (tasks, callback) { callback = (0, _once2.default)(callback || _noop2.default); if (!(0, _isArray2.default)(tasks)) return callback(new Error('First argument to waterfall must be an array of functions')); if (!tasks.length) return callback(); var taskIndex = 0; - + function nextTask(args) { var task = (0, _wrapAsync2.default)(tasks[taskIndex++]); args.push((0, _onlyOnce2.default)(next)); task.apply(null, args); } - + function next(err /*, ...args*/) { if (err || taskIndex === tasks.length) { return callback.apply(null, arguments); } nextTask((0, _slice2.default)(arguments, 1)); } - + nextTask([]); }; - + var _isArray = require('lodash/isArray'); - + var _isArray2 = _interopRequireDefault(_isArray); - + var _noop = require('lodash/noop'); - + var _noop2 = _interopRequireDefault(_noop); - + var _once = require('./internal/once'); - + var _once2 = _interopRequireDefault(_once); - + var _slice = require('./internal/slice'); - + var _slice2 = _interopRequireDefault(_slice); - + var _onlyOnce = require('./internal/onlyOnce'); - + var _onlyOnce2 = _interopRequireDefault(_onlyOnce); - + var _wrapAsync = require('./internal/wrapAsync'); - + var _wrapAsync2 = _interopRequireDefault(_wrapAsync); - + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - + module.exports = exports['default']; - + /** * Runs the `tasks` array of functions in series, each passing their results to * the next in the array. However, if any of the `tasks` pass an error to their @@ -9239,27 +9239,27 @@ },{"./internal/once":34,"./internal/onlyOnce":35,"./internal/slice":38,"./internal/wrapAsync":40,"lodash/isArray":220,"lodash/noop":229}],45:[function(require,module,exports){ // Copyright (c) 2012 Mathieu Turcotte // Licensed under the MIT license. - + var Backoff = require('./lib/backoff'); var ExponentialBackoffStrategy = require('./lib/strategy/exponential'); var FibonacciBackoffStrategy = require('./lib/strategy/fibonacci'); var FunctionCall = require('./lib/function_call.js'); - + module.exports.Backoff = Backoff; module.exports.FunctionCall = FunctionCall; module.exports.FibonacciStrategy = FibonacciBackoffStrategy; module.exports.ExponentialStrategy = ExponentialBackoffStrategy; - + // Constructs a Fibonacci backoff. module.exports.fibonacci = function(options) { return new Backoff(new FibonacciBackoffStrategy(options)); }; - + // Constructs an exponential backoff. module.exports.exponential = function(options) { return new Backoff(new ExponentialBackoffStrategy(options)); }; - + // Constructs a FunctionCall for the given function and arguments. module.exports.call = function(fn, vargs, callback) { var args = Array.prototype.slice.call(arguments); @@ -9268,47 +9268,47 @@ callback = args[args.length - 1]; return new FunctionCall(fn, vargs, callback); }; - + },{"./lib/backoff":46,"./lib/function_call.js":47,"./lib/strategy/exponential":48,"./lib/strategy/fibonacci":49}],46:[function(require,module,exports){ // Copyright (c) 2012 Mathieu Turcotte // Licensed under the MIT license. - + var events = require('events'); var precond = require('precond'); var util = require('util'); - + // A class to hold the state of a backoff operation. Accepts a backoff strategy // to generate the backoff delays. function Backoff(backoffStrategy) { events.EventEmitter.call(this); - + this.backoffStrategy_ = backoffStrategy; this.maxNumberOfRetry_ = -1; this.backoffNumber_ = 0; this.backoffDelay_ = 0; this.timeoutID_ = -1; - + this.handlers = { backoff: this.onBackoff_.bind(this) }; } util.inherits(Backoff, events.EventEmitter); - + // Sets a limit, greater than 0, on the maximum number of backoffs. A 'fail' // event will be emitted when the limit is reached. Backoff.prototype.failAfter = function(maxNumberOfRetry) { precond.checkArgument(maxNumberOfRetry > 0, 'Expected a maximum number of retry greater than 0 but got %s.', maxNumberOfRetry); - + this.maxNumberOfRetry_ = maxNumberOfRetry; }; - + // Starts a backoff operation. Accepts an optional parameter to let the // listeners know why the backoff operation was started. Backoff.prototype.backoff = function(err) { precond.checkState(this.timeoutID_ === -1, 'Backoff in progress.'); - + if (this.backoffNumber_ === this.maxNumberOfRetry_) { this.emit('fail', err); this.reset(); @@ -9318,14 +9318,14 @@ this.emit('backoff', this.backoffNumber_, this.backoffDelay_, err); } }; - + // Handles the backoff timeout completion. Backoff.prototype.onBackoff_ = function() { this.timeoutID_ = -1; this.emit('ready', this.backoffNumber_, this.backoffDelay_); this.backoffNumber_++; }; - + // Stops any backoff operation and resets the backoff delay to its inital value. Backoff.prototype.reset = function() { this.backoffNumber_ = 0; @@ -9333,43 +9333,43 @@ clearTimeout(this.timeoutID_); this.timeoutID_ = -1; }; - + module.exports = Backoff; - + },{"events":157,"precond":253,"util":333}],47:[function(require,module,exports){ // Copyright (c) 2012 Mathieu Turcotte // Licensed under the MIT license. - + var events = require('events'); var precond = require('precond'); var util = require('util'); - + var Backoff = require('./backoff'); var FibonacciBackoffStrategy = require('./strategy/fibonacci'); - + // Wraps a function to be called in a backoff loop. function FunctionCall(fn, args, callback) { events.EventEmitter.call(this); - + precond.checkIsFunction(fn, 'Expected fn to be a function.'); precond.checkIsArray(args, 'Expected args to be an array.'); precond.checkIsFunction(callback, 'Expected callback to be a function.'); - + this.function_ = fn; this.arguments_ = args; this.callback_ = callback; this.lastResult_ = []; this.numRetries_ = 0; - + this.backoff_ = null; this.strategy_ = null; this.failAfter_ = -1; this.retryPredicate_ = FunctionCall.DEFAULT_RETRY_PREDICATE_; - + this.state_ = FunctionCall.State_.PENDING; } util.inherits(FunctionCall, events.EventEmitter); - + // States in which the call can be. FunctionCall.State_ = { // Call isn't started yet. @@ -9382,32 +9382,32 @@ // The call was aborted. ABORTED: 3 }; - + // The default retry predicate which considers any error as retriable. FunctionCall.DEFAULT_RETRY_PREDICATE_ = function(err) { return true; }; - + // Checks whether the call is pending. FunctionCall.prototype.isPending = function() { return this.state_ == FunctionCall.State_.PENDING; }; - + // Checks whether the call is in progress. FunctionCall.prototype.isRunning = function() { return this.state_ == FunctionCall.State_.RUNNING; }; - + // Checks whether the call is completed. FunctionCall.prototype.isCompleted = function() { return this.state_ == FunctionCall.State_.COMPLETED; }; - + // Checks whether the call is aborted. FunctionCall.prototype.isAborted = function() { return this.state_ == FunctionCall.State_.ABORTED; }; - + // Sets the backoff strategy to use. Can only be called before the call is // started otherwise an exception will be thrown. FunctionCall.prototype.setStrategy = function(strategy) { @@ -9415,7 +9415,7 @@ this.strategy_ = strategy; return this; // Return this for chaining. }; - + // Sets the predicate which will be used to determine whether the errors // returned from the wrapped function should be retried or not, e.g. a // network error would be retriable while a type error would stop the @@ -9425,65 +9425,65 @@ this.retryPredicate_ = retryPredicate; return this; }; - + // Returns all intermediary results returned by the wrapped function since // the initial call. FunctionCall.prototype.getLastResult = function() { return this.lastResult_.concat(); }; - + // Returns the number of times the wrapped function call was retried. FunctionCall.prototype.getNumRetries = function() { return this.numRetries_; }; - + // Sets the backoff limit. FunctionCall.prototype.failAfter = function(maxNumberOfRetry) { precond.checkState(this.isPending(), 'FunctionCall in progress.'); this.failAfter_ = maxNumberOfRetry; return this; // Return this for chaining. }; - + // Aborts the call. FunctionCall.prototype.abort = function() { if (this.isCompleted() || this.isAborted()) { return; } - + if (this.isRunning()) { this.backoff_.reset(); } - + this.state_ = FunctionCall.State_.ABORTED; this.lastResult_ = [new Error('Backoff aborted.')]; this.emit('abort'); this.doCallback_(); }; - + // Initiates the call to the wrapped function. Accepts an optional factory // function used to create the backoff instance; used when testing. FunctionCall.prototype.start = function(backoffFactory) { precond.checkState(!this.isAborted(), 'FunctionCall is aborted.'); precond.checkState(this.isPending(), 'FunctionCall already started.'); - + var strategy = this.strategy_ || new FibonacciBackoffStrategy(); - + this.backoff_ = backoffFactory ? backoffFactory(strategy) : new Backoff(strategy); - + this.backoff_.on('ready', this.doCall_.bind(this, true /* isRetry */)); this.backoff_.on('fail', this.doCallback_.bind(this)); this.backoff_.on('backoff', this.handleBackoff_.bind(this)); - + if (this.failAfter_ > 0) { this.backoff_.failAfter(this.failAfter_); } - + this.state_ = FunctionCall.State_.RUNNING; this.doCall_(false /* isRetry */); }; - + // Calls the wrapped function. FunctionCall.prototype.doCall_ = function(isRetry) { if (isRetry) { @@ -9494,24 +9494,24 @@ var callback = this.handleFunctionCallback_.bind(this); this.function_.apply(null, this.arguments_.concat(callback)); }; - + // Calls the wrapped function's callback with the last result returned by the // wrapped function. FunctionCall.prototype.doCallback_ = function() { this.callback_.apply(null, this.lastResult_); }; - + // Handles wrapped function's completion. This method acts as a replacement // for the original callback function. FunctionCall.prototype.handleFunctionCallback_ = function() { if (this.isAborted()) { return; } - + var args = Array.prototype.slice.call(arguments); this.lastResult_ = args; // Save last callback arguments. events.EventEmitter.prototype.emit.apply(this, ['callback'].concat(args)); - + var err = args[0]; if (err && this.retryPredicate_(err)) { this.backoff_.backoff(err); @@ -9520,30 +9520,30 @@ this.doCallback_(); } }; - + // Handles the backoff event by reemitting it. FunctionCall.prototype.handleBackoff_ = function(number, delay, err) { this.emit('backoff', number, delay, err); }; - + module.exports = FunctionCall; - + },{"./backoff":46,"./strategy/fibonacci":49,"events":157,"precond":253,"util":333}],48:[function(require,module,exports){ // Copyright (c) 2012 Mathieu Turcotte // Licensed under the MIT license. - + var util = require('util'); var precond = require('precond'); - + var BackoffStrategy = require('./strategy'); - + // Exponential backoff strategy. function ExponentialBackoffStrategy(options) { BackoffStrategy.call(this, options); this.backoffDelay_ = 0; this.nextBackoffDelay_ = this.getInitialDelay(); this.factor_ = ExponentialBackoffStrategy.DEFAULT_FACTOR; - + if (options && options.factor !== undefined) { precond.checkArgument(options.factor > 1, 'Exponential factor should be greater than 1 but got %s.', @@ -9552,33 +9552,33 @@ } } util.inherits(ExponentialBackoffStrategy, BackoffStrategy); - + // Default multiplication factor used to compute the next backoff delay from // the current one. The value can be overridden by passing a custom factor as // part of the options. ExponentialBackoffStrategy.DEFAULT_FACTOR = 2; - + ExponentialBackoffStrategy.prototype.next_ = function() { this.backoffDelay_ = Math.min(this.nextBackoffDelay_, this.getMaxDelay()); this.nextBackoffDelay_ = this.backoffDelay_ * this.factor_; return this.backoffDelay_; }; - + ExponentialBackoffStrategy.prototype.reset_ = function() { this.backoffDelay_ = 0; this.nextBackoffDelay_ = this.getInitialDelay(); }; - + module.exports = ExponentialBackoffStrategy; - + },{"./strategy":50,"precond":253,"util":333}],49:[function(require,module,exports){ // Copyright (c) 2012 Mathieu Turcotte // Licensed under the MIT license. - + var util = require('util'); - + var BackoffStrategy = require('./strategy'); - + // Fibonacci backoff strategy. function FibonacciBackoffStrategy(options) { BackoffStrategy.call(this, options); @@ -9586,32 +9586,32 @@ this.nextBackoffDelay_ = this.getInitialDelay(); } util.inherits(FibonacciBackoffStrategy, BackoffStrategy); - + FibonacciBackoffStrategy.prototype.next_ = function() { var backoffDelay = Math.min(this.nextBackoffDelay_, this.getMaxDelay()); this.nextBackoffDelay_ += this.backoffDelay_; this.backoffDelay_ = backoffDelay; return backoffDelay; }; - + FibonacciBackoffStrategy.prototype.reset_ = function() { this.nextBackoffDelay_ = this.getInitialDelay(); this.backoffDelay_ = 0; }; - + module.exports = FibonacciBackoffStrategy; - + },{"./strategy":50,"util":333}],50:[function(require,module,exports){ // Copyright (c) 2012 Mathieu Turcotte // Licensed under the MIT license. - + var events = require('events'); var util = require('util'); - + function isDef(value) { return value !== undefined && value !== null; } - + // Abstract class defining the skeleton for the backoff strategies. Accepts an // object holding the options for the backoff strategy: // @@ -9622,39 +9622,39 @@ // * `maxDelay`: The backoff maximal delay in milliseconds. function BackoffStrategy(options) { options = options || {}; - + if (isDef(options.initialDelay) && options.initialDelay < 1) { throw new Error('The initial timeout must be greater than 0.'); } else if (isDef(options.maxDelay) && options.maxDelay < 1) { throw new Error('The maximal timeout must be greater than 0.'); } - + this.initialDelay_ = options.initialDelay || 100; this.maxDelay_ = options.maxDelay || 10000; - + if (this.maxDelay_ <= this.initialDelay_) { throw new Error('The maximal backoff delay must be ' + 'greater than the initial backoff delay.'); } - + if (isDef(options.randomisationFactor) && (options.randomisationFactor < 0 || options.randomisationFactor > 1)) { throw new Error('The randomisation factor must be between 0 and 1.'); } - + this.randomisationFactor_ = options.randomisationFactor || 0; } - + // Gets the maximal backoff delay. BackoffStrategy.prototype.getMaxDelay = function() { return this.maxDelay_; }; - + // Gets the initial backoff delay. BackoffStrategy.prototype.getInitialDelay = function() { return this.initialDelay_; }; - + // Template method that computes and returns the next backoff delay in // milliseconds. BackoffStrategy.prototype.next = function() { @@ -9663,52 +9663,52 @@ var randomizedDelay = Math.round(backoffDelay * randomisationMultiple); return randomizedDelay; }; - + // Computes and returns the next backoff delay. Intended to be overridden by // subclasses. BackoffStrategy.prototype.next_ = function() { throw new Error('BackoffStrategy.next_() unimplemented.'); }; - + // Template method that resets the backoff delay to its initial value. BackoffStrategy.prototype.reset = function() { this.reset_(); }; - + // Resets the backoff delay to its initial value. Intended to be overridden by // subclasses. BackoffStrategy.prototype.reset_ = function() { throw new Error('BackoffStrategy.reset_() unimplemented.'); }; - + module.exports = BackoffStrategy; - + },{"events":157,"util":333}],51:[function(require,module,exports){ 'use strict' - + exports.byteLength = byteLength exports.toByteArray = toByteArray exports.fromByteArray = fromByteArray - + var lookup = [] var revLookup = [] var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array - + var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' for (var i = 0, len = code.length; i < len; ++i) { lookup[i] = code[i] revLookup[code.charCodeAt(i)] = i } - + revLookup['-'.charCodeAt(0)] = 62 revLookup['_'.charCodeAt(0)] = 63 - + function placeHoldersCount (b64) { var len = b64.length if (len % 4 > 0) { throw new Error('Invalid string. Length must be a multiple of 4') } - + // the number of equal signs (place holders) // if there are two placeholders, than the two characters before it // represent one byte @@ -9716,31 +9716,31 @@ // this is just a cheap hack to not do indexOf twice return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 } - + function byteLength (b64) { // base64 is 4/3 + up to two characters of the original data return (b64.length * 3 / 4) - placeHoldersCount(b64) } - + function toByteArray (b64) { var i, l, tmp, placeHolders, arr var len = b64.length placeHolders = placeHoldersCount(b64) - + arr = new Arr((len * 3 / 4) - placeHolders) - + // if there are placeholders, only get up to the last complete 4 chars l = placeHolders > 0 ? len - 4 : len - + var L = 0 - + for (i = 0; i < l; i += 4) { tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] arr[L++] = (tmp >> 16) & 0xFF arr[L++] = (tmp >> 8) & 0xFF arr[L++] = tmp & 0xFF } - + if (placeHolders === 2) { tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) arr[L++] = tmp & 0xFF @@ -9749,14 +9749,14 @@ arr[L++] = (tmp >> 8) & 0xFF arr[L++] = tmp & 0xFF } - + return arr } - + function tripletToBase64 (num) { return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] } - + function encodeChunk (uint8, start, end) { var tmp var output = [] @@ -9766,7 +9766,7 @@ } return output.join('') } - + function fromByteArray (uint8) { var tmp var len = uint8.length @@ -9774,12 +9774,12 @@ var output = '' var parts = [] var maxChunkLength = 16383 // must be multiple of 3 - + // go through the array every three bytes, we'll deal with trailing stuff later for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) } - + // pad the end with zeros, but make sure to not forget the extra bytes if (extraBytes === 1) { tmp = uint8[len - 1] @@ -9793,72 +9793,72 @@ output += lookup[(tmp << 2) & 0x3F] output += '=' } - + parts.push(output) - + return parts.join('') } - + },{}],52:[function(require,module,exports){ // Reference https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki // Format: 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S] // NOTE: SIGHASH byte ignored AND restricted, truncate before use - + var Buffer = require('safe-buffer').Buffer - + function check (buffer) { if (buffer.length < 8) return false if (buffer.length > 72) return false if (buffer[0] !== 0x30) return false if (buffer[1] !== buffer.length - 2) return false if (buffer[2] !== 0x02) return false - + var lenR = buffer[3] if (lenR === 0) return false if (5 + lenR >= buffer.length) return false if (buffer[4 + lenR] !== 0x02) return false - + var lenS = buffer[5 + lenR] if (lenS === 0) return false if ((6 + lenR + lenS) !== buffer.length) return false - + if (buffer[4] & 0x80) return false if (lenR > 1 && (buffer[4] === 0x00) && !(buffer[5] & 0x80)) return false - + if (buffer[lenR + 6] & 0x80) return false if (lenS > 1 && (buffer[lenR + 6] === 0x00) && !(buffer[lenR + 7] & 0x80)) return false return true } - + function decode (buffer) { if (buffer.length < 8) throw new Error('DER sequence length is too short') if (buffer.length > 72) throw new Error('DER sequence length is too long') if (buffer[0] !== 0x30) throw new Error('Expected DER sequence') if (buffer[1] !== buffer.length - 2) throw new Error('DER sequence length is invalid') if (buffer[2] !== 0x02) throw new Error('Expected DER integer') - + var lenR = buffer[3] if (lenR === 0) throw new Error('R length is zero') if (5 + lenR >= buffer.length) throw new Error('R length is too long') if (buffer[4 + lenR] !== 0x02) throw new Error('Expected DER integer (2)') - + var lenS = buffer[5 + lenR] if (lenS === 0) throw new Error('S length is zero') if ((6 + lenR + lenS) !== buffer.length) throw new Error('S length is invalid') - + if (buffer[4] & 0x80) throw new Error('R value is negative') if (lenR > 1 && (buffer[4] === 0x00) && !(buffer[5] & 0x80)) throw new Error('R value excessively padded') - + if (buffer[lenR + 6] & 0x80) throw new Error('S value is negative') if (lenS > 1 && (buffer[lenR + 6] === 0x00) && !(buffer[lenR + 7] & 0x80)) throw new Error('S value excessively padded') - + // non-BIP66 - extract R, S values return { r: buffer.slice(4, 4 + lenR), s: buffer.slice(6 + lenR) } } - + /* * Expects r and s to be positive DER integers. * @@ -9892,9 +9892,9 @@ if (s[0] & 0x80) throw new Error('S value is negative') if (lenR > 1 && (r[0] === 0x00) && !(r[1] & 0x80)) throw new Error('R value excessively padded') if (lenS > 1 && (s[0] === 0x00) && !(s[1] & 0x80)) throw new Error('S value excessively padded') - + var signature = Buffer.allocUnsafe(6 + lenR + lenS) - + // 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S] signature[0] = 0x30 signature[1] = signature.length - 2 @@ -9904,25 +9904,25 @@ signature[4 + lenR] = 0x02 signature[5 + lenR] = s.length s.copy(signature, 6 + lenR) - + return signature } - + module.exports = { check: check, decode: decode, encode: encode } - + },{"safe-buffer":290}],53:[function(require,module,exports){ (function (module, exports) { 'use strict'; - + // Utils function assert (val, msg) { if (!val) throw new Error(msg || 'Assertion failed'); } - + // Could use `inherits` module, but don't want to move from single file // architecture yet. function inherits (ctor, superCtor) { @@ -9932,27 +9932,27 @@ ctor.prototype = new TempCtor(); ctor.prototype.constructor = ctor; } - + // BN - + function BN (number, base, endian) { if (BN.isBN(number)) { return number; } - + this.negative = 0; this.words = null; this.length = 0; - + // Reduction context this.red = null; - + if (number !== null) { if (base === 'le' || base === 'be') { endian = base; base = 10; } - + this._init(number || 0, base || 10, endian || 'be'); } } @@ -9961,72 +9961,72 @@ } else { exports.BN = BN; } - + BN.BN = BN; BN.wordSize = 26; - + var Buffer; try { Buffer = require('buffer').Buffer; } catch (e) { } - + BN.isBN = function isBN (num) { if (num instanceof BN) { return true; } - + return num !== null && typeof num === 'object' && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); }; - + BN.max = function max (left, right) { if (left.cmp(right) > 0) return left; return right; }; - + BN.min = function min (left, right) { if (left.cmp(right) < 0) return left; return right; }; - + BN.prototype._init = function init (number, base, endian) { if (typeof number === 'number') { return this._initNumber(number, base, endian); } - + if (typeof number === 'object') { return this._initArray(number, base, endian); } - + if (base === 'hex') { base = 16; } assert(base === (base | 0) && base >= 2 && base <= 36); - + number = number.toString().replace(/\s+/g, ''); var start = 0; if (number[0] === '-') { start++; } - + if (base === 16) { this._parseHex(number, start); } else { this._parseBase(number, base, start); } - + if (number[0] === '-') { this.negative = 1; } - + this.strip(); - + if (endian !== 'le') return; - + this._initArray(this.toArray(), base, endian); }; - + BN.prototype._initNumber = function _initNumber (number, base, endian) { if (number < 0) { this.negative = 1; @@ -10050,13 +10050,13 @@ ]; this.length = 3; } - + if (endian !== 'le') return; - + // Reverse the bytes this._initArray(this.toArray(), base, endian); }; - + BN.prototype._initArray = function _initArray (number, base, endian) { // Perhaps a Uint8Array assert(typeof number.length === 'number'); @@ -10065,13 +10065,13 @@ this.length = 1; return this; } - + this.length = Math.ceil(number.length / 3); this.words = new Array(this.length); for (var i = 0; i < this.length; i++) { this.words[i] = 0; } - + var j, w; var off = 0; if (endian === 'be') { @@ -10099,23 +10099,23 @@ } return this.strip(); }; - + function parseHex (str, start, end) { var r = 0; var len = Math.min(str.length, end); for (var i = start; i < len; i++) { var c = str.charCodeAt(i) - 48; - + r <<= 4; - + // 'a' - 'f' if (c >= 49 && c <= 54) { r |= c - 49 + 0xa; - + // 'A' - 'F' } else if (c >= 17 && c <= 22) { r |= c - 17 + 0xa; - + // '0' - '9' } else { r |= c & 0xf; @@ -10123,7 +10123,7 @@ } return r; } - + BN.prototype._parseHex = function _parseHex (number, start) { // Create possibly bigger array to ensure that it fits the number this.length = Math.ceil((number.length - start) / 6); @@ -10131,7 +10131,7 @@ for (var i = 0; i < this.length; i++) { this.words[i] = 0; } - + var j, w; // Scan 24-bit chunks and add them to the number var off = 0; @@ -10153,23 +10153,23 @@ } this.strip(); }; - + function parseBase (str, start, end, mul) { var r = 0; var len = Math.min(str.length, end); for (var i = start; i < len; i++) { var c = str.charCodeAt(i) - 48; - + r *= mul; - + // 'a' if (c >= 49) { r += c - 49 + 0xa; - + // 'A' } else if (c >= 17) { r += c - 17 + 0xa; - + // '0' - '9' } else { r += c; @@ -10177,27 +10177,27 @@ } return r; } - + BN.prototype._parseBase = function _parseBase (number, base, start) { // Initialize as zero this.words = [ 0 ]; this.length = 1; - + // Find length of limb in base for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { limbLen++; } limbLen--; limbPow = (limbPow / base) | 0; - + var total = number.length - start; var mod = total % limbLen; var end = Math.min(total, total - mod) + start; - + var word = 0; for (var i = start; i < end; i += limbLen) { word = parseBase(number, i, i + limbLen, base); - + this.imuln(limbPow); if (this.words[0] + word < 0x4000000) { this.words[0] += word; @@ -10205,15 +10205,15 @@ this._iaddn(word); } } - + if (mod !== 0) { var pow = 1; word = parseBase(number, i, number.length, base); - + for (i = 0; i < mod; i++) { pow *= base; } - + this.imuln(pow); if (this.words[0] + word < 0x4000000) { this.words[0] += word; @@ -10222,7 +10222,7 @@ } } }; - + BN.prototype.copy = function copy (dest) { dest.words = new Array(this.length); for (var i = 0; i < this.length; i++) { @@ -10232,20 +10232,20 @@ dest.negative = this.negative; dest.red = this.red; }; - + BN.prototype.clone = function clone () { var r = new BN(null); this.copy(r); return r; }; - + BN.prototype._expand = function _expand (size) { while (this.length < size) { this.words[this.length++] = 0; } return this; }; - + // Remove leading `0` from `this` BN.prototype.strip = function strip () { while (this.length > 1 && this.words[this.length - 1] === 0) { @@ -10253,7 +10253,7 @@ } return this._normSign(); }; - + BN.prototype._normSign = function _normSign () { // -0 = 0 if (this.length === 1 && this.words[0] === 0) { @@ -10261,17 +10261,17 @@ } return this; }; - + BN.prototype.inspect = function inspect () { return (this.red ? ''; }; - + /* - + var zeros = []; var groupSizes = []; var groupBases = []; - + var s = ''; var i = -1; while (++i < BN.wordSize) { @@ -10293,9 +10293,9 @@ groupSizes[base] = groupSize; groupBases[base] = groupBase; } - + */ - + var zeros = [ '', '0', @@ -10324,7 +10324,7 @@ '000000000000000000000000', '0000000000000000000000000' ]; - + var groupSizes = [ 0, 0, 25, 16, 12, 11, 10, 9, 8, @@ -10333,7 +10333,7 @@ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 ]; - + var groupBases = [ 0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, @@ -10342,11 +10342,11 @@ 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 ]; - + BN.prototype.toString = function toString (base, padding) { base = base || 10; padding = padding | 0 || 1; - + var out; if (base === 16 || base === 'hex') { out = ''; @@ -10378,7 +10378,7 @@ } return out; } - + if (base === (base | 0) && base >= 2 && base <= 36) { // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); var groupSize = groupSizes[base]; @@ -10390,7 +10390,7 @@ while (!c.isZero()) { var r = c.modn(groupBase).toString(base); c = c.idivn(groupBase); - + if (!c.isZero()) { out = zeros[groupSize - r.length] + r + out; } else { @@ -10408,10 +10408,10 @@ } return out; } - + assert(false, 'Base should be between 2 and 36'); }; - + BN.prototype.toNumber = function toNumber () { var ret = this.words[0]; if (this.length === 2) { @@ -10424,30 +10424,30 @@ } return (this.negative !== 0) ? -ret : ret; }; - + BN.prototype.toJSON = function toJSON () { return this.toString(16); }; - + BN.prototype.toBuffer = function toBuffer (endian, length) { assert(typeof Buffer !== 'undefined'); return this.toArrayLike(Buffer, endian, length); }; - + BN.prototype.toArray = function toArray (endian, length) { return this.toArrayLike(Array, endian, length); }; - + BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { var byteLength = this.byteLength(); var reqLength = length || Math.max(1, byteLength); assert(byteLength <= reqLength, 'byte array longer than desired length'); assert(reqLength > 0, 'Requested array length <= 0'); - + this.strip(); var littleEndian = endian === 'le'; var res = new ArrayType(reqLength); - + var b, i; var q = this.clone(); if (!littleEndian) { @@ -10455,29 +10455,29 @@ for (i = 0; i < reqLength - byteLength; i++) { res[i] = 0; } - + for (i = 0; !q.isZero(); i++) { b = q.andln(0xff); q.iushrn(8); - + res[reqLength - i - 1] = b; } } else { for (i = 0; !q.isZero(); i++) { b = q.andln(0xff); q.iushrn(8); - + res[i] = b; } - + for (; i < reqLength; i++) { res[i] = 0; } } - + return res; }; - + if (Math.clz32) { BN.prototype._countBits = function _countBits (w) { return 32 - Math.clz32(w); @@ -10505,11 +10505,11 @@ return r + t; }; } - + BN.prototype._zeroBits = function _zeroBits (w) { // Short-cut if (w === 0) return 26; - + var t = w; var r = 0; if ((t & 0x1fff) === 0) { @@ -10533,31 +10533,31 @@ } return r; }; - + // Return number of used bits in a BN BN.prototype.bitLength = function bitLength () { var w = this.words[this.length - 1]; var hi = this._countBits(w); return (this.length - 1) * 26 + hi; }; - + function toBitArray (num) { var w = new Array(num.bitLength()); - + for (var bit = 0; bit < w.length; bit++) { var off = (bit / 26) | 0; var wbit = bit % 26; - + w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; } - + return w; } - + // Number of trailing zero bits BN.prototype.zeroBits = function zeroBits () { if (this.isZero()) return 0; - + var r = 0; for (var i = 0; i < this.length; i++) { var b = this._zeroBits(this.words[i]); @@ -10566,71 +10566,71 @@ } return r; }; - + BN.prototype.byteLength = function byteLength () { return Math.ceil(this.bitLength() / 8); }; - + BN.prototype.toTwos = function toTwos (width) { if (this.negative !== 0) { return this.abs().inotn(width).iaddn(1); } return this.clone(); }; - + BN.prototype.fromTwos = function fromTwos (width) { if (this.testn(width - 1)) { return this.notn(width).iaddn(1).ineg(); } return this.clone(); }; - + BN.prototype.isNeg = function isNeg () { return this.negative !== 0; }; - + // Return negative clone of `this` BN.prototype.neg = function neg () { return this.clone().ineg(); }; - + BN.prototype.ineg = function ineg () { if (!this.isZero()) { this.negative ^= 1; } - + return this; }; - + // Or `num` with `this` in-place BN.prototype.iuor = function iuor (num) { while (this.length < num.length) { this.words[this.length++] = 0; } - + for (var i = 0; i < num.length; i++) { this.words[i] = this.words[i] | num.words[i]; } - + return this.strip(); }; - + BN.prototype.ior = function ior (num) { assert((this.negative | num.negative) === 0); return this.iuor(num); }; - + // Or `num` with `this` BN.prototype.or = function or (num) { if (this.length > num.length) return this.clone().ior(num); return num.clone().ior(this); }; - + BN.prototype.uor = function uor (num) { if (this.length > num.length) return this.clone().iuor(num); return num.clone().iuor(this); }; - + // And `num` with `this` in-place BN.prototype.iuand = function iuand (num) { // b = min-length(num, this) @@ -10640,32 +10640,32 @@ } else { b = this; } - + for (var i = 0; i < b.length; i++) { this.words[i] = this.words[i] & num.words[i]; } - + this.length = b.length; - + return this.strip(); }; - + BN.prototype.iand = function iand (num) { assert((this.negative | num.negative) === 0); return this.iuand(num); }; - + // And `num` with `this` BN.prototype.and = function and (num) { if (this.length > num.length) return this.clone().iand(num); return num.clone().iand(this); }; - + BN.prototype.uand = function uand (num) { if (this.length > num.length) return this.clone().iuand(num); return num.clone().iuand(this); }; - + // Xor `num` with `this` in-place BN.prototype.iuxor = function iuxor (num) { // a.length > b.length @@ -10678,99 +10678,99 @@ a = num; b = this; } - + for (var i = 0; i < b.length; i++) { this.words[i] = a.words[i] ^ b.words[i]; } - + if (this !== a) { for (; i < a.length; i++) { this.words[i] = a.words[i]; } } - + this.length = a.length; - + return this.strip(); }; - + BN.prototype.ixor = function ixor (num) { assert((this.negative | num.negative) === 0); return this.iuxor(num); }; - + // Xor `num` with `this` BN.prototype.xor = function xor (num) { if (this.length > num.length) return this.clone().ixor(num); return num.clone().ixor(this); }; - + BN.prototype.uxor = function uxor (num) { if (this.length > num.length) return this.clone().iuxor(num); return num.clone().iuxor(this); }; - + // Not ``this`` with ``width`` bitwidth BN.prototype.inotn = function inotn (width) { assert(typeof width === 'number' && width >= 0); - + var bytesNeeded = Math.ceil(width / 26) | 0; var bitsLeft = width % 26; - + // Extend the buffer with leading zeroes this._expand(bytesNeeded); - + if (bitsLeft > 0) { bytesNeeded--; } - + // Handle complete words for (var i = 0; i < bytesNeeded; i++) { this.words[i] = ~this.words[i] & 0x3ffffff; } - + // Handle the residue if (bitsLeft > 0) { this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); } - + // And remove leading zeroes return this.strip(); }; - + BN.prototype.notn = function notn (width) { return this.clone().inotn(width); }; - + // Set `bit` of `this` BN.prototype.setn = function setn (bit, val) { assert(typeof bit === 'number' && bit >= 0); - + var off = (bit / 26) | 0; var wbit = bit % 26; - + this._expand(off + 1); - + if (val) { this.words[off] = this.words[off] | (1 << wbit); } else { this.words[off] = this.words[off] & ~(1 << wbit); } - + return this.strip(); }; - + // Add `num` to `this` in-place BN.prototype.iadd = function iadd (num) { var r; - + // negative + positive if (this.negative !== 0 && num.negative === 0) { this.negative = 0; r = this.isub(num); this.negative ^= 1; return this._normSign(); - + // positive + negative } else if (this.negative === 0 && num.negative !== 0) { num.negative = 0; @@ -10778,7 +10778,7 @@ num.negative = 1; return r._normSign(); } - + // a.length > b.length var a, b; if (this.length > num.length) { @@ -10788,7 +10788,7 @@ a = num; b = this; } - + var carry = 0; for (var i = 0; i < b.length; i++) { r = (a.words[i] | 0) + (b.words[i] | 0) + carry; @@ -10800,7 +10800,7 @@ this.words[i] = r & 0x3ffffff; carry = r >>> 26; } - + this.length = a.length; if (carry !== 0) { this.words[this.length] = carry; @@ -10811,10 +10811,10 @@ this.words[i] = a.words[i]; } } - + return this; }; - + // Add `num` to `this` BN.prototype.add = function add (num) { var res; @@ -10829,12 +10829,12 @@ this.negative = 1; return res; } - + if (this.length > num.length) return this.clone().iadd(num); - + return num.clone().iadd(this); }; - + // Subtract `num` from `this` in-place BN.prototype.isub = function isub (num) { // this - (-num) = this + num @@ -10843,7 +10843,7 @@ var r = this.iadd(num); num.negative = 1; return r._normSign(); - + // -this - num = -(this + num) } else if (this.negative !== 0) { this.negative = 0; @@ -10851,10 +10851,10 @@ this.negative = 1; return this._normSign(); } - + // At this point both numbers are positive var cmp = this.cmp(num); - + // Optimization - zeroify if (cmp === 0) { this.negative = 0; @@ -10862,7 +10862,7 @@ this.words[0] = 0; return this; } - + // a > b var a, b; if (cmp > 0) { @@ -10872,7 +10872,7 @@ a = num; b = this; } - + var carry = 0; for (var i = 0; i < b.length; i++) { r = (a.words[i] | 0) - (b.words[i] | 0) + carry; @@ -10884,43 +10884,43 @@ carry = r >> 26; this.words[i] = r & 0x3ffffff; } - + // Copy rest of the words if (carry === 0 && i < a.length && a !== this) { for (; i < a.length; i++) { this.words[i] = a.words[i]; } } - + this.length = Math.max(this.length, i); - + if (a !== this) { this.negative = 1; } - + return this.strip(); }; - + // Subtract `num` from `this` BN.prototype.sub = function sub (num) { return this.clone().isub(num); }; - + function smallMulTo (self, num, out) { out.negative = num.negative ^ self.negative; var len = (self.length + num.length) | 0; out.length = len; len = (len - 1) | 0; - + // Peel one iteration (compiler can't do it, because of code complexity) var a = self.words[0] | 0; var b = num.words[0] | 0; var r = a * b; - + var lo = r & 0x3ffffff; var carry = (r / 0x4000000) | 0; out.words[0] = lo; - + for (var k = 1; k < len; k++) { // Sum all words with the same `i + j = k` and accumulate `ncarry`, // note that ncarry could be >= 0x3ffffff @@ -10943,10 +10943,10 @@ } else { out.length--; } - + return out.strip(); } - + // TODO(indutny): it may be reasonable to omit it for users who don't need // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit // multiplication (like elliptic secp256k1). @@ -11018,7 +11018,7 @@ var b9 = b[9] | 0; var bl9 = b9 & 0x1fff; var bh9 = b9 >>> 13; - + out.negative = self.negative ^ num.negative; out.length = 19; /* k = 0 */ @@ -11522,16 +11522,16 @@ } return out; }; - + // Polyfill comb if (!Math.imul) { comb10MulTo = smallMulTo; } - + function bigMulTo (self, num, out) { out.negative = num.negative ^ self.negative; out.length = self.length + num.length; - + var carry = 0; var hncarry = 0; for (var k = 0; k < out.length - 1; k++) { @@ -11546,13 +11546,13 @@ var a = self.words[i] | 0; var b = num.words[j] | 0; var r = a * b; - + var lo = r & 0x3ffffff; ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; lo = (lo + rword) | 0; rword = lo & 0x3ffffff; ncarry = (ncarry + (lo >>> 26)) | 0; - + hncarry += ncarry >>> 26; ncarry &= 0x3ffffff; } @@ -11565,15 +11565,15 @@ } else { out.length--; } - + return out.strip(); } - + function jumboMulTo (self, num, out) { var fftm = new FFTM(); return fftm.mulp(self, num, out); } - + BN.prototype.mulTo = function mulTo (num, out) { var res; var len = this.length + num.length; @@ -11586,41 +11586,41 @@ } else { res = jumboMulTo(this, num, out); } - + return res; }; - + // Cooley-Tukey algorithm for FFT // slightly revisited to rely on looping instead of recursion - + function FFTM (x, y) { this.x = x; this.y = y; } - + FFTM.prototype.makeRBT = function makeRBT (N) { var t = new Array(N); var l = BN.prototype._countBits(N) - 1; for (var i = 0; i < N; i++) { t[i] = this.revBin(i, l, N); } - + return t; }; - + // Returns binary-reversed representation of `x` FFTM.prototype.revBin = function revBin (x, l, N) { if (x === 0 || x === N - 1) return x; - + var rb = 0; for (var i = 0; i < l; i++) { rb |= (x & 1) << (l - i - 1); x >>= 1; } - + return rb; }; - + // Performs "tweedling" phase, therefore 'emulating' // behaviour of the recursive algorithm FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { @@ -11629,42 +11629,42 @@ itws[i] = iws[rbt[i]]; } }; - + FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { this.permute(rbt, rws, iws, rtws, itws, N); - + for (var s = 1; s < N; s <<= 1) { var l = s << 1; - + var rtwdf = Math.cos(2 * Math.PI / l); var itwdf = Math.sin(2 * Math.PI / l); - + for (var p = 0; p < N; p += l) { var rtwdf_ = rtwdf; var itwdf_ = itwdf; - + for (var j = 0; j < s; j++) { var re = rtws[p + j]; var ie = itws[p + j]; - + var ro = rtws[p + j + s]; var io = itws[p + j + s]; - + var rx = rtwdf_ * ro - itwdf_ * io; - + io = rtwdf_ * io + itwdf_ * ro; ro = rx; - + rtws[p + j] = re + ro; itws[p + j] = ie + io; - + rtws[p + j + s] = re - ro; itws[p + j + s] = ie - io; - + /* jshint maxdepth : false */ if (j !== l) { rx = rtwdf * rtwdf_ - itwdf * itwdf_; - + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; rtwdf_ = rx; } @@ -11672,7 +11672,7 @@ } } }; - + FFTM.prototype.guessLen13b = function guessLen13b (n, m) { var N = Math.max(m, n) | 1; var odd = N & 1; @@ -11680,135 +11680,135 @@ for (N = N / 2 | 0; N; N = N >>> 1) { i++; } - + return 1 << i + 1 + odd; }; - + FFTM.prototype.conjugate = function conjugate (rws, iws, N) { if (N <= 1) return; - + for (var i = 0; i < N / 2; i++) { var t = rws[i]; - + rws[i] = rws[N - i - 1]; rws[N - i - 1] = t; - + t = iws[i]; - + iws[i] = -iws[N - i - 1]; iws[N - i - 1] = -t; } }; - + FFTM.prototype.normalize13b = function normalize13b (ws, N) { var carry = 0; for (var i = 0; i < N / 2; i++) { var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + Math.round(ws[2 * i] / N) + carry; - + ws[i] = w & 0x3ffffff; - + if (w < 0x4000000) { carry = 0; } else { carry = w / 0x4000000 | 0; } } - + return ws; }; - + FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { var carry = 0; for (var i = 0; i < len; i++) { carry = carry + (ws[i] | 0); - + rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; } - + // Pad with zeroes for (i = 2 * len; i < N; ++i) { rws[i] = 0; } - + assert(carry === 0); assert((carry & ~0x1fff) === 0); }; - + FFTM.prototype.stub = function stub (N) { var ph = new Array(N); for (var i = 0; i < N; i++) { ph[i] = 0; } - + return ph; }; - + FFTM.prototype.mulp = function mulp (x, y, out) { var N = 2 * this.guessLen13b(x.length, y.length); - + var rbt = this.makeRBT(N); - + var _ = this.stub(N); - + var rws = new Array(N); var rwst = new Array(N); var iwst = new Array(N); - + var nrws = new Array(N); var nrwst = new Array(N); var niwst = new Array(N); - + var rmws = out.words; rmws.length = N; - + this.convert13b(x.words, x.length, rws, N); this.convert13b(y.words, y.length, nrws, N); - + this.transform(rws, _, rwst, iwst, N, rbt); this.transform(nrws, _, nrwst, niwst, N, rbt); - + for (var i = 0; i < N; i++) { var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; rwst[i] = rx; } - + this.conjugate(rwst, iwst, N); this.transform(rwst, iwst, rmws, _, N, rbt); this.conjugate(rmws, _, N); this.normalize13b(rmws, N); - + out.negative = x.negative ^ y.negative; out.length = x.length + y.length; return out.strip(); }; - + // Multiply `this` by `num` BN.prototype.mul = function mul (num) { var out = new BN(null); out.words = new Array(this.length + num.length); return this.mulTo(num, out); }; - + // Multiply employing FFT BN.prototype.mulf = function mulf (num) { var out = new BN(null); out.words = new Array(this.length + num.length); return jumboMulTo(this, num, out); }; - + // In-place Multiplication BN.prototype.imul = function imul (num) { return this.clone().mulTo(num, this); }; - + BN.prototype.imuln = function imuln (num) { assert(typeof num === 'number'); assert(num < 0x4000000); - + // Carry var carry = 0; for (var i = 0; i < this.length; i++) { @@ -11820,51 +11820,51 @@ carry += lo >>> 26; this.words[i] = lo & 0x3ffffff; } - + if (carry !== 0) { this.words[i] = carry; this.length++; } - + return this; }; - + BN.prototype.muln = function muln (num) { return this.clone().imuln(num); }; - + // `this` * `this` BN.prototype.sqr = function sqr () { return this.mul(this); }; - + // `this` * `this` in-place BN.prototype.isqr = function isqr () { return this.imul(this.clone()); }; - + // Math.pow(`this`, `num`) BN.prototype.pow = function pow (num) { var w = toBitArray(num); if (w.length === 0) return new BN(1); - + // Skip leading zeroes var res = this; for (var i = 0; i < w.length; i++, res = res.sqr()) { if (w[i] !== 0) break; } - + if (++i < w.length) { for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { if (w[i] === 0) continue; - + res = res.mul(q); } } - + return res; }; - + // Shift-left in-place BN.prototype.iushln = function iushln (bits) { assert(typeof bits === 'number' && bits >= 0); @@ -11872,44 +11872,44 @@ var s = (bits - r) / 26; var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); var i; - + if (r !== 0) { var carry = 0; - + for (i = 0; i < this.length; i++) { var newCarry = this.words[i] & carryMask; var c = ((this.words[i] | 0) - newCarry) << r; this.words[i] = c | carry; carry = newCarry >>> (26 - r); } - + if (carry) { this.words[i] = carry; this.length++; } } - + if (s !== 0) { for (i = this.length - 1; i >= 0; i--) { this.words[i + s] = this.words[i]; } - + for (i = 0; i < s; i++) { this.words[i] = 0; } - + this.length += s; } - + return this.strip(); }; - + BN.prototype.ishln = function ishln (bits) { // TODO(indutny): implement me assert(this.negative === 0); return this.iushln(bits); }; - + // Shift-right in-place // NOTE: `hint` is a lowest bit before trailing zeroes // NOTE: if `extended` is present - it will be filled with destroyed bits @@ -11921,15 +11921,15 @@ } else { h = 0; } - + var r = bits % 26; var s = Math.min((bits - r) / 26, this.length); var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); var maskedWords = extended; - + h -= s; h = Math.max(0, h); - + // Extended mode, copy masked part if (maskedWords) { for (var i = 0; i < s; i++) { @@ -11937,7 +11937,7 @@ } maskedWords.length = s; } - + if (s === 0) { // No-op, we should not move anything at all } else if (this.length > s) { @@ -11949,103 +11949,103 @@ this.words[0] = 0; this.length = 1; } - + var carry = 0; for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { var word = this.words[i] | 0; this.words[i] = (carry << (26 - r)) | (word >>> r); carry = word & mask; } - + // Push carried bits as a mask if (maskedWords && carry !== 0) { maskedWords.words[maskedWords.length++] = carry; } - + if (this.length === 0) { this.words[0] = 0; this.length = 1; } - + return this.strip(); }; - + BN.prototype.ishrn = function ishrn (bits, hint, extended) { // TODO(indutny): implement me assert(this.negative === 0); return this.iushrn(bits, hint, extended); }; - + // Shift-left BN.prototype.shln = function shln (bits) { return this.clone().ishln(bits); }; - + BN.prototype.ushln = function ushln (bits) { return this.clone().iushln(bits); }; - + // Shift-right BN.prototype.shrn = function shrn (bits) { return this.clone().ishrn(bits); }; - + BN.prototype.ushrn = function ushrn (bits) { return this.clone().iushrn(bits); }; - + // Test if n bit is set BN.prototype.testn = function testn (bit) { assert(typeof bit === 'number' && bit >= 0); var r = bit % 26; var s = (bit - r) / 26; var q = 1 << r; - + // Fast case: bit is much higher than all existing words if (this.length <= s) return false; - + // Check bit and return var w = this.words[s]; - + return !!(w & q); }; - + // Return only lowers bits of number (in-place) BN.prototype.imaskn = function imaskn (bits) { assert(typeof bits === 'number' && bits >= 0); var r = bits % 26; var s = (bits - r) / 26; - + assert(this.negative === 0, 'imaskn works only with positive numbers'); - + if (this.length <= s) { return this; } - + if (r !== 0) { s++; } this.length = Math.min(s, this.length); - + if (r !== 0) { var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); this.words[this.length - 1] &= mask; } - + return this.strip(); }; - + // Return only lowers bits of number BN.prototype.maskn = function maskn (bits) { return this.clone().imaskn(bits); }; - + // Add plain number `num` to `this` BN.prototype.iaddn = function iaddn (num) { assert(typeof num === 'number'); assert(num < 0x4000000); if (num < 0) return this.isubn(-num); - + // Possible sign change if (this.negative !== 0) { if (this.length === 1 && (this.words[0] | 0) < num) { @@ -12053,20 +12053,20 @@ this.negative = 0; return this; } - + this.negative = 0; this.isubn(num); this.negative = 1; return this; } - + // Add without checks return this._iaddn(num); }; - + BN.prototype._iaddn = function _iaddn (num) { this.words[0] += num; - + // Carry for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { this.words[i] -= 0x4000000; @@ -12077,25 +12077,25 @@ } } this.length = Math.max(this.length, i + 1); - + return this; }; - + // Subtract plain number `num` from `this` BN.prototype.isubn = function isubn (num) { assert(typeof num === 'number'); assert(num < 0x4000000); if (num < 0) return this.iaddn(-num); - + if (this.negative !== 0) { this.negative = 0; this.iaddn(num); this.negative = 1; return this; } - + this.words[0] -= num; - + if (this.length === 1 && this.words[0] < 0) { this.words[0] = -this.words[0]; this.negative = 1; @@ -12106,34 +12106,34 @@ this.words[i + 1] -= 1; } } - + return this.strip(); }; - + BN.prototype.addn = function addn (num) { return this.clone().iaddn(num); }; - + BN.prototype.subn = function subn (num) { return this.clone().isubn(num); }; - + BN.prototype.iabs = function iabs () { this.negative = 0; - + return this; }; - + BN.prototype.abs = function abs () { return this.clone().iabs(); }; - + BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { var len = num.length + shift; var i; - + this._expand(len); - + var w; var carry = 0; for (i = 0; i < num.length; i++) { @@ -12148,9 +12148,9 @@ carry = w >> 26; this.words[i + shift] = w & 0x3ffffff; } - + if (carry === 0) return this.strip(); - + // Subtraction overflow assert(carry === -1); carry = 0; @@ -12160,16 +12160,16 @@ this.words[i] = w & 0x3ffffff; } this.negative = 1; - + return this.strip(); }; - + BN.prototype._wordDiv = function _wordDiv (num, mode) { var shift = this.length - num.length; - + var a = this.clone(); var b = num; - + // Normalize var bhi = b.words[b.length - 1] | 0; var bhiBits = this._countBits(bhi); @@ -12179,11 +12179,11 @@ a.iushln(shift); bhi = b.words[b.length - 1] | 0; } - + // Initialize quotient var m = a.length - b.length; var q; - + if (mode !== 'mod') { q = new BN(null); q.length = m + 1; @@ -12192,7 +12192,7 @@ q.words[i] = 0; } } - + var diff = a.clone()._ishlnsubmul(b, 1, m); if (diff.negative === 0) { a = diff; @@ -12200,15 +12200,15 @@ q.words[m] = 1; } } - + for (var j = m - 1; j >= 0; j--) { var qj = (a.words[b.length + j] | 0) * 0x4000000 + (a.words[b.length + j - 1] | 0); - + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max // (0x7ffffff) qj = Math.min((qj / bhi) | 0, 0x3ffffff); - + a._ishlnsubmul(b, qj, j); while (a.negative !== 0) { qj--; @@ -12226,84 +12226,84 @@ q.strip(); } a.strip(); - + // Denormalize if (mode !== 'div' && shift !== 0) { a.iushrn(shift); } - + return { div: q || null, mod: a }; }; - + // NOTE: 1) `mode` can be set to `mod` to request mod only, // to `div` to request div only, or be absent to // request both div & mod // 2) `positive` is true if unsigned mod is requested BN.prototype.divmod = function divmod (num, mode, positive) { assert(!num.isZero()); - + if (this.isZero()) { return { div: new BN(0), mod: new BN(0) }; } - + var div, mod, res; if (this.negative !== 0 && num.negative === 0) { res = this.neg().divmod(num, mode); - + if (mode !== 'mod') { div = res.div.neg(); } - + if (mode !== 'div') { mod = res.mod.neg(); if (positive && mod.negative !== 0) { mod.iadd(num); } } - + return { div: div, mod: mod }; } - + if (this.negative === 0 && num.negative !== 0) { res = this.divmod(num.neg(), mode); - + if (mode !== 'mod') { div = res.div.neg(); } - + return { div: div, mod: res.mod }; } - + if ((this.negative & num.negative) !== 0) { res = this.neg().divmod(num.neg(), mode); - + if (mode !== 'div') { mod = res.mod.neg(); if (positive && mod.negative !== 0) { mod.isub(num); } } - + return { div: res.div, mod: mod }; } - + // Both numbers are positive at this point - + // Strip both numbers to approximate shift value if (num.length > this.length || this.cmp(num) < 0) { return { @@ -12311,7 +12311,7 @@ mod: this }; } - + // Very short reduction if (num.length === 1) { if (mode === 'div') { @@ -12320,119 +12320,119 @@ mod: null }; } - + if (mode === 'mod') { return { div: null, mod: new BN(this.modn(num.words[0])) }; } - + return { div: this.divn(num.words[0]), mod: new BN(this.modn(num.words[0])) }; } - + return this._wordDiv(num, mode); }; - + // Find `this` / `num` BN.prototype.div = function div (num) { return this.divmod(num, 'div', false).div; }; - + // Find `this` % `num` BN.prototype.mod = function mod (num) { return this.divmod(num, 'mod', false).mod; }; - + BN.prototype.umod = function umod (num) { return this.divmod(num, 'mod', true).mod; }; - + // Find Round(`this` / `num`) BN.prototype.divRound = function divRound (num) { var dm = this.divmod(num); - + // Fast case - exact division if (dm.mod.isZero()) return dm.div; - + var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; - + var half = num.ushrn(1); var r2 = num.andln(1); var cmp = mod.cmp(half); - + // Round down if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; - + // Round up return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); }; - + BN.prototype.modn = function modn (num) { assert(num <= 0x3ffffff); var p = (1 << 26) % num; - + var acc = 0; for (var i = this.length - 1; i >= 0; i--) { acc = (p * acc + (this.words[i] | 0)) % num; } - + return acc; }; - + // In-place division by number BN.prototype.idivn = function idivn (num) { assert(num <= 0x3ffffff); - + var carry = 0; for (var i = this.length - 1; i >= 0; i--) { var w = (this.words[i] | 0) + carry * 0x4000000; this.words[i] = (w / num) | 0; carry = w % num; } - + return this.strip(); }; - + BN.prototype.divn = function divn (num) { return this.clone().idivn(num); }; - + BN.prototype.egcd = function egcd (p) { assert(p.negative === 0); assert(!p.isZero()); - + var x = this; var y = p.clone(); - + if (x.negative !== 0) { x = x.umod(p); } else { x = x.clone(); } - + // A * x + B * y = x var A = new BN(1); var B = new BN(0); - + // C * x + D * y = y var C = new BN(0); var D = new BN(1); - + var g = 0; - + while (x.isEven() && y.isEven()) { x.iushrn(1); y.iushrn(1); ++g; } - + var yp = y.clone(); var xp = x.clone(); - + while (!x.isZero()) { for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); if (i > 0) { @@ -12442,12 +12442,12 @@ A.iadd(yp); B.isub(xp); } - + A.iushrn(1); B.iushrn(1); } } - + for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); if (j > 0) { y.iushrn(j); @@ -12456,12 +12456,12 @@ C.iadd(yp); D.isub(xp); } - + C.iushrn(1); D.iushrn(1); } } - + if (x.cmp(y) >= 0) { x.isub(y); A.isub(C); @@ -12472,35 +12472,35 @@ D.isub(B); } } - + return { a: C, b: D, gcd: y.iushln(g) }; }; - + // This is reduced incarnation of the binary EEA // above, designated to invert members of the // _prime_ fields F(p) at a maximal speed BN.prototype._invmp = function _invmp (p) { assert(p.negative === 0); assert(!p.isZero()); - + var a = this; var b = p.clone(); - + if (a.negative !== 0) { a = a.umod(p); } else { a = a.clone(); } - + var x1 = new BN(1); var x2 = new BN(0); - + var delta = b.clone(); - + while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); if (i > 0) { @@ -12509,11 +12509,11 @@ if (x1.isOdd()) { x1.iadd(delta); } - + x1.iushrn(1); } } - + for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); if (j > 0) { b.iushrn(j); @@ -12521,11 +12521,11 @@ if (x2.isOdd()) { x2.iadd(delta); } - + x2.iushrn(1); } } - + if (a.cmp(b) >= 0) { a.isub(b); x1.isub(x2); @@ -12534,36 +12534,36 @@ x2.isub(x1); } } - + var res; if (a.cmpn(1) === 0) { res = x1; } else { res = x2; } - + if (res.cmpn(0) < 0) { res.iadd(p); } - + return res; }; - + BN.prototype.gcd = function gcd (num) { if (this.isZero()) return num.abs(); if (num.isZero()) return this.abs(); - + var a = this.clone(); var b = num.clone(); a.negative = 0; b.negative = 0; - + // Remove common factor of two for (var shift = 0; a.isEven() && b.isEven(); shift++) { a.iushrn(1); b.iushrn(1); } - + do { while (a.isEven()) { a.iushrn(1); @@ -12571,7 +12571,7 @@ while (b.isEven()) { b.iushrn(1); } - + var r = a.cmp(b); if (r < 0) { // Swap `a` and `b` to make `a` always bigger than `b` @@ -12581,45 +12581,45 @@ } else if (r === 0 || b.cmpn(1) === 0) { break; } - + a.isub(b); } while (true); - + return b.iushln(shift); }; - + // Invert number in the field F(num) BN.prototype.invm = function invm (num) { return this.egcd(num).a.umod(num); }; - + BN.prototype.isEven = function isEven () { return (this.words[0] & 1) === 0; }; - + BN.prototype.isOdd = function isOdd () { return (this.words[0] & 1) === 1; }; - + // And first word and num BN.prototype.andln = function andln (num) { return this.words[0] & num; }; - + // Increment at the bit position in-line BN.prototype.bincn = function bincn (bit) { assert(typeof bit === 'number'); var r = bit % 26; var s = (bit - r) / 26; var q = 1 << r; - + // Fast case: bit is much higher than all existing words if (this.length <= s) { this._expand(s + 1); this.words[s] |= q; return this; } - + // Add bit and propagate, if needed var carry = q; for (var i = s; carry !== 0 && i < this.length; i++) { @@ -12635,19 +12635,19 @@ } return this; }; - + BN.prototype.isZero = function isZero () { return this.length === 1 && this.words[0] === 0; }; - + BN.prototype.cmpn = function cmpn (num) { var negative = num < 0; - + if (this.negative !== 0 && !negative) return -1; if (this.negative === 0 && negative) return 1; - + this.strip(); - + var res; if (this.length > 1) { res = 1; @@ -12655,16 +12655,16 @@ if (negative) { num = -num; } - + assert(num <= 0x3ffffff, 'Number is too big'); - + var w = this.words[0] | 0; res = w === num ? 0 : w < num ? -1 : 1; } if (this.negative !== 0) return -res | 0; return res; }; - + // Compare two numbers and return: // 1 - if `this` > `num` // 0 - if `this` == `num` @@ -12672,23 +12672,23 @@ BN.prototype.cmp = function cmp (num) { if (this.negative !== 0 && num.negative === 0) return -1; if (this.negative === 0 && num.negative !== 0) return 1; - + var res = this.ucmp(num); if (this.negative !== 0) return -res | 0; return res; }; - + // Unsigned comparison BN.prototype.ucmp = function ucmp (num) { // At this point both numbers have the same sign if (this.length > num.length) return 1; if (this.length < num.length) return -1; - + var res = 0; for (var i = this.length - 1; i >= 0; i--) { var a = this.words[i] | 0; var b = num.words[i] | 0; - + if (a === b) continue; if (a < b) { res = -1; @@ -12699,47 +12699,47 @@ } return res; }; - + BN.prototype.gtn = function gtn (num) { return this.cmpn(num) === 1; }; - + BN.prototype.gt = function gt (num) { return this.cmp(num) === 1; }; - + BN.prototype.gten = function gten (num) { return this.cmpn(num) >= 0; }; - + BN.prototype.gte = function gte (num) { return this.cmp(num) >= 0; }; - + BN.prototype.ltn = function ltn (num) { return this.cmpn(num) === -1; }; - + BN.prototype.lt = function lt (num) { return this.cmp(num) === -1; }; - + BN.prototype.lten = function lten (num) { return this.cmpn(num) <= 0; }; - + BN.prototype.lte = function lte (num) { return this.cmp(num) <= 0; }; - + BN.prototype.eqn = function eqn (num) { return this.cmpn(num) === 0; }; - + BN.prototype.eq = function eq (num) { return this.cmp(num) === 0; }; - + // // A reduce context, could be using montgomery or something better, depending // on the `m` itself. @@ -12747,103 +12747,103 @@ BN.red = function red (num) { return new Red(num); }; - + BN.prototype.toRed = function toRed (ctx) { assert(!this.red, 'Already a number in reduction context'); assert(this.negative === 0, 'red works only with positives'); return ctx.convertTo(this)._forceRed(ctx); }; - + BN.prototype.fromRed = function fromRed () { assert(this.red, 'fromRed works only with numbers in reduction context'); return this.red.convertFrom(this); }; - + BN.prototype._forceRed = function _forceRed (ctx) { this.red = ctx; return this; }; - + BN.prototype.forceRed = function forceRed (ctx) { assert(!this.red, 'Already a number in reduction context'); return this._forceRed(ctx); }; - + BN.prototype.redAdd = function redAdd (num) { assert(this.red, 'redAdd works only with red numbers'); return this.red.add(this, num); }; - + BN.prototype.redIAdd = function redIAdd (num) { assert(this.red, 'redIAdd works only with red numbers'); return this.red.iadd(this, num); }; - + BN.prototype.redSub = function redSub (num) { assert(this.red, 'redSub works only with red numbers'); return this.red.sub(this, num); }; - + BN.prototype.redISub = function redISub (num) { assert(this.red, 'redISub works only with red numbers'); return this.red.isub(this, num); }; - + BN.prototype.redShl = function redShl (num) { assert(this.red, 'redShl works only with red numbers'); return this.red.shl(this, num); }; - + BN.prototype.redMul = function redMul (num) { assert(this.red, 'redMul works only with red numbers'); this.red._verify2(this, num); return this.red.mul(this, num); }; - + BN.prototype.redIMul = function redIMul (num) { assert(this.red, 'redMul works only with red numbers'); this.red._verify2(this, num); return this.red.imul(this, num); }; - + BN.prototype.redSqr = function redSqr () { assert(this.red, 'redSqr works only with red numbers'); this.red._verify1(this); return this.red.sqr(this); }; - + BN.prototype.redISqr = function redISqr () { assert(this.red, 'redISqr works only with red numbers'); this.red._verify1(this); return this.red.isqr(this); }; - + // Square root over p BN.prototype.redSqrt = function redSqrt () { assert(this.red, 'redSqrt works only with red numbers'); this.red._verify1(this); return this.red.sqrt(this); }; - + BN.prototype.redInvm = function redInvm () { assert(this.red, 'redInvm works only with red numbers'); this.red._verify1(this); return this.red.invm(this); }; - + // Return negative clone of `this` % `red modulo` BN.prototype.redNeg = function redNeg () { assert(this.red, 'redNeg works only with red numbers'); this.red._verify1(this); return this.red.neg(this); }; - + BN.prototype.redPow = function redPow (num) { assert(this.red && !num.red, 'redPow(normalNum)'); this.red._verify1(this); return this.red.pow(this, num); }; - + // Prime numbers with efficient reduction var primes = { k256: null, @@ -12851,7 +12851,7 @@ p192: null, p25519: null }; - + // Pseudo-Mersenne prime function MPrime (name, p) { // P = 2 ^ N - K @@ -12859,29 +12859,29 @@ this.p = new BN(p, 16); this.n = this.p.bitLength(); this.k = new BN(1).iushln(this.n).isub(this.p); - + this.tmp = this._tmp(); } - + MPrime.prototype._tmp = function _tmp () { var tmp = new BN(null); tmp.words = new Array(Math.ceil(this.n / 13)); return tmp; }; - + MPrime.prototype.ireduce = function ireduce (num) { // Assumes that `num` is less than `P^2` // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) var r = num; var rlen; - + do { this.split(r, this.tmp); r = this.imulK(r); r = r.iadd(this.tmp); rlen = r.bitLength(); } while (rlen > this.n); - + var cmp = rlen < this.n ? -1 : r.ucmp(this.p); if (cmp === 0) { r.words[0] = 0; @@ -12891,18 +12891,18 @@ } else { r.strip(); } - + return r; }; - + MPrime.prototype.split = function split (input, out) { input.iushrn(this.n, 0, out); }; - + MPrime.prototype.imulK = function imulK (num) { return num.imul(this.k); }; - + function K256 () { MPrime.call( this, @@ -12910,27 +12910,27 @@ 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); } inherits(K256, MPrime); - + K256.prototype.split = function split (input, output) { // 256 = 9 * 26 + 22 var mask = 0x3fffff; - + var outLen = Math.min(input.length, 9); for (var i = 0; i < outLen; i++) { output.words[i] = input.words[i]; } output.length = outLen; - + if (input.length <= 9) { input.words[0] = 0; input.length = 1; return; } - + // Shift by 9 limbs var prev = input.words[9]; output.words[output.length++] = prev & mask; - + for (i = 10; i < input.length; i++) { var next = input.words[i] | 0; input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); @@ -12944,13 +12944,13 @@ input.length -= 9; } }; - + K256.prototype.imulK = function imulK (num) { // K = 0x1000003d1 = [ 0x40, 0x3d1 ] num.words[num.length] = 0; num.words[num.length + 1] = 0; num.length += 2; - + // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 var lo = 0; for (var i = 0; i < num.length; i++) { @@ -12959,7 +12959,7 @@ num.words[i] = lo & 0x3ffffff; lo = w * 0x40 + ((lo / 0x4000000) | 0); } - + // Fast length reduction if (num.words[num.length - 1] === 0) { num.length--; @@ -12969,7 +12969,7 @@ } return num; }; - + function P224 () { MPrime.call( this, @@ -12977,7 +12977,7 @@ 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); } inherits(P224, MPrime); - + function P192 () { MPrime.call( this, @@ -12985,7 +12985,7 @@ 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); } inherits(P192, MPrime); - + function P25519 () { // 2 ^ 255 - 19 MPrime.call( @@ -12994,7 +12994,7 @@ '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); } inherits(P25519, MPrime); - + P25519.prototype.imulK = function imulK (num) { // K = 0x13 var carry = 0; @@ -13002,7 +13002,7 @@ var hi = (num.words[i] | 0) * 0x13 + carry; var lo = hi & 0x3ffffff; hi >>>= 26; - + num.words[i] = lo; carry = hi; } @@ -13011,12 +13011,12 @@ } return num; }; - + // Exported mostly for testing purposes, use plain name instead BN._prime = function prime (name) { // Cached version of prime if (primes[name]) return primes[name]; - + var prime; if (name === 'k256') { prime = new K256(); @@ -13030,10 +13030,10 @@ throw new Error('Unknown prime ' + name); } primes[name] = prime; - + return prime; }; - + // // Base reduction engine // @@ -13048,106 +13048,106 @@ this.prime = null; } } - + Red.prototype._verify1 = function _verify1 (a) { assert(a.negative === 0, 'red works only with positives'); assert(a.red, 'red works only with red numbers'); }; - + Red.prototype._verify2 = function _verify2 (a, b) { assert((a.negative | b.negative) === 0, 'red works only with positives'); assert(a.red && a.red === b.red, 'red works only with red numbers'); }; - + Red.prototype.imod = function imod (a) { if (this.prime) return this.prime.ireduce(a)._forceRed(this); return a.umod(this.m)._forceRed(this); }; - + Red.prototype.neg = function neg (a) { if (a.isZero()) { return a.clone(); } - + return this.m.sub(a)._forceRed(this); }; - + Red.prototype.add = function add (a, b) { this._verify2(a, b); - + var res = a.add(b); if (res.cmp(this.m) >= 0) { res.isub(this.m); } return res._forceRed(this); }; - + Red.prototype.iadd = function iadd (a, b) { this._verify2(a, b); - + var res = a.iadd(b); if (res.cmp(this.m) >= 0) { res.isub(this.m); } return res; }; - + Red.prototype.sub = function sub (a, b) { this._verify2(a, b); - + var res = a.sub(b); if (res.cmpn(0) < 0) { res.iadd(this.m); } return res._forceRed(this); }; - + Red.prototype.isub = function isub (a, b) { this._verify2(a, b); - + var res = a.isub(b); if (res.cmpn(0) < 0) { res.iadd(this.m); } return res; }; - + Red.prototype.shl = function shl (a, num) { this._verify1(a); return this.imod(a.ushln(num)); }; - + Red.prototype.imul = function imul (a, b) { this._verify2(a, b); return this.imod(a.imul(b)); }; - + Red.prototype.mul = function mul (a, b) { this._verify2(a, b); return this.imod(a.mul(b)); }; - + Red.prototype.isqr = function isqr (a) { return this.imul(a, a.clone()); }; - + Red.prototype.sqr = function sqr (a) { return this.mul(a, a); }; - + Red.prototype.sqrt = function sqrt (a) { if (a.isZero()) return a.clone(); - + var mod3 = this.m.andln(3); assert(mod3 % 2 === 1); - + // Fast case if (mod3 === 3) { var pow = this.m.add(new BN(1)).iushrn(2); return this.pow(a, pow); } - + // Tonelli-Shanks algorithm (Totally unoptimized and slow) // // Find Q and S, that Q * 2 ^ S = (P - 1) @@ -13158,20 +13158,20 @@ q.iushrn(1); } assert(!q.isZero()); - + var one = new BN(1).toRed(this); var nOne = one.redNeg(); - + // Find quadratic non-residue // NOTE: Max is such because of generalized Riemann hypothesis. var lpow = this.m.subn(1).iushrn(1); var z = this.m.bitLength(); z = new BN(2 * z * z).toRed(this); - + while (this.pow(z, lpow).cmp(nOne) !== 0) { z.redIAdd(nOne); } - + var c = this.pow(z, q); var r = this.pow(a, q.addn(1).iushrn(1)); var t = this.pow(a, q); @@ -13183,16 +13183,16 @@ } assert(i < m); var b = this.pow(c, new BN(1).iushln(m - i - 1)); - + r = r.redMul(b); c = b.redSqr(); t = t.redMul(c); m = i; } - + return r; }; - + Red.prototype.invm = function invm (a) { var inv = a._invmp(this.m); if (inv.negative !== 0) { @@ -13202,11 +13202,11 @@ return this.imod(inv); } }; - + Red.prototype.pow = function pow (a, num) { if (num.isZero()) return new BN(1).toRed(this); if (num.cmpn(1) === 0) return a.clone(); - + var windowSize = 4; var wnd = new Array(1 << windowSize); wnd[0] = new BN(1).toRed(this); @@ -13214,7 +13214,7 @@ for (var i = 2; i < wnd.length; i++) { wnd[i] = this.mul(wnd[i - 1], a); } - + var res = wnd[0]; var current = 0; var currentLen = 0; @@ -13222,7 +13222,7 @@ if (start === 0) { start = 26; } - + for (i = num.length - 1; i >= 0; i--) { var word = num.words[i]; for (var j = start - 1; j >= 0; j--) { @@ -13230,99 +13230,99 @@ if (res !== wnd[0]) { res = this.sqr(res); } - + if (bit === 0 && current === 0) { currentLen = 0; continue; } - + current <<= 1; current |= bit; currentLen++; if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; - + res = this.mul(res, wnd[current]); currentLen = 0; current = 0; } start = 26; } - + return res; }; - + Red.prototype.convertTo = function convertTo (num) { var r = num.umod(this.m); - + return r === num ? r.clone() : r; }; - + Red.prototype.convertFrom = function convertFrom (num) { var res = num.clone(); res.red = null; return res; }; - + // // Montgomery method engine // - + BN.mont = function mont (num) { return new Mont(num); }; - + function Mont (m) { Red.call(this, m); - + this.shift = this.m.bitLength(); if (this.shift % 26 !== 0) { this.shift += 26 - (this.shift % 26); } - + this.r = new BN(1).iushln(this.shift); this.r2 = this.imod(this.r.sqr()); this.rinv = this.r._invmp(this.m); - + this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); this.minv = this.minv.umod(this.r); this.minv = this.r.sub(this.minv); } inherits(Mont, Red); - + Mont.prototype.convertTo = function convertTo (num) { return this.imod(num.ushln(this.shift)); }; - + Mont.prototype.convertFrom = function convertFrom (num) { var r = this.imod(num.mul(this.rinv)); r.red = null; return r; }; - + Mont.prototype.imul = function imul (a, b) { if (a.isZero() || b.isZero()) { a.words[0] = 0; a.length = 1; return a; } - + var t = a.imul(b); var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); var u = t.isub(c).iushrn(this.shift); var res = u; - + if (u.cmp(this.m) >= 0) { res = u.isub(this.m); } else if (u.cmpn(0) < 0) { res = u.iadd(this.m); } - + return res._forceRed(this); }; - + Mont.prototype.mul = function mul (a, b) { if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); - + var t = a.mul(b); var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); var u = t.isub(c).iushrn(this.shift); @@ -13332,47 +13332,47 @@ } else if (u.cmpn(0) < 0) { res = u.iadd(this.m); } - + return res._forceRed(this); }; - + Mont.prototype.invm = function invm (a) { // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R var res = this.imod(a._invmp(this.m).mul(this.r2)); return res._forceRed(this); }; })(typeof module === 'undefined' || module, this); - + },{"buffer":55}],54:[function(require,module,exports){ var r; - + module.exports = function rand(len) { if (!r) r = new Rand(null); - + return r.generate(len); }; - + function Rand(rand) { this.rand = rand; } module.exports.Rand = Rand; - + Rand.prototype.generate = function generate(len) { return this._rand(len); }; - + // Emulate crypto API using randy Rand.prototype._rand = function _rand(n) { if (this.rand.getBytes) return this.rand.getBytes(n); - + var res = new Uint8Array(n); for (var i = 0; i < res.length; i++) res[i] = this.rand.getByte(); return res; }; - + if (typeof self === 'object') { if (self.crypto && self.crypto.getRandomValues) { // Modern browsers @@ -13388,7 +13388,7 @@ self.msCrypto.getRandomValues(arr); return arr; }; - + // Safari's WebWorkers do not have `crypto` } else if (typeof window === 'object') { // Old junk @@ -13402,56 +13402,56 @@ var crypto = require('crypto'); if (typeof crypto.randomBytes !== 'function') throw new Error('Not supported'); - + Rand.prototype._rand = function _rand(n) { return crypto.randomBytes(n); }; } catch (e) { } } - + },{"crypto":55}],55:[function(require,module,exports){ - + },{}],56:[function(require,module,exports){ // based on the aes implimentation in triple sec // https://github.com/keybase/triplesec // which is in turn based on the one from crypto-js // https://code.google.com/p/crypto-js/ - + var Buffer = require('safe-buffer').Buffer - + function asUInt32Array (buf) { if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf) - + var len = (buf.length / 4) | 0 var out = new Array(len) - + for (var i = 0; i < len; i++) { out[i] = buf.readUInt32BE(i * 4) } - + return out } - + function scrubVec (v) { for (var i = 0; i < v.length; v++) { v[i] = 0 } } - + function cryptBlock (M, keySchedule, SUB_MIX, SBOX, nRounds) { var SUB_MIX0 = SUB_MIX[0] var SUB_MIX1 = SUB_MIX[1] var SUB_MIX2 = SUB_MIX[2] var SUB_MIX3 = SUB_MIX[3] - + var s0 = M[0] ^ keySchedule[0] var s1 = M[1] ^ keySchedule[1] var s2 = M[2] ^ keySchedule[2] var s3 = M[3] ^ keySchedule[3] var t0, t1, t2, t3 var ksRow = 4 - + for (var round = 1; round < nRounds; round++) { t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[(s1 >>> 16) & 0xff] ^ SUB_MIX2[(s2 >>> 8) & 0xff] ^ SUB_MIX3[s3 & 0xff] ^ keySchedule[ksRow++] t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[(s2 >>> 16) & 0xff] ^ SUB_MIX2[(s3 >>> 8) & 0xff] ^ SUB_MIX3[s0 & 0xff] ^ keySchedule[ksRow++] @@ -13462,7 +13462,7 @@ s2 = t2 s3 = t3 } - + t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++] t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++] t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++] @@ -13471,10 +13471,10 @@ t1 = t1 >>> 0 t2 = t2 >>> 0 t3 = t3 >>> 0 - + return [t0, t1, t2, t3] } - + // AES constants var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36] var G = (function () { @@ -13487,12 +13487,12 @@ d[j] = (j << 1) ^ 0x11b } } - + var SBOX = [] var INV_SBOX = [] var SUB_MIX = [[], [], [], []] var INV_SUB_MIX = [[], [], [], []] - + // Walk GF(2^8) var x = 0 var xi = 0 @@ -13502,26 +13502,26 @@ sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63 SBOX[x] = sx INV_SBOX[sx] = x - + // Compute multiplication var x2 = d[x] var x4 = d[x2] var x8 = d[x4] - + // Compute sub bytes, mix columns tables var t = (d[sx] * 0x101) ^ (sx * 0x1010100) SUB_MIX[0][x] = (t << 24) | (t >>> 8) SUB_MIX[1][x] = (t << 16) | (t >>> 16) SUB_MIX[2][x] = (t << 8) | (t >>> 24) SUB_MIX[3][x] = t - + // Compute inv sub bytes, inv mix columns tables t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100) INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8) INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16) INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24) INV_SUB_MIX[3][sx] = t - + if (x === 0) { x = xi = 1 } else { @@ -13529,7 +13529,7 @@ xi ^= d[d[xi]] } } - + return { SBOX: SBOX, INV_SBOX: INV_SBOX, @@ -13537,12 +13537,12 @@ INV_SUB_MIX: INV_SUB_MIX } })() - + function AES (key) { this._key = asUInt32Array(key) this._reset() } - + AES.blockSize = 4 * 4 AES.keySize = 256 / 8 AES.prototype.blockSize = AES.blockSize @@ -13552,15 +13552,15 @@ var keySize = keyWords.length var nRounds = keySize + 6 var ksRows = (nRounds + 1) * 4 - + var keySchedule = [] for (var k = 0; k < keySize; k++) { keySchedule[k] = keyWords[k] } - + for (k = keySize; k < ksRows; k++) { var t = keySchedule[k - 1] - + if (k % keySize === 0) { t = (t << 8) | (t >>> 24) t = @@ -13568,7 +13568,7 @@ (G.SBOX[(t >>> 16) & 0xff] << 16) | (G.SBOX[(t >>> 8) & 0xff] << 8) | (G.SBOX[t & 0xff]) - + t ^= RCON[(k / keySize) | 0] << 24 } else if (keySize > 6 && k % keySize === 4) { t = @@ -13577,15 +13577,15 @@ (G.SBOX[(t >>> 8) & 0xff] << 8) | (G.SBOX[t & 0xff]) } - + keySchedule[k] = keySchedule[k - keySize] ^ t } - + var invKeySchedule = [] for (var ik = 0; ik < ksRows; ik++) { var ksR = ksRows - ik var tt = keySchedule[ksR - (ik % 4 ? 0 : 4)] - + if (ik < 4 || ksR <= 4) { invKeySchedule[ik] = tt } else { @@ -13596,17 +13596,17 @@ G.INV_SUB_MIX[3][G.SBOX[tt & 0xff]] } } - + this._nRounds = nRounds this._keySchedule = keySchedule this._invKeySchedule = invKeySchedule } - + AES.prototype.encryptBlockRaw = function (M) { M = asUInt32Array(M) return cryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX, this._nRounds) } - + AES.prototype.encryptBlock = function (M) { var out = this.encryptBlockRaw(M) var buf = Buffer.allocUnsafe(16) @@ -13616,15 +13616,15 @@ buf.writeUInt32BE(out[3], 12) return buf } - + AES.prototype.decryptBlock = function (M) { M = asUInt32Array(M) - + // swap var m1 = M[1] M[1] = M[3] M[3] = m1 - + var out = cryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX, this._nRounds) var buf = Buffer.allocUnsafe(16) buf.writeUInt32BE(out[0], 0) @@ -13633,15 +13633,15 @@ buf.writeUInt32BE(out[1], 12) return buf } - + AES.prototype.scrub = function () { scrubVec(this._keySchedule) scrubVec(this._invKeySchedule) scrubVec(this._key) } - + module.exports.AES = AES - + },{"safe-buffer":290}],57:[function(require,module,exports){ var aes = require('./aes') var Buffer = require('safe-buffer').Buffer @@ -13650,19 +13650,19 @@ var GHASH = require('./ghash') var xor = require('buffer-xor') var incr32 = require('./incr32') - + function xorTest (a, b) { var out = 0 if (a.length !== b.length) out++ - + var len = Math.min(a.length, b.length) for (var i = 0; i < len; ++i) { out += (a[i] ^ b[i]) } - + return out } - + function calcIv (self, iv, ck) { if (iv.length === 12) { self._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])]) @@ -13688,14 +13688,14 @@ } function StreamCipher (mode, key, iv, decrypt) { Transform.call(this) - + var h = Buffer.alloc(4, 0) - + this._cipher = new aes.AES(key) var ck = this._cipher.encryptBlock(h) this._ghash = new GHASH(ck) iv = calcIv(this, iv, ck) - + this._prev = Buffer.from(iv) this._cache = Buffer.allocUnsafe(0) this._secCache = Buffer.allocUnsafe(0) @@ -13703,13 +13703,13 @@ this._alen = 0 this._len = 0 this._mode = mode - + this._authTag = null this._called = false } - + inherits(StreamCipher, Transform) - + StreamCipher.prototype._update = function (chunk) { if (!this._called && this._alen) { var rump = 16 - (this._alen % 16) @@ -13718,7 +13718,7 @@ this._ghash.update(rump) } } - + this._called = true var out = this._mode.encrypt(this, chunk) if (this._decrypt) { @@ -13729,53 +13729,53 @@ this._len += chunk.length return out } - + StreamCipher.prototype._final = function () { if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data') - + var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID)) if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data') - + this._authTag = tag this._cipher.scrub() } - + StreamCipher.prototype.getAuthTag = function getAuthTag () { if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state') - + return this._authTag } - + StreamCipher.prototype.setAuthTag = function setAuthTag (tag) { if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state') - + this._authTag = tag } - + StreamCipher.prototype.setAAD = function setAAD (buf) { if (this._called) throw new Error('Attempting to set AAD in unsupported state') - + this._ghash.update(buf) this._alen += buf.length } - + module.exports = StreamCipher - + },{"./aes":56,"./ghash":61,"./incr32":62,"buffer-xor":83,"cipher-base":86,"inherits":180,"safe-buffer":290}],58:[function(require,module,exports){ var ciphers = require('./encrypter') var deciphers = require('./decrypter') var modes = require('./modes/list.json') - + function getCiphers () { return Object.keys(modes) } - + exports.createCipher = exports.Cipher = ciphers.createCipher exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv exports.createDecipher = exports.Decipher = deciphers.createDecipher exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv exports.listCiphers = exports.getCiphers = getCiphers - + },{"./decrypter":59,"./encrypter":60,"./modes/list.json":70}],59:[function(require,module,exports){ var AuthCipher = require('./authCipher') var Buffer = require('safe-buffer').Buffer @@ -13785,10 +13785,10 @@ var aes = require('./aes') var ebtk = require('evp_bytestokey') var inherits = require('inherits') - + function Decipher (mode, key, iv) { Transform.call(this) - + this._cache = new Splitter() this._last = void 0 this._cipher = new aes.AES(key) @@ -13796,9 +13796,9 @@ this._mode = mode this._autopadding = true } - + inherits(Decipher, Transform) - + Decipher.prototype._update = function (data) { this._cache.add(data) var chunk @@ -13810,7 +13810,7 @@ } return Buffer.concat(out) } - + Decipher.prototype._final = function () { var chunk = this._cache.flush() if (this._autopadding) { @@ -13819,20 +13819,20 @@ throw new Error('data not multiple of block length') } } - + Decipher.prototype.setAutoPadding = function (setTo) { this._autopadding = !!setTo return this } - + function Splitter () { this.cache = Buffer.allocUnsafe(0) } - + Splitter.prototype.add = function (data) { this.cache = Buffer.concat([this.cache, data]) } - + Splitter.prototype.get = function (autoPadding) { var out if (autoPadding) { @@ -13848,14 +13848,14 @@ return out } } - + return null } - + Splitter.prototype.flush = function () { if (this.cache.length) return this.cache } - + function unpad (last) { var padded = last[15] var i = -1 @@ -13865,40 +13865,40 @@ } } if (padded === 16) return - + return last.slice(0, 16 - padded) } - + function createDecipheriv (suite, password, iv) { var config = MODES[suite.toLowerCase()] if (!config) throw new TypeError('invalid suite type') - + if (typeof iv === 'string') iv = Buffer.from(iv) if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length) - + if (typeof password === 'string') password = Buffer.from(password) if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length) - + if (config.type === 'stream') { return new StreamCipher(config.module, password, iv, true) } else if (config.type === 'auth') { return new AuthCipher(config.module, password, iv, true) } - + return new Decipher(config.module, password, iv) } - + function createDecipher (suite, password) { var config = MODES[suite.toLowerCase()] if (!config) throw new TypeError('invalid suite type') - + var keys = ebtk(password, false, config.key, config.iv) return createDecipheriv(suite, keys.key, keys.iv) } - + exports.createDecipher = createDecipher exports.createDecipheriv = createDecipheriv - + },{"./aes":56,"./authCipher":57,"./modes":69,"./streamCipher":72,"cipher-base":86,"evp_bytestokey":158,"inherits":180,"safe-buffer":290}],60:[function(require,module,exports){ var MODES = require('./modes') var AuthCipher = require('./authCipher') @@ -13908,35 +13908,35 @@ var aes = require('./aes') var ebtk = require('evp_bytestokey') var inherits = require('inherits') - + function Cipher (mode, key, iv) { Transform.call(this) - + this._cache = new Splitter() this._cipher = new aes.AES(key) this._prev = Buffer.from(iv) this._mode = mode this._autopadding = true } - + inherits(Cipher, Transform) - + Cipher.prototype._update = function (data) { this._cache.add(data) var chunk var thing var out = [] - + while ((chunk = this._cache.get())) { thing = this._mode.encrypt(this, chunk) out.push(thing) } - + return Buffer.concat(out) } - + var PADDING = Buffer.alloc(16, 0x10) - + Cipher.prototype._final = function () { var chunk = this._cache.flush() if (this._autopadding) { @@ -13944,26 +13944,26 @@ this._cipher.scrub() return chunk } - + if (!chunk.equals(PADDING)) { this._cipher.scrub() throw new Error('data not multiple of block length') } } - + Cipher.prototype.setAutoPadding = function (setTo) { this._autopadding = !!setTo return this } - + function Splitter () { this.cache = Buffer.allocUnsafe(0) } - + Splitter.prototype.add = function (data) { this.cache = Buffer.concat([this.cache, data]) } - + Splitter.prototype.get = function () { if (this.cache.length > 15) { var out = this.cache.slice(0, 16) @@ -13972,53 +13972,53 @@ } return null } - + Splitter.prototype.flush = function () { var len = 16 - this.cache.length var padBuff = Buffer.allocUnsafe(len) - + var i = -1 while (++i < len) { padBuff.writeUInt8(len, i) } - + return Buffer.concat([this.cache, padBuff]) } - + function createCipheriv (suite, password, iv) { var config = MODES[suite.toLowerCase()] if (!config) throw new TypeError('invalid suite type') - + if (typeof password === 'string') password = Buffer.from(password) if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length) - + if (typeof iv === 'string') iv = Buffer.from(iv) if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length) - + if (config.type === 'stream') { return new StreamCipher(config.module, password, iv) } else if (config.type === 'auth') { return new AuthCipher(config.module, password, iv) } - + return new Cipher(config.module, password, iv) } - + function createCipher (suite, password) { var config = MODES[suite.toLowerCase()] if (!config) throw new TypeError('invalid suite type') - + var keys = ebtk(password, false, config.key, config.iv) return createCipheriv(suite, keys.key, keys.iv) } - + exports.createCipheriv = createCipheriv exports.createCipher = createCipher - + },{"./aes":56,"./authCipher":57,"./modes":69,"./streamCipher":72,"cipher-base":86,"evp_bytestokey":158,"inherits":180,"safe-buffer":290}],61:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var ZEROES = Buffer.alloc(16, 0) - + function toArray (buf) { return [ buf.readUInt32BE(0), @@ -14027,7 +14027,7 @@ buf.readUInt32BE(12) ] } - + function fromArray (out) { var buf = Buffer.allocUnsafe(16) buf.writeUInt32BE(out[0] >>> 0, 0) @@ -14036,13 +14036,13 @@ buf.writeUInt32BE(out[3] >>> 0, 12) return buf } - + function GHASH (key) { this.h = key this.state = Buffer.alloc(16, 0) this.cache = Buffer.allocUnsafe(0) } - + // from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html // by Juho Vähä-Herttua GHASH.prototype.ghash = function (block) { @@ -14052,7 +14052,7 @@ } this._multiply() } - + GHASH.prototype._multiply = function () { var Vi = toArray(this.h) var Zi = [0, 0, 0, 0] @@ -14067,16 +14067,16 @@ Zi[2] ^= Vi[2] Zi[3] ^= Vi[3] } - + // Store the value of LSB(V_i) lsbVi = (Vi[3] & 1) !== 0 - + // V_i+1 = V_i >> 1 for (j = 3; j > 0; j--) { Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31) } Vi[0] = Vi[0] >>> 1 - + // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R if (lsbVi) { Vi[0] = Vi[0] ^ (0xe1 << 24) @@ -14084,7 +14084,7 @@ } this.state = fromArray(Zi) } - + GHASH.prototype.update = function (buf) { this.cache = Buffer.concat([this.cache, buf]) var chunk @@ -14094,18 +14094,18 @@ this.ghash(chunk) } } - + GHASH.prototype.final = function (abl, bl) { if (this.cache.length) { this.ghash(Buffer.concat([this.cache, ZEROES], 16)) } - + this.ghash(fromArray([0, abl, 0, bl])) return this.state } - + module.exports = GHASH - + },{"safe-buffer":290}],62:[function(require,module,exports){ function incr32 (iv) { var len = iv.length @@ -14122,30 +14122,30 @@ } } module.exports = incr32 - + },{}],63:[function(require,module,exports){ var xor = require('buffer-xor') - + exports.encrypt = function (self, block) { var data = xor(block, self._prev) - + self._prev = self._cipher.encryptBlock(data) return self._prev } - + exports.decrypt = function (self, block) { var pad = self._prev - + self._prev = block var out = self._cipher.decryptBlock(block) - + return xor(out, pad) } - + },{"buffer-xor":83}],64:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var xor = require('buffer-xor') - + function encryptStart (self, data, decrypt) { var len = data.length var out = xor(data, self._cache) @@ -14153,17 +14153,17 @@ self._prev = Buffer.concat([self._prev, decrypt ? data : out]) return out } - + exports.encrypt = function (self, data, decrypt) { var out = Buffer.allocUnsafe(0) var len - + while (data.length) { if (self._cache.length === 0) { self._cache = self._cipher.encryptBlock(self._prev) self._prev = Buffer.allocUnsafe(0) } - + if (self._cache.length <= data.length) { len = self._cache.length out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)]) @@ -14173,13 +14173,13 @@ break } } - + return out } - + },{"buffer-xor":83,"safe-buffer":290}],65:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer - + function encryptByte (self, byteParam, decrypt) { var pad var i = -1 @@ -14195,70 +14195,70 @@ } return out } - + function shiftIn (buffer, value) { var len = buffer.length var i = -1 var out = Buffer.allocUnsafe(buffer.length) buffer = Buffer.concat([buffer, Buffer.from([value])]) - + while (++i < len) { out[i] = buffer[i] << 1 | buffer[i + 1] >> (7) } - + return out } - + exports.encrypt = function (self, chunk, decrypt) { var len = chunk.length var out = Buffer.allocUnsafe(len) var i = -1 - + while (++i < len) { out[i] = encryptByte(self, chunk[i], decrypt) } - + return out } - + },{"safe-buffer":290}],66:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer - + function encryptByte (self, byteParam, decrypt) { var pad = self._cipher.encryptBlock(self._prev) var out = pad[0] ^ byteParam - + self._prev = Buffer.concat([ self._prev.slice(1), Buffer.from([decrypt ? byteParam : out]) ]) - + return out } - + exports.encrypt = function (self, chunk, decrypt) { var len = chunk.length var out = Buffer.allocUnsafe(len) var i = -1 - + while (++i < len) { out[i] = encryptByte(self, chunk[i], decrypt) } - + return out } - + },{"safe-buffer":290}],67:[function(require,module,exports){ var xor = require('buffer-xor') var Buffer = require('safe-buffer').Buffer var incr32 = require('../incr32') - + function getBlock (self) { var out = self._cipher.encryptBlockRaw(self._prev) incr32(self._prev) return out } - + var blockSize = 16 exports.encrypt = function (self, chunk) { var chunkNum = Math.ceil(chunk.length / blockSize) @@ -14279,16 +14279,16 @@ self._cache = self._cache.slice(chunk.length) return xor(chunk, pad) } - + },{"../incr32":62,"buffer-xor":83,"safe-buffer":290}],68:[function(require,module,exports){ exports.encrypt = function (self, block) { return self._cipher.encryptBlock(block) } - + exports.decrypt = function (self, block) { return self._cipher.decryptBlock(block) } - + },{}],69:[function(require,module,exports){ var modeModules = { ECB: require('./ecb'), @@ -14300,15 +14300,15 @@ CTR: require('./ctr'), GCM: require('./ctr') } - + var modes = require('./list.json') - + for (var key in modes) { modes[key].module = modeModules[modes[key].mode] } - + module.exports = modes - + },{"./cbc":63,"./cfb":64,"./cfb1":65,"./cfb8":66,"./ctr":67,"./ecb":68,"./list.json":70,"./ofb":71}],70:[function(require,module,exports){ module.exports={ "aes-128-ecb": { @@ -14501,36 +14501,36 @@ "type": "auth" } } - + },{}],71:[function(require,module,exports){ (function (Buffer){ var xor = require('buffer-xor') - + function getBlock (self) { self._prev = self._cipher.encryptBlock(self._prev) return self._prev } - + exports.encrypt = function (self, chunk) { while (self._cache.length < chunk.length) { self._cache = Buffer.concat([self._cache, getBlock(self)]) } - + var pad = self._cache.slice(0, chunk.length) self._cache = self._cache.slice(chunk.length) return xor(chunk, pad) } - + }).call(this,require("buffer").Buffer) },{"buffer":84,"buffer-xor":83}],72:[function(require,module,exports){ var aes = require('./aes') var Buffer = require('safe-buffer').Buffer var Transform = require('cipher-base') var inherits = require('inherits') - + function StreamCipher (mode, key, iv, decrypt) { Transform.call(this) - + this._cipher = new aes.AES(key) this._prev = Buffer.from(iv) this._cache = Buffer.allocUnsafe(0) @@ -14538,19 +14538,19 @@ this._decrypt = decrypt this._mode = mode } - + inherits(StreamCipher, Transform) - + StreamCipher.prototype._update = function (chunk) { return this._mode.encrypt(this, chunk, this._decrypt) } - + StreamCipher.prototype._final = function () { this._cipher.scrub() } - + module.exports = StreamCipher - + },{"./aes":56,"cipher-base":86,"inherits":180,"safe-buffer":290}],73:[function(require,module,exports){ var ebtk = require('evp_bytestokey') var aes = require('browserify-aes/browser') @@ -14587,7 +14587,7 @@ var keys = ebtk(password, false, keyLen, ivLen) return createDecipheriv(suite, keys.key, keys.iv) } - + function createCipheriv (suite, key, iv) { suite = suite.toLowerCase() if (aesModes[suite]) { @@ -14625,13 +14625,13 @@ return Object.keys(desModes).concat(aes.getCiphers()) } exports.listCiphers = exports.getCiphers = getCiphers - + },{"browserify-aes/browser":58,"browserify-aes/modes":69,"browserify-des":74,"browserify-des/modes":75,"evp_bytestokey":158}],74:[function(require,module,exports){ (function (Buffer){ var CipherBase = require('cipher-base') var des = require('des.js') var inherits = require('inherits') - + var modes = { 'des-ede3-cbc': des.CBC.instantiate(des.EDE), 'des-ede3': des.EDE, @@ -14671,7 +14671,7 @@ DES.prototype._final = function () { return new Buffer(this._des.final()) } - + }).call(this,require("buffer").Buffer) },{"buffer":84,"cipher-base":86,"des.js":99,"inherits":180}],75:[function(require,module,exports){ exports['des-ecb'] = { @@ -14698,7 +14698,7 @@ key: 16, iv: 0 } - + },{}],76:[function(require,module,exports){ (function (Buffer){ var bn = require('bn.js'); @@ -14741,11 +14741,11 @@ } return r; } - + }).call(this,require("buffer").Buffer) },{"bn.js":53,"buffer":84,"randombytes":270}],77:[function(require,module,exports){ module.exports = require('./browser/algorithms.json') - + },{"./browser/algorithms.json":78}],78:[function(require,module,exports){ module.exports={ "sha224WithRSAEncryption": { @@ -14899,7 +14899,7 @@ "id": "3020300c06082a864886f70d020505000410" } } - + },{}],79:[function(require,module,exports){ module.exports={ "1.3.132.0.10": "secp256k1", @@ -14909,7 +14909,7 @@ "1.3.132.0.34": "p384", "1.3.132.0.35": "p521" } - + },{}],80:[function(require,module,exports){ (function (Buffer){ var createHash = require('create-hash') @@ -14917,93 +14917,93 @@ var inherits = require('inherits') var sign = require('./sign') var verify = require('./verify') - + var algorithms = require('./algorithms.json') Object.keys(algorithms).forEach(function (key) { algorithms[key].id = new Buffer(algorithms[key].id, 'hex') algorithms[key.toLowerCase()] = algorithms[key] }) - + function Sign (algorithm) { stream.Writable.call(this) - + var data = algorithms[algorithm] if (!data) throw new Error('Unknown message digest') - + this._hashType = data.hash this._hash = createHash(data.hash) this._tag = data.id this._signType = data.sign } inherits(Sign, stream.Writable) - + Sign.prototype._write = function _write (data, _, done) { this._hash.update(data) done() } - + Sign.prototype.update = function update (data, enc) { if (typeof data === 'string') data = new Buffer(data, enc) - + this._hash.update(data) return this } - + Sign.prototype.sign = function signMethod (key, enc) { this.end() var hash = this._hash.digest() var sig = sign(hash, key, this._hashType, this._signType, this._tag) - + return enc ? sig.toString(enc) : sig } - + function Verify (algorithm) { stream.Writable.call(this) - + var data = algorithms[algorithm] if (!data) throw new Error('Unknown message digest') - + this._hash = createHash(data.hash) this._tag = data.id this._signType = data.sign } inherits(Verify, stream.Writable) - + Verify.prototype._write = function _write (data, _, done) { this._hash.update(data) done() } - + Verify.prototype.update = function update (data, enc) { if (typeof data === 'string') data = new Buffer(data, enc) - + this._hash.update(data) return this } - + Verify.prototype.verify = function verifyMethod (key, sig, enc) { if (typeof sig === 'string') sig = new Buffer(sig, enc) - + this.end() var hash = this._hash.digest() return verify(sig, hash, key, this._signType, this._tag) } - + function createSign (algorithm) { return new Sign(algorithm) } - + function createVerify (algorithm) { return new Verify(algorithm) } - + module.exports = { Sign: createSign, Verify: createVerify, createSign: createSign, createVerify: createVerify } - + }).call(this,require("buffer").Buffer) },{"./algorithms.json":78,"./sign":81,"./verify":82,"buffer":84,"create-hash":91,"inherits":180,"stream":311}],81:[function(require,module,exports){ (function (Buffer){ @@ -15014,7 +15014,7 @@ var BN = require('bn.js') var parseKeys = require('parse-asn1') var curves = require('./curves.json') - + function sign (hash, key, hashType, signType, tag) { var priv = parseKeys(key) if (priv.curve) { @@ -15034,22 +15034,22 @@ pad.push(0x00) var i = -1 while (++i < hash.length) pad.push(hash[i]) - + var out = crt(pad, priv) return out } - + function ecSign (hash, priv) { var curveId = curves[priv.curve.join('.')] if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.')) - + var curve = new EC(curveId) var key = curve.keyFromPrivate(priv.privateKey) var out = key.sign(hash) - + return new Buffer(out.toDER()) } - + function dsaSign (hash, priv, algo) { var x = priv.params.priv_key var p = priv.params.p @@ -15071,21 +15071,21 @@ } return toDER(r, s) } - + function toDER (r, s) { r = r.toArray() s = s.toArray() - + // Pad values if (r[0] & 0x80) r = [ 0 ].concat(r) if (s[0] & 0x80) s = [ 0 ].concat(s) - + var total = r.length + s.length + 4 var res = [ 0x30, total, 0x02, r.length ] res = res.concat(r, [ 0x02, s.length ], s) return new Buffer(res) } - + function getKey (x, q, hash, algo) { x = new Buffer(x.toArray()) if (x.length < q.byteLength()) { @@ -15105,14 +15105,14 @@ v = createHmac(algo, k).update(v).digest() return { k: k, v: v } } - + function bits2int (obits, q) { var bits = new BN(obits) var shift = (obits.length << 3) - q.bitLength() if (shift > 0) bits.ishrn(shift) return bits } - + function bits2octets (bits, q) { bits = bits2int(bits, q) bits = bits.mod(q) @@ -15124,35 +15124,35 @@ } return out } - + function makeKey (q, kv, algo) { var t var k - + do { t = new Buffer(0) - + while (t.length * 8 < q.bitLength()) { kv.v = createHmac(algo, kv.k).update(kv.v).digest() t = Buffer.concat([ t, kv.v ]) } - + k = bits2int(t, q) kv.k = createHmac(algo, kv.k).update(kv.v).update(new Buffer([ 0 ])).digest() kv.v = createHmac(algo, kv.k).update(kv.v).digest() } while (k.cmp(q) !== -1) - + return k } - + function makeR (g, k, p, q) { return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q) } - + module.exports = sign module.exports.getKey = getKey module.exports.makeKey = makeKey - + }).call(this,require("buffer").Buffer) },{"./curves.json":79,"bn.js":53,"browserify-rsa":76,"buffer":84,"create-hmac":94,"elliptic":109,"parse-asn1":245}],82:[function(require,module,exports){ (function (Buffer){ @@ -15161,7 +15161,7 @@ var EC = require('elliptic').ec var parseKeys = require('parse-asn1') var curves = require('./curves.json') - + function verify (sig, hash, key, signType, tag) { var pub = parseKeys(key) if (pub.type === 'ec') { @@ -15190,28 +15190,28 @@ pad = new Buffer(pad) var red = BN.mont(pub.modulus) sig = new BN(sig).toRed(red) - + sig = sig.redPow(new BN(pub.publicExponent)) sig = new Buffer(sig.fromRed().toArray()) var out = padNum < 8 ? 1 : 0 len = Math.min(sig.length, pad.length) if (sig.length !== pad.length) out = 1 - + i = -1 while (++i < len) out |= sig[i] ^ pad[i] return out === 0 } - + function ecVerify (sig, hash, pub) { var curveId = curves[pub.data.algorithm.curve.join('.')] if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.')) - + var curve = new EC(curveId) var pubkey = pub.data.subjectPrivateKey.data - + return curve.verify(hash, sig, pubkey) } - + function dsaVerify (sig, hash, pub) { var p = pub.data.p var q = pub.data.q @@ -15232,28 +15232,28 @@ .mod(q) return v.cmp(r) === 0 } - + function checkValue (b, q) { if (b.cmpn(0) <= 0) throw new Error('invalid sig') if (b.cmp(q) >= q) throw new Error('invalid sig') } - + module.exports = verify - + }).call(this,require("buffer").Buffer) },{"./curves.json":79,"bn.js":53,"buffer":84,"elliptic":109,"parse-asn1":245}],83:[function(require,module,exports){ (function (Buffer){ module.exports = function xor (a, b) { var length = Math.min(a.length, b.length) var buffer = new Buffer(length) - + for (var i = 0; i < length; ++i) { buffer[i] = a[i] ^ b[i] } - + return buffer } - + }).call(this,require("buffer").Buffer) },{"buffer":84}],84:[function(require,module,exports){ /*! @@ -15263,19 +15263,19 @@ * @license MIT */ /* eslint-disable no-proto */ - + 'use strict' - + var base64 = require('base64-js') var ieee754 = require('ieee754') - + exports.Buffer = Buffer exports.SlowBuffer = SlowBuffer exports.INSPECT_MAX_BYTES = 50 - + var K_MAX_LENGTH = 0x7fffffff exports.kMaxLength = K_MAX_LENGTH - + /** * If `Buffer.TYPED_ARRAY_SUPPORT`: * === true Use Uint8Array implementation (fastest) @@ -15291,7 +15291,7 @@ * for __proto__ and has a buggy typed array implementation. */ Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() - + if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && typeof console.error === 'function') { console.error( @@ -15299,7 +15299,7 @@ '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' ) } - + function typedArraySupport () { // Can typed array instances can be augmented? try { @@ -15310,7 +15310,7 @@ return false } } - + function createBuffer (length) { if (length > K_MAX_LENGTH) { throw new RangeError('Invalid typed array length') @@ -15320,7 +15320,7 @@ buf.__proto__ = Buffer.prototype return buf } - + /** * The Buffer constructor returns instances of `Uint8Array` that have their * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of @@ -15330,7 +15330,7 @@ * * The `Uint8Array` prototype remains unmodified. */ - + function Buffer (arg, encodingOrOffset, length) { // Common case. if (typeof arg === 'number') { @@ -15343,7 +15343,7 @@ } return from(arg, encodingOrOffset, length) } - + // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 if (typeof Symbol !== 'undefined' && Symbol.species && Buffer[Symbol.species] === Buffer) { @@ -15354,25 +15354,25 @@ writable: false }) } - + Buffer.poolSize = 8192 // not used by this implementation - + function from (value, encodingOrOffset, length) { if (typeof value === 'number') { throw new TypeError('"value" argument must not be a number') } - + if (isArrayBuffer(value)) { return fromArrayBuffer(value, encodingOrOffset, length) } - + if (typeof value === 'string') { return fromString(value, encodingOrOffset) } - + return fromObject(value) } - + /** * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError * if value is a number. @@ -15384,12 +15384,12 @@ Buffer.from = function (value, encodingOrOffset, length) { return from(value, encodingOrOffset, length) } - + // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: // https://github.com/feross/buffer/pull/148 Buffer.prototype.__proto__ = Uint8Array.prototype Buffer.__proto__ = Uint8Array - + function assertSize (size) { if (typeof size !== 'number') { throw new TypeError('"size" argument must be a number') @@ -15397,7 +15397,7 @@ throw new RangeError('"size" argument must not be negative') } } - + function alloc (size, fill, encoding) { assertSize(size) if (size <= 0) { @@ -15413,7 +15413,7 @@ } return createBuffer(size) } - + /** * Creates a new filled Buffer instance. * alloc(size[, fill[, encoding]]) @@ -15421,12 +15421,12 @@ Buffer.alloc = function (size, fill, encoding) { return alloc(size, fill, encoding) } - + function allocUnsafe (size) { assertSize(size) return createBuffer(size < 0 ? 0 : checked(size) | 0) } - + /** * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. * */ @@ -15439,31 +15439,31 @@ Buffer.allocUnsafeSlow = function (size) { return allocUnsafe(size) } - + function fromString (string, encoding) { if (typeof encoding !== 'string' || encoding === '') { encoding = 'utf8' } - + if (!Buffer.isEncoding(encoding)) { throw new TypeError('"encoding" must be a valid string encoding') } - + var length = byteLength(string, encoding) | 0 var buf = createBuffer(length) - + var actual = buf.write(string, encoding) - + if (actual !== length) { // Writing a hex string, for example, that contains invalid characters will // cause everything after the first invalid character to be ignored. (e.g. // 'abxxcd' will be treated as 'ab') buf = buf.slice(0, actual) } - + return buf } - + function fromArrayLike (array) { var length = array.length < 0 ? 0 : checked(array.length) | 0 var buf = createBuffer(length) @@ -15472,16 +15472,16 @@ } return buf } - + function fromArrayBuffer (array, byteOffset, length) { if (byteOffset < 0 || array.byteLength < byteOffset) { throw new RangeError('\'offset\' is out of bounds') } - + if (array.byteLength < byteOffset + (length || 0)) { throw new RangeError('\'length\' is out of bounds') } - + var buf if (byteOffset === undefined && length === undefined) { buf = new Uint8Array(array) @@ -15490,25 +15490,25 @@ } else { buf = new Uint8Array(array, byteOffset, length) } - + // Return an augmented `Uint8Array` instance buf.__proto__ = Buffer.prototype return buf } - + function fromObject (obj) { if (Buffer.isBuffer(obj)) { var len = checked(obj.length) | 0 var buf = createBuffer(len) - + if (buf.length === 0) { return buf } - + obj.copy(buf, 0, 0, len) return buf } - + if (obj) { if (isArrayBufferView(obj) || 'length' in obj) { if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { @@ -15516,15 +15516,15 @@ } return fromArrayLike(obj) } - + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { return fromArrayLike(obj.data) } } - + throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') } - + function checked (length) { // Note: cannot use `length < K_MAX_LENGTH` here because that fails when // length is NaN (which is otherwise coerced to zero.) @@ -15534,28 +15534,28 @@ } return length | 0 } - + function SlowBuffer (length) { if (+length != length) { // eslint-disable-line eqeqeq length = 0 } return Buffer.alloc(+length) } - + Buffer.isBuffer = function isBuffer (b) { return b != null && b._isBuffer === true } - + Buffer.compare = function compare (a, b) { if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { throw new TypeError('Arguments must be Buffers') } - + if (a === b) return 0 - + var x = a.length var y = b.length - + for (var i = 0, len = Math.min(x, y); i < len; ++i) { if (a[i] !== b[i]) { x = a[i] @@ -15563,12 +15563,12 @@ break } } - + if (x < y) return -1 if (y < x) return 1 return 0 } - + Buffer.isEncoding = function isEncoding (encoding) { switch (String(encoding).toLowerCase()) { case 'hex': @@ -15587,16 +15587,16 @@ return false } } - + Buffer.concat = function concat (list, length) { if (!Array.isArray(list)) { throw new TypeError('"list" argument must be an Array of Buffers') } - + if (list.length === 0) { return Buffer.alloc(0) } - + var i if (length === undefined) { length = 0 @@ -15604,7 +15604,7 @@ length += list[i].length } } - + var buffer = Buffer.allocUnsafe(length) var pos = 0 for (i = 0; i < list.length; ++i) { @@ -15617,7 +15617,7 @@ } return buffer } - + function byteLength (string, encoding) { if (Buffer.isBuffer(string)) { return string.length @@ -15628,10 +15628,10 @@ if (typeof string !== 'string') { string = '' + string } - + var len = string.length if (len === 0) return 0 - + // Use a for loop to avoid recursion var loweredCase = false for (;;) { @@ -15661,13 +15661,13 @@ } } Buffer.byteLength = byteLength - + function slowToString (encoding, start, end) { var loweredCase = false - + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only // property of a typed array. - + // This behaves neither like String nor Uint8Array in that we set start/end // to their upper/lower bounds if the value passed is out of range. // undefined is handled specially as per ECMA-262 6th Edition, @@ -15680,50 +15680,50 @@ if (start > this.length) { return '' } - + if (end === undefined || end > this.length) { end = this.length } - + if (end <= 0) { return '' } - + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. end >>>= 0 start >>>= 0 - + if (end <= start) { return '' } - + if (!encoding) encoding = 'utf8' - + while (true) { switch (encoding) { case 'hex': return hexSlice(this, start, end) - + case 'utf8': case 'utf-8': return utf8Slice(this, start, end) - + case 'ascii': return asciiSlice(this, start, end) - + case 'latin1': case 'binary': return latin1Slice(this, start, end) - + case 'base64': return base64Slice(this, start, end) - + case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': return utf16leSlice(this, start, end) - + default: if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) encoding = (encoding + '').toLowerCase() @@ -15731,7 +15731,7 @@ } } } - + // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) // to detect a Buffer instance. It's not possible to use `instanceof Buffer` // reliably in a browserify context because there could be multiple different @@ -15739,13 +15739,13 @@ // instances that were created from another copy of the `buffer` package. // See: https://github.com/feross/buffer/issues/154 Buffer.prototype._isBuffer = true - + function swap (b, n, m) { var i = b[n] b[n] = b[m] b[m] = i } - + Buffer.prototype.swap16 = function swap16 () { var len = this.length if (len % 2 !== 0) { @@ -15756,7 +15756,7 @@ } return this } - + Buffer.prototype.swap32 = function swap32 () { var len = this.length if (len % 4 !== 0) { @@ -15768,7 +15768,7 @@ } return this } - + Buffer.prototype.swap64 = function swap64 () { var len = this.length if (len % 8 !== 0) { @@ -15782,20 +15782,20 @@ } return this } - + Buffer.prototype.toString = function toString () { var length = this.length if (length === 0) return '' if (arguments.length === 0) return utf8Slice(this, 0, length) return slowToString.apply(this, arguments) } - + Buffer.prototype.equals = function equals (b) { if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') if (this === b) return true return Buffer.compare(this, b) === 0 } - + Buffer.prototype.inspect = function inspect () { var str = '' var max = exports.INSPECT_MAX_BYTES @@ -15805,12 +15805,12 @@ } return '' } - + Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { if (!Buffer.isBuffer(target)) { throw new TypeError('Argument must be a Buffer') } - + if (start === undefined) { start = 0 } @@ -15823,11 +15823,11 @@ if (thisEnd === undefined) { thisEnd = this.length } - + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { throw new RangeError('out of range index') } - + if (thisStart >= thisEnd && start >= end) { return 0 } @@ -15837,21 +15837,21 @@ if (start >= end) { return 1 } - + start >>>= 0 end >>>= 0 thisStart >>>= 0 thisEnd >>>= 0 - + if (this === target) return 0 - + var x = thisEnd - thisStart var y = end - start var len = Math.min(x, y) - + var thisCopy = this.slice(thisStart, thisEnd) var targetCopy = target.slice(start, end) - + for (var i = 0; i < len; ++i) { if (thisCopy[i] !== targetCopy[i]) { x = thisCopy[i] @@ -15859,12 +15859,12 @@ break } } - + if (x < y) return -1 if (y < x) return 1 return 0 } - + // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, // OR the last index of `val` in `buffer` at offset <= `byteOffset`. // @@ -15877,7 +15877,7 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { // Empty buffer means no match if (buffer.length === 0) return -1 - + // Normalize byteOffset if (typeof byteOffset === 'string') { encoding = byteOffset @@ -15892,7 +15892,7 @@ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer byteOffset = dir ? 0 : (buffer.length - 1) } - + // Normalize byteOffset: negative offsets start from the end of the buffer if (byteOffset < 0) byteOffset = buffer.length + byteOffset if (byteOffset >= buffer.length) { @@ -15902,12 +15902,12 @@ if (dir) byteOffset = 0 else return -1 } - + // Normalize val if (typeof val === 'string') { val = Buffer.from(val, encoding) } - + // Finally, search either indexOf (if dir is true) or lastIndexOf if (Buffer.isBuffer(val)) { // Special case: looking for empty string/buffer always fails @@ -15926,15 +15926,15 @@ } return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) } - + throw new TypeError('val must be string, number or Buffer') } - + function arrayIndexOf (arr, val, byteOffset, encoding, dir) { var indexSize = 1 var arrLength = arr.length var valLength = val.length - + if (encoding !== undefined) { encoding = String(encoding).toLowerCase() if (encoding === 'ucs2' || encoding === 'ucs-2' || @@ -15948,7 +15948,7 @@ byteOffset /= 2 } } - + function read (buf, i) { if (indexSize === 1) { return buf[i] @@ -15956,7 +15956,7 @@ return buf.readUInt16BE(i * indexSize) } } - + var i if (dir) { var foundIndex = -1 @@ -15982,22 +15982,22 @@ if (found) return i } } - + return -1 } - + Buffer.prototype.includes = function includes (val, byteOffset, encoding) { return this.indexOf(val, byteOffset, encoding) !== -1 } - + Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, true) } - + Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, false) } - + function hexWrite (buf, string, offset, length) { offset = Number(offset) || 0 var remaining = buf.length - offset @@ -16009,11 +16009,11 @@ length = remaining } } - + // must be an even number of digits var strLen = string.length if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') - + if (length > strLen / 2) { length = strLen / 2 } @@ -16024,27 +16024,27 @@ } return i } - + function utf8Write (buf, string, offset, length) { return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) } - + function asciiWrite (buf, string, offset, length) { return blitBuffer(asciiToBytes(string), buf, offset, length) } - + function latin1Write (buf, string, offset, length) { return asciiWrite(buf, string, offset, length) } - + function base64Write (buf, string, offset, length) { return blitBuffer(base64ToBytes(string), buf, offset, length) } - + function ucs2Write (buf, string, offset, length) { return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) } - + Buffer.prototype.write = function write (string, offset, length, encoding) { // Buffer#write(string) if (offset === undefined) { @@ -16071,43 +16071,43 @@ 'Buffer.write(string, encoding, offset[, length]) is no longer supported' ) } - + var remaining = this.length - offset if (length === undefined || length > remaining) length = remaining - + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { throw new RangeError('Attempt to write outside buffer bounds') } - + if (!encoding) encoding = 'utf8' - + var loweredCase = false for (;;) { switch (encoding) { case 'hex': return hexWrite(this, string, offset, length) - + case 'utf8': case 'utf-8': return utf8Write(this, string, offset, length) - + case 'ascii': return asciiWrite(this, string, offset, length) - + case 'latin1': case 'binary': return latin1Write(this, string, offset, length) - + case 'base64': // Warning: maxLength not taken into account in base64Write return base64Write(this, string, offset, length) - + case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': return ucs2Write(this, string, offset, length) - + default: if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) encoding = ('' + encoding).toLowerCase() @@ -16115,14 +16115,14 @@ } } } - + Buffer.prototype.toJSON = function toJSON () { return { type: 'Buffer', data: Array.prototype.slice.call(this._arr || this, 0) } } - + function base64Slice (buf, start, end) { if (start === 0 && end === buf.length) { return base64.fromByteArray(buf) @@ -16130,11 +16130,11 @@ return base64.fromByteArray(buf.slice(start, end)) } } - + function utf8Slice (buf, start, end) { end = Math.min(buf.length, end) var res = [] - + var i = start while (i < end) { var firstByte = buf[i] @@ -16143,10 +16143,10 @@ : (firstByte > 0xDF) ? 3 : (firstByte > 0xBF) ? 2 : 1 - + if (i + bytesPerSequence <= end) { var secondByte, thirdByte, fourthByte, tempCodePoint - + switch (bytesPerSequence) { case 1: if (firstByte < 0x80) { @@ -16184,7 +16184,7 @@ } } } - + if (codePoint === null) { // we did not generate a valid codePoint so insert a // replacement char (U+FFFD) and advance only 1 byte @@ -16196,25 +16196,25 @@ res.push(codePoint >>> 10 & 0x3FF | 0xD800) codePoint = 0xDC00 | codePoint & 0x3FF } - + res.push(codePoint) i += bytesPerSequence } - + return decodeCodePointsArray(res) } - + // Based on http://stackoverflow.com/a/22747272/680742, the browser with // the lowest limit is Chrome, with 0x10000 args. // We go 1 magnitude less, for safety var MAX_ARGUMENTS_LENGTH = 0x1000 - + function decodeCodePointsArray (codePoints) { var len = codePoints.length if (len <= MAX_ARGUMENTS_LENGTH) { return String.fromCharCode.apply(String, codePoints) // avoid extra slice() } - + // Decode in chunks to avoid "call stack size exceeded". var res = '' var i = 0 @@ -16226,40 +16226,40 @@ } return res } - + function asciiSlice (buf, start, end) { var ret = '' end = Math.min(buf.length, end) - + for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i] & 0x7F) } return ret } - + function latin1Slice (buf, start, end) { var ret = '' end = Math.min(buf.length, end) - + for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i]) } return ret } - + function hexSlice (buf, start, end) { var len = buf.length - + if (!start || start < 0) start = 0 if (!end || end < 0 || end > len) end = len - + var out = '' for (var i = start; i < end; ++i) { out += toHex(buf[i]) } return out } - + function utf16leSlice (buf, start, end) { var bytes = buf.slice(start, end) var res = '' @@ -16268,34 +16268,34 @@ } return res } - + Buffer.prototype.slice = function slice (start, end) { var len = this.length start = ~~start end = end === undefined ? len : ~~end - + if (start < 0) { start += len if (start < 0) start = 0 } else if (start > len) { start = len } - + if (end < 0) { end += len if (end < 0) end = 0 } else if (end > len) { end = len } - + if (end < start) end = start - + var newBuf = this.subarray(start, end) // Return an augmented `Uint8Array` instance newBuf.__proto__ = Buffer.prototype return newBuf } - + /* * Need to make sure that buffer isn't trying to write out of bounds. */ @@ -16303,81 +16303,81 @@ if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') } - + Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { offset = offset >>> 0 byteLength = byteLength >>> 0 if (!noAssert) checkOffset(offset, byteLength, this.length) - + var val = this[offset] var mul = 1 var i = 0 while (++i < byteLength && (mul *= 0x100)) { val += this[offset + i] * mul } - + return val } - + Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { offset = offset >>> 0 byteLength = byteLength >>> 0 if (!noAssert) { checkOffset(offset, byteLength, this.length) } - + var val = this[offset + --byteLength] var mul = 1 while (byteLength > 0 && (mul *= 0x100)) { val += this[offset + --byteLength] * mul } - + return val } - + Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { offset = offset >>> 0 if (!noAssert) checkOffset(offset, 1, this.length) return this[offset] } - + Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { offset = offset >>> 0 if (!noAssert) checkOffset(offset, 2, this.length) return this[offset] | (this[offset + 1] << 8) } - + Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { offset = offset >>> 0 if (!noAssert) checkOffset(offset, 2, this.length) return (this[offset] << 8) | this[offset + 1] } - + Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { offset = offset >>> 0 if (!noAssert) checkOffset(offset, 4, this.length) - + return ((this[offset]) | (this[offset + 1] << 8) | (this[offset + 2] << 16)) + (this[offset + 3] * 0x1000000) } - + Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { offset = offset >>> 0 if (!noAssert) checkOffset(offset, 4, this.length) - + return (this[offset] * 0x1000000) + ((this[offset + 1] << 16) | (this[offset + 2] << 8) | this[offset + 3]) } - + Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { offset = offset >>> 0 byteLength = byteLength >>> 0 if (!noAssert) checkOffset(offset, byteLength, this.length) - + var val = this[offset] var mul = 1 var i = 0 @@ -16385,17 +16385,17 @@ val += this[offset + i] * mul } mul *= 0x80 - + if (val >= mul) val -= Math.pow(2, 8 * byteLength) - + return val } - + Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { offset = offset >>> 0 byteLength = byteLength >>> 0 if (!noAssert) checkOffset(offset, byteLength, this.length) - + var i = byteLength var mul = 1 var val = this[offset + --i] @@ -16403,83 +16403,83 @@ val += this[offset + --i] * mul } mul *= 0x80 - + if (val >= mul) val -= Math.pow(2, 8 * byteLength) - + return val } - + Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { offset = offset >>> 0 if (!noAssert) checkOffset(offset, 1, this.length) if (!(this[offset] & 0x80)) return (this[offset]) return ((0xff - this[offset] + 1) * -1) } - + Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { offset = offset >>> 0 if (!noAssert) checkOffset(offset, 2, this.length) var val = this[offset] | (this[offset + 1] << 8) return (val & 0x8000) ? val | 0xFFFF0000 : val } - + Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { offset = offset >>> 0 if (!noAssert) checkOffset(offset, 2, this.length) var val = this[offset + 1] | (this[offset] << 8) return (val & 0x8000) ? val | 0xFFFF0000 : val } - + Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { offset = offset >>> 0 if (!noAssert) checkOffset(offset, 4, this.length) - + return (this[offset]) | (this[offset + 1] << 8) | (this[offset + 2] << 16) | (this[offset + 3] << 24) } - + Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { offset = offset >>> 0 if (!noAssert) checkOffset(offset, 4, this.length) - + return (this[offset] << 24) | (this[offset + 1] << 16) | (this[offset + 2] << 8) | (this[offset + 3]) } - + Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { offset = offset >>> 0 if (!noAssert) checkOffset(offset, 4, this.length) return ieee754.read(this, offset, true, 23, 4) } - + Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { offset = offset >>> 0 if (!noAssert) checkOffset(offset, 4, this.length) return ieee754.read(this, offset, false, 23, 4) } - + Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { offset = offset >>> 0 if (!noAssert) checkOffset(offset, 8, this.length) return ieee754.read(this, offset, true, 52, 8) } - + Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { offset = offset >>> 0 if (!noAssert) checkOffset(offset, 8, this.length) return ieee754.read(this, offset, false, 52, 8) } - + function checkInt (buf, value, offset, ext, max, min) { if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') if (offset + ext > buf.length) throw new RangeError('Index out of range') } - + Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { value = +value offset = offset >>> 0 @@ -16488,17 +16488,17 @@ var maxBytes = Math.pow(2, 8 * byteLength) - 1 checkInt(this, value, offset, byteLength, maxBytes, 0) } - + var mul = 1 var i = 0 this[offset] = value & 0xFF while (++i < byteLength && (mul *= 0x100)) { this[offset + i] = (value / mul) & 0xFF } - + return offset + byteLength } - + Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { value = +value offset = offset >>> 0 @@ -16507,17 +16507,17 @@ var maxBytes = Math.pow(2, 8 * byteLength) - 1 checkInt(this, value, offset, byteLength, maxBytes, 0) } - + var i = byteLength - 1 var mul = 1 this[offset + i] = value & 0xFF while (--i >= 0 && (mul *= 0x100)) { this[offset + i] = (value / mul) & 0xFF } - + return offset + byteLength } - + Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { value = +value offset = offset >>> 0 @@ -16525,7 +16525,7 @@ this[offset] = (value & 0xff) return offset + 1 } - + Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { value = +value offset = offset >>> 0 @@ -16534,7 +16534,7 @@ this[offset + 1] = (value >>> 8) return offset + 2 } - + Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { value = +value offset = offset >>> 0 @@ -16543,7 +16543,7 @@ this[offset + 1] = (value & 0xff) return offset + 2 } - + Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { value = +value offset = offset >>> 0 @@ -16554,7 +16554,7 @@ this[offset] = (value & 0xff) return offset + 4 } - + Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { value = +value offset = offset >>> 0 @@ -16565,16 +16565,16 @@ this[offset + 3] = (value & 0xff) return offset + 4 } - + Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { value = +value offset = offset >>> 0 if (!noAssert) { var limit = Math.pow(2, (8 * byteLength) - 1) - + checkInt(this, value, offset, byteLength, limit - 1, -limit) } - + var i = 0 var mul = 1 var sub = 0 @@ -16585,19 +16585,19 @@ } this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } - + return offset + byteLength } - + Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { value = +value offset = offset >>> 0 if (!noAssert) { var limit = Math.pow(2, (8 * byteLength) - 1) - + checkInt(this, value, offset, byteLength, limit - 1, -limit) } - + var i = byteLength - 1 var mul = 1 var sub = 0 @@ -16608,10 +16608,10 @@ } this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } - + return offset + byteLength } - + Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { value = +value offset = offset >>> 0 @@ -16620,7 +16620,7 @@ this[offset] = (value & 0xff) return offset + 1 } - + Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { value = +value offset = offset >>> 0 @@ -16629,7 +16629,7 @@ this[offset + 1] = (value >>> 8) return offset + 2 } - + Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { value = +value offset = offset >>> 0 @@ -16638,7 +16638,7 @@ this[offset + 1] = (value & 0xff) return offset + 2 } - + Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { value = +value offset = offset >>> 0 @@ -16649,7 +16649,7 @@ this[offset + 3] = (value >>> 24) return offset + 4 } - + Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { value = +value offset = offset >>> 0 @@ -16661,12 +16661,12 @@ this[offset + 3] = (value & 0xff) return offset + 4 } - + function checkIEEE754 (buf, value, offset, ext, max, min) { if (offset + ext > buf.length) throw new RangeError('Index out of range') if (offset < 0) throw new RangeError('Index out of range') } - + function writeFloat (buf, value, offset, littleEndian, noAssert) { value = +value offset = offset >>> 0 @@ -16676,15 +16676,15 @@ ieee754.write(buf, value, offset, littleEndian, 23, 4) return offset + 4 } - + Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { return writeFloat(this, value, offset, true, noAssert) } - + Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { return writeFloat(this, value, offset, false, noAssert) } - + function writeDouble (buf, value, offset, littleEndian, noAssert) { value = +value offset = offset >>> 0 @@ -16694,15 +16694,15 @@ ieee754.write(buf, value, offset, littleEndian, 52, 8) return offset + 8 } - + Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { return writeDouble(this, value, offset, true, noAssert) } - + Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { return writeDouble(this, value, offset, false, noAssert) } - + // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) Buffer.prototype.copy = function copy (target, targetStart, start, end) { if (!start) start = 0 @@ -16710,27 +16710,27 @@ if (targetStart >= target.length) targetStart = target.length if (!targetStart) targetStart = 0 if (end > 0 && end < start) end = start - + // Copy 0 bytes; we're done if (end === start) return 0 if (target.length === 0 || this.length === 0) return 0 - + // Fatal error conditions if (targetStart < 0) { throw new RangeError('targetStart out of bounds') } if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') if (end < 0) throw new RangeError('sourceEnd out of bounds') - + // Are we oob? if (end > this.length) end = this.length if (target.length - targetStart < end - start) { end = target.length - targetStart + start } - + var len = end - start var i - + if (this === target && start < targetStart && targetStart < end) { // descending copy from end for (i = len - 1; i >= 0; --i) { @@ -16748,10 +16748,10 @@ targetStart ) } - + return len } - + // Usage: // buffer.fill(number[, offset[, end]]) // buffer.fill(buffer[, offset[, end]]) @@ -16782,21 +16782,21 @@ } else if (typeof val === 'number') { val = val & 255 } - + // Invalid ranges are not set to a default, so can range check early. if (start < 0 || this.length < start || this.length < end) { throw new RangeError('Out of range index') } - + if (end <= start) { return this } - + start = start >>> 0 end = end === undefined ? this.length : end >>> 0 - + if (!val) val = 0 - + var i if (typeof val === 'number') { for (i = start; i < end; ++i) { @@ -16811,15 +16811,15 @@ this[i + start] = bytes[i % len] } } - + return this } - + // HELPER FUNCTIONS // ================ - + var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g - + function base64clean (str) { // Node strips out invalid characters like \n and \t from the string, base64-js does not str = str.trim().replace(INVALID_BASE64_RE, '') @@ -16831,22 +16831,22 @@ } return str } - + function toHex (n) { if (n < 16) return '0' + n.toString(16) return n.toString(16) } - + function utf8ToBytes (string, units) { units = units || Infinity var codePoint var length = string.length var leadSurrogate = null var bytes = [] - + for (var i = 0; i < length; ++i) { codePoint = string.charCodeAt(i) - + // is surrogate component if (codePoint > 0xD7FF && codePoint < 0xE000) { // last char was a lead @@ -16861,29 +16861,29 @@ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) continue } - + // valid lead leadSurrogate = codePoint - + continue } - + // 2 leads in a row if (codePoint < 0xDC00) { if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) leadSurrogate = codePoint continue } - + // valid surrogate pair codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 } else if (leadSurrogate) { // valid bmp char, but last char was a lead if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) } - + leadSurrogate = null - + // encode utf8 if (codePoint < 0x80) { if ((units -= 1) < 0) break @@ -16913,10 +16913,10 @@ throw new Error('Invalid code point') } } - + return bytes } - + function asciiToBytes (str) { var byteArray = [] for (var i = 0; i < str.length; ++i) { @@ -16925,27 +16925,27 @@ } return byteArray } - + function utf16leToBytes (str, units) { var c, hi, lo var byteArray = [] for (var i = 0; i < str.length; ++i) { if ((units -= 2) < 0) break - + c = str.charCodeAt(i) hi = c >> 8 lo = c % 256 byteArray.push(lo) byteArray.push(hi) } - + return byteArray } - + function base64ToBytes (str) { return base64.toByteArray(base64clean(str)) } - + function blitBuffer (src, dst, offset, length) { for (var i = 0; i < length; ++i) { if ((i + offset >= dst.length) || (i >= src.length)) break @@ -16953,7 +16953,7 @@ } return i } - + // ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check // but they should be treated as valid. See: https://github.com/feross/buffer/issues/166 function isArrayBuffer (obj) { @@ -16961,16 +16961,16 @@ (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' && typeof obj.byteLength === 'number') } - + // Node 0.10 supports `ArrayBuffer` but lacks `ArrayBuffer.isView` function isArrayBufferView (obj) { return (typeof ArrayBuffer.isView === 'function') && ArrayBuffer.isView(obj) } - + function numberIsNaN (obj) { return obj !== obj // eslint-disable-line no-self-compare } - + },{"base64-js":51,"ieee754":178}],85:[function(require,module,exports){ module.exports = { "100": "Continue", @@ -17036,13 +17036,13 @@ "510": "Not Extended", "511": "Network Authentication Required" } - + },{}],86:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var Transform = require('stream').Transform var StringDecoder = require('string_decoder').StringDecoder var inherits = require('inherits') - + function CipherBase (hashMode) { Transform.call(this) this.hashMode = typeof hashMode === 'string' @@ -17059,35 +17059,35 @@ this._encoding = null } inherits(CipherBase, Transform) - + CipherBase.prototype.update = function (data, inputEnc, outputEnc) { if (typeof data === 'string') { data = Buffer.from(data, inputEnc) } - + var outData = this._update(data) if (this.hashMode) return this - + if (outputEnc) { outData = this._toString(outData, outputEnc) } - + return outData } - + CipherBase.prototype.setAutoPadding = function () {} CipherBase.prototype.getAuthTag = function () { throw new Error('trying to get auth tag in unsupported state') } - + CipherBase.prototype.setAuthTag = function () { throw new Error('trying to set auth tag in unsupported state') } - + CipherBase.prototype.setAAD = function () { throw new Error('trying to set aad in unsupported state') } - + CipherBase.prototype._transform = function (data, _, next) { var err try { @@ -17109,7 +17109,7 @@ } catch (e) { err = e } - + done(err) } CipherBase.prototype._finalOrDigest = function (outputEnc) { @@ -17119,34 +17119,34 @@ } return outData } - + CipherBase.prototype._toString = function (value, enc, fin) { if (!this._decoder) { this._decoder = new StringDecoder(enc) this._encoding = enc } - + if (this._encoding !== enc) throw new Error('can\'t switch encodings') - + var out = this._decoder.write(value) if (fin) { out += this._decoder.end() } - + return out } - + module.exports = CipherBase - + },{"inherits":180,"safe-buffer":290,"stream":311,"string_decoder":317}],87:[function(require,module,exports){ (function (Buffer){ var clone = (function() { 'use strict'; - + function _instanceof(obj, type) { return type != null && obj instanceof type; } - + var nativeMap; try { nativeMap = Map; @@ -17155,21 +17155,21 @@ // value will ever be an instanceof. nativeMap = function() {}; } - + var nativeSet; try { nativeSet = Set; } catch(_) { nativeSet = function() {}; } - + var nativePromise; try { nativePromise = Promise; } catch(_) { nativePromise = function() {}; } - + /** * Clones (copies) an Object using deep copying. * @@ -17202,30 +17202,30 @@ // and children have the same index var allParents = []; var allChildren = []; - + var useBuffer = typeof Buffer != 'undefined'; - + if (typeof circular == 'undefined') circular = true; - + if (typeof depth == 'undefined') depth = Infinity; - + // recurse this function so we don't reset allParents and allChildren function _clone(parent, depth) { // cloning null always returns null if (parent === null) return null; - + if (depth === 0) return parent; - + var child; var proto; if (typeof parent != 'object') { return parent; } - + if (_instanceof(parent, nativeMap)) { child = new nativeMap(); } else if (_instanceof(parent, nativeSet)) { @@ -17267,17 +17267,17 @@ proto = prototype; } } - + if (circular) { var index = allParents.indexOf(parent); - + if (index != -1) { return allChildren[index]; } allParents.push(parent); allChildren.push(child); } - + if (_instanceof(parent, nativeMap)) { parent.forEach(function(value, key) { var keyChild = _clone(key, depth - 1); @@ -17291,19 +17291,19 @@ child.add(entryChild); }); } - + for (var i in parent) { var attrs; if (proto) { attrs = Object.getOwnPropertyDescriptor(proto, i); } - + if (attrs && attrs.set == null) { continue; } child[i] = _clone(parent[i], depth - 1); } - + if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(parent); for (var i = 0; i < symbols.length; i++) { @@ -17322,7 +17322,7 @@ } } } - + if (includeNonEnumerable) { var allPropertyNames = Object.getOwnPropertyNames(parent); for (var i = 0; i < allPropertyNames.length; i++) { @@ -17337,13 +17337,13 @@ }); } } - + return child; } - + return _clone(parent, depth); } - + /** * Simple flat clone using prototype, accepts only objects, usefull for property * override on FLAT configuration object (no nested props). @@ -17354,34 +17354,34 @@ clone.clonePrototype = function clonePrototype(parent) { if (parent === null) return null; - + var c = function () {}; c.prototype = parent; return new c(); }; - + // private utility functions - + function __objToStr(o) { return Object.prototype.toString.call(o); } clone.__objToStr = __objToStr; - + function __isDate(o) { return typeof o === 'object' && __objToStr(o) === '[object Date]'; } clone.__isDate = __isDate; - + function __isArray(o) { return typeof o === 'object' && __objToStr(o) === '[object Array]'; } clone.__isArray = __isArray; - + function __isRegExp(o) { return typeof o === 'object' && __objToStr(o) === '[object RegExp]'; } clone.__isRegExp = __isRegExp; - + function __getRegExpFlags(re) { var flags = ''; if (re.global) flags += 'g'; @@ -17390,20 +17390,20 @@ return flags; } clone.__getRegExpFlags = __getRegExpFlags; - + return clone; })(); - + if (typeof module === 'object' && module.exports) { module.exports = clone; } - + }).call(this,require("buffer").Buffer) },{"buffer":84}],88:[function(require,module,exports){ /* jshint node: true */ (function () { "use strict"; - + function CookieAccessInfo(domain, path, secure, script) { if (this instanceof CookieAccessInfo) { this.domain = domain || undefined; @@ -17416,7 +17416,7 @@ } CookieAccessInfo.All = Object.freeze(Object.create(null)); exports.CookieAccessInfo = CookieAccessInfo; - + function Cookie(cookiestr, request_domain, request_path) { if (cookiestr instanceof Cookie) { return cookiestr; @@ -17439,7 +17439,7 @@ return new Cookie(cookiestr, request_domain, request_path); } exports.Cookie = Cookie; - + Cookie.prototype.toString = function toString() { var str = [this.name + "=" + this.value]; if (this.expiration_date !== Infinity) { @@ -17459,11 +17459,11 @@ } return str.join("; "); }; - + Cookie.prototype.toValueString = function toValueString() { return this.name + "=" + this.value; }; - + var cookie_str_splitter = /[:](?=\s*[a-zA-Z0-9_\-]+\s*[=])/g; Cookie.prototype.parse = function parse(str, request_domain, request_path) { if (this instanceof Cookie) { @@ -17471,23 +17471,23 @@ return !!value; }); var i; - + var pair = parts[0].match(/([^=]+)=([\s\S]*)/); if (!pair) { console.warn("Invalid cookie header encountered. Header: '"+str+"'"); return; } - + var key = pair[1]; var value = pair[2]; if ( typeof key !== 'string' || key.length === 0 || typeof value !== 'string' ) { console.warn("Unable to extract values from cookie header. Cookie: '"+str+"'"); return; } - + this.name = key; this.value = value; - + for (i = 1; i < parts.length; i += 1) { pair = parts[i].match(/([^=]+)(?:=([\s\S]*))?/); key = pair[1].trim().toLowerCase(); @@ -17518,19 +17518,19 @@ break; } } - + if (!this.explicit_path) { this.path = request_path || "/"; } if (!this.explicit_domain) { this.domain = request_domain; } - + return this; } return new Cookie().parse(str, request_domain, request_path); }; - + Cookie.prototype.matches = function matches(access_info) { if (access_info === CookieAccessInfo.All) { return true; @@ -17542,7 +17542,7 @@ } return true; }; - + Cookie.prototype.collidesWith = function collidesWith(access_info) { if ((this.path && !access_info.path) || (this.domain && !access_info.domain)) { return false; @@ -17570,12 +17570,12 @@ } return true; }; - + function CookieJar() { var cookies, cookies_list, collidable_cookie; if (this instanceof CookieJar) { cookies = Object.create(null); //name: [Cookie] - + this.setCookie = function setCookie(cookie, request_domain, request_path) { var remove, i; cookie = new Cookie(cookie, request_domain, request_path); @@ -17624,7 +17624,7 @@ } continue; } - + if (cookie.matches(access_info)) { return cookie; } @@ -17649,13 +17649,13 @@ }; return matches; }; - + return this; } return new CookieJar(); } exports.CookieJar = CookieJar; - + //returns list of cookies that were set correctly. Cookies that are expired and removed are not returned. CookieJar.prototype.setCookies = function setCookies(cookies, request_domain, request_path) { cookies = Array.isArray(cookies) ? @@ -17676,7 +17676,7 @@ return successful; }; }()); - + },{}],89:[function(require,module,exports){ (function (Buffer){ // Copyright Joyent, Inc. and other Node contributors. @@ -17699,10 +17699,10 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - + // NOTE: These type checking functions intentionally don't use `instanceof` // because it is fragile and can be easily faked with `Object.create()`. - + function isArray(arg) { if (Array.isArray) { return Array.isArray(arg); @@ -17710,67 +17710,67 @@ return objectToString(arg) === '[object Array]'; } exports.isArray = isArray; - + function isBoolean(arg) { return typeof arg === 'boolean'; } exports.isBoolean = isBoolean; - + function isNull(arg) { return arg === null; } exports.isNull = isNull; - + function isNullOrUndefined(arg) { return arg == null; } exports.isNullOrUndefined = isNullOrUndefined; - + function isNumber(arg) { return typeof arg === 'number'; } exports.isNumber = isNumber; - + function isString(arg) { return typeof arg === 'string'; } exports.isString = isString; - + function isSymbol(arg) { return typeof arg === 'symbol'; } exports.isSymbol = isSymbol; - + function isUndefined(arg) { return arg === void 0; } exports.isUndefined = isUndefined; - + function isRegExp(re) { return objectToString(re) === '[object RegExp]'; } exports.isRegExp = isRegExp; - + function isObject(arg) { return typeof arg === 'object' && arg !== null; } exports.isObject = isObject; - + function isDate(d) { return objectToString(d) === '[object Date]'; } exports.isDate = isDate; - + function isError(e) { return (objectToString(e) === '[object Error]' || e instanceof Error); } exports.isError = isError; - + function isFunction(arg) { return typeof arg === 'function'; } exports.isFunction = isFunction; - + function isPrimitive(arg) { return arg === null || typeof arg === 'boolean' || @@ -17780,23 +17780,23 @@ typeof arg === 'undefined'; } exports.isPrimitive = isPrimitive; - + exports.isBuffer = Buffer.isBuffer; - + function objectToString(o) { return Object.prototype.toString.call(o); } - + }).call(this,{"isBuffer":require("../../is-buffer/index.js")}) },{"../../is-buffer/index.js":181}],90:[function(require,module,exports){ (function (Buffer){ var elliptic = require('elliptic'); var BN = require('bn.js'); - + module.exports = function createECDH(curve) { return new ECDH(curve); }; - + var aliases = { secp256k1: { name: 'secp256k1', @@ -17827,13 +17827,13 @@ byteLength: 66 } }; - + aliases.p224 = aliases.secp224r1; aliases.p256 = aliases.secp256r1 = aliases.prime256v1; aliases.p192 = aliases.secp192r1 = aliases.prime192v1; aliases.p384 = aliases.secp384r1; aliases.p521 = aliases.secp521r1; - + function ECDH(curve) { this.curveType = aliases[curve]; if (!this.curveType ) { @@ -17844,12 +17844,12 @@ this.curve = new elliptic.ec(this.curveType.name); this.keys = void 0; } - + ECDH.prototype.generateKeys = function (enc, format) { this.keys = this.curve.genKeyPair(); return this.getPublicKey(enc, format); }; - + ECDH.prototype.computeSecret = function (other, inenc, enc) { inenc = inenc || 'utf8'; if (!Buffer.isBuffer(other)) { @@ -17859,7 +17859,7 @@ var out = otherPub.mul(this.keys.getPrivate()).getX(); return formatReturnValue(out, enc, this.curveType.byteLength); }; - + ECDH.prototype.getPublicKey = function (enc, format) { var key = this.keys.getPublic(format === 'compressed', true); if (format === 'hybrid') { @@ -17871,11 +17871,11 @@ } return formatReturnValue(key, enc); }; - + ECDH.prototype.getPrivateKey = function (enc) { return formatReturnValue(this.keys.getPrivate(), enc); }; - + ECDH.prototype.setPublicKey = function (pub, enc) { enc = enc || 'utf8'; if (!Buffer.isBuffer(pub)) { @@ -17884,7 +17884,7 @@ this.keys._importPublic(pub); return this; }; - + ECDH.prototype.setPrivateKey = function (priv, enc) { enc = enc || 'utf8'; if (!Buffer.isBuffer(priv)) { @@ -17895,7 +17895,7 @@ this.keys._importPrivate(_priv); return this; }; - + function formatReturnValue(bn, enc, len) { if (!Array.isArray(bn)) { bn = bn.toArray(); @@ -17912,7 +17912,7 @@ return buf.toString(enc); } } - + }).call(this,require("buffer").Buffer) },{"bn.js":53,"buffer":84,"elliptic":109}],91:[function(require,module,exports){ (function (Buffer){ @@ -17921,54 +17921,54 @@ var md5 = require('./md5') var RIPEMD160 = require('ripemd160') var sha = require('sha.js') - + var Base = require('cipher-base') - + function HashNoConstructor (hash) { Base.call(this, 'digest') - + this._hash = hash this.buffers = [] } - + inherits(HashNoConstructor, Base) - + HashNoConstructor.prototype._update = function (data) { this.buffers.push(data) } - + HashNoConstructor.prototype._final = function () { var buf = Buffer.concat(this.buffers) var r = this._hash(buf) this.buffers = null - + return r } - + function Hash (hash) { Base.call(this, 'digest') - + this._hash = hash } - + inherits(Hash, Base) - + Hash.prototype._update = function (data) { this._hash.update(data) } - + Hash.prototype._final = function () { return this._hash.digest() } - + module.exports = function createHash (alg) { alg = alg.toLowerCase() if (alg === 'md5') return new HashNoConstructor(md5) if (alg === 'rmd160' || alg === 'ripemd160') return new Hash(new RIPEMD160()) - + return new Hash(sha(alg)) } - + }).call(this,require("buffer").Buffer) },{"./md5":93,"buffer":84,"cipher-base":86,"inherits":180,"ripemd160":288,"sha.js":304}],92:[function(require,module,exports){ (function (Buffer){ @@ -17976,24 +17976,24 @@ var intSize = 4 var zeroBuffer = new Buffer(intSize) zeroBuffer.fill(0) - + var charSize = 8 var hashSize = 16 - + function toArray (buf) { if ((buf.length % intSize) !== 0) { var len = buf.length + (intSize - (buf.length % intSize)) buf = Buffer.concat([buf, zeroBuffer], len) } - + var arr = new Array(buf.length >>> 2) for (var i = 0, j = 0; i < buf.length; i += intSize, j++) { arr[j] = buf.readInt32LE(i) } - + return arr } - + module.exports = function hash (buf, fn) { var arr = fn(toArray(buf), buf.length * charSize) buf = new Buffer(hashSize) @@ -18002,7 +18002,7 @@ } return buf } - + }).call(this,require("buffer").Buffer) },{"buffer":84}],93:[function(require,module,exports){ 'use strict' @@ -18014,9 +18014,9 @@ * Distributed under the BSD License * See http://pajhome.org.uk/crypt/md5 for more info. */ - + var makeHash = require('./make-hash') - + /* * Calculate the MD5 of an array of little-endian words, and a bit length */ @@ -18024,18 +18024,18 @@ /* append padding */ x[len >> 5] |= 0x80 << ((len) % 32) x[(((len + 64) >>> 9) << 4) + 14] = len - + var a = 1732584193 var b = -271733879 var c = -1732584194 var d = 271733878 - + for (var i = 0; i < x.length; i += 16) { var olda = a var oldb = b var oldc = c var oldd = d - + a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936) d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586) c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819) @@ -18052,7 +18052,7 @@ d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101) c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290) b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329) - + a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510) d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632) c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713) @@ -18069,7 +18069,7 @@ d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784) c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473) b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734) - + a = md5_hh(a, b, c, d, x[i + 5], 4, -378558) d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463) c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562) @@ -18086,7 +18086,7 @@ d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835) c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520) b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651) - + a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844) d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415) c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905) @@ -18103,39 +18103,39 @@ d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379) c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259) b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551) - + a = safe_add(a, olda) b = safe_add(b, oldb) c = safe_add(c, oldc) d = safe_add(d, oldd) } - + return [a, b, c, d] } - + /* * These functions implement the four basic operations the algorithm uses. */ function md5_cmn (q, a, b, x, s, t) { return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b) } - + function md5_ff (a, b, c, d, x, s, t) { return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t) } - + function md5_gg (a, b, c, d, x, s, t) { return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t) } - + function md5_hh (a, b, c, d, x, s, t) { return md5_cmn(b ^ c ^ d, a, b, x, s, t) } - + function md5_ii (a, b, c, d, x, s, t) { return md5_cmn(c ^ (b | (~d)), a, b, x, s, t) } - + /* * Add integers, wrapping at 2^32. This uses 16-bit operations internally * to work around bugs in some JS interpreters. @@ -18145,18 +18145,18 @@ var msw = (x >> 16) + (y >> 16) + (lsw >> 16) return (msw << 16) | (lsw & 0xFFFF) } - + /* * Bitwise rotate a 32-bit number to the left. */ function bit_rol (num, cnt) { return (num << cnt) | (num >>> (32 - cnt)) } - + module.exports = function md5 (buf) { return makeHash(buf, core_md5) } - + },{"./make-hash":92}],94:[function(require,module,exports){ 'use strict' var inherits = require('inherits') @@ -18165,19 +18165,19 @@ var Buffer = require('safe-buffer').Buffer var md5 = require('create-hash/md5') var RIPEMD160 = require('ripemd160') - + var sha = require('sha.js') - + var ZEROS = Buffer.alloc(128) - + function Hmac (alg, key) { Base.call(this, 'digest') if (typeof key === 'string') { key = Buffer.from(key) } - + var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64 - + this._alg = alg this._key = key if (key.length > blocksize) { @@ -18186,10 +18186,10 @@ } else if (key.length < blocksize) { key = Buffer.concat([key, ZEROS], blocksize) } - + var ipad = this._ipad = Buffer.allocUnsafe(blocksize) var opad = this._opad = Buffer.allocUnsafe(blocksize) - + for (var i = 0; i < blocksize; i++) { ipad[i] = key[i] ^ 0x36 opad[i] = key[i] ^ 0x5C @@ -18197,19 +18197,19 @@ this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg) this._hash.update(ipad) } - + inherits(Hmac, Base) - + Hmac.prototype._update = function (data) { this._hash.update(data) } - + Hmac.prototype._final = function () { var h = this._hash.digest() var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg) return hash.update(this._opad).update(h).digest() } - + module.exports = function createHmac (alg, key) { alg = alg.toLowerCase() if (alg === 'rmd160' || alg === 'ripemd160') { @@ -18220,55 +18220,55 @@ } return new Hmac(alg, key) } - + },{"./legacy":95,"cipher-base":86,"create-hash/md5":93,"inherits":180,"ripemd160":288,"safe-buffer":290,"sha.js":304}],95:[function(require,module,exports){ 'use strict' var inherits = require('inherits') var Buffer = require('safe-buffer').Buffer - + var Base = require('cipher-base') - + var ZEROS = Buffer.alloc(128) var blocksize = 64 - + function Hmac (alg, key) { Base.call(this, 'digest') if (typeof key === 'string') { key = Buffer.from(key) } - + this._alg = alg this._key = key - + if (key.length > blocksize) { key = alg(key) } else if (key.length < blocksize) { key = Buffer.concat([key, ZEROS], blocksize) } - + var ipad = this._ipad = Buffer.allocUnsafe(blocksize) var opad = this._opad = Buffer.allocUnsafe(blocksize) - + for (var i = 0; i < blocksize; i++) { ipad[i] = key[i] ^ 0x36 opad[i] = key[i] ^ 0x5C } - + this._hash = [ipad] } - + inherits(Hmac, Base) - + Hmac.prototype._update = function (data) { this._hash.push(data) } - + Hmac.prototype._final = function () { var h = this._alg(Buffer.concat(this._hash)) return this._alg(Buffer.concat([this._opad, h])) } module.exports = Hmac - + },{"cipher-base":86,"inherits":180,"safe-buffer":290}],96:[function(require,module,exports){ var __root__ = (function (root) { function F() { this.fetch = false; } @@ -18276,13 +18276,13 @@ return new F(); })(typeof self !== 'undefined' ? self : this); (function(self) { - + (function(self) { - + if (self.fetch) { return } - + var support = { searchParams: 'URLSearchParams' in self, iterable: 'Symbol' in self && 'iterator' in Symbol, @@ -18297,7 +18297,7 @@ formData: 'FormData' in self, arrayBuffer: 'ArrayBuffer' in self }; - + if (support.arrayBuffer) { var viewClasses = [ '[object Int8Array]', @@ -18310,16 +18310,16 @@ '[object Float32Array]', '[object Float64Array]' ]; - + var isDataView = function(obj) { return obj && DataView.prototype.isPrototypeOf(obj) }; - + var isArrayBufferView = ArrayBuffer.isView || function(obj) { return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 }; } - + function normalizeName(name) { if (typeof name !== 'string') { name = String(name); @@ -18329,14 +18329,14 @@ } return name.toLowerCase() } - + function normalizeValue(value) { if (typeof value !== 'string') { value = String(value); } return value } - + // Build a destructive iterator for the value list function iteratorFor(items) { var iterator = { @@ -18345,19 +18345,19 @@ return {done: value === undefined, value: value} } }; - + if (support.iterable) { iterator[Symbol.iterator] = function() { return iterator }; } - + return iterator } - + function Headers(headers) { this.map = {}; - + if (headers instanceof Headers) { headers.forEach(function(value, name) { this.append(name, value); @@ -18372,31 +18372,31 @@ }, this); } } - + Headers.prototype.append = function(name, value) { name = normalizeName(name); value = normalizeValue(value); var oldValue = this.map[name]; this.map[name] = oldValue ? oldValue+','+value : value; }; - + Headers.prototype['delete'] = function(name) { delete this.map[normalizeName(name)]; }; - + Headers.prototype.get = function(name) { name = normalizeName(name); return this.has(name) ? this.map[name] : null }; - + Headers.prototype.has = function(name) { return this.map.hasOwnProperty(normalizeName(name)) }; - + Headers.prototype.set = function(name, value) { this.map[normalizeName(name)] = normalizeValue(value); }; - + Headers.prototype.forEach = function(callback, thisArg) { for (var name in this.map) { if (this.map.hasOwnProperty(name)) { @@ -18404,36 +18404,36 @@ } } }; - + Headers.prototype.keys = function() { var items = []; this.forEach(function(value, name) { items.push(name); }); return iteratorFor(items) }; - + Headers.prototype.values = function() { var items = []; this.forEach(function(value) { items.push(value); }); return iteratorFor(items) }; - + Headers.prototype.entries = function() { var items = []; this.forEach(function(value, name) { items.push([name, value]); }); return iteratorFor(items) }; - + if (support.iterable) { Headers.prototype[Symbol.iterator] = Headers.prototype.entries; } - + function consumed(body) { if (body.bodyUsed) { return Promise.reject(new TypeError('Already read')) } body.bodyUsed = true; } - + function fileReaderReady(reader) { return new Promise(function(resolve, reject) { reader.onload = function() { @@ -18444,31 +18444,31 @@ }; }) } - + function readBlobAsArrayBuffer(blob) { var reader = new FileReader(); var promise = fileReaderReady(reader); reader.readAsArrayBuffer(blob); return promise } - + function readBlobAsText(blob) { var reader = new FileReader(); var promise = fileReaderReady(reader); reader.readAsText(blob); return promise } - + function readArrayBufferAsText(buf) { var view = new Uint8Array(buf); var chars = new Array(view.length); - + for (var i = 0; i < view.length; i++) { chars[i] = String.fromCharCode(view[i]); } return chars.join('') } - + function bufferClone(buf) { if (buf.slice) { return buf.slice(0) @@ -18478,10 +18478,10 @@ return view.buffer } } - + function Body() { this.bodyUsed = false; - + this._initBody = function(body) { this._bodyInit = body; if (!body) { @@ -18503,7 +18503,7 @@ } else { throw new Error('unsupported BodyInit type') } - + if (!this.headers.get('content-type')) { if (typeof body === 'string') { this.headers.set('content-type', 'text/plain;charset=UTF-8'); @@ -18514,14 +18514,14 @@ } } }; - + if (support.blob) { this.blob = function() { var rejected = consumed(this); if (rejected) { return rejected } - + if (this._bodyBlob) { return Promise.resolve(this._bodyBlob) } else if (this._bodyArrayBuffer) { @@ -18532,7 +18532,7 @@ return Promise.resolve(new Blob([this._bodyText])) } }; - + this.arrayBuffer = function() { if (this._bodyArrayBuffer) { return consumed(this) || Promise.resolve(this._bodyArrayBuffer) @@ -18541,13 +18541,13 @@ } }; } - + this.text = function() { var rejected = consumed(this); if (rejected) { return rejected } - + if (this._bodyBlob) { return readBlobAsText(this._bodyBlob) } else if (this._bodyArrayBuffer) { @@ -18558,32 +18558,32 @@ return Promise.resolve(this._bodyText) } }; - + if (support.formData) { this.formData = function() { return this.text().then(decode) }; } - + this.json = function() { return this.text().then(JSON.parse) }; - + return this } - + // HTTP methods whose capitalization should be normalized var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']; - + function normalizeMethod(method) { var upcased = method.toUpperCase(); return (methods.indexOf(upcased) > -1) ? upcased : method } - + function Request(input, options) { options = options || {}; var body = options.body; - + if (input instanceof Request) { if (input.bodyUsed) { throw new TypeError('Already read') @@ -18602,7 +18602,7 @@ } else { this.url = String(input); } - + this.credentials = options.credentials || this.credentials || 'omit'; if (options.headers || !this.headers) { this.headers = new Headers(options.headers); @@ -18610,17 +18610,17 @@ this.method = normalizeMethod(options.method || this.method || 'GET'); this.mode = options.mode || this.mode || null; this.referrer = null; - + if ((this.method === 'GET' || this.method === 'HEAD') && body) { throw new TypeError('Body not allowed for GET or HEAD requests') } this._initBody(body); } - + Request.prototype.clone = function() { return new Request(this, { body: this._bodyInit }) }; - + function decode(body) { var form = new FormData(); body.trim().split('&').forEach(function(bytes) { @@ -18633,7 +18633,7 @@ }); return form } - + function parseHeaders(rawHeaders) { var headers = new Headers(); // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space @@ -18649,14 +18649,14 @@ }); return headers } - + Body.call(Request.prototype); - + function Response(bodyInit, options) { if (!options) { options = {}; } - + this.type = 'default'; this.status = options.status === undefined ? 200 : options.status; this.ok = this.status >= 200 && this.status < 300; @@ -18665,9 +18665,9 @@ this.url = options.url || ''; this._initBody(bodyInit); } - + Body.call(Response.prototype); - + Response.prototype.clone = function() { return new Response(this._bodyInit, { status: this.status, @@ -18676,32 +18676,32 @@ url: this.url }) }; - + Response.error = function() { var response = new Response(null, {status: 0, statusText: ''}); response.type = 'error'; return response }; - + var redirectStatuses = [301, 302, 303, 307, 308]; - + Response.redirect = function(url, status) { if (redirectStatuses.indexOf(status) === -1) { throw new RangeError('Invalid status code') } - + return new Response(null, {status: status, headers: {location: url}}) }; - + self.Headers = Headers; self.Request = Request; self.Response = Response; - + self.fetch = function(input, init) { return new Promise(function(resolve, reject) { var request = new Request(input, init); var xhr = new XMLHttpRequest(); - + xhr.onload = function() { var options = { status: xhr.status, @@ -18712,31 +18712,31 @@ var body = 'response' in xhr ? xhr.response : xhr.responseText; resolve(new Response(body, options)); }; - + xhr.onerror = function() { reject(new TypeError('Network request failed')); }; - + xhr.ontimeout = function() { reject(new TypeError('Network request failed')); }; - + xhr.open(request.method, request.url, true); - + if (request.credentials === 'include') { xhr.withCredentials = true; } else if (request.credentials === 'omit') { xhr.withCredentials = false; } - + if ('responseType' in xhr && support.blob) { xhr.responseType = 'blob'; } - + request.headers.forEach(function(value, name) { xhr.setRequestHeader(name, value); }); - + xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit); }) }; @@ -18752,27 +18752,27 @@ // Needed for TypeScript consumers without esModuleInterop. module.exports.default = fetch; } - + },{}],97:[function(require,module,exports){ 'use strict' - + exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes') exports.createHash = exports.Hash = require('create-hash') exports.createHmac = exports.Hmac = require('create-hmac') - + var algos = require('browserify-sign/algos') var algoKeys = Object.keys(algos) var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys) exports.getHashes = function () { return hashes } - + var p = require('pbkdf2') exports.pbkdf2 = p.pbkdf2 exports.pbkdf2Sync = p.pbkdf2Sync - + var aes = require('browserify-cipher') - + exports.Cipher = aes.Cipher exports.createCipher = aes.createCipher exports.Cipheriv = aes.Cipheriv @@ -18783,31 +18783,31 @@ exports.createDecipheriv = aes.createDecipheriv exports.getCiphers = aes.getCiphers exports.listCiphers = aes.listCiphers - + var dh = require('diffie-hellman') - + exports.DiffieHellmanGroup = dh.DiffieHellmanGroup exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup exports.getDiffieHellman = dh.getDiffieHellman exports.createDiffieHellman = dh.createDiffieHellman exports.DiffieHellman = dh.DiffieHellman - + var sign = require('browserify-sign') - + exports.createSign = sign.createSign exports.Sign = sign.Sign exports.createVerify = sign.createVerify exports.Verify = sign.Verify - + exports.createECDH = require('create-ecdh') - + var publicEncrypt = require('public-encrypt') - + exports.publicEncrypt = publicEncrypt.publicEncrypt exports.privateEncrypt = publicEncrypt.privateEncrypt exports.publicDecrypt = publicEncrypt.publicDecrypt exports.privateDecrypt = publicEncrypt.privateDecrypt - + // the least I can do is make error messages for the rest of the node.js/crypto api. // ;[ // 'createCredentials' @@ -18820,12 +18820,12 @@ // ].join('\n')) // } // }) - + var rf = require('randomfill') - + exports.randomFill = rf.randomFill exports.randomFillSync = rf.randomFillSync - + exports.createCredentials = function () { throw new Error([ 'sorry, createCredentials is not implemented yet', @@ -18833,7 +18833,7 @@ 'https://github.com/crypto-browserify/crypto-browserify' ].join('\n')) } - + exports.constants = { 'DH_CHECK_P_NOT_SAFE_PRIME': 2, 'DH_CHECK_P_NOT_PRIME': 1, @@ -18851,13 +18851,13 @@ 'POINT_CONVERSION_UNCOMPRESSED': 4, 'POINT_CONVERSION_HYBRID': 6 } - + },{"browserify-cipher":73,"browserify-sign":80,"browserify-sign/algos":77,"create-ecdh":90,"create-hash":91,"create-hmac":94,"diffie-hellman":105,"pbkdf2":247,"public-encrypt":259,"randombytes":270,"randomfill":271}],98:[function(require,module,exports){ 'use strict'; var token = '%[a-f0-9]{2}'; var singleMatcher = new RegExp(token, 'gi'); var multiMatcher = new RegExp('(' + token + ')+', 'gi'); - + function decodeComponents(components, split) { try { // Try to decode the entire string first @@ -18865,43 +18865,43 @@ } catch (err) { // Do nothing } - + if (components.length === 1) { return components; } - + split = split || 1; - + // Split the array in 2 parts var left = components.slice(0, split); var right = components.slice(split); - + return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); } - + function decode(input) { try { return decodeURIComponent(input); } catch (err) { var tokens = input.match(singleMatcher); - + for (var i = 1; i < tokens.length; i++) { input = decodeComponents(tokens, i).join(''); - + tokens = input.match(singleMatcher); } - + return input; } } - + function customDecodeURIComponent(input) { // Keep track of all the replacements and prefill the map with the `BOM` var replaceMap = { '%FE%FF': '\uFFFD\uFFFD', '%FF%FE': '\uFFFD\uFFFD' }; - + var match = multiMatcher.exec(input); while (match) { try { @@ -18909,37 +18909,37 @@ replaceMap[match[0]] = decodeURIComponent(match[0]); } catch (err) { var result = decode(match[0]); - + if (result !== match[0]) { replaceMap[match[0]] = result; } } - + match = multiMatcher.exec(input); } - + // Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else replaceMap['%C2'] = '\uFFFD'; - + var entries = Object.keys(replaceMap); - + for (var i = 0; i < entries.length; i++) { // Replace all decoded components var key = entries[i]; input = input.replace(new RegExp(key, 'g'), replaceMap[key]); } - + return input; } - + module.exports = function (encodedURI) { if (typeof encodedURI !== 'string') { throw new TypeError('Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`'); } - + try { encodedURI = encodedURI.replace(/\+/g, ' '); - + // Try the built in decoder first return decodeURIComponent(encodedURI); } catch (err) { @@ -18947,269 +18947,269 @@ return customDecodeURIComponent(encodedURI); } }; - + },{}],99:[function(require,module,exports){ 'use strict'; - + exports.utils = require('./des/utils'); exports.Cipher = require('./des/cipher'); exports.DES = require('./des/des'); exports.CBC = require('./des/cbc'); exports.EDE = require('./des/ede'); - + },{"./des/cbc":100,"./des/cipher":101,"./des/des":102,"./des/ede":103,"./des/utils":104}],100:[function(require,module,exports){ 'use strict'; - + var assert = require('minimalistic-assert'); var inherits = require('inherits'); - + var proto = {}; - + function CBCState(iv) { assert.equal(iv.length, 8, 'Invalid IV length'); - + this.iv = new Array(8); for (var i = 0; i < this.iv.length; i++) this.iv[i] = iv[i]; } - + function instantiate(Base) { function CBC(options) { Base.call(this, options); this._cbcInit(); } inherits(CBC, Base); - + var keys = Object.keys(proto); for (var i = 0; i < keys.length; i++) { var key = keys[i]; CBC.prototype[key] = proto[key]; } - + CBC.create = function create(options) { return new CBC(options); }; - + return CBC; } - + exports.instantiate = instantiate; - + proto._cbcInit = function _cbcInit() { var state = new CBCState(this.options.iv); this._cbcState = state; }; - + proto._update = function _update(inp, inOff, out, outOff) { var state = this._cbcState; var superProto = this.constructor.super_.prototype; - + var iv = state.iv; if (this.type === 'encrypt') { for (var i = 0; i < this.blockSize; i++) iv[i] ^= inp[inOff + i]; - + superProto._update.call(this, iv, 0, out, outOff); - + for (var i = 0; i < this.blockSize; i++) iv[i] = out[outOff + i]; } else { superProto._update.call(this, inp, inOff, out, outOff); - + for (var i = 0; i < this.blockSize; i++) out[outOff + i] ^= iv[i]; - + for (var i = 0; i < this.blockSize; i++) iv[i] = inp[inOff + i]; } }; - + },{"inherits":180,"minimalistic-assert":234}],101:[function(require,module,exports){ 'use strict'; - + var assert = require('minimalistic-assert'); - + function Cipher(options) { this.options = options; - + this.type = this.options.type; this.blockSize = 8; this._init(); - + this.buffer = new Array(this.blockSize); this.bufferOff = 0; } module.exports = Cipher; - + Cipher.prototype._init = function _init() { // Might be overrided }; - + Cipher.prototype.update = function update(data) { if (data.length === 0) return []; - + if (this.type === 'decrypt') return this._updateDecrypt(data); else return this._updateEncrypt(data); }; - + Cipher.prototype._buffer = function _buffer(data, off) { // Append data to buffer var min = Math.min(this.buffer.length - this.bufferOff, data.length - off); for (var i = 0; i < min; i++) this.buffer[this.bufferOff + i] = data[off + i]; this.bufferOff += min; - + // Shift next return min; }; - + Cipher.prototype._flushBuffer = function _flushBuffer(out, off) { this._update(this.buffer, 0, out, off); this.bufferOff = 0; return this.blockSize; }; - + Cipher.prototype._updateEncrypt = function _updateEncrypt(data) { var inputOff = 0; var outputOff = 0; - + var count = ((this.bufferOff + data.length) / this.blockSize) | 0; var out = new Array(count * this.blockSize); - + if (this.bufferOff !== 0) { inputOff += this._buffer(data, inputOff); - + if (this.bufferOff === this.buffer.length) outputOff += this._flushBuffer(out, outputOff); } - + // Write blocks var max = data.length - ((data.length - inputOff) % this.blockSize); for (; inputOff < max; inputOff += this.blockSize) { this._update(data, inputOff, out, outputOff); outputOff += this.blockSize; } - + // Queue rest for (; inputOff < data.length; inputOff++, this.bufferOff++) this.buffer[this.bufferOff] = data[inputOff]; - + return out; }; - + Cipher.prototype._updateDecrypt = function _updateDecrypt(data) { var inputOff = 0; var outputOff = 0; - + var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1; var out = new Array(count * this.blockSize); - + // TODO(indutny): optimize it, this is far from optimal for (; count > 0; count--) { inputOff += this._buffer(data, inputOff); outputOff += this._flushBuffer(out, outputOff); } - + // Buffer rest of the input inputOff += this._buffer(data, inputOff); - + return out; }; - + Cipher.prototype.final = function final(buffer) { var first; if (buffer) first = this.update(buffer); - + var last; if (this.type === 'encrypt') last = this._finalEncrypt(); else last = this._finalDecrypt(); - + if (first) return first.concat(last); else return last; }; - + Cipher.prototype._pad = function _pad(buffer, off) { if (off === 0) return false; - + while (off < buffer.length) buffer[off++] = 0; - + return true; }; - + Cipher.prototype._finalEncrypt = function _finalEncrypt() { if (!this._pad(this.buffer, this.bufferOff)) return []; - + var out = new Array(this.blockSize); this._update(this.buffer, 0, out, 0); return out; }; - + Cipher.prototype._unpad = function _unpad(buffer) { return buffer; }; - + Cipher.prototype._finalDecrypt = function _finalDecrypt() { assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt'); var out = new Array(this.blockSize); this._flushBuffer(out, 0); - + return this._unpad(out); }; - + },{"minimalistic-assert":234}],102:[function(require,module,exports){ 'use strict'; - + var assert = require('minimalistic-assert'); var inherits = require('inherits'); - + var des = require('../des'); var utils = des.utils; var Cipher = des.Cipher; - + function DESState() { this.tmp = new Array(2); this.keys = null; } - + function DES(options) { Cipher.call(this, options); - + var state = new DESState(); this._desState = state; - + this.deriveKeys(state, options.key); } inherits(DES, Cipher); module.exports = DES; - + DES.create = function create(options) { return new DES(options); }; - + var shiftTable = [ 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 ]; - + DES.prototype.deriveKeys = function deriveKeys(state, key) { state.keys = new Array(16 * 2); - + assert.equal(key.length, this.blockSize, 'Invalid key length'); - + var kL = utils.readUInt32BE(key, 0); var kR = utils.readUInt32BE(key, 4); - + utils.pc1(kL, kR, state.tmp, 0); kL = state.tmp[0]; kR = state.tmp[1]; @@ -19220,115 +19220,115 @@ utils.pc2(kL, kR, state.keys, i); } }; - + DES.prototype._update = function _update(inp, inOff, out, outOff) { var state = this._desState; - + var l = utils.readUInt32BE(inp, inOff); var r = utils.readUInt32BE(inp, inOff + 4); - + // Initial Permutation utils.ip(l, r, state.tmp, 0); l = state.tmp[0]; r = state.tmp[1]; - + if (this.type === 'encrypt') this._encrypt(state, l, r, state.tmp, 0); else this._decrypt(state, l, r, state.tmp, 0); - + l = state.tmp[0]; r = state.tmp[1]; - + utils.writeUInt32BE(out, l, outOff); utils.writeUInt32BE(out, r, outOff + 4); }; - + DES.prototype._pad = function _pad(buffer, off) { var value = buffer.length - off; for (var i = off; i < buffer.length; i++) buffer[i] = value; - + return true; }; - + DES.prototype._unpad = function _unpad(buffer) { var pad = buffer[buffer.length - 1]; for (var i = buffer.length - pad; i < buffer.length; i++) assert.equal(buffer[i], pad); - + return buffer.slice(0, buffer.length - pad); }; - + DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) { var l = lStart; var r = rStart; - + // Apply f() x16 times for (var i = 0; i < state.keys.length; i += 2) { var keyL = state.keys[i]; var keyR = state.keys[i + 1]; - + // f(r, k) utils.expand(r, state.tmp, 0); - + keyL ^= state.tmp[0]; keyR ^= state.tmp[1]; var s = utils.substitute(keyL, keyR); var f = utils.permute(s); - + var t = r; r = (l ^ f) >>> 0; l = t; } - + // Reverse Initial Permutation utils.rip(r, l, out, off); }; - + DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) { var l = rStart; var r = lStart; - + // Apply f() x16 times for (var i = state.keys.length - 2; i >= 0; i -= 2) { var keyL = state.keys[i]; var keyR = state.keys[i + 1]; - + // f(r, k) utils.expand(l, state.tmp, 0); - + keyL ^= state.tmp[0]; keyR ^= state.tmp[1]; var s = utils.substitute(keyL, keyR); var f = utils.permute(s); - + var t = l; l = (r ^ f) >>> 0; r = t; } - + // Reverse Initial Permutation utils.rip(l, r, out, off); }; - + },{"../des":99,"inherits":180,"minimalistic-assert":234}],103:[function(require,module,exports){ 'use strict'; - + var assert = require('minimalistic-assert'); var inherits = require('inherits'); - + var des = require('../des'); var Cipher = des.Cipher; var DES = des.DES; - + function EDEState(type, key) { assert.equal(key.length, 24, 'Invalid key length'); - + var k1 = key.slice(0, 8); var k2 = key.slice(8, 16); var k3 = key.slice(16, 24); - + if (type === 'encrypt') { this.ciphers = [ DES.create({ type: 'encrypt', key: k1 }), @@ -19343,35 +19343,35 @@ ]; } } - + function EDE(options) { Cipher.call(this, options); - + var state = new EDEState(this.type, this.options.key); this._edeState = state; } inherits(EDE, Cipher); - + module.exports = EDE; - + EDE.create = function create(options) { return new EDE(options); }; - + EDE.prototype._update = function _update(inp, inOff, out, outOff) { var state = this._edeState; - + state.ciphers[0]._update(inp, inOff, out, outOff); state.ciphers[1]._update(out, outOff, out, outOff); state.ciphers[2]._update(out, outOff, out, outOff); }; - + EDE.prototype._pad = DES.prototype._pad; EDE.prototype._unpad = DES.prototype._unpad; - + },{"../des":99,"inherits":180,"minimalistic-assert":234}],104:[function(require,module,exports){ 'use strict'; - + exports.readUInt32BE = function readUInt32BE(bytes, off) { var res = (bytes[0 + off] << 24) | (bytes[1 + off] << 16) | @@ -19379,18 +19379,18 @@ bytes[3 + off]; return res >>> 0; }; - + exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) { bytes[0 + off] = value >>> 24; bytes[1 + off] = (value >>> 16) & 0xff; bytes[2 + off] = (value >>> 8) & 0xff; bytes[3 + off] = value & 0xff; }; - + exports.ip = function ip(inL, inR, out, off) { var outL = 0; var outR = 0; - + for (var i = 6; i >= 0; i -= 2) { for (var j = 0; j <= 24; j += 8) { outL <<= 1; @@ -19401,7 +19401,7 @@ outL |= (inL >>> (j + i)) & 1; } } - + for (var i = 6; i >= 0; i -= 2) { for (var j = 1; j <= 25; j += 8) { outR <<= 1; @@ -19412,15 +19412,15 @@ outR |= (inL >>> (j + i)) & 1; } } - + out[off + 0] = outL >>> 0; out[off + 1] = outR >>> 0; }; - + exports.rip = function rip(inL, inR, out, off) { var outL = 0; var outR = 0; - + for (var i = 0; i < 4; i++) { for (var j = 24; j >= 0; j -= 8) { outL <<= 1; @@ -19437,15 +19437,15 @@ outR |= (inL >>> (j + i)) & 1; } } - + out[off + 0] = outL >>> 0; out[off + 1] = outR >>> 0; }; - + exports.pc1 = function pc1(inL, inR, out, off) { var outL = 0; var outR = 0; - + // 7, 15, 23, 31, 39, 47, 55, 63 // 6, 14, 22, 30, 39, 47, 55, 63 // 5, 13, 21, 29, 39, 47, 55, 63 @@ -19464,7 +19464,7 @@ outL <<= 1; outL |= (inR >> (j + i)) & 1; } - + // 1, 9, 17, 25, 33, 41, 49, 57 // 2, 10, 18, 26, 34, 42, 50, 58 // 3, 11, 19, 27, 35, 43, 51, 59 @@ -19483,31 +19483,31 @@ outR <<= 1; outR |= (inL >> (j + i)) & 1; } - + out[off + 0] = outL >>> 0; out[off + 1] = outR >>> 0; }; - + exports.r28shl = function r28shl(num, shift) { return ((num << shift) & 0xfffffff) | (num >>> (28 - shift)); }; - + var pc2table = [ // inL => outL 14, 11, 17, 4, 27, 23, 25, 0, 13, 22, 7, 18, 5, 9, 16, 24, 2, 20, 12, 21, 1, 8, 15, 26, - + // inR => outR 15, 4, 25, 19, 9, 1, 26, 16, 5, 11, 23, 8, 12, 7, 17, 0, 22, 3, 10, 14, 6, 20, 27, 24 ]; - + exports.pc2 = function pc2(inL, inR, out, off) { var outL = 0; var outR = 0; - + var len = pc2table.length >>> 1; for (var i = 0; i < len; i++) { outL <<= 1; @@ -19517,15 +19517,15 @@ outR <<= 1; outR |= (inR >>> pc2table[i]) & 0x1; } - + out[off + 0] = outL >>> 0; out[off + 1] = outR >>> 0; }; - + exports.expand = function expand(r, out, off) { var outL = 0; var outR = 0; - + outL = ((r & 1) << 5) | (r >>> 27); for (var i = 23; i >= 15; i -= 4) { outL <<= 6; @@ -19536,77 +19536,77 @@ outR <<= 6; } outR |= ((r & 0x1f) << 1) | (r >>> 31); - + out[off + 0] = outL >>> 0; out[off + 1] = outR >>> 0; }; - + var sTable = [ 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, - + 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, - + 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, - + 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, - + 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, - + 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, - + 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, - + 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11 ]; - + exports.substitute = function substitute(inL, inR) { var out = 0; for (var i = 0; i < 4; i++) { var b = (inL >>> (18 - i * 6)) & 0x3f; var sb = sTable[i * 0x40 + b]; - + out <<= 4; out |= sb; } for (var i = 0; i < 4; i++) { var b = (inR >>> (18 - i * 6)) & 0x3f; var sb = sTable[4 * 0x40 + i * 0x40 + b]; - + out <<= 4; out |= sb; } return out >>> 0; }; - + var permuteTable = [ 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7 ]; - + exports.permute = function permute(num) { var out = 0; for (var i = 0; i < permuteTable.length; i++) { @@ -19615,63 +19615,63 @@ } return out >>> 0; }; - + exports.padSplit = function padSplit(num, size, group) { var str = num.toString(2); while (str.length < size) str = '0' + str; - + var out = []; for (var i = 0; i < size; i += group) out.push(str.slice(i, i + group)); return out.join(' '); }; - + },{}],105:[function(require,module,exports){ (function (Buffer){ var generatePrime = require('./lib/generatePrime') var primes = require('./lib/primes.json') - + var DH = require('./lib/dh') - + function getDiffieHellman (mod) { var prime = new Buffer(primes[mod].prime, 'hex') var gen = new Buffer(primes[mod].gen, 'hex') - + return new DH(prime, gen) } - + var ENCODINGS = { 'binary': true, 'hex': true, 'base64': true } - + function createDiffieHellman (prime, enc, generator, genc) { if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) { return createDiffieHellman(prime, 'binary', enc, generator) } - + enc = enc || 'binary' genc = genc || 'binary' generator = generator || new Buffer([2]) - + if (!Buffer.isBuffer(generator)) { generator = new Buffer(generator, genc) } - + if (typeof prime === 'number') { return new DH(generatePrime(prime, generator), generator, true) } - + if (!Buffer.isBuffer(prime)) { prime = new Buffer(prime, enc) } - + return new DH(prime, generator, true) } - + exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman - + }).call(this,require("buffer").Buffer) },{"./lib/dh":106,"./lib/generatePrime":107,"./lib/primes.json":108,"buffer":84}],106:[function(require,module,exports){ (function (Buffer){ @@ -19686,7 +19686,7 @@ var primes = require('./generatePrime'); var randomBytes = require('randombytes'); module.exports = DH; - + function setPublicKey(pub, enc) { enc = enc || 'utf8'; if (!Buffer.isBuffer(pub)) { @@ -19695,7 +19695,7 @@ this._pub = new BN(pub); return this; } - + function setPrivateKey(priv, enc) { enc = enc || 'utf8'; if (!Buffer.isBuffer(priv)) { @@ -19704,7 +19704,7 @@ this._priv = new BN(priv); return this; } - + var primeCache = {}; function checkPrime(prime, generator) { var gen = generator.toString('hex'); @@ -19713,14 +19713,14 @@ return primeCache[hex]; } var error = 0; - + if (prime.isEven() || !primes.simpleSieve || !primes.fermatTest(prime) || !millerRabin.test(prime)) { //not a prime so +1 error += 1; - + if (gen === '02' || gen === '05') { // we'd be able to check the generator // it would fail so +8 @@ -19758,7 +19758,7 @@ primeCache[hex] = error; return error; } - + function DH(prime, generator, malleable) { this.setGenerator(generator); this.__prime = new BN(prime); @@ -19790,7 +19790,7 @@ this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed(); return this.getPublicKey(); }; - + DH.prototype.computeSecret = function (other) { other = new BN(other); other = other.toRed(this._prime); @@ -19804,23 +19804,23 @@ } return out; }; - + DH.prototype.getPublicKey = function getPublicKey(enc) { return formatReturnValue(this._pub, enc); }; - + DH.prototype.getPrivateKey = function getPrivateKey(enc) { return formatReturnValue(this._priv, enc); }; - + DH.prototype.getPrime = function (enc) { return formatReturnValue(this.__prime, enc); }; - + DH.prototype.getGenerator = function (enc) { return formatReturnValue(this._gen, enc); }; - + DH.prototype.setGenerator = function (gen, enc) { enc = enc || 'utf8'; if (!Buffer.isBuffer(gen)) { @@ -19830,7 +19830,7 @@ this._gen = new BN(gen); return this; }; - + function formatReturnValue(bn, enc) { var buf = new Buffer(bn.toArray()); if (!enc) { @@ -19839,7 +19839,7 @@ return buf.toString(enc); } } - + }).call(this,require("buffer").Buffer) },{"./generatePrime":107,"bn.js":53,"buffer":84,"miller-rabin":233,"randombytes":270}],107:[function(require,module,exports){ var randomBytes = require('randombytes'); @@ -19862,11 +19862,11 @@ var FOUR = new BN(4); var TWELVE = new BN(12); var primes = null; - + function _getPrimes() { if (primes !== null) return primes; - + var limit = 0x100000; var res = []; res[0] = 2; @@ -19875,19 +19875,19 @@ for (var j = 0; j < i && res[j] <= sqrt; j++) if (k % res[j] === 0) break; - + if (i !== j && res[j] <= sqrt) continue; - + res[i++] = k; } primes = res; return res; } - + function simpleSieve(p) { var primes = _getPrimes(); - + for (var i = 0; i < primes.length; i++) if (p.modn(primes[i]) === 0) { if (p.cmpn(primes[i]) === 0) { @@ -19896,15 +19896,15 @@ return false; } } - + return true; } - + function fermatTest(p) { var red = BN.mont(p); return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0; } - + function findPrime(bits, gen) { if (bits < 16) { // this is what openssl does @@ -19915,9 +19915,9 @@ } } gen = new BN(gen); - + var num, n2; - + while (true) { num = new BN(randomBytes(Math.ceil(bits / 8))); while (num.bitLength() > bits) { @@ -19945,9 +19945,9 @@ return num; } } - + } - + },{"bn.js":53,"miller-rabin":233,"randombytes":270}],108:[function(require,module,exports){ module.exports={ "modp1": { @@ -19985,51 +19985,51 @@ } },{}],109:[function(require,module,exports){ 'use strict'; - + var elliptic = exports; - + elliptic.version = require('../package.json').version; elliptic.utils = require('./elliptic/utils'); elliptic.rand = require('brorand'); elliptic.curve = require('./elliptic/curve'); elliptic.curves = require('./elliptic/curves'); - + // Protocols elliptic.ec = require('./elliptic/ec'); elliptic.eddsa = require('./elliptic/eddsa'); - + },{"../package.json":124,"./elliptic/curve":112,"./elliptic/curves":115,"./elliptic/ec":116,"./elliptic/eddsa":119,"./elliptic/utils":123,"brorand":54}],110:[function(require,module,exports){ 'use strict'; - + var BN = require('bn.js'); var elliptic = require('../../elliptic'); var utils = elliptic.utils; var getNAF = utils.getNAF; var getJSF = utils.getJSF; var assert = utils.assert; - + function BaseCurve(type, conf) { this.type = type; this.p = new BN(conf.p, 16); - + // Use Montgomery, when there is no fast reduction for the prime this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); - + // Useful for many curves this.zero = new BN(0).toRed(this.red); this.one = new BN(1).toRed(this.red); this.two = new BN(2).toRed(this.red); - + // Curve configuration, optional this.n = conf.n && new BN(conf.n, 16); this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); - + // Temporary arrays this._wnafT1 = new Array(4); this._wnafT2 = new Array(4); this._wnafT3 = new Array(4); this._wnafT4 = new Array(4); - + // Generalized Greg Maxwell's trick var adjustCount = this.n && this.p.div(this.n); if (!adjustCount || adjustCount.cmpn(100) > 0) { @@ -20040,23 +20040,23 @@ } } module.exports = BaseCurve; - + BaseCurve.prototype.point = function point() { throw new Error('Not implemented'); }; - + BaseCurve.prototype.validate = function validate() { throw new Error('Not implemented'); }; - + BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { assert(p.precomputed); var doubles = p._getDoubles(); - + var naf = getNAF(k, 1); var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); I /= 3; - + // Translate into more windowed form var repr = []; for (var j = 0; j < naf.length; j += doubles.step) { @@ -20065,7 +20065,7 @@ nafW = (nafW << 1) + naf[k]; repr.push(nafW); } - + var a = this.jpoint(null, null, null); var b = this.jpoint(null, null, null); for (var i = I; i > 0; i--) { @@ -20080,18 +20080,18 @@ } return a.toP(); }; - + BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { var w = 4; - + // Precompute window var nafPoints = p._getNAFPoints(w); w = nafPoints.wnd; var wnd = nafPoints.points; - + // Get NAF form var naf = getNAF(k, w); - + // Add `this`*(N+1) for every w-NAF index var acc = this.jpoint(null, null, null); for (var i = naf.length - 1; i >= 0; i--) { @@ -20101,7 +20101,7 @@ if (i >= 0) k++; acc = acc.dblp(k); - + if (i < 0) break; var z = naf[i]; @@ -20122,7 +20122,7 @@ } return p.type === 'affine' ? acc.toP() : acc; }; - + BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, points, coeffs, @@ -20131,7 +20131,7 @@ var wndWidth = this._wnafT1; var wnd = this._wnafT2; var naf = this._wnafT3; - + // Fill all arrays var max = 0; for (var i = 0; i < len; i++) { @@ -20140,7 +20140,7 @@ wndWidth[i] = nafPoints.wnd; wnd[i] = nafPoints.points; } - + // Comb small window NAFs for (var i = len - 1; i >= 1; i -= 2) { var a = i - 1; @@ -20152,14 +20152,14 @@ max = Math.max(naf[b].length, max); continue; } - + var comb = [ points[a], /* 1 */ null, /* 3 */ null, /* 5 */ points[b] /* 7 */ ]; - + // Try to avoid Projective points, if possible if (points[a].y.cmp(points[b].y) === 0) { comb[1] = points[a].add(points[b]); @@ -20171,7 +20171,7 @@ comb[1] = points[a].toJ().mixedAdd(points[b]); comb[2] = points[a].toJ().mixedAdd(points[b].neg()); } - + var index = [ -3, /* -1 -1 */ -1, /* -1 0 */ @@ -20183,7 +20183,7 @@ 1, /* 1 0 */ 3 /* 1 1 */ ]; - + var jsf = getJSF(coeffs[a], coeffs[b]); max = Math.max(jsf[0].length, max); naf[a] = new Array(max); @@ -20191,18 +20191,18 @@ for (var j = 0; j < max; j++) { var ja = jsf[0][j] | 0; var jb = jsf[1][j] | 0; - + naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; naf[b][j] = 0; wnd[a] = comb; } } - + var acc = this.jpoint(null, null, null); var tmp = this._wnafT4; for (var i = max; i >= 0; i--) { var k = 0; - + while (i >= 0) { var zero = true; for (var j = 0; j < len; j++) { @@ -20220,7 +20220,7 @@ acc = acc.dblp(k); if (i < 0) break; - + for (var j = 0; j < len; j++) { var z = tmp[j]; var p; @@ -20230,7 +20230,7 @@ p = wnd[j][(z - 1) >> 1]; else if (z < 0) p = wnd[j][(-z - 1) >> 1].neg(); - + if (p.type === 'affine') acc = acc.mixedAdd(p); else @@ -20240,33 +20240,33 @@ // Zeroify references for (var i = 0; i < len; i++) wnd[i] = null; - + if (jacobianResult) return acc; else return acc.toP(); }; - + function BasePoint(curve, type) { this.curve = curve; this.type = type; this.precomputed = null; } BaseCurve.BasePoint = BasePoint; - + BasePoint.prototype.eq = function eq(/*other*/) { throw new Error('Not implemented'); }; - + BasePoint.prototype.validate = function validate() { return this.curve.validate(this); }; - + BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { bytes = utils.toArray(bytes, enc); - + var len = this.p.byteLength(); - + // uncompressed, hybrid-odd, hybrid-even if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && bytes.length - 1 === 2 * len) { @@ -20274,10 +20274,10 @@ assert(bytes[bytes.length - 1] % 2 === 0); else if (bytes[0] === 0x07) assert(bytes[bytes.length - 1] % 2 === 1); - + var res = this.point(bytes.slice(1, 1 + len), bytes.slice(1 + len, 1 + 2 * len)); - + return res; } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && bytes.length - 1 === len) { @@ -20285,29 +20285,29 @@ } throw new Error('Unknown point format'); }; - + BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { return this.encode(enc, true); }; - + BasePoint.prototype._encode = function _encode(compact) { var len = this.curve.p.byteLength(); var x = this.getX().toArray('be', len); - + if (compact) return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); - + return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ; }; - + BasePoint.prototype.encode = function encode(enc, compact) { return utils.encode(this._encode(compact), enc); }; - + BasePoint.prototype.precompute = function precompute(power) { if (this.precomputed) return this; - + var precomputed = { doubles: null, naf: null, @@ -20317,25 +20317,25 @@ precomputed.doubles = this._getDoubles(4, power); precomputed.beta = this._getBeta(); this.precomputed = precomputed; - + return this; }; - + BasePoint.prototype._hasDoubles = function _hasDoubles(k) { if (!this.precomputed) return false; - + var doubles = this.precomputed.doubles; if (!doubles) return false; - + return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); }; - + BasePoint.prototype._getDoubles = function _getDoubles(step, power) { if (this.precomputed && this.precomputed.doubles) return this.precomputed.doubles; - + var doubles = [ this ]; var acc = this; for (var i = 0; i < power; i += step) { @@ -20348,11 +20348,11 @@ points: doubles }; }; - + BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { if (this.precomputed && this.precomputed.naf) return this.precomputed.naf; - + var res = [ this ]; var max = (1 << wnd) - 1; var dbl = max === 1 ? null : this.dbl(); @@ -20363,133 +20363,133 @@ points: res }; }; - + BasePoint.prototype._getBeta = function _getBeta() { return null; }; - + BasePoint.prototype.dblp = function dblp(k) { var r = this; for (var i = 0; i < k; i++) r = r.dbl(); return r; }; - + },{"../../elliptic":109,"bn.js":53}],111:[function(require,module,exports){ 'use strict'; - + var curve = require('../curve'); var elliptic = require('../../elliptic'); var BN = require('bn.js'); var inherits = require('inherits'); var Base = curve.base; - + var assert = elliptic.utils.assert; - + function EdwardsCurve(conf) { // NOTE: Important as we are creating point in Base.call() this.twisted = (conf.a | 0) !== 1; this.mOneA = this.twisted && (conf.a | 0) === -1; this.extended = this.mOneA; - + Base.call(this, 'edwards', conf); - + this.a = new BN(conf.a, 16).umod(this.red.m); this.a = this.a.toRed(this.red); this.c = new BN(conf.c, 16).toRed(this.red); this.c2 = this.c.redSqr(); this.d = new BN(conf.d, 16).toRed(this.red); this.dd = this.d.redAdd(this.d); - + assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); this.oneC = (conf.c | 0) === 1; } inherits(EdwardsCurve, Base); module.exports = EdwardsCurve; - + EdwardsCurve.prototype._mulA = function _mulA(num) { if (this.mOneA) return num.redNeg(); else return this.a.redMul(num); }; - + EdwardsCurve.prototype._mulC = function _mulC(num) { if (this.oneC) return num; else return this.c.redMul(num); }; - + // Just for compatibility with Short curve EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { return this.point(x, y, z, t); }; - + EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { x = new BN(x, 16); if (!x.red) x = x.toRed(this.red); - + var x2 = x.redSqr(); var rhs = this.c2.redSub(this.a.redMul(x2)); var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2)); - + var y2 = rhs.redMul(lhs.redInvm()); var y = y2.redSqrt(); if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) throw new Error('invalid point'); - + var isOdd = y.fromRed().isOdd(); if (odd && !isOdd || !odd && isOdd) y = y.redNeg(); - + return this.point(x, y); }; - + EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { y = new BN(y, 16); if (!y.red) y = y.toRed(this.red); - + // x^2 = (y^2 - 1) / (d y^2 + 1) var y2 = y.redSqr(); var lhs = y2.redSub(this.one); var rhs = y2.redMul(this.d).redAdd(this.one); var x2 = lhs.redMul(rhs.redInvm()); - + if (x2.cmp(this.zero) === 0) { if (odd) throw new Error('invalid point'); else return this.point(this.zero, y); } - + var x = x2.redSqrt(); if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) throw new Error('invalid point'); - + if (x.isOdd() !== odd) x = x.redNeg(); - + return this.point(x, y); }; - + EdwardsCurve.prototype.validate = function validate(point) { if (point.isInfinity()) return true; - + // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) point.normalize(); - + var x2 = point.x.redSqr(); var y2 = point.y.redSqr(); var lhs = x2.redMul(this.a).redAdd(y2); var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2))); - + return lhs.cmp(rhs) === 0; }; - + function Point(curve, x, y, z, t) { Base.BasePoint.call(this, curve, 'projective'); if (x === null && y === null && z === null) { @@ -20512,7 +20512,7 @@ if (this.t && !this.t.red) this.t = this.t.toRed(this.curve.red); this.zOne = this.z === this.curve.one; - + // Use extended coordinates if (this.curve.extended && !this.t) { this.t = this.x.redMul(this.y); @@ -20522,19 +20522,19 @@ } } inherits(Point, Base.BasePoint); - + EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { return Point.fromJSON(this, obj); }; - + EdwardsCurve.prototype.point = function point(x, y, z, t) { return new Point(this, x, y, z, t); }; - + Point.fromJSON = function fromJSON(curve, obj) { return new Point(curve, obj[0], obj[1], obj[2]); }; - + Point.prototype.inspect = function inspect() { if (this.isInfinity()) return ''; @@ -20542,18 +20542,18 @@ ' y: ' + this.y.fromRed().toString(16, 2) + ' z: ' + this.z.fromRed().toString(16, 2) + '>'; }; - + Point.prototype.isInfinity = function isInfinity() { // XXX This code assumes that zero is always zero in red return this.x.cmpn(0) === 0 && this.y.cmp(this.z) === 0; }; - + Point.prototype._extDbl = function _extDbl() { // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html // #doubling-dbl-2008-hwcd // 4M + 4S - + // A = X1^2 var a = this.x.redSqr(); // B = Y1^2 @@ -20581,21 +20581,21 @@ var nz = f.redMul(g); return this.curve.point(nx, ny, nz, nt); }; - + Point.prototype._projDbl = function _projDbl() { // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html // #doubling-dbl-2008-bbjlp // #doubling-dbl-2007-bl // and others // Generally 3M + 4S or 2M + 4S - + // B = (X1 + Y1)^2 var b = this.x.redAdd(this.y).redSqr(); // C = X1^2 var c = this.x.redSqr(); // D = Y1^2 var d = this.y.redSqr(); - + var nx; var ny; var nz; @@ -20639,23 +20639,23 @@ } return this.curve.point(nx, ny, nz); }; - + Point.prototype.dbl = function dbl() { if (this.isInfinity()) return this; - + // Double in extended coordinates if (this.curve.extended) return this._extDbl(); else return this._projDbl(); }; - + Point.prototype._extAdd = function _extAdd(p) { // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html // #addition-add-2008-hwcd-3 // 8M - + // A = (Y1 - X1) * (Y2 - X2) var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x)); // B = (Y1 + X1) * (Y2 + X2) @@ -20682,13 +20682,13 @@ var nz = f.redMul(g); return this.curve.point(nx, ny, nz, nt); }; - + Point.prototype._projAdd = function _projAdd(p) { // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html // #addition-add-2008-bbjlp // #addition-add-2007-bl // 10M + 1S - + // A = Z1 * Z2 var a = this.z.redMul(p.z); // B = A^2 @@ -20721,38 +20721,38 @@ } return this.curve.point(nx, ny, nz); }; - + Point.prototype.add = function add(p) { if (this.isInfinity()) return p; if (p.isInfinity()) return this; - + if (this.curve.extended) return this._extAdd(p); else return this._projAdd(p); }; - + Point.prototype.mul = function mul(k) { if (this._hasDoubles(k)) return this.curve._fixedNafMul(this, k); else return this.curve._wnafMul(this, k); }; - + Point.prototype.mulAdd = function mulAdd(k1, p, k2) { return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); }; - + Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); }; - + Point.prototype.normalize = function normalize() { if (this.zOne) return this; - + // Normalize coordinates var zi = this.z.redInvm(); this.x = this.x.redMul(zi); @@ -20763,77 +20763,77 @@ this.zOne = true; return this; }; - + Point.prototype.neg = function neg() { return this.curve.point(this.x.redNeg(), this.y, this.z, this.t && this.t.redNeg()); }; - + Point.prototype.getX = function getX() { this.normalize(); return this.x.fromRed(); }; - + Point.prototype.getY = function getY() { this.normalize(); return this.y.fromRed(); }; - + Point.prototype.eq = function eq(other) { return this === other || this.getX().cmp(other.getX()) === 0 && this.getY().cmp(other.getY()) === 0; }; - + Point.prototype.eqXToP = function eqXToP(x) { var rx = x.toRed(this.curve.red).redMul(this.z); if (this.x.cmp(rx) === 0) return true; - + var xc = x.clone(); var t = this.curve.redN.redMul(this.z); for (;;) { xc.iadd(this.curve.n); if (xc.cmp(this.curve.p) >= 0) return false; - + rx.redIAdd(t); if (this.x.cmp(rx) === 0) return true; } return false; }; - + // Compatibility with BaseCurve Point.prototype.toP = Point.prototype.normalize; Point.prototype.mixedAdd = Point.prototype.add; - + },{"../../elliptic":109,"../curve":112,"bn.js":53,"inherits":180}],112:[function(require,module,exports){ 'use strict'; - + var curve = exports; - + curve.base = require('./base'); curve.short = require('./short'); curve.mont = require('./mont'); curve.edwards = require('./edwards'); - + },{"./base":110,"./edwards":111,"./mont":113,"./short":114}],113:[function(require,module,exports){ 'use strict'; - + var curve = require('../curve'); var BN = require('bn.js'); var inherits = require('inherits'); var Base = curve.base; - + var elliptic = require('../../elliptic'); var utils = elliptic.utils; - + function MontCurve(conf) { Base.call(this, 'mont', conf); - + this.a = new BN(conf.a, 16).toRed(this.red); this.b = new BN(conf.b, 16).toRed(this.red); this.i4 = new BN(4).toRed(this.red).redInvm(); @@ -20842,16 +20842,16 @@ } inherits(MontCurve, Base); module.exports = MontCurve; - + MontCurve.prototype.validate = function validate(point) { var x = point.normalize().x; var x2 = x.redSqr(); var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x); var y = rhs.redSqrt(); - + return y.redSqr().cmp(rhs) === 0; }; - + function Point(curve, x, z) { Base.BasePoint.call(this, curve, 'projective'); if (x === null && z === null) { @@ -20867,47 +20867,47 @@ } } inherits(Point, Base.BasePoint); - + MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { return this.point(utils.toArray(bytes, enc), 1); }; - + MontCurve.prototype.point = function point(x, z) { return new Point(this, x, z); }; - + MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { return Point.fromJSON(this, obj); }; - + Point.prototype.precompute = function precompute() { // No-op }; - + Point.prototype._encode = function _encode() { return this.getX().toArray('be', this.curve.p.byteLength()); }; - + Point.fromJSON = function fromJSON(curve, obj) { return new Point(curve, obj[0], obj[1] || curve.one); }; - + Point.prototype.inspect = function inspect() { if (this.isInfinity()) return ''; return ''; }; - + Point.prototype.isInfinity = function isInfinity() { // XXX This code assumes that zero is always zero in red return this.z.cmpn(0) === 0; }; - + Point.prototype.dbl = function dbl() { // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 // 2M + 2S + 4A - + // A = X1 + Z1 var a = this.x.redAdd(this.z); // AA = A^2 @@ -20924,15 +20924,15 @@ var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c))); return this.curve.point(nx, nz); }; - + Point.prototype.add = function add() { throw new Error('Not supported on Montgomery curve'); }; - + Point.prototype.diffAdd = function diffAdd(p, diff) { // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 // 4M + 2S + 6A - + // A = X2 + Z2 var a = this.x.redAdd(this.z); // B = X2 - Z2 @@ -20951,16 +20951,16 @@ var nz = diff.x.redMul(da.redISub(cb).redSqr()); return this.curve.point(nx, nz); }; - + Point.prototype.mul = function mul(k) { var t = k.clone(); var a = this; // (N / 2) * Q + Q var b = this.curve.point(null, null); // (N / 2) * Q var c = this; // Q - + for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) bits.push(t.andln(1)); - + for (var i = bits.length - 1; i >= 0; i--) { if (bits[i] === 0) { // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q @@ -20976,53 +20976,53 @@ } return b; }; - + Point.prototype.mulAdd = function mulAdd() { throw new Error('Not supported on Montgomery curve'); }; - + Point.prototype.jumlAdd = function jumlAdd() { throw new Error('Not supported on Montgomery curve'); }; - + Point.prototype.eq = function eq(other) { return this.getX().cmp(other.getX()) === 0; }; - + Point.prototype.normalize = function normalize() { this.x = this.x.redMul(this.z.redInvm()); this.z = this.curve.one; return this; }; - + Point.prototype.getX = function getX() { // Normalize coordinates this.normalize(); - + return this.x.fromRed(); }; - + },{"../../elliptic":109,"../curve":112,"bn.js":53,"inherits":180}],114:[function(require,module,exports){ 'use strict'; - + var curve = require('../curve'); var elliptic = require('../../elliptic'); var BN = require('bn.js'); var inherits = require('inherits'); var Base = curve.base; - + var assert = elliptic.utils.assert; - + function ShortCurve(conf) { Base.call(this, 'short', conf); - + this.a = new BN(conf.a, 16).toRed(this.red); this.b = new BN(conf.b, 16).toRed(this.red); this.tinv = this.two.redInvm(); - + this.zeroA = this.a.fromRed().cmpn(0) === 0; this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; - + // If the curve is endomorphic, precalculate beta and lambda this.endo = this._getEndomorphism(conf); this._endoWnafT1 = new Array(4); @@ -21030,12 +21030,12 @@ } inherits(ShortCurve, Base); module.exports = ShortCurve; - + ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { // No efficient endomorphism if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) return; - + // Compute beta and lambda, that lambda * P = (beta * Px; Py) var beta; var lambda; @@ -21059,7 +21059,7 @@ assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); } } - + // Get basis vectors, used for balanced length-two representation var basis; if (conf.basis) { @@ -21072,14 +21072,14 @@ } else { basis = this._getEndoBasis(lambda); } - + return { beta: beta, lambda: lambda, basis: basis }; }; - + ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { // Find roots of for x^2 + x + 1 in F // Root = (-1 +- Sqrt(-3)) / 2 @@ -21087,18 +21087,18 @@ var red = num === this.p ? this.red : BN.mont(num); var tinv = new BN(2).toRed(red).redInvm(); var ntinv = tinv.redNeg(); - + var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); - + var l1 = ntinv.redAdd(s).fromRed(); var l2 = ntinv.redSub(s).fromRed(); return [ l1, l2 ]; }; - + ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { // aprxSqrt >= sqrt(this.n) var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); - + // 3.74 // Run EGCD, until r(L + 1) < aprxSqrt var u = lambda; @@ -21107,7 +21107,7 @@ var y1 = new BN(0); var x2 = new BN(0); var y2 = new BN(1); - + // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) var a0; var b0; @@ -21117,7 +21117,7 @@ // Second vector var a2; var b2; - + var prevR; var i = 0; var r; @@ -21127,7 +21127,7 @@ r = v.sub(q.mul(u)); x = x2.sub(q.mul(x1)); var y = y2.sub(q.mul(y1)); - + if (!a1 && r.cmp(aprxSqrt) < 0) { a0 = prevR.neg(); b0 = x1; @@ -21137,7 +21137,7 @@ break; } prevR = r; - + v = u; u = r; x2 = x1; @@ -21147,14 +21147,14 @@ } a2 = r.neg(); b2 = x; - + var len1 = a1.sqr().add(b1.sqr()); var len2 = a2.sqr().add(b2.sqr()); if (len2.cmp(len1) >= 0) { a2 = a0; b2 = b0; } - + // Normalize signs if (a1.negative) { a1 = a1.neg(); @@ -21164,63 +21164,63 @@ a2 = a2.neg(); b2 = b2.neg(); } - + return [ { a: a1, b: b1 }, { a: a2, b: b2 } ]; }; - + ShortCurve.prototype._endoSplit = function _endoSplit(k) { var basis = this.endo.basis; var v1 = basis[0]; var v2 = basis[1]; - + var c1 = v2.b.mul(k).divRound(this.n); var c2 = v1.b.neg().mul(k).divRound(this.n); - + var p1 = c1.mul(v1.a); var p2 = c2.mul(v2.a); var q1 = c1.mul(v1.b); var q2 = c2.mul(v2.b); - + // Calculate answer var k1 = k.sub(p1).sub(p2); var k2 = q1.add(q2).neg(); return { k1: k1, k2: k2 }; }; - + ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { x = new BN(x, 16); if (!x.red) x = x.toRed(this.red); - + var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); var y = y2.redSqrt(); if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) throw new Error('invalid point'); - + // XXX Is there any way to tell if the number is odd without converting it // to non-red form? var isOdd = y.fromRed().isOdd(); if (odd && !isOdd || !odd && isOdd) y = y.redNeg(); - + return this.point(x, y); }; - + ShortCurve.prototype.validate = function validate(point) { if (point.inf) return true; - + var x = point.x; var y = point.y; - + var ax = this.a.redMul(x); var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); return y.redSqr().redISub(rhs).cmpn(0) === 0; }; - + ShortCurve.prototype._endoWnafMulAdd = function _endoWnafMulAdd(points, coeffs, jacobianResult) { var npoints = this._endoWnafT1; @@ -21229,7 +21229,7 @@ var split = this._endoSplit(coeffs[i]); var p = points[i]; var beta = p._getBeta(); - + if (split.k1.negative) { split.k1.ineg(); p = p.neg(true); @@ -21238,14 +21238,14 @@ split.k2.ineg(); beta = beta.neg(true); } - + npoints[i * 2] = p; npoints[i * 2 + 1] = beta; ncoeffs[i * 2] = split.k1; ncoeffs[i * 2 + 1] = split.k2; } var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); - + // Clean-up references to points and coefficients for (var j = 0; j < i * 2; j++) { npoints[j] = null; @@ -21253,7 +21253,7 @@ } return res; }; - + function Point(curve, x, y, isRed) { Base.BasePoint.call(this, curve, 'affine'); if (x === null && y === null) { @@ -21276,23 +21276,23 @@ } } inherits(Point, Base.BasePoint); - + ShortCurve.prototype.point = function point(x, y, isRed) { return new Point(this, x, y, isRed); }; - + ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { return Point.fromJSON(this, obj, red); }; - + Point.prototype._getBeta = function _getBeta() { if (!this.curve.endo) return; - + var pre = this.precomputed; if (pre && pre.beta) return pre.beta; - + var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); if (pre) { var curve = this.curve; @@ -21314,11 +21314,11 @@ } return beta; }; - + Point.prototype.toJSON = function toJSON() { if (!this.precomputed) return [ this.x, this.y ]; - + return [ this.x, this.y, this.precomputed && { doubles: this.precomputed.doubles && { step: this.precomputed.doubles.step, @@ -21330,18 +21330,18 @@ } } ]; }; - + Point.fromJSON = function fromJSON(curve, obj, red) { if (typeof obj === 'string') obj = JSON.parse(obj); var res = curve.point(obj[0], obj[1], red); if (!obj[2]) return res; - + function obj2point(obj) { return curve.point(obj[0], obj[1], red); } - + var pre = obj[2]; res.precomputed = { beta: null, @@ -21356,39 +21356,39 @@ }; return res; }; - + Point.prototype.inspect = function inspect() { if (this.isInfinity()) return ''; return ''; }; - + Point.prototype.isInfinity = function isInfinity() { return this.inf; }; - + Point.prototype.add = function add(p) { // O + P = P if (this.inf) return p; - + // P + O = P if (p.inf) return this; - + // P + P = 2P if (this.eq(p)) return this.dbl(); - + // P + (-P) = O if (this.neg().eq(p)) return this.curve.point(null, null); - + // P + Q = O if (this.x.cmp(p.x) === 0) return this.curve.point(null, null); - + var c = this.y.redSub(p.y); if (c.cmpn(0) !== 0) c = c.redMul(this.x.redSub(p.x).redInvm()); @@ -21396,38 +21396,38 @@ var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); return this.curve.point(nx, ny); }; - + Point.prototype.dbl = function dbl() { if (this.inf) return this; - + // 2P = O var ys1 = this.y.redAdd(this.y); if (ys1.cmpn(0) === 0) return this.curve.point(null, null); - + var a = this.curve.a; - + var x2 = this.x.redSqr(); var dyinv = ys1.redInvm(); var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); - + var nx = c.redSqr().redISub(this.x.redAdd(this.x)); var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); return this.curve.point(nx, ny); }; - + Point.prototype.getX = function getX() { return this.x.fromRed(); }; - + Point.prototype.getY = function getY() { return this.y.fromRed(); }; - + Point.prototype.mul = function mul(k) { k = new BN(k, 16); - + if (this._hasDoubles(k)) return this.curve._fixedNafMul(this, k); else if (this.curve.endo) @@ -21435,7 +21435,7 @@ else return this.curve._wnafMul(this, k); }; - + Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { var points = [ this, p2 ]; var coeffs = [ k1, k2 ]; @@ -21444,7 +21444,7 @@ else return this.curve._wnafMulAdd(1, points, coeffs, 2); }; - + Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { var points = [ this, p2 ]; var coeffs = [ k1, k2 ]; @@ -21453,17 +21453,17 @@ else return this.curve._wnafMulAdd(1, points, coeffs, 2, true); }; - + Point.prototype.eq = function eq(p) { return this === p || this.inf === p.inf && (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); }; - + Point.prototype.neg = function neg(_precompute) { if (this.inf) return this; - + var res = this.curve.point(this.x, this.y.redNeg()); if (_precompute && this.precomputed) { var pre = this.precomputed; @@ -21483,15 +21483,15 @@ } return res; }; - + Point.prototype.toJ = function toJ() { if (this.inf) return this.curve.jpoint(null, null, null); - + var res = this.curve.jpoint(this.x, this.y, this.curve.one); return res; }; - + function JPoint(curve, x, y, z) { Base.BasePoint.call(this, curve, 'jacobian'); if (x === null && y === null && z === null) { @@ -21509,40 +21509,40 @@ this.y = this.y.toRed(this.curve.red); if (!this.z.red) this.z = this.z.toRed(this.curve.red); - + this.zOne = this.z === this.curve.one; } inherits(JPoint, Base.BasePoint); - + ShortCurve.prototype.jpoint = function jpoint(x, y, z) { return new JPoint(this, x, y, z); }; - + JPoint.prototype.toP = function toP() { if (this.isInfinity()) return this.curve.point(null, null); - + var zinv = this.z.redInvm(); var zinv2 = zinv.redSqr(); var ax = this.x.redMul(zinv2); var ay = this.y.redMul(zinv2).redMul(zinv); - + return this.curve.point(ax, ay); }; - + JPoint.prototype.neg = function neg() { return this.curve.jpoint(this.x, this.y.redNeg(), this.z); }; - + JPoint.prototype.add = function add(p) { // O + P = P if (this.isInfinity()) return p; - + // P + O = P if (p.isInfinity()) return this; - + // 12M + 4S + 7A var pz2 = p.z.redSqr(); var z2 = this.z.redSqr(); @@ -21550,7 +21550,7 @@ var u2 = p.x.redMul(z2); var s1 = this.y.redMul(pz2.redMul(p.z)); var s2 = p.y.redMul(z2.redMul(this.z)); - + var h = u1.redSub(u2); var r = s1.redSub(s2); if (h.cmpn(0) === 0) { @@ -21559,34 +21559,34 @@ else return this.dbl(); } - + var h2 = h.redSqr(); var h3 = h2.redMul(h); var v = u1.redMul(h2); - + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); var nz = this.z.redMul(p.z).redMul(h); - + return this.curve.jpoint(nx, ny, nz); }; - + JPoint.prototype.mixedAdd = function mixedAdd(p) { // O + P = P if (this.isInfinity()) return p.toJ(); - + // P + O = P if (p.isInfinity()) return this; - + // 8M + 3S + 7A var z2 = this.z.redSqr(); var u1 = this.x; var u2 = p.x.redMul(z2); var s1 = this.y; var s2 = p.y.redMul(z2).redMul(this.z); - + var h = u1.redSub(u2); var r = s1.redSub(s2); if (h.cmpn(0) === 0) { @@ -21595,18 +21595,18 @@ else return this.dbl(); } - + var h2 = h.redSqr(); var h3 = h2.redMul(h); var v = u1.redMul(h2); - + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); var nz = this.z.redMul(h); - + return this.curve.jpoint(nx, ny, nz); }; - + JPoint.prototype.dblp = function dblp(pow) { if (pow === 0) return this; @@ -21614,24 +21614,24 @@ return this; if (!pow) return this.dbl(); - + if (this.curve.zeroA || this.curve.threeA) { var r = this; for (var i = 0; i < pow; i++) r = r.dbl(); return r; } - + // 1M + 2S + 1A + N * (4S + 5M + 8A) // N = 1 => 6M + 6S + 9A var a = this.curve.a; var tinv = this.curve.tinv; - + var jx = this.x; var jy = this.y; var jz = this.z; var jz4 = jz.redSqr().redSqr(); - + // Reuse results var jyd = jy.redAdd(jy); for (var i = 0; i < pow; i++) { @@ -21639,7 +21639,7 @@ var jyd2 = jyd.redSqr(); var jyd4 = jyd2.redSqr(); var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); - + var t1 = jx.redMul(jyd2); var nx = c.redSqr().redISub(t1.redAdd(t1)); var t2 = t1.redISub(nx); @@ -21648,19 +21648,19 @@ var nz = jyd.redMul(jz); if (i + 1 < pow) jz4 = jz4.redMul(jyd4); - + jx = nx; jz = nz; jyd = dny; } - + return this.curve.jpoint(jx, jyd.redMul(tinv), jz); }; - + JPoint.prototype.dbl = function dbl() { if (this.isInfinity()) return this; - + if (this.curve.zeroA) return this._zeroDbl(); else if (this.curve.threeA) @@ -21668,7 +21668,7 @@ else return this._dbl(); }; - + JPoint.prototype._zeroDbl = function _zeroDbl() { var nx; var ny; @@ -21678,7 +21678,7 @@ // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html // #doubling-mdbl-2007-bl // 1M + 5S + 14A - + // XX = X1^2 var xx = this.x.redSqr(); // YY = Y1^2 @@ -21692,12 +21692,12 @@ var m = xx.redAdd(xx).redIAdd(xx); // T = M ^ 2 - 2*S var t = m.redSqr().redISub(s).redISub(s); - + // 8 * YYYY var yyyy8 = yyyy.redIAdd(yyyy); yyyy8 = yyyy8.redIAdd(yyyy8); yyyy8 = yyyy8.redIAdd(yyyy8); - + // X3 = T nx = t; // Y3 = M * (S - T) - 8 * YYYY @@ -21708,7 +21708,7 @@ // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html // #doubling-dbl-2009-l // 2M + 5S + 13A - + // A = X1^2 var a = this.x.redSqr(); // B = Y1^2 @@ -21722,12 +21722,12 @@ var e = a.redAdd(a).redIAdd(a); // F = E^2 var f = e.redSqr(); - + // 8 * C var c8 = c.redIAdd(c); c8 = c8.redIAdd(c8); c8 = c8.redIAdd(c8); - + // X3 = F - 2 * D nx = f.redISub(d).redISub(d); // Y3 = E * (D - X3) - 8 * C @@ -21736,10 +21736,10 @@ nz = this.y.redMul(this.z); nz = nz.redIAdd(nz); } - + return this.curve.jpoint(nx, ny, nz); }; - + JPoint.prototype._threeDbl = function _threeDbl() { var nx; var ny; @@ -21749,7 +21749,7 @@ // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html // #doubling-mdbl-2007-bl // 1M + 5S + 15A - + // XX = X1^2 var xx = this.x.redSqr(); // YY = Y1^2 @@ -21775,7 +21775,7 @@ } else { // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b // 3M + 5S - + // delta = Z1^2 var delta = this.z.redSqr(); // gamma = Y1^2 @@ -21799,47 +21799,47 @@ ggamma8 = ggamma8.redIAdd(ggamma8); ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); } - + return this.curve.jpoint(nx, ny, nz); }; - + JPoint.prototype._dbl = function _dbl() { var a = this.curve.a; - + // 4M + 6S + 10A var jx = this.x; var jy = this.y; var jz = this.z; var jz4 = jz.redSqr().redSqr(); - + var jx2 = jx.redSqr(); var jy2 = jy.redSqr(); - + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); - + var jxd4 = jx.redAdd(jx); jxd4 = jxd4.redIAdd(jxd4); var t1 = jxd4.redMul(jy2); var nx = c.redSqr().redISub(t1.redAdd(t1)); var t2 = t1.redISub(nx); - + var jyd8 = jy2.redSqr(); jyd8 = jyd8.redIAdd(jyd8); jyd8 = jyd8.redIAdd(jyd8); jyd8 = jyd8.redIAdd(jyd8); var ny = c.redMul(t2).redISub(jyd8); var nz = jy.redAdd(jy).redMul(jz); - + return this.curve.jpoint(nx, ny, nz); }; - + JPoint.prototype.trpl = function trpl() { if (!this.curve.zeroA) return this.dbl().add(this); - + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl // 5M + 10S + ... - + // XX = X1^2 var xx = this.x.redSqr(); // YY = Y1^2 @@ -21880,55 +21880,55 @@ ny = ny.redIAdd(ny); // Z3 = (Z1 + E)^2 - ZZ - EE var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); - + return this.curve.jpoint(nx, ny, nz); }; - + JPoint.prototype.mul = function mul(k, kbase) { k = new BN(k, kbase); - + return this.curve._wnafMul(this, k); }; - + JPoint.prototype.eq = function eq(p) { if (p.type === 'affine') return this.eq(p.toJ()); - + if (this === p) return true; - + // x1 * z2^2 == x2 * z1^2 var z2 = this.z.redSqr(); var pz2 = p.z.redSqr(); if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) return false; - + // y1 * z2^3 == y2 * z1^3 var z3 = z2.redMul(this.z); var pz3 = pz2.redMul(p.z); return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; }; - + JPoint.prototype.eqXToP = function eqXToP(x) { var zs = this.z.redSqr(); var rx = x.toRed(this.curve.red).redMul(zs); if (this.x.cmp(rx) === 0) return true; - + var xc = x.clone(); var t = this.curve.redN.redMul(zs); for (;;) { xc.iadd(this.curve.n); if (xc.cmp(this.curve.p) >= 0) return false; - + rx.redIAdd(t); if (this.x.cmp(rx) === 0) return true; } return false; }; - + JPoint.prototype.inspect = function inspect() { if (this.isInfinity()) return ''; @@ -21936,22 +21936,22 @@ ' y: ' + this.y.toString(16, 2) + ' z: ' + this.z.toString(16, 2) + '>'; }; - + JPoint.prototype.isInfinity = function isInfinity() { // XXX This code assumes that zero is always zero in red return this.z.cmpn(0) === 0; }; - + },{"../../elliptic":109,"../curve":112,"bn.js":53,"inherits":180}],115:[function(require,module,exports){ 'use strict'; - + var curves = exports; - + var hash = require('hash.js'); var elliptic = require('../elliptic'); - + var assert = elliptic.utils.assert; - + function PresetCurve(options) { if (options.type === 'short') this.curve = new elliptic.curve.short(options); @@ -21962,12 +21962,12 @@ this.g = this.curve.g; this.n = this.curve.n; this.hash = options.hash; - + assert(this.g.validate(), 'Invalid curve'); assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); } curves.PresetCurve = PresetCurve; - + function defineCurve(name, options) { Object.defineProperty(curves, name, { configurable: true, @@ -21983,7 +21983,7 @@ } }); } - + defineCurve('p192', { type: 'short', prime: 'p192', @@ -21998,7 +21998,7 @@ '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811' ] }); - + defineCurve('p224', { type: 'short', prime: 'p224', @@ -22013,7 +22013,7 @@ 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34' ] }); - + defineCurve('p256', { type: 'short', prime: null, @@ -22028,7 +22028,7 @@ '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5' ] }); - + defineCurve('p384', { type: 'short', prime: null, @@ -22049,7 +22049,7 @@ '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f' ] }); - + defineCurve('p521', { type: 'short', prime: null, @@ -22076,7 +22076,7 @@ '3fad0761 353c7086 a272c240 88be9476 9fd16650' ] }); - + defineCurve('curve25519', { type: 'mont', prime: 'p25519', @@ -22090,7 +22090,7 @@ '9' ] }); - + defineCurve('ed25519', { type: 'edwards', prime: 'p25519', @@ -22104,19 +22104,19 @@ gRed: false, g: [ '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', - + // 4/5 '6666666666666666666666666666666666666666666666666666666666666658' ] }); - + var pre; try { pre = require('./precomputed/secp256k1'); } catch (e) { pre = undefined; } - + defineCurve('secp256k1', { type: 'short', prime: 'k256', @@ -22126,7 +22126,7 @@ n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', h: '1', hash: hash.sha256, - + // Precomputed endomorphism beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', @@ -22140,7 +22140,7 @@ b: '3086d221a7d46bcde86c90e49284eb15' } ], - + gRed: false, g: [ '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', @@ -22148,64 +22148,64 @@ pre ] }); - + },{"../elliptic":109,"./precomputed/secp256k1":122,"hash.js":162}],116:[function(require,module,exports){ 'use strict'; - + var BN = require('bn.js'); var HmacDRBG = require('hmac-drbg'); var elliptic = require('../../elliptic'); var utils = elliptic.utils; var assert = utils.assert; - + var KeyPair = require('./key'); var Signature = require('./signature'); - + function EC(options) { if (!(this instanceof EC)) return new EC(options); - + // Shortcut `elliptic.ec(curve-name)` if (typeof options === 'string') { assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options); - + options = elliptic.curves[options]; } - + // Shortcut for `elliptic.ec(elliptic.curves.curveName)` if (options instanceof elliptic.curves.PresetCurve) options = { curve: options }; - + this.curve = options.curve.curve; this.n = this.curve.n; this.nh = this.n.ushrn(1); this.g = this.curve.g; - + // Point on curve this.g = options.curve.g; this.g.precompute(options.curve.n.bitLength() + 1); - + // Hash for function for DRBG this.hash = options.hash || options.curve.hash; } module.exports = EC; - + EC.prototype.keyPair = function keyPair(options) { return new KeyPair(this, options); }; - + EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { return KeyPair.fromPrivate(this, priv, enc); }; - + EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { return KeyPair.fromPublic(this, pub, enc); }; - + EC.prototype.genKeyPair = function genKeyPair(options) { if (!options) options = {}; - + // Instantiate Hmac_DRBG var drbg = new HmacDRBG({ hash: this.hash, @@ -22215,19 +22215,19 @@ entropyEnc: options.entropy && options.entropyEnc || 'utf8', nonce: this.n.toArray() }); - + var bytes = this.n.byteLength(); var ns2 = this.n.sub(new BN(2)); do { var priv = new BN(drbg.generate(bytes)); if (priv.cmp(ns2) > 0) continue; - + priv.iaddn(1); return this.keyFromPrivate(priv); } while (true); }; - + EC.prototype._truncateToN = function truncateToN(msg, truncOnly) { var delta = msg.byteLength() * 8 - this.n.bitLength(); if (delta > 0) @@ -22237,7 +22237,7 @@ else return msg; }; - + EC.prototype.sign = function sign(msg, key, enc, options) { if (typeof enc === 'object') { options = enc; @@ -22245,17 +22245,17 @@ } if (!options) options = {}; - + key = this.keyFromPrivate(key, enc); msg = this._truncateToN(new BN(msg, 16)); - + // Zero-extend key to provide enough entropy var bytes = this.n.byteLength(); var bkey = key.getPrivate().toArray('be', bytes); - + // Zero-extend nonce to have the same byte size as N var nonce = msg.toArray('be', bytes); - + // Instantiate Hmac_DRBG var drbg = new HmacDRBG({ hash: this.hash, @@ -22264,10 +22264,10 @@ pers: options.pers, persEnc: options.persEnc || 'utf8' }); - + // Number of bytes to generate var ns1 = this.n.sub(new BN(1)); - + for (var iter = 0; true; iter++) { var k = options.k ? options.k(iter) : @@ -22275,39 +22275,39 @@ k = this._truncateToN(k, true); if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) continue; - + var kp = this.g.mul(k); if (kp.isInfinity()) continue; - + var kpX = kp.getX(); var r = kpX.umod(this.n); if (r.cmpn(0) === 0) continue; - + var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); s = s.umod(this.n); if (s.cmpn(0) === 0) continue; - + var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | (kpX.cmp(r) !== 0 ? 2 : 0); - + // Use complement of `s`, if it is > `n / 2` if (options.canonical && s.cmp(this.nh) > 0) { s = this.n.sub(s); recoveryParam ^= 1; } - + return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); } }; - + EC.prototype.verify = function verify(msg, signature, key, enc) { msg = this._truncateToN(new BN(msg, 16)); key = this.keyFromPublic(key, enc); signature = new Signature(signature, 'hex'); - + // Perform primitive values validation var r = signature.r; var s = signature.s; @@ -22315,68 +22315,68 @@ return false; if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) return false; - + // Validate signature var sinv = s.invm(this.n); var u1 = sinv.mul(msg).umod(this.n); var u2 = sinv.mul(r).umod(this.n); - + if (!this.curve._maxwellTrick) { var p = this.g.mulAdd(u1, key.getPublic(), u2); if (p.isInfinity()) return false; - + return p.getX().umod(this.n).cmp(r) === 0; } - + // NOTE: Greg Maxwell's trick, inspired by: // https://git.io/vad3K - + var p = this.g.jmulAdd(u1, key.getPublic(), u2); if (p.isInfinity()) return false; - + // Compare `p.x` of Jacobian point with `r`, // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the // inverse of `p.z^2` return p.eqXToP(r); }; - + EC.prototype.recoverPubKey = function(msg, signature, j, enc) { assert((3 & j) === j, 'The recovery param is more than two bits'); signature = new Signature(signature, enc); - + var n = this.n; var e = new BN(msg); var r = signature.r; var s = signature.s; - + // A set LSB signifies that the y-coordinate is odd var isYOdd = j & 1; var isSecondKey = j >> 1; if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) throw new Error('Unable to find sencond key candinate'); - + // 1.1. Let x = r + jn. if (isSecondKey) r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); else r = this.curve.pointFromX(r, isYOdd); - + var rInv = signature.r.invm(n); var s1 = n.sub(e).mul(rInv).umod(n); var s2 = s.mul(rInv).umod(n); - + // 1.6.1 Compute Q = r^-1 (sR - eG) // Q = r^-1 (sR + -eG) return this.g.mulAdd(s1, r, s2); }; - + EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { signature = new Signature(signature, enc); if (signature.recoveryParam !== null) return signature.recoveryParam; - + for (var i = 0; i < 4; i++) { var Qprime; try { @@ -22384,26 +22384,26 @@ } catch (e) { continue; } - + if (Qprime.eq(Q)) return i; } throw new Error('Unable to find valid recovery factor'); }; - + },{"../../elliptic":109,"./key":117,"./signature":118,"bn.js":53,"hmac-drbg":174}],117:[function(require,module,exports){ 'use strict'; - + var BN = require('bn.js'); var elliptic = require('../../elliptic'); var utils = elliptic.utils; var assert = utils.assert; - + function KeyPair(ec, options) { this.ec = ec; this.priv = null; this.pub = null; - + // KeyPair(ec, { priv: ..., pub: ... }) if (options.priv) this._importPrivate(options.priv, options.privEnc); @@ -22411,71 +22411,71 @@ this._importPublic(options.pub, options.pubEnc); } module.exports = KeyPair; - + KeyPair.fromPublic = function fromPublic(ec, pub, enc) { if (pub instanceof KeyPair) return pub; - + return new KeyPair(ec, { pub: pub, pubEnc: enc }); }; - + KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { if (priv instanceof KeyPair) return priv; - + return new KeyPair(ec, { priv: priv, privEnc: enc }); }; - + KeyPair.prototype.validate = function validate() { var pub = this.getPublic(); - + if (pub.isInfinity()) return { result: false, reason: 'Invalid public key' }; if (!pub.validate()) return { result: false, reason: 'Public key is not a point' }; if (!pub.mul(this.ec.curve.n).isInfinity()) return { result: false, reason: 'Public key * N != O' }; - + return { result: true, reason: null }; }; - + KeyPair.prototype.getPublic = function getPublic(compact, enc) { // compact is optional argument if (typeof compact === 'string') { enc = compact; compact = null; } - + if (!this.pub) this.pub = this.ec.g.mul(this.priv); - + if (!enc) return this.pub; - + return this.pub.encode(enc, compact); }; - + KeyPair.prototype.getPrivate = function getPrivate(enc) { if (enc === 'hex') return this.priv.toString(16, 2); else return this.priv; }; - + KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { this.priv = new BN(key, enc || 16); - + // Ensure that the priv won't be bigger than n, otherwise we may fail // in fixed multiplication method this.priv = this.priv.umod(this.ec.curve.n); }; - + KeyPair.prototype._importPublic = function _importPublic(key, enc) { if (key.x || key.y) { // Montgomery points only have an `x` coordinate. @@ -22492,42 +22492,42 @@ } this.pub = this.ec.curve.decodePoint(key, enc); }; - + // ECDH KeyPair.prototype.derive = function derive(pub) { return pub.mul(this.priv).getX(); }; - + // ECDSA KeyPair.prototype.sign = function sign(msg, enc, options) { return this.ec.sign(msg, this, enc, options); }; - + KeyPair.prototype.verify = function verify(msg, signature) { return this.ec.verify(msg, signature, this); }; - + KeyPair.prototype.inspect = function inspect() { return ''; }; - + },{"../../elliptic":109,"bn.js":53}],118:[function(require,module,exports){ 'use strict'; - + var BN = require('bn.js'); - + var elliptic = require('../../elliptic'); var utils = elliptic.utils; var assert = utils.assert; - + function Signature(options, enc) { if (options instanceof Signature) return options; - + if (this._importDER(options, enc)) return; - + assert(options.r && options.s, 'Signature without r or s'); this.r = new BN(options.r, 16); this.s = new BN(options.s, 16); @@ -22537,11 +22537,11 @@ this.recoveryParam = options.recoveryParam; } module.exports = Signature; - + function Position() { this.place = 0; } - + function getLength(buf, p) { var initial = buf[p.place++]; if (!(initial & 0x80)) { @@ -22556,7 +22556,7 @@ p.place = off; return val; } - + function rmPadding(buf) { var i = 0; var len = buf.length - 1; @@ -22568,7 +22568,7 @@ } return buf.slice(i); } - + Signature.prototype._importDER = function _importDER(data, enc) { data = utils.toArray(data, enc); var p = new Position(); @@ -22599,14 +22599,14 @@ if (s[0] === 0 && (s[1] & 0x80)) { s = s.slice(1); } - + this.r = new BN(r); this.s = new BN(s); this.recoveryParam = null; - + return true; }; - + function constructLength(arr, len) { if (len < 0x80) { arr.push(len); @@ -22619,21 +22619,21 @@ } arr.push(len); } - + Signature.prototype.toDER = function toDER(enc) { var r = this.r.toArray(); var s = this.s.toArray(); - + // Pad values if (r[0] & 0x80) r = [ 0 ].concat(r); // Pad values if (s[0] & 0x80) s = [ 0 ].concat(s); - + r = rmPadding(r); s = rmPadding(s); - + while (!s[0] && !(s[1] & 0x80)) { s = s.slice(1); } @@ -22648,10 +22648,10 @@ res = res.concat(backHalf); return utils.encode(res, enc); }; - + },{"../../elliptic":109,"bn.js":53}],119:[function(require,module,exports){ 'use strict'; - + var hash = require('hash.js'); var elliptic = require('../../elliptic'); var utils = elliptic.utils; @@ -22659,25 +22659,25 @@ var parseBytes = utils.parseBytes; var KeyPair = require('./key'); var Signature = require('./signature'); - + function EDDSA(curve) { assert(curve === 'ed25519', 'only tested with ed25519 so far'); - + if (!(this instanceof EDDSA)) return new EDDSA(curve); - + var curve = elliptic.curves[curve].curve; this.curve = curve; this.g = curve.g; this.g.precompute(curve.n.bitLength() + 1); - + this.pointClass = curve.point().constructor; this.encodingLength = Math.ceil(curve.n.bitLength() / 8); this.hash = hash.sha512; } - + module.exports = EDDSA; - + /** * @param {Array|String} message - message bytes * @param {Array|String|KeyPair} secret - secret bytes or a keypair @@ -22694,7 +22694,7 @@ var S = r.add(s_).umod(this.curve.n); return this.makeSignature({ R: R, S: S, Rencoded: Rencoded }); }; - + /** * @param {Array} message - message bytes * @param {Array|String|Signature} sig - sig bytes @@ -22710,28 +22710,28 @@ var RplusAh = sig.R().add(key.pub().mul(h)); return RplusAh.eq(SG); }; - + EDDSA.prototype.hashInt = function hashInt() { var hash = this.hash(); for (var i = 0; i < arguments.length; i++) hash.update(arguments[i]); return utils.intFromLE(hash.digest()).umod(this.curve.n); }; - + EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { return KeyPair.fromPublic(this, pub); }; - + EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { return KeyPair.fromSecret(this, secret); }; - + EDDSA.prototype.makeSignature = function makeSignature(sig) { if (sig instanceof Signature) return sig; return new Signature(this, sig); }; - + /** * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2 * @@ -22745,39 +22745,39 @@ enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0; return enc; }; - + EDDSA.prototype.decodePoint = function decodePoint(bytes) { bytes = utils.parseBytes(bytes); - + var lastIx = bytes.length - 1; var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); var xIsOdd = (bytes[lastIx] & 0x80) !== 0; - + var y = utils.intFromLE(normed); return this.curve.pointFromY(y, xIsOdd); }; - + EDDSA.prototype.encodeInt = function encodeInt(num) { return num.toArray('le', this.encodingLength); }; - + EDDSA.prototype.decodeInt = function decodeInt(bytes) { return utils.intFromLE(bytes); }; - + EDDSA.prototype.isPoint = function isPoint(val) { return val instanceof this.pointClass; }; - + },{"../../elliptic":109,"./key":120,"./signature":121,"hash.js":162}],120:[function(require,module,exports){ 'use strict'; - + var elliptic = require('../../elliptic'); var utils = elliptic.utils; var assert = utils.assert; var parseBytes = utils.parseBytes; var cachedProperty = utils.cachedProperty; - + /** * @param {EDDSA} eddsa - instance * @param {Object} params - public/private key parameters @@ -22795,88 +22795,88 @@ else this._pubBytes = parseBytes(params.pub); } - + KeyPair.fromPublic = function fromPublic(eddsa, pub) { if (pub instanceof KeyPair) return pub; return new KeyPair(eddsa, { pub: pub }); }; - + KeyPair.fromSecret = function fromSecret(eddsa, secret) { if (secret instanceof KeyPair) return secret; return new KeyPair(eddsa, { secret: secret }); }; - + KeyPair.prototype.secret = function secret() { return this._secret; }; - + cachedProperty(KeyPair, 'pubBytes', function pubBytes() { return this.eddsa.encodePoint(this.pub()); }); - + cachedProperty(KeyPair, 'pub', function pub() { if (this._pubBytes) return this.eddsa.decodePoint(this._pubBytes); return this.eddsa.g.mul(this.priv()); }); - + cachedProperty(KeyPair, 'privBytes', function privBytes() { var eddsa = this.eddsa; var hash = this.hash(); var lastIx = eddsa.encodingLength - 1; - + var a = hash.slice(0, eddsa.encodingLength); a[0] &= 248; a[lastIx] &= 127; a[lastIx] |= 64; - + return a; }); - + cachedProperty(KeyPair, 'priv', function priv() { return this.eddsa.decodeInt(this.privBytes()); }); - + cachedProperty(KeyPair, 'hash', function hash() { return this.eddsa.hash().update(this.secret()).digest(); }); - + cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { return this.hash().slice(this.eddsa.encodingLength); }); - + KeyPair.prototype.sign = function sign(message) { assert(this._secret, 'KeyPair can only verify'); return this.eddsa.sign(message, this); }; - + KeyPair.prototype.verify = function verify(message, sig) { return this.eddsa.verify(message, sig, this); }; - + KeyPair.prototype.getSecret = function getSecret(enc) { assert(this._secret, 'KeyPair is public only'); return utils.encode(this.secret(), enc); }; - + KeyPair.prototype.getPublic = function getPublic(enc) { return utils.encode(this.pubBytes(), enc); }; - + module.exports = KeyPair; - + },{"../../elliptic":109}],121:[function(require,module,exports){ 'use strict'; - + var BN = require('bn.js'); var elliptic = require('../../elliptic'); var utils = elliptic.utils; var assert = utils.assert; var cachedProperty = utils.cachedProperty; var parseBytes = utils.parseBytes; - + /** * @param {EDDSA} eddsa - eddsa instance * @param {Array|Object} sig - @@ -22887,54 +22887,54 @@ */ function Signature(eddsa, sig) { this.eddsa = eddsa; - + if (typeof sig !== 'object') sig = parseBytes(sig); - + if (Array.isArray(sig)) { sig = { R: sig.slice(0, eddsa.encodingLength), S: sig.slice(eddsa.encodingLength) }; } - + assert(sig.R && sig.S, 'Signature without R or S'); - + if (eddsa.isPoint(sig.R)) this._R = sig.R; if (sig.S instanceof BN) this._S = sig.S; - + this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; } - + cachedProperty(Signature, 'S', function S() { return this.eddsa.decodeInt(this.Sencoded()); }); - + cachedProperty(Signature, 'R', function R() { return this.eddsa.decodePoint(this.Rencoded()); }); - + cachedProperty(Signature, 'Rencoded', function Rencoded() { return this.eddsa.encodePoint(this.R()); }); - + cachedProperty(Signature, 'Sencoded', function Sencoded() { return this.eddsa.encodeInt(this.S()); }); - + Signature.prototype.toBytes = function toBytes() { return this.Rencoded().concat(this.Sencoded()); }; - + Signature.prototype.toHex = function toHex() { return utils.encode(this.toBytes(), 'hex').toUpperCase(); }; - + module.exports = Signature; - + },{"../../elliptic":109,"bn.js":53}],122:[function(require,module,exports){ module.exports = { doubles: { @@ -23716,21 +23716,21 @@ ] } }; - + },{}],123:[function(require,module,exports){ 'use strict'; - + var utils = exports; var BN = require('bn.js'); var minAssert = require('minimalistic-assert'); var minUtils = require('minimalistic-crypto-utils'); - + utils.assert = minAssert; utils.toArray = minUtils.toArray; utils.zero2 = minUtils.zero2; utils.toHex = minUtils.toHex; utils.encode = minUtils.encode; - + // Represent num in a w-NAF form function getNAF(num, w) { var naf = []; @@ -23749,31 +23749,31 @@ z = 0; } naf.push(z); - + // Optimization, shift by word if possible var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1; for (var i = 1; i < shift; i++) naf.push(0); k.iushrn(shift); } - + return naf; } utils.getNAF = getNAF; - + // Represent k1, k2 in a Joint Sparse Form function getJSF(k1, k2) { var jsf = [ [], [] ]; - + k1 = k1.clone(); k2 = k2.clone(); var d1 = 0; var d2 = 0; while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { - + // First phase var m14 = (k1.andln(3) + d1) & 3; var m24 = (k2.andln(3) + d2) & 3; @@ -23792,7 +23792,7 @@ u1 = m14; } jsf[0].push(u1); - + var u2; if ((m24 & 1) === 0) { u2 = 0; @@ -23804,7 +23804,7 @@ u2 = m24; } jsf[1].push(u2); - + // Second phase if (2 * d1 === u1 + 1) d1 = 1 - d1; @@ -23813,11 +23813,11 @@ k1.iushrn(1); k2.iushrn(1); } - + return jsf; } utils.getJSF = getJSF; - + function cachedProperty(obj, name, computer) { var key = '_' + name; obj.prototype[name] = function cachedProperty() { @@ -23826,19 +23826,19 @@ }; } utils.cachedProperty = cachedProperty; - + function parseBytes(bytes) { return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : bytes; } utils.parseBytes = parseBytes; - + function intFromLE(bytes) { return new BN(bytes, 'hex', 'le'); } utils.intFromLE = intFromLE; - - + + },{"bn.js":53,"minimalistic-assert":234,"minimalistic-crypto-utils":235}],124:[function(require,module,exports){ module.exports={ "_from": "elliptic@^6.0.0", @@ -23927,21 +23927,21 @@ }, "version": "6.4.0" } - + },{}],125:[function(require,module,exports){ 'use strict' - + const ethjsUtil = require('ethjs-util') - + module.exports = { incrementHexNumber, formatHex, } - + function incrementHexNumber(hexNum) { return formatHex(ethjsUtil.intToHex((parseInt(hexNum, 16) + 1))) } - + function formatHex (hexNum) { let stripped = ethjsUtil.stripHexPrefix(hexNum) while (stripped[0] === '0') { @@ -23949,7 +23949,7 @@ } return `0x${stripped}` } - + },{"ethjs-util":155}],126:[function(require,module,exports){ // const EthQuery = require('ethjs-query') const EthQuery = require('eth-query') @@ -23959,9 +23959,9 @@ const incrementHexNumber = hexUtils.incrementHexNumber const sec = 1000 const min = 60 * sec - + class RpcBlockTracker extends EventEmitter { - + constructor(opts = {}) { super() if (!opts.provider) throw new Error('RpcBlockTracker - no provider specified.') @@ -23979,15 +23979,15 @@ this._performSync = this._performSync.bind(this) this._handleNewBlockNotification = this._handleNewBlockNotification.bind(this) } - + getTrackingBlock () { return this._trackingBlock } - + getCurrentBlock () { return this._currentBlock } - + async awaitCurrentBlock () { // return if available if (this._currentBlock) return this._currentBlock @@ -23996,7 +23996,7 @@ // return newly set current block return this._currentBlock } - + async start (opts = {}) { // abort if already started if (this._isRunning) return @@ -24018,18 +24018,18 @@ }) } } - + async stop () { this._isRunning = false if (this._provider.on) { await this._removeSubscription() } } - + // // private // - + async _setTrackingBlock (newBlock) { if (this._trackingBlock && (this._trackingBlock.hash === newBlock.hash)) return // check for large timestamp lapse @@ -24045,7 +24045,7 @@ this.emit('block', newBlock) } } - + async _setCurrentBlock (newBlock) { if (this._currentBlock && (this._currentBlock.hash === newBlock.hash)) return const oldBlock = this._currentBlock @@ -24053,23 +24053,23 @@ this.emit('latest', newBlock) this.emit('sync', { newBlock, oldBlock }) } - + async _warpToLatest() { // set latest as tracking block await this._setTrackingBlock(await this._fetchLatestBlock()) } - + async _pollForNextBlock () { setTimeout(() => this._performSync(), this._pollingInterval) } - + async _performSync () { if (!this._isRunning) return const trackingBlock = this.getTrackingBlock() if (!trackingBlock) throw new Error('RpcBlockTracker - tracking block is missing') const nextNumber = incrementHexNumber(trackingBlock.number) try { - + const newBlock = await this._fetchBlockByNumber(nextNumber) if (newBlock) { // set as new tracking block @@ -24082,9 +24082,9 @@ // setup poll for next block this._pollForNextBlock() } - + } catch (err) { - + // hotfix for https://github.com/ethereumjs/testrpc/issues/290 if (err.message.includes('index out of range') || err.message.includes("Couldn't find block by reference")) { @@ -24096,25 +24096,25 @@ console.error(err) this._pollForNextBlock() } - + } } - + async _handleNewBlockNotification(err, notification) { if (notification.id != this._subscriptionId) return // this notification isn't for us - + if (err) { this.emit('error', err) await this._removeSubscription() } - + await this._setTrackingBlock(await this._fetchBlockByNumber(notification.result.number)) } - + async _initSubscription() { this._provider.on('data', this._handleNewBlockNotification) - + let result = await pify(this._provider.sendAsync || this._provider.send)({ jsonrpc: '2.0', id: new Date().getTime(), @@ -24123,15 +24123,15 @@ 'newHeads' ], }) - + this._subscriptionId = result.result } - + async _removeSubscription() { if (!this._subscriptionId) throw new Error("Not subscribed.") - + this._provider.removeListener('data', this._handleNewBlockNotification) - + await pify(this._provider.sendAsync || this._provider.send)({ jsonrpc: '2.0', id: new Date().getTime(), @@ -24140,23 +24140,23 @@ this._subscriptionId ], }) - + delete this._subscriptionId } - + _fetchLatestBlock () { return pify(this._query.getBlockByNumber).call(this._query, 'latest', true) } - + _fetchBlockByNumber (hexNumber) { const cleanHex = hexUtils.formatHex(hexNumber) return pify(this._query.getBlockByNumber).call(this._query, cleanHex, true) } - + } - + module.exports = RpcBlockTracker - + // ├─ difficulty: 0x2892ddca // ├─ extraData: 0xd983010507846765746887676f312e372e348777696e646f7773 // ├─ gasLimit: 0x47e7c4 @@ -24192,40 +24192,40 @@ // │ └─ s: 0x1610cdac2782c91065fd43584cd8974f7f3b4e6d46a2aafe7b101788285bf3f2 // ├─ transactionsRoot: 0xb090c32d840dec1e9752719f21bbae4a73e58333aecb89bc3b8ed559fb2712a3 // └─ uncles - + },{"./hexUtils":125,"eth-query":135,"events":157,"pify":252}],127:[function(require,module,exports){ (function (Buffer){ var sha3 = require('js-sha3').keccak_256 var uts46 = require('idna-uts46-hx') - + function namehash (inputName) { // Reject empty names: var node = '' for (var i = 0; i < 32; i++) { node += '00' } - + name = normalize(inputName) - + if (name) { var labels = name.split('.') - + for(var i = labels.length - 1; i >= 0; i--) { var labelSha = sha3(labels[i]) node = sha3(new Buffer(node + labelSha, 'hex')) } } - + return '0x' + node } - + function normalize(name) { return name ? uts46.toUnicode(name, {useStd3ASCII: true, transitional: false}) : name } - + exports.hash = namehash exports.normalize = normalize - + }).call(this,require("buffer").Buffer) },{"buffer":84,"idna-uts46-hx":177,"js-sha3":128}],128:[function(require,module,exports){ (function (process,global){ @@ -24240,7 +24240,7 @@ /*jslint bitwise: true */ (function () { 'use strict'; - + var root = typeof window === 'object' ? window : {}; var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; if (NODE_JS) { @@ -24260,19 +24260,19 @@ var BITS = [224, 256, 384, 512]; var SHAKE_BITS = [128, 256]; var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array']; - + var createOutputMethod = function (bits, padding, outputType) { return function (message) { return new Keccak(bits, padding, bits).update(message)[outputType](); }; }; - + var createShakeOutputMethod = function (bits, padding, outputType) { return function (message, outputBits) { return new Keccak(bits, padding, outputBits).update(message)[outputType](); }; }; - + var createMethod = function (bits, padding) { var method = createOutputMethod(bits, padding, 'hex'); method.create = function () { @@ -24287,7 +24287,7 @@ } return method; }; - + var createShakeMethod = function (bits, padding) { var method = createShakeOutputMethod(bits, padding, 'hex'); method.create = function (outputBits) { @@ -24302,15 +24302,15 @@ } return method; }; - + var algorithms = [ {name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod}, {name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod}, {name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod} ]; - + var methods = {}, methodNames = []; - + for (var i = 0; i < algorithms.length; ++i) { var algorithm = algorithms[i]; var bits = algorithm.bits; @@ -24320,7 +24320,7 @@ methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); } } - + function Keccak(bits, padding, outputBits) { this.blocks = []; this.s = []; @@ -24333,12 +24333,12 @@ this.byteCount = this.blockCount << 2; this.outputBlocks = outputBits >> 5; this.extraBytes = (outputBits & 31) >> 3; - + for (var i = 0; i < 50; ++i) { this.s[i] = 0; } } - + Keccak.prototype.update = function (message) { var notString = typeof message !== 'string'; if (notString && message.constructor === ArrayBuffer) { @@ -24346,7 +24346,7 @@ } var length = message.length, blocks = this.blocks, byteCount = this.byteCount, blockCount = this.blockCount, index = 0, s = this.s, i, code; - + while (index < length) { if (this.reset) { this.reset = false; @@ -24395,7 +24395,7 @@ } return this; }; - + Keccak.prototype.finalize = function () { var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; blocks[i >> 2] |= this.padding[i & 3]; @@ -24411,10 +24411,10 @@ } f(s); }; - + Keccak.prototype.toString = Keccak.prototype.hex = function () { this.finalize(); - + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, extraBytes = this.extraBytes, i = 0, j = 0; var hex = '', block; @@ -24445,10 +24445,10 @@ } return hex; }; - + Keccak.prototype.arrayBuffer = function () { this.finalize(); - + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, extraBytes = this.extraBytes, i = 0, j = 0; var bytes = this.outputBits >> 3; @@ -24473,12 +24473,12 @@ } return buffer; }; - + Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; - + Keccak.prototype.digest = Keccak.prototype.array = function () { this.finalize(); - + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, extraBytes = this.extraBytes, i = 0, j = 0; var array = [], offset, block; @@ -24510,7 +24510,7 @@ } return array; }; - + var f = function (s) { var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, @@ -24527,7 +24527,7 @@ c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; - + h = c8 ^ ((c2 << 1) | (c3 >>> 31)); l = c9 ^ ((c3 << 1) | (c2 >>> 31)); s[0] ^= h; @@ -24588,7 +24588,7 @@ s[39] ^= l; s[48] ^= h; s[49] ^= l; - + b0 = s[0]; b1 = s[1]; b32 = (s[11] << 4) | (s[10] >>> 28); @@ -24639,7 +24639,7 @@ b27 = (s[39] << 8) | (s[38] >>> 24); b8 = (s[48] << 14) | (s[49] >>> 18); b9 = (s[49] << 14) | (s[48] >>> 18); - + s[0] = b0 ^ (~b2 & b4); s[1] = b1 ^ (~b3 & b5); s[10] = b10 ^ (~b12 & b14); @@ -24690,12 +24690,12 @@ s[39] = b39 ^ (~b31 & b33); s[48] = b48 ^ (~b40 & b42); s[49] = b49 ^ (~b41 & b43); - + s[0] ^= RC[n]; s[1] ^= RC[n + 1]; } }; - + if (COMMON_JS) { module.exports = methods; } else { @@ -24704,27 +24704,27 @@ } } })(); - + }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"_process":257}],129:[function(require,module,exports){ const RpcEngine = require('json-rpc-engine') const providerFromEngine = require('eth-json-rpc-middleware/providerFromEngine') const createInfuraMiddleware = require('./index') - - + + module.exports = createProvider - + function createProvider(opts){ const engine = new RpcEngine() engine.push(createInfuraMiddleware(opts)) return providerFromEngine(engine) } - + },{"./index":130,"eth-json-rpc-middleware/providerFromEngine":131,"json-rpc-engine":188}],130:[function(require,module,exports){ const createAsyncMiddleware = require('json-rpc-engine/src/createAsyncMiddleware') const JsonRpcError = require('json-rpc-error') const fetch = require('cross-fetch') - + const POST_METHODS = ['eth_call', 'eth_estimateGas', 'eth_sendRawTransaction'] const RETRIABLE_ERRORS = [ // ignore server overload errors @@ -24735,16 +24735,16 @@ // or truncated json responses 'SyntaxError', ] - + module.exports = createInfuraMiddleware module.exports.fetchConfigFromReq = fetchConfigFromReq - + function createInfuraMiddleware(opts = {}) { const network = opts.network || 'mainnet' const maxAttempts = opts.maxAttempts || 5 // validate options if (!maxAttempts) throw new Error(`Invalid value for 'maxAttempts': "${maxAttempts}" (${typeof maxAttempts})`) - + return createAsyncMiddleware(async (req, res, next) => { // retry MAX_ATTEMPTS times, if error matches filter for (let attempt = 1; attempt <= maxAttempts; attempt++) { @@ -24774,18 +24774,18 @@ // request was handled correctly, end }) } - + function timeout(length) { return new Promise((resolve) => { setTimeout(resolve, length) }) } - + function isRetriableError(err) { const errMessage = err.toString() return RETRIABLE_ERRORS.some(phrase => errMessage.includes(phrase)) } - + async function performFetch(network, req, res){ const { fetchUrl, fetchParams } = fetchConfigFromReq({ network, req }) const response = await fetch(fetchUrl, fetchParams) @@ -24795,37 +24795,37 @@ switch (response.status) { case 405: throw new JsonRpcError.MethodNotFound() - + case 418: throw createRatelimitError() - + case 503: case 504: throw createTimeoutError() - + default: throw createInternalError(rawData) } } - + // special case for now if (req.method === 'eth_getBlockByNumber' && rawData === 'Not Found') { res.result = null return } - + // parse JSON const data = JSON.parse(rawData) - + // finally return result res.result = data.result res.error = data.error } - + function fetchConfigFromReq({ network, req }) { const cleanReq = normalizeReq(req) const { method, params } = cleanReq - + const fetchParams = {} let fetchUrl = `https://api.infura.io/v1/jsonrpc/${network}` const isPostMethod = POST_METHODS.includes(method) @@ -24841,10 +24841,10 @@ const paramsString = encodeURIComponent(JSON.stringify(params)) fetchUrl += `/${method}?params=${paramsString}` } - + return { fetchUrl, fetchParams } } - + // strips out extra keys that could be rejected by strict nodes like parity function normalizeReq(req) { return { @@ -24854,31 +24854,31 @@ params: req.params, } } - + function createRatelimitError () { let msg = `Request is being rate limited.` return createInternalError(msg) } - + function createTimeoutError () { let msg = `Gateway timeout. The request took too long to process. ` msg += `This can happen when querying logs over too wide a block range.` return createInternalError(msg) } - + function createInternalError (msg) { const err = new Error(msg) return new JsonRpcError.InternalError(err) } - + },{"cross-fetch":96,"json-rpc-engine/src/createAsyncMiddleware":187,"json-rpc-error":189}],131:[function(require,module,exports){ module.exports = providerFromEngine - + function providerFromEngine (engine) { const provider = { sendAsync: engine.handle.bind(engine) } return provider } - + },{}],132:[function(require,module,exports){ var generate = function generate(num, fn) { var a = []; @@ -24886,17 +24886,17 @@ a.push(fn(i)); }return a; }; - + var replicate = function replicate(num, val) { return generate(num, function () { return val; }); }; - + var concat = function concat(a, b) { return a.concat(b); }; - + var flatten = function flatten(a) { var r = []; for (var j = 0, J = a.length; j < J; ++j) { @@ -24905,14 +24905,14 @@ } }return r; }; - + var chunksOf = function chunksOf(n, a) { var b = []; for (var i = 0, l = a.length; i < l; i += n) { b.push(a.slice(i, i + n)); }return b; }; - + module.exports = { generate: generate, replicate: replicate, @@ -24922,11 +24922,11 @@ }; },{}],133:[function(require,module,exports){ var A = require("./array.js"); - + var at = function at(bytes, index) { return parseInt(bytes.slice(index * 2 + 2, index * 2 + 4), 16); }; - + var random = function random(bytes) { var rnd = void 0; if (typeof window !== "undefined" && window.crypto && window.crypto.getRandomValues) rnd = window.crypto.getRandomValues(new Uint8Array(bytes));else if (typeof require !== "undefined") rnd = require("c" + "rypto").randomBytes(bytes);else throw "Safe random numbers not available."; @@ -24935,21 +24935,21 @@ hex += ("00" + rnd[i].toString(16)).slice(-2); }return hex; }; - + var length = function length(a) { return (a.length - 2) / 2; }; - + var flatten = function flatten(a) { return "0x" + a.reduce(function (r, s) { return r + s.slice(2); }, ""); }; - + var slice = function slice(i, j, bs) { return "0x" + bs.slice(i * 2 + 2, j * 2 + 2); }; - + var reverse = function reverse(hex) { var rev = "0x"; for (var i = 0, l = length(hex); i < l; ++i) { @@ -24957,22 +24957,22 @@ } return rev; }; - + var pad = function pad(l, hex) { return hex.length === l * 2 + 2 ? hex : pad(l, "0x" + "0" + hex.slice(2)); }; - + var padRight = function padRight(l, hex) { return hex.length === l * 2 + 2 ? hex : padRight(l, hex + "0"); }; - + var toArray = function toArray(hex) { var arr = []; for (var i = 2, l = hex.length; i < l; i += 2) { arr.push(parseInt(hex.slice(i, i + 2), 16)); }return arr; }; - + var fromArray = function fromArray(arr) { var hex = "0x"; for (var i = 0, l = arr.length; i < l; ++i) { @@ -24981,50 +24981,50 @@ } return hex; }; - + var toUint8Array = function toUint8Array(hex) { return new Uint8Array(toArray(hex)); }; - + var fromUint8Array = function fromUint8Array(arr) { return fromArray([].slice.call(arr, 0)); }; - + var fromNumber = function fromNumber(num) { var hex = num.toString(16); return hex.length % 2 === 0 ? "0x" + hex : "0x0" + hex; }; - + var toNumber = function toNumber(hex) { return parseInt(hex.slice(2), 16); }; - + var concat = function concat(a, b) { return a.concat(b.slice(2)); }; - + var fromNat = function fromNat(bn) { return bn === "0x0" ? "0x" : bn.length % 2 === 0 ? bn : "0x0" + bn.slice(2); }; - + var toNat = function toNat(bn) { return bn[2] === "0" ? "0x" + bn.slice(3) : bn; }; - + var fromAscii = function fromAscii(ascii) { var hex = "0x"; for (var i = 0; i < ascii.length; ++i) { hex += ("00" + ascii.charCodeAt(i).toString(16)).slice(-2); }return hex; }; - + var toAscii = function toAscii(hex) { var ascii = ""; for (var i = 2; i < hex.length; i += 2) { ascii += String.fromCharCode(parseInt(hex.slice(i, i + 2), 16)); }return ascii; }; - + // From https://gist.github.com/pascaldekloe/62546103a1576803dade9269ccf76330 var fromString = function fromString(s) { var makeByte = function makeByte(uint8) { @@ -25058,7 +25058,7 @@ } return bytes; }; - + var toString = function toString(bytes) { var s = ''; var i = 0; @@ -25086,7 +25086,7 @@ } return s; }; - + module.exports = { random: random, length: length, @@ -25114,7 +25114,7 @@ // modifications and pruning. It is licensed under MIT: // // Copyright 2015-2016 Chen, Yi-Cyuan - // + // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including @@ -25122,10 +25122,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: - // + // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. - // + // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -25133,12 +25133,12 @@ // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - + var HEX_CHARS = '0123456789abcdef'.split(''); var KECCAK_PADDING = [1, 256, 65536, 16777216]; var SHIFT = [0, 8, 16, 24]; var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; - + var Keccak = function Keccak(bits) { return { blocks: [], @@ -25152,7 +25152,7 @@ }([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) }; }; - + var update = function update(state, message) { var length = message.length, blocks = state.blocks, @@ -25163,7 +25163,7 @@ index = 0, i, code; - + // update while (index < length) { if (state.reset) { @@ -25211,7 +25211,7 @@ state.start = i; } } - + // finalize i = state.lastByteIndex; blocks[i >> 2] |= KECCAK_PADDING[i & 3]; @@ -25226,7 +25226,7 @@ s[i] ^= blocks[i]; } f(s); - + // toString var hex = '', i = 0, @@ -25244,10 +25244,10 @@ } return "0x" + hex; }; - + var f = function f(s) { var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; - + for (n = 0; n < 48; n += 2) { c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; @@ -25259,7 +25259,7 @@ c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; - + h = c8 ^ (c2 << 1 | c3 >>> 31); l = c9 ^ (c3 << 1 | c2 >>> 31); s[0] ^= h; @@ -25320,7 +25320,7 @@ s[39] ^= l; s[48] ^= h; s[49] ^= l; - + b0 = s[0]; b1 = s[1]; b32 = s[11] << 4 | s[10] >>> 28; @@ -25371,7 +25371,7 @@ b27 = s[39] << 8 | s[38] >>> 24; b8 = s[48] << 14 | s[49] >>> 18; b9 = s[49] << 14 | s[48] >>> 18; - + s[0] = b0 ^ ~b2 & b4; s[1] = b1 ^ ~b3 & b5; s[10] = b10 ^ ~b12 & b14; @@ -25422,12 +25422,12 @@ s[39] = b39 ^ ~b31 & b33; s[48] = b48 ^ ~b40 & b42; s[49] = b49 ^ ~b41 & b43; - + s[0] ^= RC[n]; s[1] ^= RC[n + 1]; } }; - + var keccak = function keccak(bits) { return function (str) { var msg; @@ -25442,7 +25442,7 @@ return update(Keccak(bits, bits), msg); }; }; - + module.exports = { keccak256: keccak(256), keccak512: keccak(512), @@ -25452,19 +25452,19 @@ },{}],135:[function(require,module,exports){ const extend = require('xtend') const createRandomId = require('json-rpc-random-id')() - + module.exports = EthQuery - - + + function EthQuery(provider){ const self = this self.currentProvider = provider } - + // // base queries // - + // default block EthQuery.prototype.getBalance = generateFnWithDefaultBlockFor(2, 'eth_getBalance') EthQuery.prototype.getCode = generateFnWithDefaultBlockFor(2, 'eth_getCode') @@ -25510,9 +25510,9 @@ EthQuery.prototype.getWork = generateFnFor('eth_getWork') EthQuery.prototype.submitWork = generateFnFor('eth_submitWork') EthQuery.prototype.submitHashrate = generateFnFor('eth_submitHashrate') - + // network level - + EthQuery.prototype.sendAsync = function(opts, cb){ const self = this self.currentProvider.sendAsync(createPayload(opts), function(err, response){ @@ -25521,9 +25521,9 @@ cb(null, response.result) }) } - + // util - + function generateFnFor(methodName){ return function(){ const self = this @@ -25535,7 +25535,7 @@ }, cb) } } - + function generateFnWithDefaultBlockFor(argCount, methodName){ return function(){ const self = this @@ -25549,7 +25549,7 @@ }, cb) } } - + function createPayload(data){ return extend({ // defaults @@ -25559,13 +25559,13 @@ // user-specified }, data) } - + },{"json-rpc-random-id":191,"xtend":423}],136:[function(require,module,exports){ const ethUtil = require('ethereumjs-util') const ethAbi = require('ethereumjs-abi') - + module.exports = { - + concatSig: function (v, r, s) { const rSig = ethUtil.fromSigned(r) const sSig = ethUtil.fromSigned(s) @@ -25575,24 +25575,24 @@ const vStr = ethUtil.stripHexPrefix(ethUtil.intToHex(vSig)) return ethUtil.addHexPrefix(rStr.concat(sStr, vStr)).toString('hex') }, - + normalize: function (input) { if (!input) return - + if (typeof input === 'number') { const buffer = ethUtil.toBuffer(input) input = ethUtil.bufferToHex(buffer) } - + if (typeof input !== 'string') { var msg = 'eth-sig-util.normalize() requires hex string or integer input.' msg += ' received ' + (typeof input) + ': ' + input throw new Error(msg) } - + return ethUtil.addHexPrefix(input.toLowerCase()) }, - + personalSign: function (privateKey, msgParams) { var message = ethUtil.toBuffer(msgParams.data) var msgHash = ethUtil.hashPersonalMessage(message) @@ -25600,39 +25600,39 @@ var serialized = ethUtil.bufferToHex(this.concatSig(sig.v, sig.r, sig.s)) return serialized }, - + recoverPersonalSignature: function (msgParams) { const publicKey = getPublicKeyFor(msgParams) const sender = ethUtil.publicToAddress(publicKey) const senderHex = ethUtil.bufferToHex(sender) return senderHex }, - + extractPublicKey: function (msgParams) { const publicKey = getPublicKeyFor(msgParams) return '0x' + publicKey.toString('hex') }, - + typedSignatureHash: function (typedData) { const hashBuffer = typedSignatureHash(typedData) return ethUtil.bufferToHex(hashBuffer) }, - + signTypedData: function (privateKey, msgParams) { const msgHash = typedSignatureHash(msgParams.data) const sig = ethUtil.ecsign(msgHash, privateKey) return ethUtil.bufferToHex(this.concatSig(sig.v, sig.r, sig.s)) }, - + recoverTypedSignature: function (msgParams) { const msgHash = typedSignatureHash(msgParams.data) const publicKey = recoverPublicKey(msgHash, msgParams.sig) const sender = ethUtil.publicToAddress(publicKey) return ethUtil.bufferToHex(sender) } - + } - + /** * @param typedData - Array of data along with types, as per EIP712. * @returns Buffer @@ -25640,7 +25640,7 @@ function typedSignatureHash(typedData) { const error = new Error('Expect argument to be non-empty array') if (typeof typedData !== 'object' || !typedData.length) throw error - + const data = typedData.map(function (e) { return e.type === 'bytes' ? ethUtil.toBuffer(e.value) : e.value }) @@ -25649,7 +25649,7 @@ if (!e.name) throw error return e.type + ' ' + e.name }) - + return ethAbi.soliditySHA3( ['bytes32', 'bytes32'], [ @@ -25658,20 +25658,20 @@ ] ) } - + function recoverPublicKey(hash, sig) { const signature = ethUtil.toBuffer(sig) const sigParams = ethUtil.fromRpcSig(signature) return ethUtil.ecrecover(hash, sigParams.v, sigParams.r, sigParams.s) } - + function getPublicKeyFor (msgParams) { const message = ethUtil.toBuffer(msgParams.data) const msgHash = ethUtil.hashPersonalMessage(message) return recoverPublicKey(msgHash, msgParams.sig) } - - + + function padWithZeroes (number, length) { var myString = '' + number while (myString.length < length) { @@ -25679,7 +25679,7 @@ } return myString } - + },{"ethereumjs-abi":138,"ethereumjs-util":141}],137:[function(require,module,exports){ module.exports={ "genesisGasLimit": { @@ -25742,7 +25742,7 @@ "v": 1024, "d": "Maximum depth of call/create stack." }, - + "tierStepGas": { "v": [0, 2, 3, 5, 8, 10, 20], "d": "Once per operation, for a selection of them." @@ -25755,7 +25755,7 @@ "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, - + "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." @@ -25784,7 +25784,7 @@ "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, - + "logGas": { "v": 375, "d": "Per LOG* operation." @@ -25797,12 +25797,12 @@ "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, - + "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, - + "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." @@ -25819,12 +25819,12 @@ "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, - + "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, - + "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." @@ -25833,7 +25833,7 @@ "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, - + "createDataGas": { "v": 200, "d": "" @@ -25854,12 +25854,12 @@ "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, - + "copyGas": { "v": 3, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, - + "ecrecoverGas": { "v": 3000, "d": "" @@ -25916,18 +25916,18 @@ "v": 2 } } - + },{}],138:[function(require,module,exports){ module.exports = require('./lib/index.js') - + },{"./lib/index.js":139}],139:[function(require,module,exports){ (function (Buffer){ const utils = require('ethereumjs-util') const BN = require('bn.js') - + var ABI = function () { } - + // Convert from short to canonical names // FIXME: optimise or make this nicer? function elementaryName (name) { @@ -25950,28 +25950,28 @@ } return name } - + ABI.eventID = function (name, types) { // FIXME: use node.js util.format? var sig = name + '(' + types.map(elementaryName).join(',') + ')' return utils.sha3(new Buffer(sig)) } - + ABI.methodID = function (name, types) { return ABI.eventID(name, types).slice(0, 4) } - + // Parse N from type function parseTypeN (type) { return parseInt(/^\D+(\d+)$/.exec(type)[1], 10) } - + // Parse N,M from typex function parseTypeNxM (type) { var tmp = /^\D+(\d+)x(\d+)$/.exec(type) return [ parseInt(tmp[1], 10), parseInt(tmp[2], 10) ] } - + // Parse N in type[] where "type" can itself be an array type. function parseTypeArray (type) { var tmp = type.match(/(.*)\[(.*?)\]$/) @@ -25980,7 +25980,7 @@ } return null } - + function parseNumber (arg) { var type = typeof arg if (type === 'string') { @@ -25998,7 +25998,7 @@ throw new Error('Argument is not a number') } } - + // someMethod(bytes,uint) // someMethod(bytes,uint):(boolean) function parseSignature (sig) { @@ -26006,9 +26006,9 @@ if (tmp.length !== 3) { throw new Error('Invalid method signature') } - + var args = /^(.+)\):\((.+)$/.exec(tmp[2]) - + if (args !== null && args.length === 3) { return { method: tmp[1], @@ -26022,12 +26022,12 @@ } } } - + // Encodes a single item (can be dynamic array) // @returns: Buffer function encodeSingle (type, arg) { var size, num, ret, i - + if (type === 'address') { return encodeSingle('uint160', parseNumber(arg)) } else if (type === 'bool') { @@ -26059,68 +26059,68 @@ return Buffer.concat(ret) } else if (type === 'bytes') { arg = new Buffer(arg) - + ret = Buffer.concat([ encodeSingle('uint256', arg.length), arg ]) - + if ((arg.length % 32) !== 0) { ret = Buffer.concat([ ret, utils.zeros(32 - (arg.length % 32)) ]) } - + return ret } else if (type.startsWith('bytes')) { size = parseTypeN(type) if (size < 1 || size > 32) { throw new Error('Invalid bytes width: ' + size) } - + return utils.setLengthRight(arg, 32) } else if (type.startsWith('uint')) { size = parseTypeN(type) if ((size % 8) || (size < 8) || (size > 256)) { throw new Error('Invalid uint width: ' + size) } - + num = parseNumber(arg) if (num.bitLength() > size) { throw new Error('Supplied uint exceeds width: ' + size + ' vs ' + num.bitLength()) } - + if (num < 0) { throw new Error('Supplied uint is negative') } - + return num.toArrayLike(Buffer, 'be', 32) } else if (type.startsWith('int')) { size = parseTypeN(type) if ((size % 8) || (size < 8) || (size > 256)) { throw new Error('Invalid int width: ' + size) } - + num = parseNumber(arg) if (num.bitLength() > size) { throw new Error('Supplied int exceeds width: ' + size + ' vs ' + num.bitLength()) } - + return num.toTwos(256).toArrayLike(Buffer, 'be', 32) } else if (type.startsWith('ufixed')) { size = parseTypeNxM(type) - + num = parseNumber(arg) - + if (num < 0) { throw new Error('Supplied ufixed is negative') } - + return encodeSingle('uint256', num.mul(new BN(2).pow(new BN(size[1])))) } else if (type.startsWith('fixed')) { size = parseTypeNxM(type) - + return encodeSingle('int256', parseNumber(arg).mul(new BN(2).pow(new BN(size[1])))) } - + throw new Error('Unsupported or invalid type: ' + type) } - + // Decodes a single item (can be dynamic array) // @returns: array // FIXME: this method will need a lot of attention at checking limits and validation @@ -26129,7 +26129,7 @@ parsedType = parseType(parsedType) } var size, num, ret, i - + if (parsedType.name === 'address') { return decodeSingle(parsedType.rawType, data, offset).toArrayLike(Buffer, 'be', 20).toString('hex') } else if (parsedType.name === 'bool') { @@ -26142,7 +26142,7 @@ // NOTE: we catch here all calls to arrays, that simplifies the rest ret = [] size = parsedType.size - + if (parsedType.size === 'dynamic') { offset = decodeSingle('uint256', data, offset).toNumber() size = decodeSingle('uint256', data, offset).toNumber() @@ -26171,7 +26171,7 @@ if (num.bitLength() > parsedType.size) { throw new Error('Decoded uint exceeds width: ' + parsedType.size + ' vs ' + num.bitLength()) } - + return num } else if (parsedType.name.startsWith('ufixed')) { size = new BN(2).pow(new BN(parsedType.size[1])) @@ -26190,7 +26190,7 @@ } throw new Error('Unsupported or invalid type: ' + parsedType.name) } - + // Parse the given type // @returns: {} containing the type itself, memory usage and (including size and subArray if applicable) function parseType (type) { @@ -26226,13 +26226,13 @@ name: type, memoryUsage: 32 } - + if (type.startsWith('bytes') && type !== 'bytes' || type.startsWith('uint') || type.startsWith('int')) { ret.size = parseTypeN(type) } else if (type.startsWith('ufixed') || type.startsWith('fixed')) { ret.size = parseTypeNxM(type) } - + if (type.startsWith('bytes') && type !== 'bytes' && (ret.size < 1 || ret.size > 32)) { throw new Error('Invalid bytes width: ' + ret.size) } @@ -26242,31 +26242,31 @@ return ret } } - + // Is a type dynamic? function isDynamic (type) { // FIXME: handle all types? I don't think anything is missing now return (type === 'string') || (type === 'bytes') || (parseTypeArray(type) === 'dynamic') } - + // Is a type an array? function isArray (type) { return type.lastIndexOf(']') === type.length - 1 } - + // Encode a method/event with arguments // @types an array of string type names // @args an array of the appropriate values ABI.rawEncode = function (types, values) { var output = [] var data = [] - + var headLength = 0 - + types.forEach(function (type) { if (isArray(type)) { var size = parseTypeArray(type) - + if (size !== 'dynamic') { headLength += 32 * size } else { @@ -26276,12 +26276,12 @@ headLength += 32 } }) - + for (var i = 0; i < types.length; i++) { var type = elementaryName(types[i]) var value = values[i] var cur = encodeSingle(type, value) - + // Use the head/tail method for storing dynamic data if (isDynamic(type)) { output.push(encodeSingle('uint256', headLength)) @@ -26291,10 +26291,10 @@ output.push(cur) } } - + return Buffer.concat(output.concat(data)) } - + ABI.rawDecode = function (types, data) { var ret = [] data = new Buffer(data) @@ -26308,30 +26308,30 @@ } return ret } - + ABI.simpleEncode = function (method) { var args = Array.prototype.slice.call(arguments).slice(1) var sig = parseSignature(method) - + // FIXME: validate/convert arguments if (args.length !== sig.args.length) { throw new Error('Argument count mismatch') } - + return Buffer.concat([ ABI.methodID(sig.method, sig.args), ABI.rawEncode(sig.args, args) ]) } - + ABI.simpleDecode = function (method, data) { var sig = parseSignature(method) - + // FIXME: validate/convert arguments if (!sig.retargs) { throw new Error('No return values in method') } - + return ABI.rawDecode(sig.retargs, data) } - + function stringify (type, value) { if (type.startsWith('address') || type.startsWith('bytes')) { return '0x' + value.toString('hex') @@ -26339,14 +26339,14 @@ return value.toString() } } - + ABI.stringify = function (types, values) { var ret = [] - + for (var i in types) { var type = types[i] var value = values[i] - + // if it is an array type, concat the items if (/^[^\[]+\[.*\]$/.test(type)) { value = value.map(function (item) { @@ -26355,25 +26355,25 @@ } else { value = stringify(type, value) } - + ret.push(value) } - + return ret } - + ABI.solidityPack = function (types, values) { if (types.length !== values.length) { throw new Error('Number of types are not matching the values') } - + var size, num var ret = [] - + for (var i = 0; i < types.length; i++) { var type = elementaryName(types[i]) var value = values[i] - + if (type === 'bytes') { ret.push(value) } else if (type === 'string') { @@ -26387,65 +26387,65 @@ if (size < 1 || size > 32) { throw new Error('Invalid bytes width: ' + size) } - + ret.push(utils.setLengthRight(value, size)) } else if (type.startsWith('uint')) { size = parseTypeN(type) if ((size % 8) || (size < 8) || (size > 256)) { throw new Error('Invalid uint width: ' + size) } - + num = parseNumber(value) if (num.bitLength() > size) { throw new Error('Supplied uint exceeds width: ' + size + ' vs ' + num.bitLength()) } - + ret.push(num.toArrayLike(Buffer, 'be', size / 8)) } else if (type.startsWith('int')) { size = parseTypeN(type) if ((size % 8) || (size < 8) || (size > 256)) { throw new Error('Invalid int width: ' + size) } - + num = parseNumber(value) if (num.bitLength() > size) { throw new Error('Supplied int exceeds width: ' + size + ' vs ' + num.bitLength()) } - + ret.push(num.toTwos(size).toArrayLike(Buffer, 'be', size / 8)) } else { // FIXME: support all other types throw new Error('Unsupported or invalid type: ' + type) } } - + return Buffer.concat(ret) } - + ABI.soliditySHA3 = function (types, values) { return utils.sha3(ABI.solidityPack(types, values)) } - + ABI.soliditySHA256 = function (types, values) { return utils.sha256(ABI.solidityPack(types, values)) } - + ABI.solidityRIPEMD160 = function (types, values) { return utils.ripemd160(ABI.solidityPack(types, values), true) } - + // Serpent's users are familiar with this encoding // - s: string // - b: bytes // - b: bytes // - i: int256 // - a: int256[] - + function isNumeric (c) { // FIXME: is this correct? Seems to work return (c >= '0') && (c <= '9') } - + // For a "documentation" refer to https://github.com/ethereum/serpent/blob/develop/preprocess.cpp ABI.fromSerpent = function (sig) { var ret = [] @@ -26472,7 +26472,7 @@ } return ret } - + ABI.toSerpent = function (types) { var ret = [] for (var i = 0; i < types.length; i++) { @@ -26491,23 +26491,23 @@ } return ret.join('') } - + module.exports = ABI - + }).call(this,require("buffer").Buffer) },{"bn.js":53,"buffer":84,"ethereumjs-util":141}],140:[function(require,module,exports){ (function (Buffer){ 'use strict'; - + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - + var ethUtil = require('ethereumjs-util'); var fees = require('ethereum-common/params.json'); var BN = ethUtil.BN; - + // secp256k1n/2 var N_DIV_2 = new BN('7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0', 16); - + /** * Creates a new transaction object. * @@ -26544,11 +26544,11 @@ * @param {Buffer} data.s EC recovery ID * @param {Number} data.chainId EIP 155 chainId - mainnet: 1, ropsten: 3 * */ - + var Transaction = function () { function Transaction(data) { _classCallCheck(this, Transaction); - + data = data || {}; // Define Properties var fields = [{ @@ -26599,7 +26599,7 @@ allowLess: true, default: new Buffer([]) }]; - + /** * Returns the rlp encoding of the transaction * @method serialize @@ -26609,7 +26609,7 @@ */ // attached serialize ethUtil.defineProperties(this, fields, data); - + /** * @property {Buffer} from (read only) sender address of this transaction, mathematically derived from other parameters. * @name from @@ -26620,42 +26620,42 @@ configurable: true, get: this.getSenderAddress.bind(this) }); - + // calculate chainId from signature var sigV = ethUtil.bufferToInt(this.v); var chainId = Math.floor((sigV - 35) / 2); if (chainId < 0) chainId = 0; - + // set chainId this._chainId = chainId || data.chainId || 0; this._homestead = true; } - + /** * If the tx's `to` is to the creation address * @return {Boolean} */ - - + + Transaction.prototype.toCreationAddress = function toCreationAddress() { return this.to.toString('hex') === ''; }; - + /** * Computes a sha3-256 hash of the serialized tx * @param {Boolean} [includeSignature=true] whether or not to inculde the signature * @return {Buffer} */ - - + + Transaction.prototype.hash = function hash(includeSignature) { if (includeSignature === undefined) includeSignature = true; - + // EIP155 spec: // when computing the hash of a transaction for purposes of signing or recovering, // instead of hashing only the first six elements (ie. nonce, gasprice, startgas, to, value, data), // hash nine elements, with v replaced by CHAIN_ID, r = 0 and s = 0 - + var items = void 0; if (includeSignature) { items = this.raw; @@ -26671,27 +26671,27 @@ items = this.raw.slice(0, 6); } } - + // create hash return ethUtil.rlphash(items); }; - + /** * returns the public key of the sender * @return {Buffer} */ - - + + Transaction.prototype.getChainId = function getChainId() { return this._chainId; }; - + /** * returns the sender's address * @return {Buffer} */ - - + + Transaction.prototype.getSenderAddress = function getSenderAddress() { if (this._from) { return this._from; @@ -26700,33 +26700,33 @@ this._from = ethUtil.publicToAddress(pubkey); return this._from; }; - + /** * returns the public key of the sender * @return {Buffer} */ - - + + Transaction.prototype.getSenderPublicKey = function getSenderPublicKey() { if (!this._senderPubKey || !this._senderPubKey.length) { if (!this.verifySignature()) throw new Error('Invalid Signature'); } return this._senderPubKey; }; - + /** * Determines if the signature is valid * @return {Boolean} */ - - + + Transaction.prototype.verifySignature = function verifySignature() { var msgHash = this.hash(false); // All transaction signatures whose s-value is greater than secp256k1n/2 are considered invalid. if (this._homestead && new BN(this.s).cmp(N_DIV_2) === 1) { return false; } - + try { var v = ethUtil.bufferToInt(this.v); if (this._chainId > 0) { @@ -26736,16 +26736,16 @@ } catch (e) { return false; } - + return !!this._senderPubKey; }; - + /** * sign a transaction with a given a private key * @param {Buffer} privateKey */ - - + + Transaction.prototype.sign = function sign(privateKey) { var msgHash = this.hash(false); var sig = ethUtil.ecsign(msgHash, privateKey); @@ -26754,13 +26754,13 @@ } Object.assign(this, sig); }; - + /** * The amount of gas paid for the data in this tx * @return {BN} */ - - + + Transaction.prototype.getDataFee = function getDataFee() { var data = this.raw[5]; var cost = new BN(0); @@ -26769,13 +26769,13 @@ } return cost; }; - + /** * the minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee) * @return {BN} */ - - + + Transaction.prototype.getBaseFee = function getBaseFee() { var fee = this.getDataFee().iaddn(fees.txGas.v); if (this._homestead && this.toCreationAddress()) { @@ -26783,51 +26783,51 @@ } return fee; }; - + /** * the up front amount that an account must have for this transaction to be valid * @return {BN} */ - - + + Transaction.prototype.getUpfrontCost = function getUpfrontCost() { return new BN(this.gasLimit).imul(new BN(this.gasPrice)).iadd(new BN(this.value)); }; - + /** * validates the signature and checks to see if it has enough gas * @param {Boolean} [stringError=false] whether to return a string with a dscription of why the validation failed or return a Bloolean * @return {Boolean|String} */ - - + + Transaction.prototype.validate = function validate(stringError) { var errors = []; if (!this.verifySignature()) { errors.push('Invalid Signature'); } - + if (this.getBaseFee().cmp(new BN(this.gasLimit)) > 0) { errors.push(['gas limit is too low. Need at least ' + this.getBaseFee()]); } - + if (stringError === undefined || stringError === false) { return errors.length === 0; } else { return errors.join(' '); } }; - + return Transaction; }(); - + module.exports = Transaction; }).call(this,require("buffer").Buffer) },{"buffer":84,"ethereum-common/params.json":137,"ethereumjs-util":141}],141:[function(require,module,exports){ 'use strict'; - + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - + var createKeccakHash = require('keccak'); var secp256k1 = require('secp256k1'); var assert = require('assert'); @@ -26836,79 +26836,79 @@ var createHash = require('create-hash'); var Buffer = require('safe-buffer').Buffer; Object.assign(exports, require('ethjs-util')); - + /** * the max integer that this VM can handle (a ```BN```) * @var {BN} MAX_INTEGER */ exports.MAX_INTEGER = new BN('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16); - + /** * 2^256 (a ```BN```) * @var {BN} TWO_POW256 */ exports.TWO_POW256 = new BN('10000000000000000000000000000000000000000000000000000000000000000', 16); - + /** * Keccak-256 hash of null (a ```String```) * @var {String} KECCAK256_NULL_S */ exports.KECCAK256_NULL_S = 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'; exports.SHA3_NULL_S = exports.KECCAK256_NULL_S; - + /** * Keccak-256 hash of null (a ```Buffer```) * @var {Buffer} KECCAK256_NULL */ exports.KECCAK256_NULL = Buffer.from(exports.KECCAK256_NULL_S, 'hex'); exports.SHA3_NULL = exports.KECCAK256_NULL; - + /** * Keccak-256 of an RLP of an empty array (a ```String```) * @var {String} KECCAK256_RLP_ARRAY_S */ exports.KECCAK256_RLP_ARRAY_S = '1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'; exports.SHA3_RLP_ARRAY_S = exports.KECCAK256_RLP_ARRAY_S; - + /** * Keccak-256 of an RLP of an empty array (a ```Buffer```) * @var {Buffer} KECCAK256_RLP_ARRAY */ exports.KECCAK256_RLP_ARRAY = Buffer.from(exports.KECCAK256_RLP_ARRAY_S, 'hex'); exports.SHA3_RLP_ARRAY = exports.KECCAK256_RLP_ARRAY; - + /** * Keccak-256 hash of the RLP of null (a ```String```) * @var {String} KECCAK256_RLP_S */ exports.KECCAK256_RLP_S = '56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'; exports.SHA3_RLP_S = exports.KECCAK256_RLP_S; - + /** * Keccak-256 hash of the RLP of null (a ```Buffer```) * @var {Buffer} KECCAK256_RLP */ exports.KECCAK256_RLP = Buffer.from(exports.KECCAK256_RLP_S, 'hex'); exports.SHA3_RLP = exports.KECCAK256_RLP; - + /** * [`BN`](https://github.com/indutny/bn.js) * @var {Function} */ exports.BN = BN; - + /** * [`rlp`](https://github.com/ethereumjs/rlp) * @var {Function} */ exports.rlp = rlp; - + /** * [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/) * @var {Object} */ exports.secp256k1 = secp256k1; - + /** * Returns a buffer filled with 0s * @method zeros @@ -26918,7 +26918,7 @@ exports.zeros = function (bytes) { return Buffer.allocUnsafe(bytes).fill(0); }; - + /** * Returns a zero address * @method zeroAddress @@ -26929,7 +26929,7 @@ var zeroAddress = exports.zeros(addressLength); return exports.bufferToHex(zeroAddress); }; - + /** * Left Pads an `Array` or `Buffer` with leading zeros till it has `length` bytes. * Or it truncates the beginning if it exceeds. @@ -26956,7 +26956,7 @@ return msg.slice(-length); } }; - + /** * Right Pads an `Array` or `Buffer` with leading zeros till it has `length` bytes. * Or it truncates the beginning if it exceeds. @@ -26967,7 +26967,7 @@ exports.setLengthRight = function (msg, length) { return exports.setLength(msg, length, true); }; - + /** * Trims leading zeros from a `Buffer` or an `Array` * @param {Buffer|Array|String} a @@ -27011,7 +27011,7 @@ } return v; }; - + /** * Converts a `Buffer` to a `Number` * @param {Buffer} buf @@ -27021,7 +27021,7 @@ exports.bufferToInt = function (buf) { return new BN(exports.toBuffer(buf)).toNumber(); }; - + /** * Converts a `Buffer` into a hex `String` * @param {Buffer} buf @@ -27031,7 +27031,7 @@ buf = exports.toBuffer(buf); return '0x' + buf.toString('hex'); }; - + /** * Interprets a `Buffer` as a signed integer and returns a `BN`. Assumes 256-bit numbers. * @param {Buffer} num @@ -27040,7 +27040,7 @@ exports.fromSigned = function (num) { return new BN(num).fromTwos(256); }; - + /** * Converts a `BN` to an unsigned integer and returns it as a `Buffer`. Assumes 256-bit numbers. * @param {BN} num @@ -27049,7 +27049,7 @@ exports.toUnsigned = function (num) { return Buffer.from(num.toTwos(256).toArray()); }; - + /** * Creates Keccak hash of the input * @param {Buffer|Array|String|Number} a the input data @@ -27059,10 +27059,10 @@ exports.keccak = function (a, bits) { a = exports.toBuffer(a); if (!bits) bits = 256; - + return createKeccakHash('keccak' + bits).update(a).digest(); }; - + /** * Creates Keccak-256 hash of the input, alias for keccak(a, 256) * @param {Buffer|Array|String|Number} a the input data @@ -27071,7 +27071,7 @@ exports.keccak256 = function (a) { return exports.keccak(a); }; - + /** * Creates SHA-3 (Keccak) hash of the input [OBSOLETE] * @param {Buffer|Array|String|Number} a the input data @@ -27079,7 +27079,7 @@ * @return {Buffer} */ exports.sha3 = exports.keccak; - + /** * Creates SHA256 hash of the input * @param {Buffer|Array|String|Number} a the input data @@ -27089,7 +27089,7 @@ a = exports.toBuffer(a); return createHash('sha256').update(a).digest(); }; - + /** * Creates RIPEMD160 hash of the input * @param {Buffer|Array|String|Number} a the input data @@ -27105,7 +27105,7 @@ return hash; } }; - + /** * Creates SHA-3 hash of the RLP encoded version of the input * @param {Buffer|Array|String|Number} a the input data @@ -27114,7 +27114,7 @@ exports.rlphash = function (a) { return exports.keccak(rlp.encode(a)); }; - + /** * Checks if the private key satisfies the rules of the curve secp256k1. * @param {Buffer} privateKey @@ -27123,7 +27123,7 @@ exports.isValidPrivate = function (privateKey) { return secp256k1.privateKeyVerify(privateKey); }; - + /** * Checks if the public key satisfies the rules of the curve secp256k1 * and the requirements of Ethereum. @@ -27136,14 +27136,14 @@ // Convert to SEC1 for secp256k1 return secp256k1.publicKeyVerify(Buffer.concat([Buffer.from([4]), publicKey])); } - + if (!sanitize) { return false; } - + return secp256k1.publicKeyVerify(publicKey); }; - + /** * Returns the ethereum address of a given public key. * Accepts "Ethereum public keys" and SEC1 encoded keys. @@ -27160,7 +27160,7 @@ // Only take the lower 160bits of the hash return exports.keccak(pubKey).slice(-20); }; - + /** * Returns the ethereum public key of a given private key * @param {Buffer} privateKey A private key must be 256 bits wide @@ -27171,7 +27171,7 @@ // skip the type flag and use the X, Y points return secp256k1.publicKeyCreate(privateKey, false).slice(1); }; - + /** * Converts a public key to the Ethereum format. * @param {Buffer} publicKey @@ -27184,7 +27184,7 @@ } return publicKey; }; - + /** * ECDSA sign * @param {Buffer} msgHash @@ -27193,14 +27193,14 @@ */ exports.ecsign = function (msgHash, privateKey) { var sig = secp256k1.sign(msgHash, privateKey); - + var ret = {}; ret.r = sig.signature.slice(0, 32); ret.s = sig.signature.slice(32, 64); ret.v = sig.recovery + 27; return ret; }; - + /** * Returns the keccak-256 hash of `message`, prefixed with the header used by the `eth_sign` RPC call. * The output of this function can be fed into `ecsign` to produce the same signature as the `eth_sign` @@ -27213,7 +27213,7 @@ var prefix = exports.toBuffer('\x19Ethereum Signed Message:\n' + message.length.toString()); return exports.keccak(Buffer.concat([prefix, message])); }; - + /** * ECDSA public key recovery from signature * @param {Buffer} msgHash @@ -27231,7 +27231,7 @@ var senderPubKey = secp256k1.recover(msgHash, signature, recovery); return secp256k1.publicKeyConvert(senderPubKey, false).slice(1); }; - + /** * Convert signature parameters into the format of `eth_sign` RPC method * @param {Number} v @@ -27244,12 +27244,12 @@ if (v !== 27 && v !== 28) { throw new Error('Invalid recovery id'); } - + // geth (and the RPC eth_sign method) uses the 65 byte format used by Bitcoin // FIXME: this might change in the future - https://github.com/ethereum/go-ethereum/issues/2053 return exports.bufferToHex(Buffer.concat([exports.setLengthLeft(r, 32), exports.setLengthLeft(s, 32), exports.toBuffer(v - 27)])); }; - + /** * Convert signature format of the `eth_sign` RPC method to signature parameters * NOTE: all because of a bug in geth: https://github.com/ethereum/go-ethereum/issues/2053 @@ -27258,25 +27258,25 @@ */ exports.fromRpcSig = function (sig) { sig = exports.toBuffer(sig); - + // NOTE: with potential introduction of chainId this might need to be updated if (sig.length !== 65) { throw new Error('Invalid signature length'); } - + var v = sig[64]; // support both versions of `eth_sign` responses if (v < 27) { v += 27; } - + return { v: v, r: sig.slice(0, 32), s: sig.slice(32, 64) }; }; - + /** * Returns the ethereum address of a given private key * @param {Buffer} privateKey A private key must be 256 bits wide @@ -27285,7 +27285,7 @@ exports.privateToAddress = function (privateKey) { return exports.publicToAddress(privateToPublic(privateKey)); }; - + /** * Checks if the address is a valid. Accepts checksummed addresses too * @param {String} address @@ -27295,7 +27295,7 @@ return (/^0x[0-9a-fA-F]{40}$/.test(address) ); }; - + /** * Checks if a given address is a zero address * @method isZeroAddress @@ -27306,7 +27306,7 @@ var zeroAddress = exports.zeroAddress(); return zeroAddress === exports.addHexPrefix(address); }; - + /** * Returns a checksummed address * @param {String} address @@ -27316,7 +27316,7 @@ address = exports.stripHexPrefix(address).toLowerCase(); var hash = exports.keccak(address).toString('hex'); var ret = '0x'; - + for (var i = 0; i < address.length; i++) { if (parseInt(hash[i], 16) >= 8) { ret += address[i].toUpperCase(); @@ -27324,10 +27324,10 @@ ret += address[i]; } } - + return ret; }; - + /** * Checks if the address is a valid checksummed address * @param {Buffer} address @@ -27336,7 +27336,7 @@ exports.isValidChecksumAddress = function (address) { return exports.isValidAddress(address) && exports.toChecksumAddress(address) === address; }; - + /** * Generates an address of a newly created contract * @param {Buffer} from the address which is creating this new address @@ -27346,7 +27346,7 @@ exports.generateAddress = function (from, nonce) { from = exports.toBuffer(from); nonce = new BN(nonce); - + if (nonce.isZero()) { // in RLP we want to encode null in the case of zero nonce // read the RLP documentation for an answer if you dare @@ -27354,11 +27354,11 @@ } else { nonce = Buffer.from(nonce.toArray()); } - + // Only take the lower 160bits of the hash return exports.rlphash([from, nonce]).slice(-20); }; - + /** * Returns true if the supplied address belongs to a precompiled account (Byzantium) * @param {Buffer|String} address @@ -27368,7 +27368,7 @@ var a = exports.unpad(address); return a.length === 1 && a[0] >= 1 && a[0] <= 8; }; - + /** * Adds "0x" to a given `String` if it does not already start with "0x" * @param {String} str @@ -27378,10 +27378,10 @@ if (typeof str !== 'string') { return str; } - + return exports.isHexPrefixed(str) ? str : '0x' + str; }; - + /** * Validate ECDSA signature * @method isValidSignature @@ -27391,33 +27391,33 @@ * @param {Boolean} [homestead=true] * @return {Boolean} */ - + exports.isValidSignature = function (v, r, s, homestead) { var SECP256K1_N_DIV_2 = new BN('7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0', 16); var SECP256K1_N = new BN('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141', 16); - + if (r.length !== 32 || s.length !== 32) { return false; } - + if (v !== 27 && v !== 28) { return false; } - + r = new BN(r); s = new BN(s); - + if (r.isZero() || r.gt(SECP256K1_N) || s.isZero() || s.gt(SECP256K1_N)) { return false; } - + if (homestead === false && new BN(s).cmp(SECP256K1_N_DIV_2) === 1) { return false; } - + return true; }; - + /** * Converts a `Buffer` or `Array` to JSON * @param {Buffer|Array} ba @@ -27434,7 +27434,7 @@ return array; } }; - + /** * Defines properties on a `Object`. It make the assumption that underlying data is binary. * @param {Object} self the `Object` to define properties on @@ -27448,7 +27448,7 @@ exports.defineProperties = function (self, fields, data) { self.raw = []; self._fields = []; - + // attach the `toJSON` self.toJSON = function (label) { if (label) { @@ -27460,11 +27460,11 @@ } return exports.baToJSON(this.raw); }; - + self.serialize = function serialize() { return rlp.encode(self.raw); }; - + fields.forEach(function (field, i) { self._fields.push(field.name); function getter() { @@ -27472,32 +27472,32 @@ } function setter(v) { v = exports.toBuffer(v); - + if (v.toString('hex') === '00' && !field.allowZero) { v = Buffer.allocUnsafe(0); } - + if (field.allowLess && field.length) { v = exports.stripZeros(v); assert(field.length >= v.length, 'The field ' + field.name + ' must not have more ' + field.length + ' bytes'); } else if (!(field.allowZero && v.length === 0) && field.length) { assert(field.length === v.length, 'The field ' + field.name + ' must have byte length of ' + field.length); } - + self.raw[i] = v; } - + Object.defineProperty(self, field.name, { enumerable: true, configurable: true, get: getter, set: setter }); - + if (field.default) { self[field.name] = field.default; } - + // attach alias if (field.alias) { Object.defineProperty(self, field.alias, { @@ -27508,22 +27508,22 @@ }); } }); - + // if the constuctor is passed data if (data) { if (typeof data === 'string') { data = Buffer.from(exports.stripHexPrefix(data), 'hex'); } - + if (Buffer.isBuffer(data)) { data = rlp.decode(data); } - + if (Array.isArray(data)) { if (data.length > self._fields.length) { throw new Error('wrong number of fields in data'); } - + // make sure all the items are buffers data.forEach(function (d, i) { self[self._fields[i]] = exports.toBuffer(d); @@ -28459,7 +28459,7 @@ }()); exports.AbiCoder = AbiCoder; exports.defaultAbiCoder = new AbiCoder(); - + },{"./address":144,"./bignumber":145,"./bytes":146,"./errors":147,"./properties":149,"./utf8":152}],144:[function(require,module,exports){ 'use strict'; var __importDefault = (this && this.__importDefault) || function (mod) { @@ -28585,7 +28585,7 @@ ])).substring(26)); } exports.getContractAddress = getContractAddress; - + },{"./bytes":146,"./errors":147,"./keccak256":148,"./rlp":150,"bn.js":53}],145:[function(require,module,exports){ 'use strict'; var __extends = (this && this.__extends) || (function () { @@ -28779,7 +28779,7 @@ exports.ConstantOne = bigNumberify(1); exports.ConstantTwo = bigNumberify(2); exports.ConstantWeiPerEther = bigNumberify('1000000000000000000'); - + },{"./bytes":146,"./errors":147,"./properties":149,"./types":151,"bn.js":53}],146:[function(require,module,exports){ "use strict"; /** @@ -29043,7 +29043,7 @@ ])); } exports.joinSignature = joinSignature; - + },{"./errors":147}],147:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); @@ -29147,7 +29147,7 @@ _permanentCensorErrors = !!permanent; } exports.setCensorship = setCensorship; - + },{}],148:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); @@ -29157,7 +29157,7 @@ return '0x' + sha3.keccak_256(bytes_1.arrayify(data)); } exports.keccak256 = keccak256; - + },{"./bytes":146,"js-sha3":142}],149:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); @@ -29209,7 +29209,7 @@ return JSON.parse(JSON.stringify(object)); } exports.jsonCopy = jsonCopy; - + },{}],150:[function(require,module,exports){ "use strict"; //See: https://github.com/ethereum/wiki/wiki/RLP @@ -29327,7 +29327,7 @@ return decoded.result; } exports.decode = decode; - + },{"./bytes":146}],151:[function(require,module,exports){ "use strict"; /////////////////////////////// @@ -29384,7 +29384,7 @@ return HDNode; }()); exports.HDNode = HDNode; - + },{}],152:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); @@ -29509,16 +29509,16 @@ return result; } exports.toUtf8String = toUtf8String; - + },{"./bytes":146}],153:[function(require,module,exports){ 'use strict'; - + var BN = require('bn.js'); var numberToBN = require('number-to-bn'); - + var zero = new BN(0); var negative1 = new BN(-1); - + // complete ethereum unit map var unitMap = { 'noether': '0', // eslint-disable-line @@ -29548,7 +29548,7 @@ 'mether': '1000000000000000000000000', // eslint-disable-line 'gether': '1000000000000000000000000000', // eslint-disable-line 'tether': '1000000000000000000000000000000' }; - + /** * Returns value of unit in Wei * @@ -29560,14 +29560,14 @@ function getValueOfUnit(unitInput) { var unit = unitInput ? unitInput.toLowerCase() : 'ether'; var unitValue = unitMap[unit]; // eslint-disable-line - + if (typeof unitValue !== 'string') { throw new Error('[ethjs-unit] the unit provided ' + unitInput + ' doesn\'t exists, please use the one of the following units ' + JSON.stringify(unitMap, null, 2)); } - + return new BN(unitValue, 10); } - + function numberToString(arg) { if (typeof arg === 'string') { if (!arg.match(/^-?[0-9.]+$/)) { @@ -29586,67 +29586,67 @@ } throw new Error('while converting number to string, invalid number value \'' + arg + '\' type ' + typeof arg + '.'); } - + function fromWei(weiInput, unit, optionsInput) { var wei = numberToBN(weiInput); // eslint-disable-line var negative = wei.lt(zero); // eslint-disable-line var base = getValueOfUnit(unit); var baseLength = unitMap[unit].length - 1 || 1; var options = optionsInput || {}; - + if (negative) { wei = wei.mul(negative1); } - + var fraction = wei.mod(base).toString(10); // eslint-disable-line - + while (fraction.length < baseLength) { fraction = '0' + fraction; } - + if (!options.pad) { fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1]; } - + var whole = wei.div(base).toString(10); // eslint-disable-line - + if (options.commify) { whole = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ','); } - + var value = '' + whole + (fraction == '0' ? '' : '.' + fraction); // eslint-disable-line - + if (negative) { value = '-' + value; } - + return value; } - + function toWei(etherInput, unit) { var ether = numberToString(etherInput); // eslint-disable-line var base = getValueOfUnit(unit); var baseLength = unitMap[unit].length - 1 || 1; - + // Is it negative? var negative = ether.substring(0, 1) === '-'; // eslint-disable-line if (negative) { ether = ether.substring(1); } - + if (ether === '.') { throw new Error('[ethjs-unit] while converting number ' + etherInput + ' to wei, invalid value'); } - + // Split it into a whole and fractional part var comps = ether.split('.'); // eslint-disable-line if (comps.length > 2) { throw new Error('[ethjs-unit] while converting number ' + etherInput + ' to wei, too many decimal points'); } - + var whole = comps[0], fraction = comps[1]; // eslint-disable-line - + if (!whole) { whole = '0'; } @@ -29656,22 +29656,22 @@ if (fraction.length > baseLength) { throw new Error('[ethjs-unit] while converting number ' + etherInput + ' to wei, too many decimal places'); } - + while (fraction.length < baseLength) { fraction += '0'; } - + whole = new BN(whole); fraction = new BN(fraction); var wei = whole.mul(base).add(fraction); // eslint-disable-line - + if (negative) { wei = wei.mul(negative1); } - + return new BN(wei.toString(10), 10); } - + module.exports = { unitMap: unitMap, numberToString: numberToString, @@ -29682,12 +29682,12 @@ },{"bn.js":154,"number-to-bn":237}],154:[function(require,module,exports){ (function (module, exports) { 'use strict'; - + // Utils function assert (val, msg) { if (!val) throw new Error(msg || 'Assertion failed'); } - + // Could use `inherits` module, but don't want to move from single file // architecture yet. function inherits (ctor, superCtor) { @@ -29697,27 +29697,27 @@ ctor.prototype = new TempCtor(); ctor.prototype.constructor = ctor; } - + // BN - + function BN (number, base, endian) { if (BN.isBN(number)) { return number; } - + this.negative = 0; this.words = null; this.length = 0; - + // Reduction context this.red = null; - + if (number !== null) { if (base === 'le' || base === 'be') { endian = base; base = 10; } - + this._init(number || 0, base || 10, endian || 'be'); } } @@ -29726,72 +29726,72 @@ } else { exports.BN = BN; } - + BN.BN = BN; BN.wordSize = 26; - + var Buffer; try { Buffer = require('buf' + 'fer').Buffer; } catch (e) { } - + BN.isBN = function isBN (num) { if (num instanceof BN) { return true; } - + return num !== null && typeof num === 'object' && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); }; - + BN.max = function max (left, right) { if (left.cmp(right) > 0) return left; return right; }; - + BN.min = function min (left, right) { if (left.cmp(right) < 0) return left; return right; }; - + BN.prototype._init = function init (number, base, endian) { if (typeof number === 'number') { return this._initNumber(number, base, endian); } - + if (typeof number === 'object') { return this._initArray(number, base, endian); } - + if (base === 'hex') { base = 16; } assert(base === (base | 0) && base >= 2 && base <= 36); - + number = number.toString().replace(/\s+/g, ''); var start = 0; if (number[0] === '-') { start++; } - + if (base === 16) { this._parseHex(number, start); } else { this._parseBase(number, base, start); } - + if (number[0] === '-') { this.negative = 1; } - + this.strip(); - + if (endian !== 'le') return; - + this._initArray(this.toArray(), base, endian); }; - + BN.prototype._initNumber = function _initNumber (number, base, endian) { if (number < 0) { this.negative = 1; @@ -29815,13 +29815,13 @@ ]; this.length = 3; } - + if (endian !== 'le') return; - + // Reverse the bytes this._initArray(this.toArray(), base, endian); }; - + BN.prototype._initArray = function _initArray (number, base, endian) { // Perhaps a Uint8Array assert(typeof number.length === 'number'); @@ -29830,13 +29830,13 @@ this.length = 1; return this; } - + this.length = Math.ceil(number.length / 3); this.words = new Array(this.length); for (var i = 0; i < this.length; i++) { this.words[i] = 0; } - + var j, w; var off = 0; if (endian === 'be') { @@ -29864,23 +29864,23 @@ } return this.strip(); }; - + function parseHex (str, start, end) { var r = 0; var len = Math.min(str.length, end); for (var i = start; i < len; i++) { var c = str.charCodeAt(i) - 48; - + r <<= 4; - + // 'a' - 'f' if (c >= 49 && c <= 54) { r |= c - 49 + 0xa; - + // 'A' - 'F' } else if (c >= 17 && c <= 22) { r |= c - 17 + 0xa; - + // '0' - '9' } else { r |= c & 0xf; @@ -29888,7 +29888,7 @@ } return r; } - + BN.prototype._parseHex = function _parseHex (number, start) { // Create possibly bigger array to ensure that it fits the number this.length = Math.ceil((number.length - start) / 6); @@ -29896,7 +29896,7 @@ for (var i = 0; i < this.length; i++) { this.words[i] = 0; } - + var j, w; // Scan 24-bit chunks and add them to the number var off = 0; @@ -29918,23 +29918,23 @@ } this.strip(); }; - + function parseBase (str, start, end, mul) { var r = 0; var len = Math.min(str.length, end); for (var i = start; i < len; i++) { var c = str.charCodeAt(i) - 48; - + r *= mul; - + // 'a' if (c >= 49) { r += c - 49 + 0xa; - + // 'A' } else if (c >= 17) { r += c - 17 + 0xa; - + // '0' - '9' } else { r += c; @@ -29942,27 +29942,27 @@ } return r; } - + BN.prototype._parseBase = function _parseBase (number, base, start) { // Initialize as zero this.words = [ 0 ]; this.length = 1; - + // Find length of limb in base for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { limbLen++; } limbLen--; limbPow = (limbPow / base) | 0; - + var total = number.length - start; var mod = total % limbLen; var end = Math.min(total, total - mod) + start; - + var word = 0; for (var i = start; i < end; i += limbLen) { word = parseBase(number, i, i + limbLen, base); - + this.imuln(limbPow); if (this.words[0] + word < 0x4000000) { this.words[0] += word; @@ -29970,15 +29970,15 @@ this._iaddn(word); } } - + if (mod !== 0) { var pow = 1; word = parseBase(number, i, number.length, base); - + for (i = 0; i < mod; i++) { pow *= base; } - + this.imuln(pow); if (this.words[0] + word < 0x4000000) { this.words[0] += word; @@ -29987,7 +29987,7 @@ } } }; - + BN.prototype.copy = function copy (dest) { dest.words = new Array(this.length); for (var i = 0; i < this.length; i++) { @@ -29997,20 +29997,20 @@ dest.negative = this.negative; dest.red = this.red; }; - + BN.prototype.clone = function clone () { var r = new BN(null); this.copy(r); return r; }; - + BN.prototype._expand = function _expand (size) { while (this.length < size) { this.words[this.length++] = 0; } return this; }; - + // Remove leading `0` from `this` BN.prototype.strip = function strip () { while (this.length > 1 && this.words[this.length - 1] === 0) { @@ -30018,7 +30018,7 @@ } return this._normSign(); }; - + BN.prototype._normSign = function _normSign () { // -0 = 0 if (this.length === 1 && this.words[0] === 0) { @@ -30026,17 +30026,17 @@ } return this; }; - + BN.prototype.inspect = function inspect () { return (this.red ? ''; }; - + /* - + var zeros = []; var groupSizes = []; var groupBases = []; - + var s = ''; var i = -1; while (++i < BN.wordSize) { @@ -30058,9 +30058,9 @@ groupSizes[base] = groupSize; groupBases[base] = groupBase; } - + */ - + var zeros = [ '', '0', @@ -30089,7 +30089,7 @@ '000000000000000000000000', '0000000000000000000000000' ]; - + var groupSizes = [ 0, 0, 25, 16, 12, 11, 10, 9, 8, @@ -30098,7 +30098,7 @@ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 ]; - + var groupBases = [ 0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, @@ -30107,11 +30107,11 @@ 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 ]; - + BN.prototype.toString = function toString (base, padding) { base = base || 10; padding = padding | 0 || 1; - + var out; if (base === 16 || base === 'hex') { out = ''; @@ -30143,7 +30143,7 @@ } return out; } - + if (base === (base | 0) && base >= 2 && base <= 36) { // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); var groupSize = groupSizes[base]; @@ -30155,7 +30155,7 @@ while (!c.isZero()) { var r = c.modn(groupBase).toString(base); c = c.idivn(groupBase); - + if (!c.isZero()) { out = zeros[groupSize - r.length] + r + out; } else { @@ -30173,10 +30173,10 @@ } return out; } - + assert(false, 'Base should be between 2 and 36'); }; - + BN.prototype.toNumber = function toNumber () { var ret = this.words[0]; if (this.length === 2) { @@ -30189,30 +30189,30 @@ } return (this.negative !== 0) ? -ret : ret; }; - + BN.prototype.toJSON = function toJSON () { return this.toString(16); }; - + BN.prototype.toBuffer = function toBuffer (endian, length) { assert(typeof Buffer !== 'undefined'); return this.toArrayLike(Buffer, endian, length); }; - + BN.prototype.toArray = function toArray (endian, length) { return this.toArrayLike(Array, endian, length); }; - + BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { var byteLength = this.byteLength(); var reqLength = length || Math.max(1, byteLength); assert(byteLength <= reqLength, 'byte array longer than desired length'); assert(reqLength > 0, 'Requested array length <= 0'); - + this.strip(); var littleEndian = endian === 'le'; var res = new ArrayType(reqLength); - + var b, i; var q = this.clone(); if (!littleEndian) { @@ -30220,29 +30220,29 @@ for (i = 0; i < reqLength - byteLength; i++) { res[i] = 0; } - + for (i = 0; !q.isZero(); i++) { b = q.andln(0xff); q.iushrn(8); - + res[reqLength - i - 1] = b; } } else { for (i = 0; !q.isZero(); i++) { b = q.andln(0xff); q.iushrn(8); - + res[i] = b; } - + for (; i < reqLength; i++) { res[i] = 0; } } - + return res; }; - + if (Math.clz32) { BN.prototype._countBits = function _countBits (w) { return 32 - Math.clz32(w); @@ -30270,11 +30270,11 @@ return r + t; }; } - + BN.prototype._zeroBits = function _zeroBits (w) { // Short-cut if (w === 0) return 26; - + var t = w; var r = 0; if ((t & 0x1fff) === 0) { @@ -30298,31 +30298,31 @@ } return r; }; - + // Return number of used bits in a BN BN.prototype.bitLength = function bitLength () { var w = this.words[this.length - 1]; var hi = this._countBits(w); return (this.length - 1) * 26 + hi; }; - + function toBitArray (num) { var w = new Array(num.bitLength()); - + for (var bit = 0; bit < w.length; bit++) { var off = (bit / 26) | 0; var wbit = bit % 26; - + w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; } - + return w; } - + // Number of trailing zero bits BN.prototype.zeroBits = function zeroBits () { if (this.isZero()) return 0; - + var r = 0; for (var i = 0; i < this.length; i++) { var b = this._zeroBits(this.words[i]); @@ -30331,71 +30331,71 @@ } return r; }; - + BN.prototype.byteLength = function byteLength () { return Math.ceil(this.bitLength() / 8); }; - + BN.prototype.toTwos = function toTwos (width) { if (this.negative !== 0) { return this.abs().inotn(width).iaddn(1); } return this.clone(); }; - + BN.prototype.fromTwos = function fromTwos (width) { if (this.testn(width - 1)) { return this.notn(width).iaddn(1).ineg(); } return this.clone(); }; - + BN.prototype.isNeg = function isNeg () { return this.negative !== 0; }; - + // Return negative clone of `this` BN.prototype.neg = function neg () { return this.clone().ineg(); }; - + BN.prototype.ineg = function ineg () { if (!this.isZero()) { this.negative ^= 1; } - + return this; }; - + // Or `num` with `this` in-place BN.prototype.iuor = function iuor (num) { while (this.length < num.length) { this.words[this.length++] = 0; } - + for (var i = 0; i < num.length; i++) { this.words[i] = this.words[i] | num.words[i]; } - + return this.strip(); }; - + BN.prototype.ior = function ior (num) { assert((this.negative | num.negative) === 0); return this.iuor(num); }; - + // Or `num` with `this` BN.prototype.or = function or (num) { if (this.length > num.length) return this.clone().ior(num); return num.clone().ior(this); }; - + BN.prototype.uor = function uor (num) { if (this.length > num.length) return this.clone().iuor(num); return num.clone().iuor(this); }; - + // And `num` with `this` in-place BN.prototype.iuand = function iuand (num) { // b = min-length(num, this) @@ -30405,32 +30405,32 @@ } else { b = this; } - + for (var i = 0; i < b.length; i++) { this.words[i] = this.words[i] & num.words[i]; } - + this.length = b.length; - + return this.strip(); }; - + BN.prototype.iand = function iand (num) { assert((this.negative | num.negative) === 0); return this.iuand(num); }; - + // And `num` with `this` BN.prototype.and = function and (num) { if (this.length > num.length) return this.clone().iand(num); return num.clone().iand(this); }; - + BN.prototype.uand = function uand (num) { if (this.length > num.length) return this.clone().iuand(num); return num.clone().iuand(this); }; - + // Xor `num` with `this` in-place BN.prototype.iuxor = function iuxor (num) { // a.length > b.length @@ -30443,99 +30443,99 @@ a = num; b = this; } - + for (var i = 0; i < b.length; i++) { this.words[i] = a.words[i] ^ b.words[i]; } - + if (this !== a) { for (; i < a.length; i++) { this.words[i] = a.words[i]; } } - + this.length = a.length; - + return this.strip(); }; - + BN.prototype.ixor = function ixor (num) { assert((this.negative | num.negative) === 0); return this.iuxor(num); }; - + // Xor `num` with `this` BN.prototype.xor = function xor (num) { if (this.length > num.length) return this.clone().ixor(num); return num.clone().ixor(this); }; - + BN.prototype.uxor = function uxor (num) { if (this.length > num.length) return this.clone().iuxor(num); return num.clone().iuxor(this); }; - + // Not ``this`` with ``width`` bitwidth BN.prototype.inotn = function inotn (width) { assert(typeof width === 'number' && width >= 0); - + var bytesNeeded = Math.ceil(width / 26) | 0; var bitsLeft = width % 26; - + // Extend the buffer with leading zeroes this._expand(bytesNeeded); - + if (bitsLeft > 0) { bytesNeeded--; } - + // Handle complete words for (var i = 0; i < bytesNeeded; i++) { this.words[i] = ~this.words[i] & 0x3ffffff; } - + // Handle the residue if (bitsLeft > 0) { this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); } - + // And remove leading zeroes return this.strip(); }; - + BN.prototype.notn = function notn (width) { return this.clone().inotn(width); }; - + // Set `bit` of `this` BN.prototype.setn = function setn (bit, val) { assert(typeof bit === 'number' && bit >= 0); - + var off = (bit / 26) | 0; var wbit = bit % 26; - + this._expand(off + 1); - + if (val) { this.words[off] = this.words[off] | (1 << wbit); } else { this.words[off] = this.words[off] & ~(1 << wbit); } - + return this.strip(); }; - + // Add `num` to `this` in-place BN.prototype.iadd = function iadd (num) { var r; - + // negative + positive if (this.negative !== 0 && num.negative === 0) { this.negative = 0; r = this.isub(num); this.negative ^= 1; return this._normSign(); - + // positive + negative } else if (this.negative === 0 && num.negative !== 0) { num.negative = 0; @@ -30543,7 +30543,7 @@ num.negative = 1; return r._normSign(); } - + // a.length > b.length var a, b; if (this.length > num.length) { @@ -30553,7 +30553,7 @@ a = num; b = this; } - + var carry = 0; for (var i = 0; i < b.length; i++) { r = (a.words[i] | 0) + (b.words[i] | 0) + carry; @@ -30565,7 +30565,7 @@ this.words[i] = r & 0x3ffffff; carry = r >>> 26; } - + this.length = a.length; if (carry !== 0) { this.words[this.length] = carry; @@ -30576,10 +30576,10 @@ this.words[i] = a.words[i]; } } - + return this; }; - + // Add `num` to `this` BN.prototype.add = function add (num) { var res; @@ -30594,12 +30594,12 @@ this.negative = 1; return res; } - + if (this.length > num.length) return this.clone().iadd(num); - + return num.clone().iadd(this); }; - + // Subtract `num` from `this` in-place BN.prototype.isub = function isub (num) { // this - (-num) = this + num @@ -30608,7 +30608,7 @@ var r = this.iadd(num); num.negative = 1; return r._normSign(); - + // -this - num = -(this + num) } else if (this.negative !== 0) { this.negative = 0; @@ -30616,10 +30616,10 @@ this.negative = 1; return this._normSign(); } - + // At this point both numbers are positive var cmp = this.cmp(num); - + // Optimization - zeroify if (cmp === 0) { this.negative = 0; @@ -30627,7 +30627,7 @@ this.words[0] = 0; return this; } - + // a > b var a, b; if (cmp > 0) { @@ -30637,7 +30637,7 @@ a = num; b = this; } - + var carry = 0; for (var i = 0; i < b.length; i++) { r = (a.words[i] | 0) - (b.words[i] | 0) + carry; @@ -30649,43 +30649,43 @@ carry = r >> 26; this.words[i] = r & 0x3ffffff; } - + // Copy rest of the words if (carry === 0 && i < a.length && a !== this) { for (; i < a.length; i++) { this.words[i] = a.words[i]; } } - + this.length = Math.max(this.length, i); - + if (a !== this) { this.negative = 1; } - + return this.strip(); }; - + // Subtract `num` from `this` BN.prototype.sub = function sub (num) { return this.clone().isub(num); }; - + function smallMulTo (self, num, out) { out.negative = num.negative ^ self.negative; var len = (self.length + num.length) | 0; out.length = len; len = (len - 1) | 0; - + // Peel one iteration (compiler can't do it, because of code complexity) var a = self.words[0] | 0; var b = num.words[0] | 0; var r = a * b; - + var lo = r & 0x3ffffff; var carry = (r / 0x4000000) | 0; out.words[0] = lo; - + for (var k = 1; k < len; k++) { // Sum all words with the same `i + j = k` and accumulate `ncarry`, // note that ncarry could be >= 0x3ffffff @@ -30708,10 +30708,10 @@ } else { out.length--; } - + return out.strip(); } - + // TODO(indutny): it may be reasonable to omit it for users who don't need // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit // multiplication (like elliptic secp256k1). @@ -30783,7 +30783,7 @@ var b9 = b[9] | 0; var bl9 = b9 & 0x1fff; var bh9 = b9 >>> 13; - + out.negative = self.negative ^ num.negative; out.length = 19; /* k = 0 */ @@ -31287,16 +31287,16 @@ } return out; }; - + // Polyfill comb if (!Math.imul) { comb10MulTo = smallMulTo; } - + function bigMulTo (self, num, out) { out.negative = num.negative ^ self.negative; out.length = self.length + num.length; - + var carry = 0; var hncarry = 0; for (var k = 0; k < out.length - 1; k++) { @@ -31311,13 +31311,13 @@ var a = self.words[i] | 0; var b = num.words[j] | 0; var r = a * b; - + var lo = r & 0x3ffffff; ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; lo = (lo + rword) | 0; rword = lo & 0x3ffffff; ncarry = (ncarry + (lo >>> 26)) | 0; - + hncarry += ncarry >>> 26; ncarry &= 0x3ffffff; } @@ -31330,15 +31330,15 @@ } else { out.length--; } - + return out.strip(); } - + function jumboMulTo (self, num, out) { var fftm = new FFTM(); return fftm.mulp(self, num, out); } - + BN.prototype.mulTo = function mulTo (num, out) { var res; var len = this.length + num.length; @@ -31351,41 +31351,41 @@ } else { res = jumboMulTo(this, num, out); } - + return res; }; - + // Cooley-Tukey algorithm for FFT // slightly revisited to rely on looping instead of recursion - + function FFTM (x, y) { this.x = x; this.y = y; } - + FFTM.prototype.makeRBT = function makeRBT (N) { var t = new Array(N); var l = BN.prototype._countBits(N) - 1; for (var i = 0; i < N; i++) { t[i] = this.revBin(i, l, N); } - + return t; }; - + // Returns binary-reversed representation of `x` FFTM.prototype.revBin = function revBin (x, l, N) { if (x === 0 || x === N - 1) return x; - + var rb = 0; for (var i = 0; i < l; i++) { rb |= (x & 1) << (l - i - 1); x >>= 1; } - + return rb; }; - + // Performs "tweedling" phase, therefore 'emulating' // behaviour of the recursive algorithm FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { @@ -31394,42 +31394,42 @@ itws[i] = iws[rbt[i]]; } }; - + FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { this.permute(rbt, rws, iws, rtws, itws, N); - + for (var s = 1; s < N; s <<= 1) { var l = s << 1; - + var rtwdf = Math.cos(2 * Math.PI / l); var itwdf = Math.sin(2 * Math.PI / l); - + for (var p = 0; p < N; p += l) { var rtwdf_ = rtwdf; var itwdf_ = itwdf; - + for (var j = 0; j < s; j++) { var re = rtws[p + j]; var ie = itws[p + j]; - + var ro = rtws[p + j + s]; var io = itws[p + j + s]; - + var rx = rtwdf_ * ro - itwdf_ * io; - + io = rtwdf_ * io + itwdf_ * ro; ro = rx; - + rtws[p + j] = re + ro; itws[p + j] = ie + io; - + rtws[p + j + s] = re - ro; itws[p + j + s] = ie - io; - + /* jshint maxdepth : false */ if (j !== l) { rx = rtwdf * rtwdf_ - itwdf * itwdf_; - + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; rtwdf_ = rx; } @@ -31437,7 +31437,7 @@ } } }; - + FFTM.prototype.guessLen13b = function guessLen13b (n, m) { var N = Math.max(m, n) | 1; var odd = N & 1; @@ -31445,135 +31445,135 @@ for (N = N / 2 | 0; N; N = N >>> 1) { i++; } - + return 1 << i + 1 + odd; }; - + FFTM.prototype.conjugate = function conjugate (rws, iws, N) { if (N <= 1) return; - + for (var i = 0; i < N / 2; i++) { var t = rws[i]; - + rws[i] = rws[N - i - 1]; rws[N - i - 1] = t; - + t = iws[i]; - + iws[i] = -iws[N - i - 1]; iws[N - i - 1] = -t; } }; - + FFTM.prototype.normalize13b = function normalize13b (ws, N) { var carry = 0; for (var i = 0; i < N / 2; i++) { var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + Math.round(ws[2 * i] / N) + carry; - + ws[i] = w & 0x3ffffff; - + if (w < 0x4000000) { carry = 0; } else { carry = w / 0x4000000 | 0; } } - + return ws; }; - + FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { var carry = 0; for (var i = 0; i < len; i++) { carry = carry + (ws[i] | 0); - + rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; } - + // Pad with zeroes for (i = 2 * len; i < N; ++i) { rws[i] = 0; } - + assert(carry === 0); assert((carry & ~0x1fff) === 0); }; - + FFTM.prototype.stub = function stub (N) { var ph = new Array(N); for (var i = 0; i < N; i++) { ph[i] = 0; } - + return ph; }; - + FFTM.prototype.mulp = function mulp (x, y, out) { var N = 2 * this.guessLen13b(x.length, y.length); - + var rbt = this.makeRBT(N); - + var _ = this.stub(N); - + var rws = new Array(N); var rwst = new Array(N); var iwst = new Array(N); - + var nrws = new Array(N); var nrwst = new Array(N); var niwst = new Array(N); - + var rmws = out.words; rmws.length = N; - + this.convert13b(x.words, x.length, rws, N); this.convert13b(y.words, y.length, nrws, N); - + this.transform(rws, _, rwst, iwst, N, rbt); this.transform(nrws, _, nrwst, niwst, N, rbt); - + for (var i = 0; i < N; i++) { var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; rwst[i] = rx; } - + this.conjugate(rwst, iwst, N); this.transform(rwst, iwst, rmws, _, N, rbt); this.conjugate(rmws, _, N); this.normalize13b(rmws, N); - + out.negative = x.negative ^ y.negative; out.length = x.length + y.length; return out.strip(); }; - + // Multiply `this` by `num` BN.prototype.mul = function mul (num) { var out = new BN(null); out.words = new Array(this.length + num.length); return this.mulTo(num, out); }; - + // Multiply employing FFT BN.prototype.mulf = function mulf (num) { var out = new BN(null); out.words = new Array(this.length + num.length); return jumboMulTo(this, num, out); }; - + // In-place Multiplication BN.prototype.imul = function imul (num) { return this.clone().mulTo(num, this); }; - + BN.prototype.imuln = function imuln (num) { assert(typeof num === 'number'); assert(num < 0x4000000); - + // Carry var carry = 0; for (var i = 0; i < this.length; i++) { @@ -31585,51 +31585,51 @@ carry += lo >>> 26; this.words[i] = lo & 0x3ffffff; } - + if (carry !== 0) { this.words[i] = carry; this.length++; } - + return this; }; - + BN.prototype.muln = function muln (num) { return this.clone().imuln(num); }; - + // `this` * `this` BN.prototype.sqr = function sqr () { return this.mul(this); }; - + // `this` * `this` in-place BN.prototype.isqr = function isqr () { return this.imul(this.clone()); }; - + // Math.pow(`this`, `num`) BN.prototype.pow = function pow (num) { var w = toBitArray(num); if (w.length === 0) return new BN(1); - + // Skip leading zeroes var res = this; for (var i = 0; i < w.length; i++, res = res.sqr()) { if (w[i] !== 0) break; } - + if (++i < w.length) { for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { if (w[i] === 0) continue; - + res = res.mul(q); } } - + return res; }; - + // Shift-left in-place BN.prototype.iushln = function iushln (bits) { assert(typeof bits === 'number' && bits >= 0); @@ -31637,44 +31637,44 @@ var s = (bits - r) / 26; var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); var i; - + if (r !== 0) { var carry = 0; - + for (i = 0; i < this.length; i++) { var newCarry = this.words[i] & carryMask; var c = ((this.words[i] | 0) - newCarry) << r; this.words[i] = c | carry; carry = newCarry >>> (26 - r); } - + if (carry) { this.words[i] = carry; this.length++; } } - + if (s !== 0) { for (i = this.length - 1; i >= 0; i--) { this.words[i + s] = this.words[i]; } - + for (i = 0; i < s; i++) { this.words[i] = 0; } - + this.length += s; } - + return this.strip(); }; - + BN.prototype.ishln = function ishln (bits) { // TODO(indutny): implement me assert(this.negative === 0); return this.iushln(bits); }; - + // Shift-right in-place // NOTE: `hint` is a lowest bit before trailing zeroes // NOTE: if `extended` is present - it will be filled with destroyed bits @@ -31686,15 +31686,15 @@ } else { h = 0; } - + var r = bits % 26; var s = Math.min((bits - r) / 26, this.length); var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); var maskedWords = extended; - + h -= s; h = Math.max(0, h); - + // Extended mode, copy masked part if (maskedWords) { for (var i = 0; i < s; i++) { @@ -31702,7 +31702,7 @@ } maskedWords.length = s; } - + if (s === 0) { // No-op, we should not move anything at all } else if (this.length > s) { @@ -31714,103 +31714,103 @@ this.words[0] = 0; this.length = 1; } - + var carry = 0; for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { var word = this.words[i] | 0; this.words[i] = (carry << (26 - r)) | (word >>> r); carry = word & mask; } - + // Push carried bits as a mask if (maskedWords && carry !== 0) { maskedWords.words[maskedWords.length++] = carry; } - + if (this.length === 0) { this.words[0] = 0; this.length = 1; } - + return this.strip(); }; - + BN.prototype.ishrn = function ishrn (bits, hint, extended) { // TODO(indutny): implement me assert(this.negative === 0); return this.iushrn(bits, hint, extended); }; - + // Shift-left BN.prototype.shln = function shln (bits) { return this.clone().ishln(bits); }; - + BN.prototype.ushln = function ushln (bits) { return this.clone().iushln(bits); }; - + // Shift-right BN.prototype.shrn = function shrn (bits) { return this.clone().ishrn(bits); }; - + BN.prototype.ushrn = function ushrn (bits) { return this.clone().iushrn(bits); }; - + // Test if n bit is set BN.prototype.testn = function testn (bit) { assert(typeof bit === 'number' && bit >= 0); var r = bit % 26; var s = (bit - r) / 26; var q = 1 << r; - + // Fast case: bit is much higher than all existing words if (this.length <= s) return false; - + // Check bit and return var w = this.words[s]; - + return !!(w & q); }; - + // Return only lowers bits of number (in-place) BN.prototype.imaskn = function imaskn (bits) { assert(typeof bits === 'number' && bits >= 0); var r = bits % 26; var s = (bits - r) / 26; - + assert(this.negative === 0, 'imaskn works only with positive numbers'); - + if (this.length <= s) { return this; } - + if (r !== 0) { s++; } this.length = Math.min(s, this.length); - + if (r !== 0) { var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); this.words[this.length - 1] &= mask; } - + return this.strip(); }; - + // Return only lowers bits of number BN.prototype.maskn = function maskn (bits) { return this.clone().imaskn(bits); }; - + // Add plain number `num` to `this` BN.prototype.iaddn = function iaddn (num) { assert(typeof num === 'number'); assert(num < 0x4000000); if (num < 0) return this.isubn(-num); - + // Possible sign change if (this.negative !== 0) { if (this.length === 1 && (this.words[0] | 0) < num) { @@ -31818,20 +31818,20 @@ this.negative = 0; return this; } - + this.negative = 0; this.isubn(num); this.negative = 1; return this; } - + // Add without checks return this._iaddn(num); }; - + BN.prototype._iaddn = function _iaddn (num) { this.words[0] += num; - + // Carry for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { this.words[i] -= 0x4000000; @@ -31842,25 +31842,25 @@ } } this.length = Math.max(this.length, i + 1); - + return this; }; - + // Subtract plain number `num` from `this` BN.prototype.isubn = function isubn (num) { assert(typeof num === 'number'); assert(num < 0x4000000); if (num < 0) return this.iaddn(-num); - + if (this.negative !== 0) { this.negative = 0; this.iaddn(num); this.negative = 1; return this; } - + this.words[0] -= num; - + if (this.length === 1 && this.words[0] < 0) { this.words[0] = -this.words[0]; this.negative = 1; @@ -31871,34 +31871,34 @@ this.words[i + 1] -= 1; } } - + return this.strip(); }; - + BN.prototype.addn = function addn (num) { return this.clone().iaddn(num); }; - + BN.prototype.subn = function subn (num) { return this.clone().isubn(num); }; - + BN.prototype.iabs = function iabs () { this.negative = 0; - + return this; }; - + BN.prototype.abs = function abs () { return this.clone().iabs(); }; - + BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { var len = num.length + shift; var i; - + this._expand(len); - + var w; var carry = 0; for (i = 0; i < num.length; i++) { @@ -31913,9 +31913,9 @@ carry = w >> 26; this.words[i + shift] = w & 0x3ffffff; } - + if (carry === 0) return this.strip(); - + // Subtraction overflow assert(carry === -1); carry = 0; @@ -31925,16 +31925,16 @@ this.words[i] = w & 0x3ffffff; } this.negative = 1; - + return this.strip(); }; - + BN.prototype._wordDiv = function _wordDiv (num, mode) { var shift = this.length - num.length; - + var a = this.clone(); var b = num; - + // Normalize var bhi = b.words[b.length - 1] | 0; var bhiBits = this._countBits(bhi); @@ -31944,11 +31944,11 @@ a.iushln(shift); bhi = b.words[b.length - 1] | 0; } - + // Initialize quotient var m = a.length - b.length; var q; - + if (mode !== 'mod') { q = new BN(null); q.length = m + 1; @@ -31957,7 +31957,7 @@ q.words[i] = 0; } } - + var diff = a.clone()._ishlnsubmul(b, 1, m); if (diff.negative === 0) { a = diff; @@ -31965,15 +31965,15 @@ q.words[m] = 1; } } - + for (var j = m - 1; j >= 0; j--) { var qj = (a.words[b.length + j] | 0) * 0x4000000 + (a.words[b.length + j - 1] | 0); - + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max // (0x7ffffff) qj = Math.min((qj / bhi) | 0, 0x3ffffff); - + a._ishlnsubmul(b, qj, j); while (a.negative !== 0) { qj--; @@ -31991,84 +31991,84 @@ q.strip(); } a.strip(); - + // Denormalize if (mode !== 'div' && shift !== 0) { a.iushrn(shift); } - + return { div: q || null, mod: a }; }; - + // NOTE: 1) `mode` can be set to `mod` to request mod only, // to `div` to request div only, or be absent to // request both div & mod // 2) `positive` is true if unsigned mod is requested BN.prototype.divmod = function divmod (num, mode, positive) { assert(!num.isZero()); - + if (this.isZero()) { return { div: new BN(0), mod: new BN(0) }; } - + var div, mod, res; if (this.negative !== 0 && num.negative === 0) { res = this.neg().divmod(num, mode); - + if (mode !== 'mod') { div = res.div.neg(); } - + if (mode !== 'div') { mod = res.mod.neg(); if (positive && mod.negative !== 0) { mod.iadd(num); } } - + return { div: div, mod: mod }; } - + if (this.negative === 0 && num.negative !== 0) { res = this.divmod(num.neg(), mode); - + if (mode !== 'mod') { div = res.div.neg(); } - + return { div: div, mod: res.mod }; } - + if ((this.negative & num.negative) !== 0) { res = this.neg().divmod(num.neg(), mode); - + if (mode !== 'div') { mod = res.mod.neg(); if (positive && mod.negative !== 0) { mod.isub(num); } } - + return { div: res.div, mod: mod }; } - + // Both numbers are positive at this point - + // Strip both numbers to approximate shift value if (num.length > this.length || this.cmp(num) < 0) { return { @@ -32076,7 +32076,7 @@ mod: this }; } - + // Very short reduction if (num.length === 1) { if (mode === 'div') { @@ -32085,119 +32085,119 @@ mod: null }; } - + if (mode === 'mod') { return { div: null, mod: new BN(this.modn(num.words[0])) }; } - + return { div: this.divn(num.words[0]), mod: new BN(this.modn(num.words[0])) }; } - + return this._wordDiv(num, mode); }; - + // Find `this` / `num` BN.prototype.div = function div (num) { return this.divmod(num, 'div', false).div; }; - + // Find `this` % `num` BN.prototype.mod = function mod (num) { return this.divmod(num, 'mod', false).mod; }; - + BN.prototype.umod = function umod (num) { return this.divmod(num, 'mod', true).mod; }; - + // Find Round(`this` / `num`) BN.prototype.divRound = function divRound (num) { var dm = this.divmod(num); - + // Fast case - exact division if (dm.mod.isZero()) return dm.div; - + var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; - + var half = num.ushrn(1); var r2 = num.andln(1); var cmp = mod.cmp(half); - + // Round down if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; - + // Round up return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); }; - + BN.prototype.modn = function modn (num) { assert(num <= 0x3ffffff); var p = (1 << 26) % num; - + var acc = 0; for (var i = this.length - 1; i >= 0; i--) { acc = (p * acc + (this.words[i] | 0)) % num; } - + return acc; }; - + // In-place division by number BN.prototype.idivn = function idivn (num) { assert(num <= 0x3ffffff); - + var carry = 0; for (var i = this.length - 1; i >= 0; i--) { var w = (this.words[i] | 0) + carry * 0x4000000; this.words[i] = (w / num) | 0; carry = w % num; } - + return this.strip(); }; - + BN.prototype.divn = function divn (num) { return this.clone().idivn(num); }; - + BN.prototype.egcd = function egcd (p) { assert(p.negative === 0); assert(!p.isZero()); - + var x = this; var y = p.clone(); - + if (x.negative !== 0) { x = x.umod(p); } else { x = x.clone(); } - + // A * x + B * y = x var A = new BN(1); var B = new BN(0); - + // C * x + D * y = y var C = new BN(0); var D = new BN(1); - + var g = 0; - + while (x.isEven() && y.isEven()) { x.iushrn(1); y.iushrn(1); ++g; } - + var yp = y.clone(); var xp = x.clone(); - + while (!x.isZero()) { for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); if (i > 0) { @@ -32207,12 +32207,12 @@ A.iadd(yp); B.isub(xp); } - + A.iushrn(1); B.iushrn(1); } } - + for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); if (j > 0) { y.iushrn(j); @@ -32221,12 +32221,12 @@ C.iadd(yp); D.isub(xp); } - + C.iushrn(1); D.iushrn(1); } } - + if (x.cmp(y) >= 0) { x.isub(y); A.isub(C); @@ -32237,35 +32237,35 @@ D.isub(B); } } - + return { a: C, b: D, gcd: y.iushln(g) }; }; - + // This is reduced incarnation of the binary EEA // above, designated to invert members of the // _prime_ fields F(p) at a maximal speed BN.prototype._invmp = function _invmp (p) { assert(p.negative === 0); assert(!p.isZero()); - + var a = this; var b = p.clone(); - + if (a.negative !== 0) { a = a.umod(p); } else { a = a.clone(); } - + var x1 = new BN(1); var x2 = new BN(0); - + var delta = b.clone(); - + while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); if (i > 0) { @@ -32274,11 +32274,11 @@ if (x1.isOdd()) { x1.iadd(delta); } - + x1.iushrn(1); } } - + for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); if (j > 0) { b.iushrn(j); @@ -32286,11 +32286,11 @@ if (x2.isOdd()) { x2.iadd(delta); } - + x2.iushrn(1); } } - + if (a.cmp(b) >= 0) { a.isub(b); x1.isub(x2); @@ -32299,36 +32299,36 @@ x2.isub(x1); } } - + var res; if (a.cmpn(1) === 0) { res = x1; } else { res = x2; } - + if (res.cmpn(0) < 0) { res.iadd(p); } - + return res; }; - + BN.prototype.gcd = function gcd (num) { if (this.isZero()) return num.abs(); if (num.isZero()) return this.abs(); - + var a = this.clone(); var b = num.clone(); a.negative = 0; b.negative = 0; - + // Remove common factor of two for (var shift = 0; a.isEven() && b.isEven(); shift++) { a.iushrn(1); b.iushrn(1); } - + do { while (a.isEven()) { a.iushrn(1); @@ -32336,7 +32336,7 @@ while (b.isEven()) { b.iushrn(1); } - + var r = a.cmp(b); if (r < 0) { // Swap `a` and `b` to make `a` always bigger than `b` @@ -32346,45 +32346,45 @@ } else if (r === 0 || b.cmpn(1) === 0) { break; } - + a.isub(b); } while (true); - + return b.iushln(shift); }; - + // Invert number in the field F(num) BN.prototype.invm = function invm (num) { return this.egcd(num).a.umod(num); }; - + BN.prototype.isEven = function isEven () { return (this.words[0] & 1) === 0; }; - + BN.prototype.isOdd = function isOdd () { return (this.words[0] & 1) === 1; }; - + // And first word and num BN.prototype.andln = function andln (num) { return this.words[0] & num; }; - + // Increment at the bit position in-line BN.prototype.bincn = function bincn (bit) { assert(typeof bit === 'number'); var r = bit % 26; var s = (bit - r) / 26; var q = 1 << r; - + // Fast case: bit is much higher than all existing words if (this.length <= s) { this._expand(s + 1); this.words[s] |= q; return this; } - + // Add bit and propagate, if needed var carry = q; for (var i = s; carry !== 0 && i < this.length; i++) { @@ -32400,19 +32400,19 @@ } return this; }; - + BN.prototype.isZero = function isZero () { return this.length === 1 && this.words[0] === 0; }; - + BN.prototype.cmpn = function cmpn (num) { var negative = num < 0; - + if (this.negative !== 0 && !negative) return -1; if (this.negative === 0 && negative) return 1; - + this.strip(); - + var res; if (this.length > 1) { res = 1; @@ -32420,16 +32420,16 @@ if (negative) { num = -num; } - + assert(num <= 0x3ffffff, 'Number is too big'); - + var w = this.words[0] | 0; res = w === num ? 0 : w < num ? -1 : 1; } if (this.negative !== 0) return -res | 0; return res; }; - + // Compare two numbers and return: // 1 - if `this` > `num` // 0 - if `this` == `num` @@ -32437,23 +32437,23 @@ BN.prototype.cmp = function cmp (num) { if (this.negative !== 0 && num.negative === 0) return -1; if (this.negative === 0 && num.negative !== 0) return 1; - + var res = this.ucmp(num); if (this.negative !== 0) return -res | 0; return res; }; - + // Unsigned comparison BN.prototype.ucmp = function ucmp (num) { // At this point both numbers have the same sign if (this.length > num.length) return 1; if (this.length < num.length) return -1; - + var res = 0; for (var i = this.length - 1; i >= 0; i--) { var a = this.words[i] | 0; var b = num.words[i] | 0; - + if (a === b) continue; if (a < b) { res = -1; @@ -32464,47 +32464,47 @@ } return res; }; - + BN.prototype.gtn = function gtn (num) { return this.cmpn(num) === 1; }; - + BN.prototype.gt = function gt (num) { return this.cmp(num) === 1; }; - + BN.prototype.gten = function gten (num) { return this.cmpn(num) >= 0; }; - + BN.prototype.gte = function gte (num) { return this.cmp(num) >= 0; }; - + BN.prototype.ltn = function ltn (num) { return this.cmpn(num) === -1; }; - + BN.prototype.lt = function lt (num) { return this.cmp(num) === -1; }; - + BN.prototype.lten = function lten (num) { return this.cmpn(num) <= 0; }; - + BN.prototype.lte = function lte (num) { return this.cmp(num) <= 0; }; - + BN.prototype.eqn = function eqn (num) { return this.cmpn(num) === 0; }; - + BN.prototype.eq = function eq (num) { return this.cmp(num) === 0; }; - + // // A reduce context, could be using montgomery or something better, depending // on the `m` itself. @@ -32512,103 +32512,103 @@ BN.red = function red (num) { return new Red(num); }; - + BN.prototype.toRed = function toRed (ctx) { assert(!this.red, 'Already a number in reduction context'); assert(this.negative === 0, 'red works only with positives'); return ctx.convertTo(this)._forceRed(ctx); }; - + BN.prototype.fromRed = function fromRed () { assert(this.red, 'fromRed works only with numbers in reduction context'); return this.red.convertFrom(this); }; - + BN.prototype._forceRed = function _forceRed (ctx) { this.red = ctx; return this; }; - + BN.prototype.forceRed = function forceRed (ctx) { assert(!this.red, 'Already a number in reduction context'); return this._forceRed(ctx); }; - + BN.prototype.redAdd = function redAdd (num) { assert(this.red, 'redAdd works only with red numbers'); return this.red.add(this, num); }; - + BN.prototype.redIAdd = function redIAdd (num) { assert(this.red, 'redIAdd works only with red numbers'); return this.red.iadd(this, num); }; - + BN.prototype.redSub = function redSub (num) { assert(this.red, 'redSub works only with red numbers'); return this.red.sub(this, num); }; - + BN.prototype.redISub = function redISub (num) { assert(this.red, 'redISub works only with red numbers'); return this.red.isub(this, num); }; - + BN.prototype.redShl = function redShl (num) { assert(this.red, 'redShl works only with red numbers'); return this.red.shl(this, num); }; - + BN.prototype.redMul = function redMul (num) { assert(this.red, 'redMul works only with red numbers'); this.red._verify2(this, num); return this.red.mul(this, num); }; - + BN.prototype.redIMul = function redIMul (num) { assert(this.red, 'redMul works only with red numbers'); this.red._verify2(this, num); return this.red.imul(this, num); }; - + BN.prototype.redSqr = function redSqr () { assert(this.red, 'redSqr works only with red numbers'); this.red._verify1(this); return this.red.sqr(this); }; - + BN.prototype.redISqr = function redISqr () { assert(this.red, 'redISqr works only with red numbers'); this.red._verify1(this); return this.red.isqr(this); }; - + // Square root over p BN.prototype.redSqrt = function redSqrt () { assert(this.red, 'redSqrt works only with red numbers'); this.red._verify1(this); return this.red.sqrt(this); }; - + BN.prototype.redInvm = function redInvm () { assert(this.red, 'redInvm works only with red numbers'); this.red._verify1(this); return this.red.invm(this); }; - + // Return negative clone of `this` % `red modulo` BN.prototype.redNeg = function redNeg () { assert(this.red, 'redNeg works only with red numbers'); this.red._verify1(this); return this.red.neg(this); }; - + BN.prototype.redPow = function redPow (num) { assert(this.red && !num.red, 'redPow(normalNum)'); this.red._verify1(this); return this.red.pow(this, num); }; - + // Prime numbers with efficient reduction var primes = { k256: null, @@ -32616,7 +32616,7 @@ p192: null, p25519: null }; - + // Pseudo-Mersenne prime function MPrime (name, p) { // P = 2 ^ N - K @@ -32624,29 +32624,29 @@ this.p = new BN(p, 16); this.n = this.p.bitLength(); this.k = new BN(1).iushln(this.n).isub(this.p); - + this.tmp = this._tmp(); } - + MPrime.prototype._tmp = function _tmp () { var tmp = new BN(null); tmp.words = new Array(Math.ceil(this.n / 13)); return tmp; }; - + MPrime.prototype.ireduce = function ireduce (num) { // Assumes that `num` is less than `P^2` // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) var r = num; var rlen; - + do { this.split(r, this.tmp); r = this.imulK(r); r = r.iadd(this.tmp); rlen = r.bitLength(); } while (rlen > this.n); - + var cmp = rlen < this.n ? -1 : r.ucmp(this.p); if (cmp === 0) { r.words[0] = 0; @@ -32656,18 +32656,18 @@ } else { r.strip(); } - + return r; }; - + MPrime.prototype.split = function split (input, out) { input.iushrn(this.n, 0, out); }; - + MPrime.prototype.imulK = function imulK (num) { return num.imul(this.k); }; - + function K256 () { MPrime.call( this, @@ -32675,27 +32675,27 @@ 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); } inherits(K256, MPrime); - + K256.prototype.split = function split (input, output) { // 256 = 9 * 26 + 22 var mask = 0x3fffff; - + var outLen = Math.min(input.length, 9); for (var i = 0; i < outLen; i++) { output.words[i] = input.words[i]; } output.length = outLen; - + if (input.length <= 9) { input.words[0] = 0; input.length = 1; return; } - + // Shift by 9 limbs var prev = input.words[9]; output.words[output.length++] = prev & mask; - + for (i = 10; i < input.length; i++) { var next = input.words[i] | 0; input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); @@ -32709,13 +32709,13 @@ input.length -= 9; } }; - + K256.prototype.imulK = function imulK (num) { // K = 0x1000003d1 = [ 0x40, 0x3d1 ] num.words[num.length] = 0; num.words[num.length + 1] = 0; num.length += 2; - + // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 var lo = 0; for (var i = 0; i < num.length; i++) { @@ -32724,7 +32724,7 @@ num.words[i] = lo & 0x3ffffff; lo = w * 0x40 + ((lo / 0x4000000) | 0); } - + // Fast length reduction if (num.words[num.length - 1] === 0) { num.length--; @@ -32734,7 +32734,7 @@ } return num; }; - + function P224 () { MPrime.call( this, @@ -32742,7 +32742,7 @@ 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); } inherits(P224, MPrime); - + function P192 () { MPrime.call( this, @@ -32750,7 +32750,7 @@ 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); } inherits(P192, MPrime); - + function P25519 () { // 2 ^ 255 - 19 MPrime.call( @@ -32759,7 +32759,7 @@ '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); } inherits(P25519, MPrime); - + P25519.prototype.imulK = function imulK (num) { // K = 0x13 var carry = 0; @@ -32767,7 +32767,7 @@ var hi = (num.words[i] | 0) * 0x13 + carry; var lo = hi & 0x3ffffff; hi >>>= 26; - + num.words[i] = lo; carry = hi; } @@ -32776,12 +32776,12 @@ } return num; }; - + // Exported mostly for testing purposes, use plain name instead BN._prime = function prime (name) { // Cached version of prime if (primes[name]) return primes[name]; - + var prime; if (name === 'k256') { prime = new K256(); @@ -32795,10 +32795,10 @@ throw new Error('Unknown prime ' + name); } primes[name] = prime; - + return prime; }; - + // // Base reduction engine // @@ -32813,106 +32813,106 @@ this.prime = null; } } - + Red.prototype._verify1 = function _verify1 (a) { assert(a.negative === 0, 'red works only with positives'); assert(a.red, 'red works only with red numbers'); }; - + Red.prototype._verify2 = function _verify2 (a, b) { assert((a.negative | b.negative) === 0, 'red works only with positives'); assert(a.red && a.red === b.red, 'red works only with red numbers'); }; - + Red.prototype.imod = function imod (a) { if (this.prime) return this.prime.ireduce(a)._forceRed(this); return a.umod(this.m)._forceRed(this); }; - + Red.prototype.neg = function neg (a) { if (a.isZero()) { return a.clone(); } - + return this.m.sub(a)._forceRed(this); }; - + Red.prototype.add = function add (a, b) { this._verify2(a, b); - + var res = a.add(b); if (res.cmp(this.m) >= 0) { res.isub(this.m); } return res._forceRed(this); }; - + Red.prototype.iadd = function iadd (a, b) { this._verify2(a, b); - + var res = a.iadd(b); if (res.cmp(this.m) >= 0) { res.isub(this.m); } return res; }; - + Red.prototype.sub = function sub (a, b) { this._verify2(a, b); - + var res = a.sub(b); if (res.cmpn(0) < 0) { res.iadd(this.m); } return res._forceRed(this); }; - + Red.prototype.isub = function isub (a, b) { this._verify2(a, b); - + var res = a.isub(b); if (res.cmpn(0) < 0) { res.iadd(this.m); } return res; }; - + Red.prototype.shl = function shl (a, num) { this._verify1(a); return this.imod(a.ushln(num)); }; - + Red.prototype.imul = function imul (a, b) { this._verify2(a, b); return this.imod(a.imul(b)); }; - + Red.prototype.mul = function mul (a, b) { this._verify2(a, b); return this.imod(a.mul(b)); }; - + Red.prototype.isqr = function isqr (a) { return this.imul(a, a.clone()); }; - + Red.prototype.sqr = function sqr (a) { return this.mul(a, a); }; - + Red.prototype.sqrt = function sqrt (a) { if (a.isZero()) return a.clone(); - + var mod3 = this.m.andln(3); assert(mod3 % 2 === 1); - + // Fast case if (mod3 === 3) { var pow = this.m.add(new BN(1)).iushrn(2); return this.pow(a, pow); } - + // Tonelli-Shanks algorithm (Totally unoptimized and slow) // // Find Q and S, that Q * 2 ^ S = (P - 1) @@ -32923,20 +32923,20 @@ q.iushrn(1); } assert(!q.isZero()); - + var one = new BN(1).toRed(this); var nOne = one.redNeg(); - + // Find quadratic non-residue // NOTE: Max is such because of generalized Riemann hypothesis. var lpow = this.m.subn(1).iushrn(1); var z = this.m.bitLength(); z = new BN(2 * z * z).toRed(this); - + while (this.pow(z, lpow).cmp(nOne) !== 0) { z.redIAdd(nOne); } - + var c = this.pow(z, q); var r = this.pow(a, q.addn(1).iushrn(1)); var t = this.pow(a, q); @@ -32948,16 +32948,16 @@ } assert(i < m); var b = this.pow(c, new BN(1).iushln(m - i - 1)); - + r = r.redMul(b); c = b.redSqr(); t = t.redMul(c); m = i; } - + return r; }; - + Red.prototype.invm = function invm (a) { var inv = a._invmp(this.m); if (inv.negative !== 0) { @@ -32967,11 +32967,11 @@ return this.imod(inv); } }; - + Red.prototype.pow = function pow (a, num) { if (num.isZero()) return new BN(1); if (num.cmpn(1) === 0) return a.clone(); - + var windowSize = 4; var wnd = new Array(1 << windowSize); wnd[0] = new BN(1).toRed(this); @@ -32979,7 +32979,7 @@ for (var i = 2; i < wnd.length; i++) { wnd[i] = this.mul(wnd[i - 1], a); } - + var res = wnd[0]; var current = 0; var currentLen = 0; @@ -32987,7 +32987,7 @@ if (start === 0) { start = 26; } - + for (i = num.length - 1; i >= 0; i--) { var word = num.words[i]; for (var j = start - 1; j >= 0; j--) { @@ -32995,99 +32995,99 @@ if (res !== wnd[0]) { res = this.sqr(res); } - + if (bit === 0 && current === 0) { currentLen = 0; continue; } - + current <<= 1; current |= bit; currentLen++; if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; - + res = this.mul(res, wnd[current]); currentLen = 0; current = 0; } start = 26; } - + return res; }; - + Red.prototype.convertTo = function convertTo (num) { var r = num.umod(this.m); - + return r === num ? r.clone() : r; }; - + Red.prototype.convertFrom = function convertFrom (num) { var res = num.clone(); res.red = null; return res; }; - + // // Montgomery method engine // - + BN.mont = function mont (num) { return new Mont(num); }; - + function Mont (m) { Red.call(this, m); - + this.shift = this.m.bitLength(); if (this.shift % 26 !== 0) { this.shift += 26 - (this.shift % 26); } - + this.r = new BN(1).iushln(this.shift); this.r2 = this.imod(this.r.sqr()); this.rinv = this.r._invmp(this.m); - + this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); this.minv = this.minv.umod(this.r); this.minv = this.r.sub(this.minv); } inherits(Mont, Red); - + Mont.prototype.convertTo = function convertTo (num) { return this.imod(num.ushln(this.shift)); }; - + Mont.prototype.convertFrom = function convertFrom (num) { var r = this.imod(num.mul(this.rinv)); r.red = null; return r; }; - + Mont.prototype.imul = function imul (a, b) { if (a.isZero() || b.isZero()) { a.words[0] = 0; a.length = 1; return a; } - + var t = a.imul(b); var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); var u = t.isub(c).iushrn(this.shift); var res = u; - + if (u.cmp(this.m) >= 0) { res = u.isub(this.m); } else if (u.cmpn(0) < 0) { res = u.iadd(this.m); } - + return res._forceRed(this); }; - + Mont.prototype.mul = function mul (a, b) { if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); - + var t = a.mul(b); var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); var u = t.isub(c).iushrn(this.shift); @@ -33097,24 +33097,24 @@ } else if (u.cmpn(0) < 0) { res = u.iadd(this.m); } - + return res._forceRed(this); }; - + Mont.prototype.invm = function invm (a) { // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R var res = this.imod(a._invmp(this.m).mul(this.r2)); return res._forceRed(this); }; })(typeof module === 'undefined' || module, this); - + },{}],155:[function(require,module,exports){ (function (Buffer){ 'use strict'; - + var isHexPrefixed = require('is-hex-prefixed'); var stripHexPrefix = require('strip-hex-prefix'); - + /** * Pads a `String` to have an even length * @param {String} value @@ -33122,18 +33122,18 @@ */ function padToEven(value) { var a = value; // eslint-disable-line - + if (typeof a !== 'string') { throw new Error('[ethjs-util] while padding to even, value must be string, is currently ' + typeof a + ', while padToEven.'); } - + if (a.length % 2) { a = '0' + a; } - + return a; } - + /** * Converts a `Number` into a hex `String` * @param {Number} i @@ -33141,10 +33141,10 @@ */ function intToHex(i) { var hex = i.toString(16); // eslint-disable-line - + return '0x' + hex; } - + /** * Converts an `Number` to a `Buffer` * @param {Number} i @@ -33152,10 +33152,10 @@ */ function intToBuffer(i) { var hex = intToHex(i); - + return new Buffer(padToEven(hex.slice(2)), 'hex'); } - + /** * Get the binary size of a string * @param {String} str @@ -33165,10 +33165,10 @@ if (typeof str !== 'string') { throw new Error('[ethjs-util] while getting binary size, method getBinarySize requires input \'str\' to be type String, got \'' + typeof str + '\'.'); } - + return Buffer.byteLength(str, 'utf8'); } - + /** * Returns TRUE if the first specified array contains all elements * from the second one. FALSE otherwise. @@ -33185,12 +33185,12 @@ if (Array.isArray(subset) !== true) { throw new Error('[ethjs-util] method arrayContainsArray requires input \'subset\' to be an array got type \'' + typeof subset + '\''); } - + return subset[Boolean(some) && 'some' || 'every'](function (value) { return superset.indexOf(value) >= 0; }); } - + /** * Should be called to get utf8 from it's hex representation * @@ -33200,10 +33200,10 @@ */ function toUtf8(hex) { var bufferValue = new Buffer(padToEven(stripHexPrefix(hex).replace(/^0+|0+$/g, '')), 'hex'); - + return bufferValue.toString('utf8'); } - + /** * Should be called to get ascii from it's hex representation * @@ -33215,19 +33215,19 @@ var str = ''; // eslint-disable-line var i = 0, l = hex.length; // eslint-disable-line - + if (hex.substring(0, 2) === '0x') { i = 2; } - + for (; i < l; i += 2) { var code = parseInt(hex.substr(i, 2), 16); str += String.fromCharCode(code); } - + return str; } - + /** * Should be called to get hex representation (prefixed by 0x) of utf8 string * @@ -33238,10 +33238,10 @@ */ function fromUtf8(stringValue) { var str = new Buffer(stringValue, 'utf8'); - + return '0x' + padToEven(str.toString('hex')).replace(/^0+|0+$/g, ''); } - + /** * Should be called to get hex representation (prefixed by 0x) of ascii string * @@ -33258,10 +33258,10 @@ var n = code.toString(16); hex += n.length < 2 ? '0' + n : n; } - + return '0x' + hex; } - + /** * getKeys([{a: 1, b: 2}, {a: 3, b: 4}], 'a') => [1, 3] * @@ -33278,9 +33278,9 @@ if (typeof key !== 'string') { throw new Error('[ethjs-util] method getKeys expecting type String for input \'key\' got \'' + typeof key + '\'.'); } - + var result = []; // eslint-disable-line - + for (var i = 0; i < params.length; i++) { // eslint-disable-line var value = params[i][key]; // eslint-disable-line @@ -33291,10 +33291,10 @@ } result.push(value); } - + return result; } - + /** * Is the string a hex string. * @@ -33307,14 +33307,14 @@ if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) { return false; } - + if (length && value.length !== 2 + 2 * length) { return false; } - + return true; } - + module.exports = { arrayContainsArray: arrayContainsArray, intToBuffer: intToBuffer, @@ -33333,7 +33333,7 @@ }).call(this,require("buffer").Buffer) },{"buffer":84,"is-hex-prefixed":185,"strip-hex-prefix":318}],156:[function(require,module,exports){ 'use strict'; - + // // We store our EE objects in a plain object whose properties are event names. // If `Object.create(null)` is not supported we prefix the event names with a @@ -33343,7 +33343,7 @@ // is an ES6 Symbol. // var prefix = typeof Object.create !== 'function' ? '~' : false; - + /** * Representation of a single EventEmitter function. * @@ -33357,7 +33357,7 @@ this.context = context; this.once = once || false; } - + /** * Minimal EventEmitter interface that is molded against the Node.js * EventEmitter interface. @@ -33366,7 +33366,7 @@ * @api public */ function EventEmitter() { /* Nothing to set */ } - + /** * Holds the assigned EventEmitters by name. * @@ -33374,7 +33374,7 @@ * @private */ EventEmitter.prototype._events = undefined; - + /** * Return a list of assigned event listeners. * @@ -33386,18 +33386,18 @@ EventEmitter.prototype.listeners = function listeners(event, exists) { var evt = prefix ? prefix + event : event , available = this._events && this._events[evt]; - + if (exists) return !!available; if (!available) return []; if (available.fn) return [available.fn]; - + for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) { ee[i] = available[i].fn; } - + return ee; }; - + /** * Emit an event to all registered event listeners. * @@ -33407,17 +33407,17 @@ */ EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { var evt = prefix ? prefix + event : event; - + if (!this._events || !this._events[evt]) return false; - + var listeners = this._events[evt] , len = arguments.length , args , i; - + if ('function' === typeof listeners.fn) { if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); - + switch (len) { case 1: return listeners.fn.call(listeners.context), true; case 2: return listeners.fn.call(listeners.context, a1), true; @@ -33426,19 +33426,19 @@ case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; } - + for (i = 1, args = new Array(len -1); i < len; i++) { args[i - 1] = arguments[i]; } - + listeners.fn.apply(listeners.context, args); } else { var length = listeners.length , j; - + for (i = 0; i < length; i++) { if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); - + switch (len) { case 1: listeners[i].fn.call(listeners[i].context); break; case 2: listeners[i].fn.call(listeners[i].context, a1); break; @@ -33447,15 +33447,15 @@ if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { args[j - 1] = arguments[j]; } - + listeners[i].fn.apply(listeners[i].context, args); } } } - + return true; }; - + /** * Register a new EventListener for the given event. * @@ -33467,7 +33467,7 @@ EventEmitter.prototype.on = function on(event, fn, context) { var listener = new EE(fn, context || this) , evt = prefix ? prefix + event : event; - + if (!this._events) this._events = prefix ? {} : Object.create(null); if (!this._events[evt]) this._events[evt] = listener; else { @@ -33476,10 +33476,10 @@ this._events[evt], listener ]; } - + return this; }; - + /** * Add an EventListener that's only called once. * @@ -33491,7 +33491,7 @@ EventEmitter.prototype.once = function once(event, fn, context) { var listener = new EE(fn, context || this, true) , evt = prefix ? prefix + event : event; - + if (!this._events) this._events = prefix ? {} : Object.create(null); if (!this._events[evt]) this._events[evt] = listener; else { @@ -33500,10 +33500,10 @@ this._events[evt], listener ]; } - + return this; }; - + /** * Remove event listeners. * @@ -33515,12 +33515,12 @@ */ EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { var evt = prefix ? prefix + event : event; - + if (!this._events || !this._events[evt]) return this; - + var listeners = this._events[evt] , events = []; - + if (fn) { if (listeners.fn) { if ( @@ -33542,7 +33542,7 @@ } } } - + // // Reset the array, or remove it completely if we have no more listeners. // @@ -33551,10 +33551,10 @@ } else { delete this._events[evt]; } - + return this; }; - + /** * Remove all listeners or only the listeners for the specified event. * @@ -33563,38 +33563,38 @@ */ EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { if (!this._events) return this; - + if (event) delete this._events[prefix ? prefix + event : event]; else this._events = prefix ? {} : Object.create(null); - + return this; }; - + // // Alias methods names because people roll like that. // EventEmitter.prototype.off = EventEmitter.prototype.removeListener; EventEmitter.prototype.addListener = EventEmitter.prototype.on; - + // // This function doesn't apply anymore. // EventEmitter.prototype.setMaxListeners = function setMaxListeners() { return this; }; - + // // Expose the prefix. // EventEmitter.prefixed = prefix; - + // // Expose the module. // if ('undefined' !== typeof module) { module.exports = EventEmitter; } - + },{}],157:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // @@ -33616,23 +33616,23 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - + function EventEmitter() { this._events = this._events || {}; this._maxListeners = this._maxListeners || undefined; } module.exports = EventEmitter; - + // Backwards-compat with node 0.10.x EventEmitter.EventEmitter = EventEmitter; - + EventEmitter.prototype._events = undefined; EventEmitter.prototype._maxListeners = undefined; - + // By default EventEmitters will print a warning if more than 10 listeners are // added to it. This is a useful default which helps finding memory leaks. EventEmitter.defaultMaxListeners = 10; - + // Obviously not all Emitters should be limited to 10. This function allows // that to be increased. Set to zero for unlimited. EventEmitter.prototype.setMaxListeners = function(n) { @@ -33641,13 +33641,13 @@ this._maxListeners = n; return this; }; - + EventEmitter.prototype.emit = function(type) { var er, handler, len, args, i, listeners; - + if (!this._events) this._events = {}; - + // If there is no 'error' event listener then throw. if (type === 'error') { if (!this._events.error || @@ -33663,12 +33663,12 @@ } } } - + handler = this._events[type]; - + if (isUndefined(handler)) return false; - + if (isFunction(handler)) { switch (arguments.length) { // fast cases @@ -33693,26 +33693,26 @@ for (i = 0; i < len; i++) listeners[i].apply(this, args); } - + return true; }; - + EventEmitter.prototype.addListener = function(type, listener) { var m; - + if (!isFunction(listener)) throw TypeError('listener must be a function'); - + if (!this._events) this._events = {}; - + // To avoid recursion in the case that type === "newListener"! Before // adding it to the listeners, first emit "newListener". if (this._events.newListener) this.emit('newListener', type, isFunction(listener.listener) ? listener.listener : listener); - + if (!this._events[type]) // Optimize the case of one listener. Don't need the extra array object. this._events[type] = listener; @@ -33722,7 +33722,7 @@ else // Adding the second element, need to change to array. this._events[type] = [this._events[type], listener]; - + // Check for listener leak if (isObject(this._events[type]) && !this._events[type].warned) { if (!isUndefined(this._maxListeners)) { @@ -33730,7 +33730,7 @@ } else { m = EventEmitter.defaultMaxListeners; } - + if (m && m > 0 && this._events[type].length > m) { this._events[type].warned = true; console.error('(node) warning: possible EventEmitter memory ' + @@ -33743,53 +33743,53 @@ } } } - + return this; }; - + EventEmitter.prototype.on = EventEmitter.prototype.addListener; - + EventEmitter.prototype.once = function(type, listener) { if (!isFunction(listener)) throw TypeError('listener must be a function'); - + var fired = false; - + function g() { this.removeListener(type, g); - + if (!fired) { fired = true; listener.apply(this, arguments); } } - + g.listener = listener; this.on(type, g); - + return this; }; - + // emits a 'removeListener' event iff the listener was removed EventEmitter.prototype.removeListener = function(type, listener) { var list, position, length, i; - + if (!isFunction(listener)) throw TypeError('listener must be a function'); - + if (!this._events || !this._events[type]) return this; - + list = this._events[type]; length = list.length; position = -1; - + if (list === listener || (isFunction(list.listener) && list.listener === listener)) { delete this._events[type]; if (this._events.removeListener) this.emit('removeListener', type, listener); - + } else if (isObject(list)) { for (i = length; i-- > 0;) { if (list[i] === listener || @@ -33798,30 +33798,30 @@ break; } } - + if (position < 0) return this; - + if (list.length === 1) { list.length = 0; delete this._events[type]; } else { list.splice(position, 1); } - + if (this._events.removeListener) this.emit('removeListener', type, listener); } - + return this; }; - + EventEmitter.prototype.removeAllListeners = function(type) { var key, listeners; - + if (!this._events) return this; - + // not listening for removeListener, no need to emit if (!this._events.removeListener) { if (arguments.length === 0) @@ -33830,7 +33830,7 @@ delete this._events[type]; return this; } - + // emit removeListener for all listeners on all events if (arguments.length === 0) { for (key in this._events) { @@ -33841,9 +33841,9 @@ this._events = {}; return this; } - + listeners = this._events[type]; - + if (isFunction(listeners)) { this.removeListener(type, listeners); } else if (listeners) { @@ -33852,10 +33852,10 @@ this.removeListener(type, listeners[listeners.length - 1]); } delete this._events[type]; - + return this; }; - + EventEmitter.prototype.listeners = function(type) { var ret; if (!this._events || !this._events[type]) @@ -33866,11 +33866,11 @@ ret = this._events[type].slice(); return ret; }; - + EventEmitter.prototype.listenerCount = function(type) { if (this._events) { var evlistener = this._events[type]; - + if (isFunction(evlistener)) return 1; else if (evlistener) @@ -33878,31 +33878,31 @@ } return 0; }; - + EventEmitter.listenerCount = function(emitter, type) { return emitter.listenerCount(type); }; - + function isFunction(arg) { return typeof arg === 'function'; } - + function isNumber(arg) { return typeof arg === 'number'; } - + function isObject(arg) { return typeof arg === 'object' && arg !== null; } - + function isUndefined(arg) { return arg === void 0; } - + },{}],158:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var MD5 = require('md5.js') - + /* eslint-disable camelcase */ function EVP_BytesToKey (password, salt, keyBits, ivLen) { if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary') @@ -33910,28 +33910,28 @@ if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary') if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length') } - + var keyLen = keyBits / 8 var key = Buffer.alloc(keyLen) var iv = Buffer.alloc(ivLen || 0) var tmp = Buffer.alloc(0) - + while (keyLen > 0 || ivLen > 0) { var hash = new MD5() hash.update(tmp) hash.update(password) if (salt) hash.update(salt) tmp = hash.digest() - + var used = 0 - + if (keyLen > 0) { var keyStart = key.length - keyLen used = Math.min(keyLen, tmp.length) tmp.copy(key, keyStart, 0, used) keyLen -= used } - + if (used < tmp.length && ivLen > 0) { var ivStart = iv.length - ivLen var length = Math.min(ivLen, tmp.length - used) @@ -33939,21 +33939,21 @@ ivLen -= length } } - + tmp.fill(0) return { key: key, iv: iv } } - + module.exports = EVP_BytesToKey - + },{"md5.js":231,"safe-buffer":290}],159:[function(require,module,exports){ 'use strict'; - + var isCallable = require('is-callable'); - + var toStr = Object.prototype.toString; var hasOwnProperty = Object.prototype.hasOwnProperty; - + var forEachArray = function forEachArray(array, iterator, receiver) { for (var i = 0, len = array.length; i < len; i++) { if (hasOwnProperty.call(array, i)) { @@ -33965,7 +33965,7 @@ } } }; - + var forEachString = function forEachString(string, iterator, receiver) { for (var i = 0, len = string.length; i < len; i++) { // no such thing as a sparse string. @@ -33976,7 +33976,7 @@ } } }; - + var forEachObject = function forEachObject(object, iterator, receiver) { for (var k in object) { if (hasOwnProperty.call(object, k)) { @@ -33988,17 +33988,17 @@ } } }; - + var forEach = function forEach(list, iterator, thisArg) { if (!isCallable(iterator)) { throw new TypeError('iterator must be a function'); } - + var receiver; if (arguments.length >= 3) { receiver = thisArg; } - + if (toStr.call(list) === '[object Array]') { forEachArray(list, iterator, receiver); } else if (typeof list === 'string') { @@ -34007,13 +34007,13 @@ forEachObject(list, iterator, receiver); } }; - + module.exports = forEach; - + },{"is-callable":182}],160:[function(require,module,exports){ (function (global){ var win; - + if (typeof window !== "undefined") { win = window; } else if (typeof global !== "undefined") { @@ -34023,29 +34023,29 @@ } else { win = {}; } - + module.exports = win; - + }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],161:[function(require,module,exports){ (function (Buffer){ 'use strict' var Transform = require('stream').Transform var inherits = require('inherits') - + function HashBase (blockSize) { Transform.call(this) - + this._block = new Buffer(blockSize) this._blockSize = blockSize this._blockOffset = 0 this._length = [0, 0, 0, 0] - + this._finalized = false } - + inherits(HashBase, Transform) - + HashBase.prototype._transform = function (chunk, encoding, callback) { var error = null try { @@ -34054,10 +34054,10 @@ } catch (err) { error = err } - + callback(error) } - + HashBase.prototype._flush = function (callback) { var error = null try { @@ -34065,15 +34065,15 @@ } catch (err) { error = err } - + callback(error) } - + HashBase.prototype.update = function (data, encoding) { if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer') if (this._finalized) throw new Error('Digest already called') if (!Buffer.isBuffer(data)) data = new Buffer(data, encoding || 'binary') - + // consume data var block = this._block var offset = 0 @@ -34083,46 +34083,46 @@ this._blockOffset = 0 } while (offset < data.length) block[this._blockOffset++] = data[offset++] - + // update length for (var j = 0, carry = data.length * 8; carry > 0; ++j) { this._length[j] += carry carry = (this._length[j] / 0x0100000000) | 0 if (carry > 0) this._length[j] -= 0x0100000000 * carry } - + return this } - + HashBase.prototype._update = function (data) { throw new Error('_update is not implemented') } - + HashBase.prototype.digest = function (encoding) { if (this._finalized) throw new Error('Digest already called') this._finalized = true - + var digest = this._digest() if (encoding !== undefined) digest = digest.toString(encoding) return digest } - + HashBase.prototype._digest = function () { throw new Error('_digest is not implemented') } - + module.exports = HashBase - + }).call(this,require("buffer").Buffer) },{"buffer":84,"inherits":180,"stream":311}],162:[function(require,module,exports){ var hash = exports; - + hash.utils = require('./hash/utils'); hash.common = require('./hash/common'); hash.sha = require('./hash/sha'); hash.ripemd = require('./hash/ripemd'); hash.hmac = require('./hash/hmac'); - + // Proxy hash functions to the main object hash.sha1 = hash.sha.sha1; hash.sha256 = hash.sha.sha256; @@ -34130,13 +34130,13 @@ hash.sha384 = hash.sha.sha384; hash.sha512 = hash.sha.sha512; hash.ripemd160 = hash.ripemd.ripemd160; - + },{"./hash/common":163,"./hash/hmac":164,"./hash/ripemd":165,"./hash/sha":166,"./hash/utils":173}],163:[function(require,module,exports){ 'use strict'; - + var utils = require('./utils'); var assert = require('minimalistic-assert'); - + function BlockHash() { this.pending = null; this.pendingTotal = 0; @@ -34145,12 +34145,12 @@ this.hmacStrength = this.constructor.hmacStrength; this.padLength = this.constructor.padLength / 8; this.endian = 'big'; - + this._delta8 = this.blockSize / 8; this._delta32 = this.blockSize / 32; } exports.BlockHash = BlockHash; - + BlockHash.prototype.update = function update(msg, enc) { // Convert message to array, pad it, and join into 32bit blocks msg = utils.toArray(msg, enc); @@ -34159,32 +34159,32 @@ else this.pending = this.pending.concat(msg); this.pendingTotal += msg.length; - + // Enough data, try updating if (this.pending.length >= this._delta8) { msg = this.pending; - + // Process pending data in blocks var r = msg.length % this._delta8; this.pending = msg.slice(msg.length - r, msg.length); if (this.pending.length === 0) this.pending = null; - + msg = utils.join32(msg, 0, msg.length - r, this.endian); for (var i = 0; i < msg.length; i += this._delta32) this._update(msg, i, i + this._delta32); } - + return this; }; - + BlockHash.prototype.digest = function digest(enc) { this.update(this._pad()); assert(this.pending === null); - + return this._digest(enc); }; - + BlockHash.prototype._pad = function pad() { var len = this.pendingTotal; var bytes = this._delta8; @@ -34193,13 +34193,13 @@ res[0] = 0x80; for (var i = 1; i < k; i++) res[i] = 0; - + // Append length len <<= 3; if (this.endian === 'big') { for (var t = 8; t < this.padLength; t++) res[i++] = 0; - + res[i++] = 0; res[i++] = 0; res[i++] = 0; @@ -34217,20 +34217,20 @@ res[i++] = 0; res[i++] = 0; res[i++] = 0; - + for (t = 8; t < this.padLength; t++) res[i++] = 0; } - + return res; }; - + },{"./utils":173,"minimalistic-assert":234}],164:[function(require,module,exports){ 'use strict'; - + var utils = require('./utils'); var assert = require('minimalistic-assert'); - + function Hmac(hash, key, enc) { if (!(this instanceof Hmac)) return new Hmac(hash, key, enc); @@ -34239,70 +34239,70 @@ this.outSize = hash.outSize / 8; this.inner = null; this.outer = null; - + this._init(utils.toArray(key, enc)); } module.exports = Hmac; - + Hmac.prototype._init = function init(key) { // Shorten key, if needed if (key.length > this.blockSize) key = new this.Hash().update(key).digest(); assert(key.length <= this.blockSize); - + // Add padding to key for (var i = key.length; i < this.blockSize; i++) key.push(0); - + for (i = 0; i < key.length; i++) key[i] ^= 0x36; this.inner = new this.Hash().update(key); - + // 0x36 ^ 0x5c = 0x6a for (i = 0; i < key.length; i++) key[i] ^= 0x6a; this.outer = new this.Hash().update(key); }; - + Hmac.prototype.update = function update(msg, enc) { this.inner.update(msg, enc); return this; }; - + Hmac.prototype.digest = function digest(enc) { this.outer.update(this.inner.digest()); return this.outer.digest(enc); }; - + },{"./utils":173,"minimalistic-assert":234}],165:[function(require,module,exports){ 'use strict'; - + var utils = require('./utils'); var common = require('./common'); - + var rotl32 = utils.rotl32; var sum32 = utils.sum32; var sum32_3 = utils.sum32_3; var sum32_4 = utils.sum32_4; var BlockHash = common.BlockHash; - + function RIPEMD160() { if (!(this instanceof RIPEMD160)) return new RIPEMD160(); - + BlockHash.call(this); - + this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ]; this.endian = 'little'; } utils.inherits(RIPEMD160, BlockHash); exports.ripemd160 = RIPEMD160; - + RIPEMD160.blockSize = 512; RIPEMD160.outSize = 160; RIPEMD160.hmacStrength = 192; RIPEMD160.padLength = 64; - + RIPEMD160.prototype._update = function update(msg, start) { var A = this.h[0]; var B = this.h[1]; @@ -34343,14 +34343,14 @@ this.h[4] = sum32_3(this.h[0], B, Ch); this.h[0] = T; }; - + RIPEMD160.prototype._digest = function digest(enc) { if (enc === 'hex') return utils.toHex32(this.h, 'little'); else return utils.split32(this.h, 'little'); }; - + function f(j, x, y, z) { if (j <= 15) return x ^ y ^ z; @@ -34363,7 +34363,7 @@ else return x ^ (y | (~z)); } - + function K(j) { if (j <= 15) return 0x00000000; @@ -34376,7 +34376,7 @@ else return 0xa953fd4e; } - + function Kh(j) { if (j <= 15) return 0x50a28be6; @@ -34389,7 +34389,7 @@ else return 0x00000000; } - + var r = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, @@ -34397,7 +34397,7 @@ 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 ]; - + var rh = [ 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, @@ -34405,7 +34405,7 @@ 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 ]; - + var s = [ 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, @@ -34413,7 +34413,7 @@ 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]; - + var sh = [ 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, @@ -34421,68 +34421,68 @@ 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]; - + },{"./common":163,"./utils":173}],166:[function(require,module,exports){ 'use strict'; - + exports.sha1 = require('./sha/1'); exports.sha224 = require('./sha/224'); exports.sha256 = require('./sha/256'); exports.sha384 = require('./sha/384'); exports.sha512 = require('./sha/512'); - + },{"./sha/1":167,"./sha/224":168,"./sha/256":169,"./sha/384":170,"./sha/512":171}],167:[function(require,module,exports){ 'use strict'; - + var utils = require('../utils'); var common = require('../common'); var shaCommon = require('./common'); - + var rotl32 = utils.rotl32; var sum32 = utils.sum32; var sum32_5 = utils.sum32_5; var ft_1 = shaCommon.ft_1; var BlockHash = common.BlockHash; - + var sha1_K = [ 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 ]; - + function SHA1() { if (!(this instanceof SHA1)) return new SHA1(); - + BlockHash.call(this); this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ]; this.W = new Array(80); } - + utils.inherits(SHA1, BlockHash); module.exports = SHA1; - + SHA1.blockSize = 512; SHA1.outSize = 160; SHA1.hmacStrength = 80; SHA1.padLength = 64; - + SHA1.prototype._update = function _update(msg, start) { var W = this.W; - + for (var i = 0; i < 16; i++) W[i] = msg[start + i]; - + for(; i < W.length; i++) W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1); - + var a = this.h[0]; var b = this.h[1]; var c = this.h[2]; var d = this.h[3]; var e = this.h[4]; - + for (i = 0; i < W.length; i++) { var s = ~~(i / 20); var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]); @@ -34492,31 +34492,31 @@ b = a; a = t; } - + this.h[0] = sum32(this.h[0], a); this.h[1] = sum32(this.h[1], b); this.h[2] = sum32(this.h[2], c); this.h[3] = sum32(this.h[3], d); this.h[4] = sum32(this.h[4], e); }; - + SHA1.prototype._digest = function digest(enc) { if (enc === 'hex') return utils.toHex32(this.h, 'big'); else return utils.split32(this.h, 'big'); }; - + },{"../common":163,"../utils":173,"./common":172}],168:[function(require,module,exports){ 'use strict'; - + var utils = require('../utils'); var SHA256 = require('./256'); - + function SHA224() { if (!(this instanceof SHA224)) return new SHA224(); - + SHA256.call(this); this.h = [ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, @@ -34524,12 +34524,12 @@ } utils.inherits(SHA224, SHA256); module.exports = SHA224; - + SHA224.blockSize = 512; SHA224.outSize = 224; SHA224.hmacStrength = 192; SHA224.padLength = 64; - + SHA224.prototype._digest = function digest(enc) { // Just truncate output if (enc === 'hex') @@ -34537,16 +34537,16 @@ else return utils.split32(this.h.slice(0, 7), 'big'); }; - - + + },{"../utils":173,"./256":169}],169:[function(require,module,exports){ 'use strict'; - + var utils = require('../utils'); var common = require('../common'); var shaCommon = require('./common'); var assert = require('minimalistic-assert'); - + var sum32 = utils.sum32; var sum32_4 = utils.sum32_4; var sum32_5 = utils.sum32_5; @@ -34556,9 +34556,9 @@ var s1_256 = shaCommon.s1_256; var g0_256 = shaCommon.g0_256; var g1_256 = shaCommon.g1_256; - + var BlockHash = common.BlockHash; - + var sha256_K = [ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, @@ -34577,11 +34577,11 @@ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 ]; - + function SHA256() { if (!(this instanceof SHA256)) return new SHA256(); - + BlockHash.call(this); this.h = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, @@ -34592,20 +34592,20 @@ } utils.inherits(SHA256, BlockHash); module.exports = SHA256; - + SHA256.blockSize = 512; SHA256.outSize = 256; SHA256.hmacStrength = 192; SHA256.padLength = 64; - + SHA256.prototype._update = function _update(msg, start) { var W = this.W; - + for (var i = 0; i < 16; i++) W[i] = msg[start + i]; for (; i < W.length; i++) W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]); - + var a = this.h[0]; var b = this.h[1]; var c = this.h[2]; @@ -34614,7 +34614,7 @@ var f = this.h[5]; var g = this.h[6]; var h = this.h[7]; - + assert(this.k.length === W.length); for (i = 0; i < W.length; i++) { var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]); @@ -34628,7 +34628,7 @@ b = a; a = sum32(T1, T2); } - + this.h[0] = sum32(this.h[0], a); this.h[1] = sum32(this.h[1], b); this.h[2] = sum32(this.h[2], c); @@ -34638,25 +34638,25 @@ this.h[6] = sum32(this.h[6], g); this.h[7] = sum32(this.h[7], h); }; - + SHA256.prototype._digest = function digest(enc) { if (enc === 'hex') return utils.toHex32(this.h, 'big'); else return utils.split32(this.h, 'big'); }; - + },{"../common":163,"../utils":173,"./common":172,"minimalistic-assert":234}],170:[function(require,module,exports){ 'use strict'; - + var utils = require('../utils'); - + var SHA512 = require('./512'); - + function SHA384() { if (!(this instanceof SHA384)) return new SHA384(); - + SHA512.call(this); this.h = [ 0xcbbb9d5d, 0xc1059ed8, @@ -34670,26 +34670,26 @@ } utils.inherits(SHA384, SHA512); module.exports = SHA384; - + SHA384.blockSize = 1024; SHA384.outSize = 384; SHA384.hmacStrength = 192; SHA384.padLength = 128; - + SHA384.prototype._digest = function digest(enc) { if (enc === 'hex') return utils.toHex32(this.h.slice(0, 12), 'big'); else return utils.split32(this.h.slice(0, 12), 'big'); }; - + },{"../utils":173,"./512":171}],171:[function(require,module,exports){ 'use strict'; - + var utils = require('../utils'); var common = require('../common'); var assert = require('minimalistic-assert'); - + var rotr64_hi = utils.rotr64_hi; var rotr64_lo = utils.rotr64_lo; var shr64_hi = utils.shr64_hi; @@ -34701,9 +34701,9 @@ var sum64_4_lo = utils.sum64_4_lo; var sum64_5_hi = utils.sum64_5_hi; var sum64_5_lo = utils.sum64_5_lo; - + var BlockHash = common.BlockHash; - + var sha512_K = [ 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, @@ -34746,11 +34746,11 @@ 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 ]; - + function SHA512() { if (!(this instanceof SHA512)) return new SHA512(); - + BlockHash.call(this); this.h = [ 0x6a09e667, 0xf3bcc908, @@ -34766,15 +34766,15 @@ } utils.inherits(SHA512, BlockHash); module.exports = SHA512; - + SHA512.blockSize = 1024; SHA512.outSize = 512; SHA512.hmacStrength = 192; SHA512.padLength = 128; - + SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) { var W = this.W; - + // 32 x 32bit words for (var i = 0; i < 32; i++) W[i] = msg[start + i]; @@ -34787,7 +34787,7 @@ var c2_lo = g0_512_lo(W[i - 30], W[i - 29]); var c3_hi = W[i - 32]; // i - 16 var c3_lo = W[i - 31]; - + W[i] = sum64_4_hi( c0_hi, c0_lo, c1_hi, c1_lo, @@ -34800,12 +34800,12 @@ c3_hi, c3_lo); } }; - + SHA512.prototype._update = function _update(msg, start) { this._prepareBlock(msg, start); - + var W = this.W; - + var ah = this.h[0]; var al = this.h[1]; var bh = this.h[2]; @@ -34822,7 +34822,7 @@ var gl = this.h[13]; var hh = this.h[14]; var hl = this.h[15]; - + assert(this.k.length === W.length); for (var i = 0; i < W.length; i += 2) { var c0_hi = hh; @@ -34835,7 +34835,7 @@ var c3_lo = this.k[i + 1]; var c4_hi = W[i]; var c4_lo = W[i + 1]; - + var T1_hi = sum64_5_hi( c0_hi, c0_lo, c1_hi, c1_lo, @@ -34848,40 +34848,40 @@ c2_hi, c2_lo, c3_hi, c3_lo, c4_hi, c4_lo); - + c0_hi = s0_512_hi(ah, al); c0_lo = s0_512_lo(ah, al); c1_hi = maj64_hi(ah, al, bh, bl, ch, cl); c1_lo = maj64_lo(ah, al, bh, bl, ch, cl); - + var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo); var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo); - + hh = gh; hl = gl; - + gh = fh; gl = fl; - + fh = eh; fl = el; - + eh = sum64_hi(dh, dl, T1_hi, T1_lo); el = sum64_lo(dl, dl, T1_hi, T1_lo); - + dh = ch; dl = cl; - + ch = bh; cl = bl; - + bh = ah; bl = al; - + ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo); al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo); } - + sum64(this.h, 0, ah, al); sum64(this.h, 2, bh, bl); sum64(this.h, 4, ch, cl); @@ -34891,136 +34891,136 @@ sum64(this.h, 12, gh, gl); sum64(this.h, 14, hh, hl); }; - + SHA512.prototype._digest = function digest(enc) { if (enc === 'hex') return utils.toHex32(this.h, 'big'); else return utils.split32(this.h, 'big'); }; - + function ch64_hi(xh, xl, yh, yl, zh) { var r = (xh & yh) ^ ((~xh) & zh); if (r < 0) r += 0x100000000; return r; } - + function ch64_lo(xh, xl, yh, yl, zh, zl) { var r = (xl & yl) ^ ((~xl) & zl); if (r < 0) r += 0x100000000; return r; } - + function maj64_hi(xh, xl, yh, yl, zh) { var r = (xh & yh) ^ (xh & zh) ^ (yh & zh); if (r < 0) r += 0x100000000; return r; } - + function maj64_lo(xh, xl, yh, yl, zh, zl) { var r = (xl & yl) ^ (xl & zl) ^ (yl & zl); if (r < 0) r += 0x100000000; return r; } - + function s0_512_hi(xh, xl) { var c0_hi = rotr64_hi(xh, xl, 28); var c1_hi = rotr64_hi(xl, xh, 2); // 34 var c2_hi = rotr64_hi(xl, xh, 7); // 39 - + var r = c0_hi ^ c1_hi ^ c2_hi; if (r < 0) r += 0x100000000; return r; } - + function s0_512_lo(xh, xl) { var c0_lo = rotr64_lo(xh, xl, 28); var c1_lo = rotr64_lo(xl, xh, 2); // 34 var c2_lo = rotr64_lo(xl, xh, 7); // 39 - + var r = c0_lo ^ c1_lo ^ c2_lo; if (r < 0) r += 0x100000000; return r; } - + function s1_512_hi(xh, xl) { var c0_hi = rotr64_hi(xh, xl, 14); var c1_hi = rotr64_hi(xh, xl, 18); var c2_hi = rotr64_hi(xl, xh, 9); // 41 - + var r = c0_hi ^ c1_hi ^ c2_hi; if (r < 0) r += 0x100000000; return r; } - + function s1_512_lo(xh, xl) { var c0_lo = rotr64_lo(xh, xl, 14); var c1_lo = rotr64_lo(xh, xl, 18); var c2_lo = rotr64_lo(xl, xh, 9); // 41 - + var r = c0_lo ^ c1_lo ^ c2_lo; if (r < 0) r += 0x100000000; return r; } - + function g0_512_hi(xh, xl) { var c0_hi = rotr64_hi(xh, xl, 1); var c1_hi = rotr64_hi(xh, xl, 8); var c2_hi = shr64_hi(xh, xl, 7); - + var r = c0_hi ^ c1_hi ^ c2_hi; if (r < 0) r += 0x100000000; return r; } - + function g0_512_lo(xh, xl) { var c0_lo = rotr64_lo(xh, xl, 1); var c1_lo = rotr64_lo(xh, xl, 8); var c2_lo = shr64_lo(xh, xl, 7); - + var r = c0_lo ^ c1_lo ^ c2_lo; if (r < 0) r += 0x100000000; return r; } - + function g1_512_hi(xh, xl) { var c0_hi = rotr64_hi(xh, xl, 19); var c1_hi = rotr64_hi(xl, xh, 29); // 61 var c2_hi = shr64_hi(xh, xl, 6); - + var r = c0_hi ^ c1_hi ^ c2_hi; if (r < 0) r += 0x100000000; return r; } - + function g1_512_lo(xh, xl) { var c0_lo = rotr64_lo(xh, xl, 19); var c1_lo = rotr64_lo(xl, xh, 29); // 61 var c2_lo = shr64_lo(xh, xl, 6); - + var r = c0_lo ^ c1_lo ^ c2_lo; if (r < 0) r += 0x100000000; return r; } - + },{"../common":163,"../utils":173,"minimalistic-assert":234}],172:[function(require,module,exports){ 'use strict'; - + var utils = require('../utils'); var rotr32 = utils.rotr32; - + function ft_1(s, x, y, z) { if (s === 0) return ch32(x, y, z); @@ -35030,50 +35030,50 @@ return maj32(x, y, z); } exports.ft_1 = ft_1; - + function ch32(x, y, z) { return (x & y) ^ ((~x) & z); } exports.ch32 = ch32; - + function maj32(x, y, z) { return (x & y) ^ (x & z) ^ (y & z); } exports.maj32 = maj32; - + function p32(x, y, z) { return x ^ y ^ z; } exports.p32 = p32; - + function s0_256(x) { return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22); } exports.s0_256 = s0_256; - + function s1_256(x) { return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25); } exports.s1_256 = s1_256; - + function g0_256(x) { return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3); } exports.g0_256 = g0_256; - + function g1_256(x) { return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10); } exports.g1_256 = g1_256; - + },{"../utils":173}],173:[function(require,module,exports){ 'use strict'; - + var assert = require('minimalistic-assert'); var inherits = require('inherits'); - + exports.inherits = inherits; - + function toArray(msg, enc) { if (Array.isArray(msg)) return msg.slice(); @@ -35105,7 +35105,7 @@ return res; } exports.toArray = toArray; - + function toHex(msg) { var res = ''; for (var i = 0; i < msg.length; i++) @@ -35113,7 +35113,7 @@ return res; } exports.toHex = toHex; - + function htonl(w) { var res = (w >>> 24) | ((w >>> 8) & 0xff00) | @@ -35122,7 +35122,7 @@ return res >>> 0; } exports.htonl = htonl; - + function toHex32(msg, endian) { var res = ''; for (var i = 0; i < msg.length; i++) { @@ -35134,7 +35134,7 @@ return res; } exports.toHex32 = toHex32; - + function zero2(word) { if (word.length === 1) return '0' + word; @@ -35142,7 +35142,7 @@ return word; } exports.zero2 = zero2; - + function zero8(word) { if (word.length === 7) return '0' + word; @@ -35162,7 +35162,7 @@ return word; } exports.zero8 = zero8; - + function join32(msg, start, end, endian) { var len = end - start; assert(len % 4 === 0); @@ -35178,7 +35178,7 @@ return res; } exports.join32 = join32; - + function split32(msg, endian) { var res = new Array(msg.length * 4); for (var i = 0, k = 0; i < msg.length; i++, k += 4) { @@ -35198,61 +35198,61 @@ return res; } exports.split32 = split32; - + function rotr32(w, b) { return (w >>> b) | (w << (32 - b)); } exports.rotr32 = rotr32; - + function rotl32(w, b) { return (w << b) | (w >>> (32 - b)); } exports.rotl32 = rotl32; - + function sum32(a, b) { return (a + b) >>> 0; } exports.sum32 = sum32; - + function sum32_3(a, b, c) { return (a + b + c) >>> 0; } exports.sum32_3 = sum32_3; - + function sum32_4(a, b, c, d) { return (a + b + c + d) >>> 0; } exports.sum32_4 = sum32_4; - + function sum32_5(a, b, c, d, e) { return (a + b + c + d + e) >>> 0; } exports.sum32_5 = sum32_5; - + function sum64(buf, pos, ah, al) { var bh = buf[pos]; var bl = buf[pos + 1]; - + var lo = (al + bl) >>> 0; var hi = (lo < al ? 1 : 0) + ah + bh; buf[pos] = hi >>> 0; buf[pos + 1] = lo; } exports.sum64 = sum64; - + function sum64_hi(ah, al, bh, bl) { var lo = (al + bl) >>> 0; var hi = (lo < al ? 1 : 0) + ah + bh; return hi >>> 0; } exports.sum64_hi = sum64_hi; - + function sum64_lo(ah, al, bh, bl) { var lo = al + bl; return lo >>> 0; } exports.sum64_lo = sum64_lo; - + function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) { var carry = 0; var lo = al; @@ -35262,18 +35262,18 @@ carry += lo < cl ? 1 : 0; lo = (lo + dl) >>> 0; carry += lo < dl ? 1 : 0; - + var hi = ah + bh + ch + dh + carry; return hi >>> 0; } exports.sum64_4_hi = sum64_4_hi; - + function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) { var lo = al + bl + cl + dl; return lo >>> 0; } exports.sum64_4_lo = sum64_4_lo; - + function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { var carry = 0; var lo = al; @@ -35285,63 +35285,63 @@ carry += lo < dl ? 1 : 0; lo = (lo + el) >>> 0; carry += lo < el ? 1 : 0; - + var hi = ah + bh + ch + dh + eh + carry; return hi >>> 0; } exports.sum64_5_hi = sum64_5_hi; - + function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { var lo = al + bl + cl + dl + el; - + return lo >>> 0; } exports.sum64_5_lo = sum64_5_lo; - + function rotr64_hi(ah, al, num) { var r = (al << (32 - num)) | (ah >>> num); return r >>> 0; } exports.rotr64_hi = rotr64_hi; - + function rotr64_lo(ah, al, num) { var r = (ah << (32 - num)) | (al >>> num); return r >>> 0; } exports.rotr64_lo = rotr64_lo; - + function shr64_hi(ah, al, num) { return ah >>> num; } exports.shr64_hi = shr64_hi; - + function shr64_lo(ah, al, num) { var r = (ah << (32 - num)) | (al >>> num); return r >>> 0; } exports.shr64_lo = shr64_lo; - + },{"inherits":180,"minimalistic-assert":234}],174:[function(require,module,exports){ 'use strict'; - + var hash = require('hash.js'); var utils = require('minimalistic-crypto-utils'); var assert = require('minimalistic-assert'); - + function HmacDRBG(options) { if (!(this instanceof HmacDRBG)) return new HmacDRBG(options); this.hash = options.hash; this.predResist = !!options.predResist; - + this.outLen = this.hash.outSize; this.minEntropy = options.minEntropy || this.hash.hmacStrength; - + this._reseed = null; this.reseedInterval = null; this.K = null; this.V = null; - + var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex'); var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex'); var pers = utils.toArray(options.pers, options.persEnc || 'hex'); @@ -35350,26 +35350,26 @@ this._init(entropy, nonce, pers); } module.exports = HmacDRBG; - + HmacDRBG.prototype._init = function init(entropy, nonce, pers) { var seed = entropy.concat(nonce).concat(pers); - + this.K = new Array(this.outLen / 8); this.V = new Array(this.outLen / 8); for (var i = 0; i < this.V.length; i++) { this.K[i] = 0x00; this.V[i] = 0x01; } - + this._update(seed); this._reseed = 1; this.reseedInterval = 0x1000000000000; // 2^48 }; - + HmacDRBG.prototype._hmac = function hmac() { return new hash.hmac(this.hash, this.K); }; - + HmacDRBG.prototype._update = function update(seed) { var kmac = this._hmac() .update(this.V) @@ -35380,7 +35380,7 @@ this.V = this._hmac().update(this.V).digest(); if (!seed) return; - + this.K = this._hmac() .update(this.V) .update([ 0x01 ]) @@ -35388,7 +35388,7 @@ .digest(); this.V = this._hmac().update(this.V).digest(); }; - + HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) { // Optional entropy enc if (typeof entropyEnc !== 'string') { @@ -35396,66 +35396,66 @@ add = entropyEnc; entropyEnc = null; } - + entropy = utils.toArray(entropy, entropyEnc); add = utils.toArray(add, addEnc); - + assert(entropy.length >= (this.minEntropy / 8), 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); - + this._update(entropy.concat(add || [])); this._reseed = 1; }; - + HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { if (this._reseed > this.reseedInterval) throw new Error('Reseed is required'); - + // Optional encoding if (typeof enc !== 'string') { addEnc = add; add = enc; enc = null; } - + // Optional additional data if (add) { add = utils.toArray(add, addEnc || 'hex'); this._update(add); } - + var temp = []; while (temp.length < len) { this.V = this._hmac().update(this.V).digest(); temp = temp.concat(this.V); } - + var res = temp.slice(0, len); this._update(add); this._reseed++; return utils.encode(res, enc); }; - + },{"hash.js":162,"minimalistic-assert":234,"minimalistic-crypto-utils":235}],175:[function(require,module,exports){ var http = require('http') var url = require('url') - + var https = module.exports - + for (var key in http) { if (http.hasOwnProperty(key)) https[key] = http[key] } - + https.request = function (params, cb) { params = validateParams(params) return http.request.call(this, params, cb) } - + https.get = function (params, cb) { params = validateParams(params) return http.get.call(this, params, cb) } - + function validateParams (params) { if (typeof params === 'string') { params = url.parse(params) @@ -35468,12 +35468,12 @@ } return params } - + },{"http":312,"url":327}],176:[function(require,module,exports){ /* This file is generated from the Unicode IDNA table, using the build-unicode-tables.py script. Please edit that script instead of this file. */ - + /* istanbul ignore next */ (function (root, factory) { if (typeof define === 'function' && define.amd) { @@ -36211,7 +36211,7 @@ ]; var blockIdxes = new Uint16Array([616,616,565,147,161,411,330,2,131,131,328,454,241,408,86,86,696,113,285,350,325,301,473,214,639,232,447,64,369,598,124,672,567,223,621,154,107,86,86,86,86,86,86,505,86,68,634,86,218,218,218,218,486,218,218,513,188,608,216,86,217,463,668,85,700,360,184,86,86,86,647,402,153,10,346,718,662,260,145,298,117,1,443,342,138,54,563,86,240,572,218,70,387,86,118,460,641,602,86,86,306,218,86,692,86,86,86,86,86,162,707,86,458,26,86,218,638,86,86,86,86,86,65,449,86,86,306,183,86,58,391,667,86,157,131,131,131,131,86,433,131,406,31,218,247,86,86,693,218,581,351,86,438,295,69,462,45,126,173,650,14,295,69,97,168,187,641,78,523,390,69,108,287,664,173,219,83,295,69,108,431,426,173,694,412,115,628,52,257,398,641,118,501,121,69,579,151,423,173,620,464,121,69,382,151,476,173,27,53,121,86,594,578,226,173,86,632,130,86,96,228,268,641,622,563,86,86,21,148,650,131,131,321,43,144,343,381,531,131,131,178,20,86,399,156,375,164,541,30,60,715,198,92,118,131,131,86,86,306,407,86,280,457,196,488,358,131,131,244,86,86,143,86,86,86,86,86,667,563,86,86,86,86,86,86,86,86,86,86,86,86,86,336,363,86,86,336,86,86,380,678,67,86,86,86,678,86,86,86,512,86,307,86,708,86,86,86,86,86,528,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,563,307,86,86,86,86,86,104,450,337,86,720,86,32,450,397,86,86,86,587,218,558,708,708,293,708,86,86,86,86,86,694,205,86,8,86,86,86,86,549,86,667,697,697,679,86,458,460,86,86,650,86,708,543,86,86,86,245,86,86,86,140,218,127,708,708,458,197,131,131,131,131,500,86,86,483,251,86,306,510,515,86,722,86,86,86,65,201,86,86,483,580,470,86,86,86,368,131,131,131,694,114,110,555,86,86,123,721,163,142,713,418,86,317,675,209,218,218,218,371,545,592,629,490,603,199,46,320,525,680,310,279,388,111,42,252,593,607,235,617,410,377,50,548,135,356,17,520,189,116,392,600,349,332,482,699,690,535,119,106,451,71,152,667,131,218,218,265,671,637,492,504,533,683,269,269,658,86,86,86,86,86,86,86,86,86,491,619,86,86,6,86,86,86,86,86,86,86,86,86,86,86,229,86,86,86,86,86,86,86,86,86,86,86,86,667,86,86,171,131,118,131,656,206,234,571,89,334,670,246,311,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,534,86,86,86,86,86,86,82,86,86,86,86,86,430,86,86,86,86,86,86,86,86,86,599,86,324,86,470,69,640,264,131,626,101,174,86,86,667,233,105,73,374,394,221,204,84,28,326,86,86,471,86,86,86,109,573,86,171,200,200,200,200,218,218,86,86,86,86,460,131,131,131,86,506,86,86,86,86,86,220,404,34,614,47,442,305,25,612,338,601,648,7,344,255,131,131,51,86,312,507,563,86,86,86,86,588,86,86,86,86,86,530,511,86,458,3,435,384,556,522,230,527,86,118,86,86,717,86,137,273,79,181,484,23,93,112,655,249,417,703,370,87,98,313,684,585,155,465,596,481,695,18,416,428,61,701,706,282,643,495,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,549,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,549,131,131,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,307,86,86,86,171,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,650,131,422,542,420,263,24,172,86,86,86,86,86,566,86,86,132,540,395,353,494,519,19,485,284,472,131,131,131,16,714,86,211,708,86,86,86,694,698,86,86,483,704,708,218,272,86,86,120,86,159,478,86,307,247,86,86,663,597,459,627,667,86,86,277,455,39,302,86,250,86,86,86,271,99,452,306,281,329,400,200,86,86,362,549,352,646,461,323,586,86,86,4,708,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,717,86,518,86,86,650,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,125,554,480,300,613,72,333,288,561,544,604,48,719,91,169,176,590,224,76,191,29,559,560,231,537,166,477,538,256,437,131,131,469,167,40,0,685,266,441,705,239,642,475,568,640,610,299,673,517,318,385,22,202,180,179,359,424,215,90,66,521,653,467,682,453,409,479,88,131,661,35,303,15,262,666,630,712,131,131,618,659,175,218,195,347,193,227,261,150,165,709,546,294,569,710,270,413,376,524,55,242,38,419,529,170,657,3,304,122,379,278,131,651,86,67,576,458,458,131,131,86,86,86,86,86,86,86,118,309,86,86,547,86,86,86,86,667,650,664,131,131,86,86,56,131,131,131,131,131,131,131,131,86,307,86,86,86,664,238,650,86,86,717,86,118,86,86,315,86,59,86,86,574,549,131,131,340,57,436,86,86,86,86,86,86,458,708,499,691,62,86,650,86,86,694,86,86,86,319,131,131,131,131,131,131,131,131,131,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,171,86,549,694,131,131,131,131,131,131,131,131,131,77,86,86,139,86,502,86,86,86,667,595,131,131,131,86,12,86,13,86,609,131,131,131,131,86,86,86,625,86,669,86,86,182,129,86,5,694,104,86,86,86,86,131,131,86,86,386,171,86,86,86,345,86,324,86,589,86,213,36,131,131,131,131,131,86,86,86,86,104,131,131,131,141,290,80,677,86,86,86,267,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,86,667,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,515,86,86,33,136,669,86,711,515,86,86,550,640,86,104,708,515,86,159,372,717,86,86,444,515,86,86,663,37,86,563,460,86,390,624,702,131,131,131,131,389,59,708,86,86,341,208,708,635,295,69,108,431,508,100,190,131,131,131,131,131,131,131,131,86,86,86,649,516,660,131,131,86,86,86,218,631,708,131,131,131,131,131,131,131,131,131,131,86,86,341,575,238,514,131,131,86,86,86,218,291,708,307,131,86,86,306,367,708,131,131,131,86,378,697,86,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,615,253,86,86,86,292,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,86,86,86,104,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,69,86,341,553,549,86,307,86,86,645,275,455,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,708,131,131,131,131,131,131,86,86,86,86,86,86,667,460,86,86,86,86,86,86,86,86,86,86,86,86,717,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,667,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,171,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,104,86,667,459,131,131,131,131,131,131,86,458,225,86,86,86,516,549,11,390,405,86,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,86,86,86,86,460,44,218,197,711,515,131,131,131,131,664,131,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,307,131,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,308,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,640,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,86,86,86,86,86,86,118,307,104,286,591,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,549,86,86,681,86,86,75,185,314,582,86,358,496,474,86,104,131,86,86,86,86,146,131,131,131,131,131,131,131,131,131,131,131,86,86,86,86,86,171,86,640,131,131,131,131,131,131,131,131,246,503,689,339,674,81,258,415,439,128,562,366,414,246,503,689,583,222,557,316,636,665,186,355,95,670,246,503,689,339,674,557,258,415,439,186,355,95,670,246,503,689,446,644,536,652,331,532,335,440,274,421,297,570,74,425,364,425,606,552,403,509,134,365,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,218,218,218,498,218,218,577,627,551,497,572,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,553,354,236,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,86,86,86,86,86,86,86,86,86,86,86,86,296,455,131,131,456,243,103,86,41,459,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,9,276,158,716,393,564,383,489,401,654,210,654,131,131,131,640,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,86,86,650,86,86,86,86,86,86,717,667,563,563,563,86,549,102,686,133,246,605,86,448,86,86,207,307,131,131,131,641,86,177,611,445,373,194,584,131,131,131,131,131,131,131,131,131,131,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,308,307,171,86,86,86,86,86,86,86,717,86,86,86,86,86,460,131,131,650,86,86,86,694,708,86,86,694,86,458,131,131,131,131,131,131,667,694,289,650,667,131,131,86,640,131,131,664,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,171,131,131,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,460,86,86,86,86,86,86,86,86,86,86,86,86,86,458,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,640,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,466,203,149,429,94,432,160,687,539,63,237,283,192,248,348,259,427,526,396,676,254,468,487,212,327,623,49,633,322,493,434,688,357,361,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131]); var mappingStr = "صلى الله عليه وسلمجل جلالهキロメートルrad∕s2エスクードキログラムキロワットグラムトンクルゼイロサンチームパーセントピアストルファラッドブッシェルヘクタールマンションミリバールレントゲン′′′′1⁄10viii(10)(11)(12)(13)(14)(15)(16)(17)(18)(19)(20)∫∫∫∫(오전)(오후)アパートアルファアンペアイニングエーカーカラットカロリーキュリーギルダークローネサイクルシリングバーレルフィートポイントマイクロミクロンメガトンリットルルーブル株式会社kcalm∕s2c∕kgاكبرمحمدصلعمرسولریال1⁄41⁄23⁄4 ̈́ྲཱྀླཱྀ ̈͂ ̓̀ ̓́ ̓͂ ̔̀ ̔́ ̔͂ ̈̀‵‵‵a/ca/sc/oc/utelfax1⁄71⁄91⁄32⁄31⁄52⁄53⁄54⁄51⁄65⁄61⁄83⁄85⁄87⁄8xii0⁄3∮∮∮(1)(2)(3)(4)(5)(6)(7)(8)(9)(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)(q)(r)(s)(t)(u)(v)(w)(x)(y)(z)::====(ᄀ)(ᄂ)(ᄃ)(ᄅ)(ᄆ)(ᄇ)(ᄉ)(ᄋ)(ᄌ)(ᄎ)(ᄏ)(ᄐ)(ᄑ)(ᄒ)(가)(나)(다)(라)(마)(바)(사)(아)(자)(차)(카)(타)(파)(하)(주)(一)(二)(三)(四)(五)(六)(七)(八)(九)(十)(月)(火)(水)(木)(金)(土)(日)(株)(有)(社)(名)(特)(財)(祝)(労)(代)(呼)(学)(監)(企)(資)(協)(祭)(休)(自)(至)pte10月11月12月ergltdアールインチウォンオンスオームカイリガロンガンマギニーケースコルナコーポセンチダースノットハイツパーツピクルフランペニヒヘルツペンスページベータボルトポンドホールホーンマイルマッハマルクヤードヤールユアンルピー10点11点12点13点14点15点16点17点18点19点20点21点22点23点24点hpabardm2dm3khzmhzghzthzmm2cm2km2mm3cm3km3kpampagpalogmilmolppmv∕ma∕m10日11日12日13日14日15日16日17日18日19日20日21日22日23日24日25日26日27日28日29日30日31日galffifflשּׁשּׂ ٌّ ٍّ َّ ُّ ِّ ّٰـَّـُّـِّتجمتحجتحمتخمتمجتمحتمخجمححميحمىسحجسجحسجىسمحسمجسممصححصممشحمشجيشمخشممضحىضخمطمحطممطميعجمعممعمىغممغميغمىفخمقمحقمملحملحيلحىلججلخملمحمحجمحيمجحمجممخممجخهمجهممنحمنحىنجمنجىنمينمىيممبخيتجيتجىتخيتخىتميتمىجميجحىجمىسخىصحيشحيضحيلجيلمييحييجييميمميقمينحيعميكمينجحمخيلجمكممجحيحجيمجيفميبحيسخينجيصلےقلے𝅘𝅥𝅮𝅘𝅥𝅯𝅘𝅥𝅰𝅘𝅥𝅱𝅘𝅥𝅲𝆹𝅥𝅮𝆺𝅥𝅮𝆹𝅥𝅯𝆺𝅥𝅯〔s〕ppv〔本〕〔三〕〔二〕〔安〕〔点〕〔打〕〔盗〕〔勝〕〔敗〕 ̄ ́ ̧ssi̇ijl·ʼndžljnjdz ̆ ̇ ̊ ̨ ̃ ̋ ιեւاٴوٴۇٴيٴक़ख़ग़ज़ड़ढ़फ़य़ড়ঢ়য়ਲ਼ਸ਼ਖ਼ਗ਼ਜ਼ਫ਼ଡ଼ଢ଼ําໍາຫນຫມགྷཌྷདྷབྷཛྷཀྵཱཱིུྲྀླྀྒྷྜྷྡྷྦྷྫྷྐྵaʾἀιἁιἂιἃιἄιἅιἆιἇιἠιἡιἢιἣιἤιἥιἦιἧιὠιὡιὢιὣιὤιὥιὦιὧιὰιαιάιᾶι ͂ὴιηιήιῆιὼιωιώιῶι ̳!! ̅???!!?rs°c°fnosmtmivix⫝̸ ゙ ゚よりコト333435참고주의363738394042444546474849503月4月5月6月7月8月9月hgevギガデシドルナノピコビルペソホンリラレムdaauovpciu平成昭和大正明治naμakakbmbgbpfnfμfμgmgμlmldlklfmnmμmpsnsμsmsnvμvkvpwnwμwmwkwkωmωbqcccddbgyhainkkktlnlxphprsrsvwbstմնմեմիվնմխיִײַשׁשׂאַאָאּבּגּדּהּוּזּטּיּךּכּלּמּנּסּףּפּצּקּרּתּוֹבֿכֿפֿאלئائەئوئۇئۆئۈئېئىئجئحئمئيبجبمبىبيتىتيثجثمثىثيخحضجضمطحظمغجفجفحفىفيقحقىقيكاكجكحكخكلكىكينخنىنيهجهىهييىذٰرٰىٰئرئزئنبزبنترتزتنثرثزثنمانرنزننيريزئخئهبهتهصخنههٰثهسهشهطىطيعىعيغىغيسىسيشىشيصىصيضىضيشخشرسرصرضراً ًـًـّ ْـْلآلألإ𝅗𝅥0,1,2,3,4,5,6,7,8,9,wzhvsdwcmcmddjほかココàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįĵķĺļľłńņňŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷÿźżɓƃƅɔƈɖɗƌǝəɛƒɠɣɩɨƙɯɲɵơƣƥʀƨʃƭʈưʊʋƴƶʒƹƽǎǐǒǔǖǘǚǜǟǡǣǥǧǩǫǭǯǵƕƿǹǻǽǿȁȃȅȇȉȋȍȏȑȓȕȗșțȝȟƞȣȥȧȩȫȭȯȱȳⱥȼƚⱦɂƀʉʌɇɉɋɍɏɦɹɻʁʕͱͳʹͷ;ϳέίόύβγδεζθκλνξοπρστυφχψϊϋϗϙϛϝϟϡϣϥϧϩϫϭϯϸϻͻͼͽѐёђѓєѕіїјљњћќѝўџабвгдежзийклмнопрстуфхцчшщъыьэюяѡѣѥѧѩѫѭѯѱѳѵѷѹѻѽѿҁҋҍҏґғҕҗҙқҝҟҡңҥҧҩҫҭүұҳҵҷҹһҽҿӂӄӆӈӊӌӎӑӓӕӗәӛӝӟӡӣӥӧөӫӭӯӱӳӵӷӹӻӽӿԁԃԅԇԉԋԍԏԑԓԕԗԙԛԝԟԡԣԥԧԩԫԭԯաբգդզէըթժլծկհձղճյշոչպջռստրցփքօֆ་ⴧⴭნᏰᏱᏲᏳᏴᏵꙋɐɑᴂɜᴖᴗᴝᴥɒɕɟɡɥɪᵻʝɭᶅʟɱɰɳɴɸʂƫᴜʐʑḁḃḅḇḉḋḍḏḑḓḕḗḙḛḝḟḡḣḥḧḩḫḭḯḱḳḵḷḹḻḽḿṁṃṅṇṉṋṍṏṑṓṕṗṙṛṝṟṡṣṥṧṩṫṭṯṱṳṵṷṹṻṽṿẁẃẅẇẉẋẍẏẑẓẕạảấầẩẫậắằẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹỻỽỿἐἑἒἓἔἕἰἱἲἳἴἵἶἷὀὁὂὃὄὅὑὓὕὗᾰᾱὲΐῐῑὶΰῠῡὺῥ`ὸ‐+−∑〈〉ⰰⰱⰲⰳⰴⰵⰶⰷⰸⰹⰺⰻⰼⰽⰾⰿⱀⱁⱂⱃⱄⱅⱆⱇⱈⱉⱊⱋⱌⱍⱎⱏⱐⱑⱒⱓⱔⱕⱖⱗⱘⱙⱚⱛⱜⱝⱞⱡɫᵽɽⱨⱪⱬⱳⱶȿɀⲁⲃⲅⲇⲉⲋⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⲳⲵⲷⲹⲻⲽⲿⳁⳃⳅⳇⳉⳋⳍⳏⳑⳓⳕⳗⳙⳛⳝⳟⳡⳣⳬⳮⳳⵡ母龟丨丶丿乙亅亠人儿入冂冖冫几凵刀力勹匕匚匸卜卩厂厶又口囗士夂夊夕女子宀寸小尢尸屮山巛工己巾干幺广廴廾弋弓彐彡彳心戈戶手支攴文斗斤方无曰欠止歹殳毋比毛氏气爪父爻爿片牙牛犬玄玉瓜瓦甘生用田疋疒癶白皮皿目矛矢石示禸禾穴立竹米糸缶网羊羽老而耒耳聿肉臣臼舌舛舟艮色艸虍虫血行衣襾見角言谷豆豕豸貝赤走足身車辛辰辵邑酉釆里長門阜隶隹雨靑非面革韋韭音頁風飛食首香馬骨高髟鬥鬯鬲鬼魚鳥鹵鹿麥麻黃黍黑黹黽鼎鼓鼠鼻齊齒龍龜龠.〒卄卅ᄁᆪᆬᆭᄄᆰᆱᆲᆳᆴᆵᄚᄈᄡᄊ짜ᅢᅣᅤᅥᅦᅧᅨᅩᅪᅫᅬᅭᅮᅯᅰᅱᅲᅳᅴᅵᄔᄕᇇᇈᇌᇎᇓᇗᇙᄜᇝᇟᄝᄞᄠᄢᄣᄧᄩᄫᄬᄭᄮᄯᄲᄶᅀᅇᅌᇱᇲᅗᅘᅙᆄᆅᆈᆑᆒᆔᆞᆡ上中下甲丙丁天地問幼箏우秘男適優印注項写左右医宗夜テヌモヨヰヱヲꙁꙃꙅꙇꙉꙍꙏꙑꙓꙕꙗꙙꙛꙝꙟꙡꙣꙥꙧꙩꙫꙭꚁꚃꚅꚇꚉꚋꚍꚏꚑꚓꚕꚗꚙꚛꜣꜥꜧꜩꜫꜭꜯꜳꜵꜷꜹꜻꜽꜿꝁꝃꝅꝇꝉꝋꝍꝏꝑꝓꝕꝗꝙꝛꝝꝟꝡꝣꝥꝧꝩꝫꝭꝯꝺꝼᵹꝿꞁꞃꞅꞇꞌꞑꞓꞗꞙꞛꞝꞟꞡꞣꞥꞧꞩɬʞʇꭓꞵꞷꬷꭒᎠᎡᎢᎣᎤᎥᎦᎧᎨᎩᎪᎫᎬᎭᎮᎯᎰᎱᎲᎳᎴᎵᎶᎷᎸᎹᎺᎻᎼᎽᎾᎿᏀᏁᏂᏃᏄᏅᏆᏇᏈᏉᏊᏋᏌᏍᏎᏏᏐᏑᏒᏓᏔᏕᏖᏗᏘᏙᏚᏛᏜᏝᏞᏟᏠᏡᏢᏣᏤᏥᏦᏧᏨᏩᏪᏫᏬᏭᏮᏯ豈更賈滑串句契喇奈懶癩羅蘿螺裸邏樂洛烙珞落酪駱亂卵欄爛蘭鸞嵐濫藍襤拉臘蠟廊朗浪狼郎來冷勞擄櫓爐盧蘆虜路露魯鷺碌祿綠菉錄論壟弄籠聾牢磊賂雷壘屢樓淚漏累縷陋勒肋凜凌稜綾菱陵讀拏諾丹寧怒率異北磻便復不泌數索參塞省葉說殺沈拾若掠略亮兩凉梁糧良諒量勵呂廬旅濾礪閭驪麗黎曆歷轢年憐戀撚漣煉璉秊練聯輦蓮連鍊列劣咽烈裂廉念捻殮簾獵令囹嶺怜玲瑩羚聆鈴零靈領例禮醴隸惡了僚寮尿料燎療蓼遼暈阮劉杻柳流溜琉留硫紐類戮陸倫崙淪輪律慄栗隆利吏履易李梨泥理痢罹裏裡離匿溺吝燐璘藺隣鱗麟林淋臨笠粒狀炙識什茶刺切度拓糖宅洞暴輻降廓兀嗀塚晴凞猪益礼神祥福靖精蘒諸逸都飯飼館鶴郞隷侮僧免勉勤卑喝嘆器塀墨層悔慨憎懲敏既暑梅海渚漢煮爫琢碑祉祈祐祖禍禎穀突節縉繁署者臭艹著褐視謁謹賓贈辶難響頻恵𤋮舘並况全侀充冀勇勺啕喙嗢墳奄奔婢嬨廒廙彩徭惘慎愈慠戴揄搜摒敖望杖滛滋瀞瞧爵犯瑱甆画瘝瘟盛直睊着磌窱类絛缾荒華蝹襁覆調請諭變輸遲醙鉶陼韛頋鬒𢡊𢡄𣏕㮝䀘䀹𥉉𥳐𧻓齃龎עםٱٻپڀٺٿٹڤڦڄڃچڇڍڌڎڈژڑکگڳڱںڻۀہھۓڭۋۅۉ、〖〗—–_{}【】《》「」『』[]#&*-<>\\$%@ءؤة\"'^|~⦅⦆・ゥャ¢£¬¦¥₩│←↑→↓■○𐐨𐐩𐐪𐐫𐐬𐐭𐐮𐐯𐐰𐐱𐐲𐐳𐐴𐐵𐐶𐐷𐐸𐐹𐐺𐐻𐐼𐐽𐐾𐐿𐑀𐑁𐑂𐑃𐑄𐑅𐑆𐑇𐑈𐑉𐑊𐑋𐑌𐑍𐑎𐑏𐓘𐓙𐓚𐓛𐓜𐓝𐓞𐓟𐓠𐓡𐓢𐓣𐓤𐓥𐓦𐓧𐓨𐓩𐓪𐓫𐓬𐓭𐓮𐓯𐓰𐓱𐓲𐓳𐓴𐓵𐓶𐓷𐓸𐓹𐓺𐓻𐳀𐳁𐳂𐳃𐳄𐳅𐳆𐳇𐳈𐳉𐳊𐳋𐳌𐳍𐳎𐳏𐳐𐳑𐳒𐳓𐳔𐳕𐳖𐳗𐳘𐳙𐳚𐳛𐳜𐳝𐳞𐳟𐳠𐳡𐳢𐳣𐳤𐳥𐳦𐳧𐳨𐳩𐳪𐳫𐳬𐳭𐳮𐳯𐳰𐳱𐳲𑣀𑣁𑣂𑣃𑣄𑣅𑣆𑣇𑣈𑣉𑣊𑣋𑣌𑣍𑣎𑣏𑣐𑣑𑣒𑣓𑣔𑣕𑣖𑣗𑣘𑣙𑣚𑣛𑣜𑣝𑣞𑣟ıȷ∇∂𞤢𞤣𞤤𞤥𞤦𞤧𞤨𞤩𞤪𞤫𞤬𞤭𞤮𞤯𞤰𞤱𞤲𞤳𞤴𞤵𞤶𞤷𞤸𞤹𞤺𞤻𞤼𞤽𞤾𞤿𞥀𞥁𞥂𞥃ٮڡٯ字双多解交映無前後再新初終販声吹演投捕遊指禁空合満申割営配得可丽丸乁𠄢你侻倂偺備像㒞𠘺兔兤具𠔜㒹內𠕋冗冤仌冬𩇟刃㓟刻剆剷㔕包匆卉博即卽卿𠨬灰及叟𠭣叫叱吆咞吸呈周咢哶唐啓啣善喫喳嗂圖圗噑噴壮城埴堍型堲報墬𡓤売壷夆夢奢𡚨𡛪姬娛娧姘婦㛮嬈嬾𡧈寃寘寳𡬘寿将㞁屠峀岍𡷤嵃𡷦嵮嵫嵼巡巢㠯巽帨帽幩㡢𢆃㡼庰庳庶𪎒𢌱舁弢㣇𣊸𦇚形彫㣣徚忍志忹悁㤺㤜𢛔惇慈慌慺憲憤憯懞戛扝抱拔捐𢬌挽拼捨掃揤𢯱搢揅掩㨮摩摾撝摷㩬敬𣀊旣書晉㬙㬈㫤冒冕最暜肭䏙朡杞杓𣏃㭉柺枅桒𣑭梎栟椔楂榣槪檨𣚣櫛㰘次𣢧歔㱎歲殟殻𣪍𡴋𣫺汎𣲼沿泍汧洖派浩浸涅𣴞洴港湮㴳滇𣻑淹潮𣽞𣾎濆瀹瀛㶖灊災灷炭𠔥煅𤉣熜爨牐𤘈犀犕𤜵𤠔獺王㺬玥㺸瑇瑜璅瓊㼛甤𤰶甾𤲒𢆟瘐𤾡𤾸𥁄㿼䀈𥃳𥃲𥄙𥄳眞真瞋䁆䂖𥐝硎䃣𥘦𥚚𥛅秫䄯穊穏𥥼𥪧䈂𥮫篆築䈧𥲀糒䊠糨糣紀𥾆絣䌁緇縂繅䌴𦈨𦉇䍙𦋙罺𦌾羕翺𦓚𦔣聠𦖨聰𣍟䏕育脃䐋脾媵𦞧𦞵𣎓𣎜舄辞䑫芑芋芝劳花芳芽苦𦬼茝荣莭茣莽菧荓菊菌菜𦰶𦵫𦳕䔫蓱蓳蔖𧏊蕤𦼬䕝䕡𦾱𧃒䕫虐虧虩蚩蚈蜎蛢蜨蝫螆蟡蠁䗹衠𧙧裗裞䘵裺㒻𧢮𧥦䚾䛇誠𧲨貫賁贛起𧼯𠠄跋趼跰𠣞軔𨗒𨗭邔郱鄑𨜮鄛鈸鋗鋘鉼鏹鐕𨯺開䦕閷𨵷䧦雃嶲霣𩅅𩈚䩮䩶韠𩐊䪲𩒖頩𩖶飢䬳餩馧駂駾䯎𩬰鱀鳽䳎䳭鵧𪃎䳸𪄅𪈎𪊑䵖黾鼅鼏鼖𪘀"; - + function mapChar(codePoint) { if (codePoint >= 0x30000) { // High planes are special cased. @@ -36221,13 +36221,13 @@ } return blocks[blockIdxes[codePoint >> 4]][codePoint & 15]; } - + return { mapStr: mappingStr, mapChar: mapChar }; })); - + },{}],177:[function(require,module,exports){ (function(root, factory) { /* istanbul ignore next */ @@ -36243,7 +36243,7 @@ root.uts46 = factory(root.punycode, root.idna_map); } }(this, function(punycode, idna_map) { - + function mapLabel(label, useStd3ASCII, transitional) { var mapped = []; var chars = punycode.ucs2.decode(label); @@ -36270,20 +36270,20 @@ mapped.push(ch); } } - + var newLabel = mapped.join("").normalize("NFC"); return newLabel; } - + function process(domain, transitional, useStd3ASCII) { /* istanbul ignore if */ if (useStd3ASCII === undefined) useStd3ASCII = false; var mappedIDNA = mapLabel(domain, useStd3ASCII, transitional); - + // Step 3. Break var labels = mappedIDNA.split("."); - + // Step 4. Convert/Validate labels = labels.map(function(label) { if (label.startsWith("xn--")) { @@ -36295,37 +36295,37 @@ } return label; }); - + return labels.join("."); } - + function validateLabel(label, useStd3ASCII, transitional) { // 2. The label must not contain a U+002D HYPHEN-MINUS character in both the // third position and fourth positions. if (label[2] === '-' && label[3] === '-') throw new Error("Failed to validate " + label); - + // 3. The label must neither begin nor end with a U+002D HYPHEN-MINUS // character. if (label.startsWith('-') || label.endsWith('-')) throw new Error("Failed to validate " + label); - + // 4. The label must not contain a U+002E ( . ) FULL STOP. // this should nerver happen as label is chunked internally by this character /* istanbul ignore if */ if (label.includes('.')) throw new Error("Failed to validate " + label); - + if (mapLabel(label, useStd3ASCII, transitional) !== label) throw new Error("Failed to validate " + label); - + // 5. The label must not begin with a combining mark, that is: // General_Category=Mark. var ch = label.codePointAt(0); if (idna_map.mapChar(ch) & (0x2 << 23)) throw new Error("Label contains illegal character: " + ch); } - + function toAscii(domain, options) { if (options === undefined) options = {}; @@ -36348,20 +36348,20 @@ } return asciiString; } - + function toUnicode(domain, options) { if (options === undefined) options = {}; var useStd3ASCII = 'useStd3ASCII' in options ? options.useStd3ASCII : false; return process(domain, false, useStd3ASCII); } - + return { toUnicode: toUnicode, toAscii: toAscii, }; })); - + },{"./idna-map":176,"punycode":265}],178:[function(require,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m @@ -36372,19 +36372,19 @@ var i = isLE ? (nBytes - 1) : 0 var d = isLE ? -1 : 1 var s = buffer[offset + i] - + i += d - + e = s & ((1 << (-nBits)) - 1) s >>= (-nBits) nBits += eLen for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} - + m = e & ((1 << (-nBits)) - 1) e >>= (-nBits) nBits += mLen for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} - + if (e === 0) { e = 1 - eBias } else if (e === eMax) { @@ -36395,7 +36395,7 @@ } return (s ? -1 : 1) * m * Math.pow(2, e - mLen) } - + exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { var e, m, c var eLen = nBytes * 8 - mLen - 1 @@ -36405,9 +36405,9 @@ var i = isLE ? 0 : (nBytes - 1) var d = isLE ? 1 : -1 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 - + value = Math.abs(value) - + if (isNaN(value) || value === Infinity) { m = isNaN(value) ? 1 : 0 e = eMax @@ -36426,7 +36426,7 @@ e++ c /= 2 } - + if (e + eBias >= eMax) { m = 0 e = eMax @@ -36438,20 +36438,20 @@ e = 0 } } - + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - + e = (e << mLen) | m eLen += mLen for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - + buffer[offset + i - d] |= s * 128 } - + },{}],179:[function(require,module,exports){ - + var indexOf = [].indexOf; - + module.exports = function(arr, obj){ if (indexOf) return arr.indexOf(obj); for (var i = 0; i < arr.length; ++i) { @@ -36483,7 +36483,7 @@ ctor.prototype.constructor = ctor } } - + },{}],181:[function(require,module,exports){ /*! * Determine if an object is a Buffer @@ -36491,27 +36491,27 @@ * @author Feross Aboukhadijeh * @license MIT */ - + // The _isBuffer check is for Safari 5-7 support, because it's missing // Object.prototype.constructor. Remove this eventually module.exports = function (obj) { return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) } - + function isBuffer (obj) { return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) } - + // For Node v0.10 support. Remove this eventually. function isSlowBuffer (obj) { return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) } - + },{}],182:[function(require,module,exports){ 'use strict'; - + var fnToStr = Function.prototype.toString; - + var constructorRegex = /^\s*class\b/; var isES6ClassFn = function isES6ClassFunction(value) { try { @@ -36521,7 +36521,7 @@ return false; // not a function } }; - + var tryFunctionObject = function tryFunctionToStr(value) { try { if (isES6ClassFn(value)) { return false; } @@ -36535,7 +36535,7 @@ var fnClass = '[object Function]'; var genClass = '[object GeneratorFunction]'; var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; - + module.exports = function isCallable(value) { if (!value) { return false; } if (typeof value !== 'function' && typeof value !== 'object') { return false; } @@ -36545,20 +36545,20 @@ var strClass = toStr.call(value); return strClass === fnClass || strClass === genClass; }; - + },{}],183:[function(require,module,exports){ 'use strict'; var toString = Object.prototype.toString; - + module.exports = function (x) { return toString.call(x) === '[object Function]'; }; - + },{}],184:[function(require,module,exports){ module.exports = isFunction - + var toString = Object.prototype.toString - + function isFunction (fn) { var string = toString.call(fn) return string === '[object Function]' || @@ -36570,7 +36570,7 @@ fn === window.confirm || fn === window.prompt)) }; - + },{}],185:[function(require,module,exports){ /** * Returns a `Boolean` on whether or not the a `String` starts with '0x' @@ -36582,26 +36582,26 @@ if (typeof str !== 'string') { throw new Error("[is-hex-prefixed] value must be type 'string', is currently type " + (typeof str) + ", while checking isHexPrefixed."); } - + return str.slice(0, 2) === '0x'; } - + },{}],186:[function(require,module,exports){ var toString = {}.toString; - + module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; - + },{}],187:[function(require,module,exports){ 'use strict'; - + function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } - + var promiseToCallback = require('promise-to-callback'); - + module.exports = createAsyncMiddleware; - + function createAsyncMiddleware(asyncMiddleware) { return function (req, res, next, end) { var getNextPromise = function () { @@ -36613,10 +36613,10 @@ nextDonePromise = getNextDoneCallback(); _context.next = 3; return nextDonePromise; - + case 3: return _context.abrupt('return', undefined); - + case 4: case 'end': return _context.stop(); @@ -36624,12 +36624,12 @@ } }, _callee, this); })); - + return function getNextPromise() { return _ref.apply(this, arguments); }; }(); - + var nextDonePromise = null; var finishedPromise = asyncMiddleware(req, res, getNextPromise); promiseToCallback(finishedPromise)(function (err) { @@ -36650,7 +36650,7 @@ end(err); } }); - + function getNextDoneCallback() { return new Promise(function (resolve) { next(function (cb) { @@ -36660,37 +36660,37 @@ } }; } - + },{"promise-to-callback":258}],188:[function(require,module,exports){ 'use strict'; - + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - + function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - + function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - + var async = require('async'); var SafeEventEmitter = require('safe-event-emitter'); - + var RpcEngine = function (_SafeEventEmitter) { _inherits(RpcEngine, _SafeEventEmitter); - + function RpcEngine() { _classCallCheck(this, RpcEngine); - + var _this = _possibleConstructorReturn(this, (RpcEngine.__proto__ || Object.getPrototypeOf(RpcEngine)).call(this)); - + _this._middleware = []; return _this; } - + // // Public // - + _createClass(RpcEngine, [{ key: 'push', value: function push(middleware) { @@ -36706,11 +36706,11 @@ this._handle(req, cb); } } - + // // Private // - + }, { key: '_handle', value: function _handle(_req, cb) { @@ -36730,18 +36730,18 @@ key: '_runMiddleware', value: function _runMiddleware(req, res, onDone) { var _this2 = this; - + // flow async.waterfall([function (cb) { return _this2._runMiddlewareDown(req, res, cb); }, checkForCompletion, function (returnHandlers, cb) { return _this2._runReturnHandlersUp(returnHandlers, cb); }], onDone); - + function checkForCompletion(_ref, cb) { var isComplete = _ref.isComplete, returnHandlers = _ref.returnHandlers; - + // fail if not completed if (!('result' in res) && !('error' in res)) { var requestBody = JSON.stringify(req, null, 2); @@ -36756,16 +36756,16 @@ // continue return cb(null, returnHandlers); } - + function runReturnHandlers(returnHandlers, cb) { async.eachSeries(returnHandlers, function (handler, next) { return handler(next); }, onDone); } } - + // walks down stack of middleware - + }, { key: '_runMiddlewareDown', value: function _runMiddlewareDown(req, res, onDone) { @@ -36773,17 +36773,17 @@ var allReturnHandlers = []; // flag for stack return var isComplete = false; - + // down stack of middleware, call and collect optional allReturnHandlers async.mapSeries(this._middleware, eachMiddleware, completeRequest); - + // runs an individual middleware function eachMiddleware(middleware, cb) { // skip middleware if completed if (isComplete) return cb(); // run individual middleware middleware(req, res, next, end); - + function next(returnHandler) { // add return handler allReturnHandlers.push(returnHandler); @@ -36796,7 +36796,7 @@ cb(); } } - + // returns, indicating whether or not it ended function completeRequest(err) { if (err) { @@ -36811,9 +36811,9 @@ onDone(null, { isComplete: isComplete, returnHandlers: returnHandlers }); } } - + // climbs the stack calling return handlers - + }, { key: '_runReturnHandlersUp', value: function _runReturnHandlersUp(returnHandlers, cb) { @@ -36822,133 +36822,133 @@ }, cb); } }]); - + return RpcEngine; }(SafeEventEmitter); - + module.exports = RpcEngine; - + },{"async":21,"safe-event-emitter":291}],189:[function(require,module,exports){ module.exports = require('./lib/errors'); },{"./lib/errors":190}],190:[function(require,module,exports){ var inherits = require('inherits'); - + var JsonRpcError = function(message, code, data) { if (!(this instanceof JsonRpcError)) { return new JsonRpcError(message, code, data); } - + this.message = message; this.code = code; - + if (typeof data !== 'undefined') { this.data = data; } }; - + inherits(JsonRpcError, Error); - + var ParseError = function() { if (!(this instanceof ParseError)) { return new ParseError(); } - + JsonRpcError.call(this, 'Parse error', -32700); }; - + inherits(ParseError, JsonRpcError); - + var InvalidRequest = function() { if (!(this instanceof InvalidRequest)) { return new InvalidRequest(); } - + JsonRpcError.call(this, 'Invalid Request', -32600); }; - + inherits(InvalidRequest, JsonRpcError); - + var MethodNotFound = function() { if (!(this instanceof MethodNotFound)) { return new MethodNotFound(); } - + JsonRpcError.call(this, 'Method not found', -32601); }; - + inherits(MethodNotFound, JsonRpcError); - + var InvalidParams = function() { if (!(this instanceof InvalidParams)) { return new InvalidParams(); } - + JsonRpcError.call(this, 'Invalid params', -32602); }; - + inherits(InvalidParams, JsonRpcError); - + var InternalError = function(err) { var message; - + if (!(this instanceof InternalError)) { return new InternalError(err); } - + if (err && err.message) { message = err.message; } else { message = 'Internal error'; } - + JsonRpcError.call(this, message, -32603); }; - + inherits(InternalError, JsonRpcError); - + var ServerError = function(code) { if (code < -32099 || code > -32000) { throw new Error('Invalid error code'); } - + if (!(this instanceof ServerError)) { return new ServerError(code); } - + JsonRpcError.call(this, 'Server error', code); }; - + inherits(ServerError, JsonRpcError); - + JsonRpcError.ParseError = ParseError; JsonRpcError.InvalidRequest = InvalidRequest; JsonRpcError.MethodNotFound = MethodNotFound; JsonRpcError.InvalidParams = InvalidParams; JsonRpcError.InternalError = InternalError; JsonRpcError.ServerError = ServerError; - + module.exports = JsonRpcError; - - - + + + },{"inherits":180}],191:[function(require,module,exports){ module.exports = IdIterator - + function IdIterator(opts){ opts = opts || {} var max = opts.max || Number.MAX_SAFE_INTEGER var idCounter = typeof opts.start !== 'undefined' ? opts.start : Math.floor(Math.random() * max) - + return function createRandomId () { idCounter = idCounter % max return idCounter++ } - + } },{}],192:[function(require,module,exports){ exports.parse = require('./lib/parse'); exports.stringify = require('./lib/stringify'); - + },{"./lib/parse":193,"./lib/stringify":194}],193:[function(require,module,exports){ var at, // The index of the current character ch, // The current character @@ -36963,7 +36963,7 @@ t: '\t' }, text, - + error = function (m) { // Call error when something is wrong. throw { @@ -36973,26 +36973,26 @@ text: text }; }, - + next = function (c) { // If a c parameter is provided, verify that it matches the current character. if (c && c !== ch) { error("Expected '" + c + "' instead of '" + ch + "'"); } - + // Get the next character. When there are no more characters, // return the empty string. - + ch = text.charAt(at); at += 1; return ch; }, - + number = function () { // Parse a number value. var number, string = ''; - + if (ch === '-') { string = '-'; next('-'); @@ -37026,14 +37026,14 @@ return number; } }, - + string = function () { // Parse a string value. var hex, i, string = '', uffff; - + // When parsing for string values, we must look for " and \ characters. if (ch === '"') { while (next()) { @@ -37064,20 +37064,20 @@ } error("Bad string"); }, - + white = function () { - + // Skip whitespace. - + while (ch && ch <= ' ') { next(); } }, - + word = function () { - + // true, false, or null. - + switch (ch) { case 't': next('t'); @@ -37101,15 +37101,15 @@ } error("Unexpected '" + ch + "'"); }, - + value, // Place holder for the value function. - + array = function () { - + // Parse an array value. - + var array = []; - + if (ch === '[') { next('['); white(); @@ -37130,14 +37130,14 @@ } error("Bad array"); }, - + object = function () { - + // Parse an object value. - + var key, object = {}; - + if (ch === '{') { next('{'); white(); @@ -37164,12 +37164,12 @@ } error("Bad object"); }; - + value = function () { - + // Parse a JSON value. It could be an object, an array, a string, a number, // or a word. - + white(); switch (ch) { case '{': @@ -37184,13 +37184,13 @@ return ch >= '0' && ch <= '9' ? number() : word(); } }; - + // Return the json_parse function. It will have access to all of the above // functions and variables. - + module.exports = function (source, reviver) { var result; - + text = source; at = 0; ch = ' '; @@ -37199,13 +37199,13 @@ if (ch) { error("Syntax error"); } - + // If there is a reviver function, we recursively walk the new structure, // passing each name/value pair to the reviver function for possible // transformation, starting with a temporary root object that holds the result // in an empty key. If there is not a reviver function, we simply return the // result. - + return typeof reviver === 'function' ? (function walk(holder, key) { var k, v, value = holder[key]; if (value && typeof value === 'object') { @@ -37223,7 +37223,7 @@ return reviver.call(holder, key, value); }({'': result}, '')) : result; }; - + },{}],194:[function(require,module,exports){ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, @@ -37239,13 +37239,13 @@ '\\': '\\\\' }, rep; - + function quote(string) { // If the string contains no control characters, no quote characters, and no // backslash characters, then we can safely slap some quotes around it. // Otherwise we must also replace the offending characters with safe escape // sequences. - + escapable.lastIndex = 0; return escapable.test(string) ? '"' + string.replace(escapable, function (a) { var c = meta[a]; @@ -37253,7 +37253,7 @@ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }) + '"' : '"' + string + '"'; } - + function str(key, holder) { // Produce a string from holder[key]. var i, // The loop counter. @@ -37263,47 +37263,47 @@ mind = gap, partial, value = holder[key]; - + // If the value has a toJSON method, call it to obtain a replacement value. if (value && typeof value === 'object' && typeof value.toJSON === 'function') { value = value.toJSON(key); } - + // If we were called with a replacer function, then call the replacer to // obtain a replacement value. if (typeof rep === 'function') { value = rep.call(holder, key, value); } - + // What happens next depends on the value's type. switch (typeof value) { case 'string': return quote(value); - + case 'number': // JSON numbers must be finite. Encode non-finite numbers as null. return isFinite(value) ? String(value) : 'null'; - + case 'boolean': case 'null': // If the value is a boolean or null, convert it to a string. Note: // typeof null does not produce 'null'. The case is included here in // the remote chance that this gets fixed someday. return String(value); - + case 'object': if (!value) return 'null'; gap += indent; partial = []; - + // Array.isArray if (Object.prototype.toString.apply(value) === '[object Array]') { length = value.length; for (i = 0; i < length; i += 1) { partial[i] = str(i, value) || 'null'; } - + // Join all of the elements together, separated with commas, and // wrap them in brackets. v = partial.length === 0 ? '[]' : gap ? @@ -37312,7 +37312,7 @@ gap = mind; return v; } - + // If the replacer is an array, use it to select the members to be // stringified. if (rep && typeof rep === 'object') { @@ -37338,10 +37338,10 @@ } } } - + // Join all of the member texts together, separated with commas, // and wrap them in braces. - + v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : '{' + partial.join(',') + '}'; @@ -37349,12 +37349,12 @@ return v; } } - + module.exports = function (value, replacer, space) { var i; gap = ''; indent = ''; - + // If the space parameter is a number, make an indent string containing that // many spaces. if (typeof space === 'number') { @@ -37366,7 +37366,7 @@ else if (typeof space === 'string') { indent = space; } - + // If there is a replacer, it must be a function or an array. // Otherwise, throw an error. rep = replacer; @@ -37374,25 +37374,25 @@ && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) { throw new Error('JSON.stringify'); } - + // Make a fake root object containing our value under the key of ''. // Return the result of stringifying the value. return str('', {'': value}); }; - + },{}],195:[function(require,module,exports){ 'use strict' module.exports = require('./lib/api')(require('./lib/keccak')) - + },{"./lib/api":196,"./lib/keccak":200}],196:[function(require,module,exports){ 'use strict' var createKeccak = require('./keccak') var createShake = require('./shake') - + module.exports = function (KeccakState) { var Keccak = createKeccak(KeccakState) var Shake = createShake(KeccakState) - + return function (algorithm, options) { var hash = typeof algorithm === 'string' ? algorithm.toLowerCase() : algorithm switch (hash) { @@ -37400,43 +37400,43 @@ case 'keccak256': return new Keccak(1088, 512, null, 256, options) case 'keccak384': return new Keccak(832, 768, null, 384, options) case 'keccak512': return new Keccak(576, 1024, null, 512, options) - + case 'sha3-224': return new Keccak(1152, 448, 0x06, 224, options) case 'sha3-256': return new Keccak(1088, 512, 0x06, 256, options) case 'sha3-384': return new Keccak(832, 768, 0x06, 384, options) case 'sha3-512': return new Keccak(576, 1024, 0x06, 512, options) - + case 'shake128': return new Shake(1344, 256, 0x1f, options) case 'shake256': return new Shake(1088, 512, 0x1f, options) - + default: throw new Error('Invald algorithm: ' + algorithm) } } } - + },{"./keccak":197,"./shake":198}],197:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer var Transform = require('stream').Transform var inherits = require('inherits') - + module.exports = function (KeccakState) { function Keccak (rate, capacity, delimitedSuffix, hashBitLength, options) { Transform.call(this, options) - + this._rate = rate this._capacity = capacity this._delimitedSuffix = delimitedSuffix this._hashBitLength = hashBitLength this._options = options - + this._state = new KeccakState() this._state.initialize(rate, capacity) this._finalized = false } - + inherits(Keccak, Transform) - + Keccak.prototype._transform = function (chunk, encoding, callback) { var error = null try { @@ -37444,10 +37444,10 @@ } catch (err) { error = err } - + callback(error) } - + Keccak.prototype._flush = function (callback) { var error = null try { @@ -37455,73 +37455,73 @@ } catch (err) { error = err } - + callback(error) } - + Keccak.prototype.update = function (data, encoding) { if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer') if (this._finalized) throw new Error('Digest already called') if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding) - + this._state.absorb(data) - + return this } - + Keccak.prototype.digest = function (encoding) { if (this._finalized) throw new Error('Digest already called') this._finalized = true - + if (this._delimitedSuffix) this._state.absorbLastFewBits(this._delimitedSuffix) var digest = this._state.squeeze(this._hashBitLength / 8) if (encoding !== undefined) digest = digest.toString(encoding) - + this._resetState() - + return digest } - + // remove result from memory Keccak.prototype._resetState = function () { this._state.initialize(this._rate, this._capacity) return this } - + // because sometimes we need hash right now and little later Keccak.prototype._clone = function () { var clone = new Keccak(this._rate, this._capacity, this._delimitedSuffix, this._hashBitLength, this._options) this._state.copy(clone._state) clone._finalized = this._finalized - + return clone } - + return Keccak } - + },{"inherits":180,"safe-buffer":290,"stream":311}],198:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer var Transform = require('stream').Transform var inherits = require('inherits') - + module.exports = function (KeccakState) { function Shake (rate, capacity, delimitedSuffix, options) { Transform.call(this, options) - + this._rate = rate this._capacity = capacity this._delimitedSuffix = delimitedSuffix this._options = options - + this._state = new KeccakState() this._state.initialize(rate, capacity) this._finalized = false } - + inherits(Shake, Transform) - + Shake.prototype._transform = function (chunk, encoding, callback) { var error = null try { @@ -37529,58 +37529,58 @@ } catch (err) { error = err } - + callback(error) } - + Shake.prototype._flush = function () {} - + Shake.prototype._read = function (size) { this.push(this.squeeze(size)) } - + Shake.prototype.update = function (data, encoding) { if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer') if (this._finalized) throw new Error('Squeeze already called') if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding) - + this._state.absorb(data) - + return this } - + Shake.prototype.squeeze = function (dataByteLength, encoding) { if (!this._finalized) { this._finalized = true this._state.absorbLastFewBits(this._delimitedSuffix) } - + var data = this._state.squeeze(dataByteLength) if (encoding !== undefined) data = data.toString(encoding) - + return data } - + Shake.prototype._resetState = function () { this._state.initialize(this._rate, this._capacity) return this } - + Shake.prototype._clone = function () { var clone = new Shake(this._rate, this._capacity, this._delimitedSuffix, this._options) this._state.copy(clone._state) clone._finalized = this._finalized - + return clone } - + return Shake } - + },{"inherits":180,"safe-buffer":290,"stream":311}],199:[function(require,module,exports){ 'use strict' var P1600_ROUND_CONSTANTS = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648] - + exports.p1600 = function (s) { for (var round = 0; round < 24; ++round) { // theta @@ -37594,7 +37594,7 @@ var hi3 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47] var lo4 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48] var hi4 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49] - + var lo = lo4 ^ (lo1 << 1 | hi1 >>> 31) var hi = hi4 ^ (hi1 << 1 | lo1 >>> 31) var t1slo0 = s[0] ^ lo @@ -37655,7 +37655,7 @@ var t1shi19 = s[39] ^ hi var t1slo24 = s[48] ^ lo var t1shi24 = s[49] ^ hi - + // rho & pi var t2slo0 = t1slo0 var t2shi0 = t1shi0 @@ -37707,7 +37707,7 @@ var t2shi13 = (t1shi19 << 8 | t1slo19 >>> 24) var t2slo4 = (t1slo24 << 14 | t1shi24 >>> 18) var t2shi4 = (t1shi24 << 14 | t1slo24 >>> 18) - + // chi s[0] = t2slo0 ^ (~t2slo1 & t2slo2) s[1] = t2shi0 ^ (~t2shi1 & t2shi2) @@ -37759,18 +37759,18 @@ s[39] = t2shi19 ^ (~t2shi15 & t2shi16) s[48] = t2slo24 ^ (~t2slo20 & t2slo21) s[49] = t2shi24 ^ (~t2shi20 & t2shi21) - + // iota s[0] ^= P1600_ROUND_CONSTANTS[round * 2] s[1] ^= P1600_ROUND_CONSTANTS[round * 2 + 1] } } - + },{}],200:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer var keccakState = require('./keccak-state-unroll') - + function Keccak () { // much faster than `new Array(50)` this.state = [ @@ -37780,19 +37780,19 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] - + this.blockSize = null this.count = 0 this.squeezing = false } - + Keccak.prototype.initialize = function (rate, capacity) { for (var i = 0; i < 50; ++i) this.state[i] = 0 this.blockSize = rate / 8 this.count = 0 this.squeezing = false } - + Keccak.prototype.absorb = function (data) { for (var i = 0; i < data.length; ++i) { this.state[~~(this.count / 4)] ^= data[i] << (8 * (this.count % 4)) @@ -37803,7 +37803,7 @@ } } } - + Keccak.prototype.absorbLastFewBits = function (bits) { this.state[~~(this.count / 4)] ^= bits << (8 * (this.count % 4)) if ((bits & 0x80) !== 0 && this.count === (this.blockSize - 1)) keccakState.p1600(this.state) @@ -37812,10 +37812,10 @@ this.count = 0 this.squeezing = true } - + Keccak.prototype.squeeze = function (length) { if (!this.squeezing) this.absorbLastFewBits(0x01) - + var output = Buffer.alloc(length) for (var i = 0; i < length; ++i) { output[i] = (this.state[~~(this.count / 4)] >>> (8 * (this.count % 4))) & 0xff @@ -37825,27 +37825,27 @@ this.count = 0 } } - + return output } - + Keccak.prototype.copy = function (dest) { for (var i = 0; i < 50; ++i) dest.state[i] = this.state[i] dest.blockSize = this.blockSize dest.count = this.count dest.squeezing = this.squeezing } - + module.exports = Keccak - + },{"./keccak-state-unroll":199,"safe-buffer":290}],201:[function(require,module,exports){ var root = require('./_root'); - + /** Built-in value references. */ var Symbol = root.Symbol; - + module.exports = Symbol; - + },{"./_root":217}],202:[function(require,module,exports){ var baseTimes = require('./_baseTimes'), isArguments = require('./isArguments'), @@ -37853,13 +37853,13 @@ isBuffer = require('./isBuffer'), isIndex = require('./_isIndex'), isTypedArray = require('./isTypedArray'); - + /** Used for built-in method references. */ var objectProto = Object.prototype; - + /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; - + /** * Creates an array of the enumerable property names of the array-like `value`. * @@ -37876,7 +37876,7 @@ skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; - + for (var key in value) { if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && ( @@ -37894,21 +37894,21 @@ } return result; } - + module.exports = arrayLikeKeys; - + },{"./_baseTimes":207,"./_isIndex":211,"./isArguments":219,"./isArray":220,"./isBuffer":222,"./isTypedArray":227}],203:[function(require,module,exports){ var Symbol = require('./_Symbol'), getRawTag = require('./_getRawTag'), objectToString = require('./_objectToString'); - + /** `Object#toString` result references. */ var nullTag = '[object Null]', undefinedTag = '[object Undefined]'; - + /** Built-in value references. */ var symToStringTag = Symbol ? Symbol.toStringTag : undefined; - + /** * The base implementation of `getTag` without fallbacks for buggy environments. * @@ -37924,16 +37924,16 @@ ? getRawTag(value) : objectToString(value); } - + module.exports = baseGetTag; - + },{"./_Symbol":201,"./_getRawTag":210,"./_objectToString":215}],204:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isObjectLike = require('./isObjectLike'); - + /** `Object#toString` result references. */ var argsTag = '[object Arguments]'; - + /** * The base implementation of `_.isArguments`. * @@ -37944,14 +37944,14 @@ function baseIsArguments(value) { return isObjectLike(value) && baseGetTag(value) == argsTag; } - + module.exports = baseIsArguments; - + },{"./_baseGetTag":203,"./isObjectLike":226}],205:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isLength = require('./isLength'), isObjectLike = require('./isObjectLike'); - + /** `Object#toString` result references. */ var argsTag = '[object Arguments]', arrayTag = '[object Array]', @@ -37966,7 +37966,7 @@ setTag = '[object Set]', stringTag = '[object String]', weakMapTag = '[object WeakMap]'; - + var arrayBufferTag = '[object ArrayBuffer]', dataViewTag = '[object DataView]', float32Tag = '[object Float32Array]', @@ -37978,7 +37978,7 @@ uint8ClampedTag = '[object Uint8ClampedArray]', uint16Tag = '[object Uint16Array]', uint32Tag = '[object Uint32Array]'; - + /** Used to identify `toStringTag` values of typed arrays. */ var typedArrayTags = {}; typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = @@ -37994,7 +37994,7 @@ typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; - + /** * The base implementation of `_.isTypedArray` without Node.js optimizations. * @@ -38006,19 +38006,19 @@ return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; } - + module.exports = baseIsTypedArray; - + },{"./_baseGetTag":203,"./isLength":224,"./isObjectLike":226}],206:[function(require,module,exports){ var isPrototype = require('./_isPrototype'), nativeKeys = require('./_nativeKeys'); - + /** Used for built-in method references. */ var objectProto = Object.prototype; - + /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; - + /** * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. * @@ -38038,9 +38038,9 @@ } return result; } - + module.exports = baseKeys; - + },{"./_isPrototype":212,"./_nativeKeys":213}],207:[function(require,module,exports){ /** * The base implementation of `_.times` without support for iteratee shorthands @@ -38054,15 +38054,15 @@ function baseTimes(n, iteratee) { var index = -1, result = Array(n); - + while (++index < n) { result[index] = iteratee(index); } return result; } - + module.exports = baseTimes; - + },{}],208:[function(require,module,exports){ /** * The base implementation of `_.unary` without support for storing metadata. @@ -38076,36 +38076,36 @@ return func(value); }; } - + module.exports = baseUnary; - + },{}],209:[function(require,module,exports){ (function (global){ /** Detect free variable `global` from Node.js. */ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - + module.exports = freeGlobal; - + }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],210:[function(require,module,exports){ var Symbol = require('./_Symbol'); - + /** Used for built-in method references. */ var objectProto = Object.prototype; - + /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; - + /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var nativeObjectToString = objectProto.toString; - + /** Built-in value references. */ var symToStringTag = Symbol ? Symbol.toStringTag : undefined; - + /** * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. * @@ -38116,12 +38116,12 @@ function getRawTag(value) { var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag]; - + try { value[symToStringTag] = undefined; var unmasked = true; } catch (e) {} - + var result = nativeObjectToString.call(value); if (unmasked) { if (isOwn) { @@ -38132,16 +38132,16 @@ } return result; } - + module.exports = getRawTag; - + },{"./_Symbol":201}],211:[function(require,module,exports){ /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; - + /** Used to detect unsigned integer values. */ var reIsUint = /^(?:0|[1-9]\d*)$/; - + /** * Checks if `value` is a valid array-like index. * @@ -38156,13 +38156,13 @@ (typeof value == 'number' || reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length); } - + module.exports = isIndex; - + },{}],212:[function(require,module,exports){ /** Used for built-in method references. */ var objectProto = Object.prototype; - + /** * Checks if `value` is likely a prototype object. * @@ -38173,55 +38173,55 @@ function isPrototype(value) { var Ctor = value && value.constructor, proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; - + return value === proto; } - + module.exports = isPrototype; - + },{}],213:[function(require,module,exports){ var overArg = require('./_overArg'); - + /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeKeys = overArg(Object.keys, Object); - + module.exports = nativeKeys; - + },{"./_overArg":216}],214:[function(require,module,exports){ var freeGlobal = require('./_freeGlobal'); - + /** Detect free variable `exports`. */ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; - + /** Detect free variable `module`. */ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; - + /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; - + /** Detect free variable `process` from Node.js. */ var freeProcess = moduleExports && freeGlobal.process; - + /** Used to access faster Node.js helpers. */ var nodeUtil = (function() { try { return freeProcess && freeProcess.binding && freeProcess.binding('util'); } catch (e) {} }()); - + module.exports = nodeUtil; - + },{"./_freeGlobal":209}],215:[function(require,module,exports){ /** Used for built-in method references. */ var objectProto = Object.prototype; - + /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var nativeObjectToString = objectProto.toString; - + /** * Converts `value` to a string using `Object.prototype.toString`. * @@ -38232,9 +38232,9 @@ function objectToString(value) { return nativeObjectToString.call(value); } - + module.exports = objectToString; - + },{}],216:[function(require,module,exports){ /** * Creates a unary function that invokes `func` with its argument transformed. @@ -38249,20 +38249,20 @@ return func(transform(arg)); }; } - + module.exports = overArg; - + },{}],217:[function(require,module,exports){ var freeGlobal = require('./_freeGlobal'); - + /** Detect free variable `self`. */ var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - + /** Used as a reference to the global object. */ var root = freeGlobal || freeSelf || Function('return this')(); - + module.exports = root; - + },{"./_freeGlobal":209}],218:[function(require,module,exports){ /** * Creates a function that returns `value`. @@ -38288,22 +38288,22 @@ return value; }; } - + module.exports = constant; - + },{}],219:[function(require,module,exports){ var baseIsArguments = require('./_baseIsArguments'), isObjectLike = require('./isObjectLike'); - + /** Used for built-in method references. */ var objectProto = Object.prototype; - + /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; - + /** Built-in value references. */ var propertyIsEnumerable = objectProto.propertyIsEnumerable; - + /** * Checks if `value` is likely an `arguments` object. * @@ -38326,9 +38326,9 @@ return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); }; - + module.exports = isArguments; - + },{"./_baseIsArguments":204,"./isObjectLike":226}],220:[function(require,module,exports){ /** * Checks if `value` is classified as an `Array` object. @@ -38354,13 +38354,13 @@ * // => false */ var isArray = Array.isArray; - + module.exports = isArray; - + },{}],221:[function(require,module,exports){ var isFunction = require('./isFunction'), isLength = require('./isLength'); - + /** * Checks if `value` is array-like. A value is considered array-like if it's * not a function and has a `value.length` that's an integer greater than or @@ -38389,28 +38389,28 @@ function isArrayLike(value) { return value != null && isLength(value.length) && !isFunction(value); } - + module.exports = isArrayLike; - + },{"./isFunction":223,"./isLength":224}],222:[function(require,module,exports){ var root = require('./_root'), stubFalse = require('./stubFalse'); - + /** Detect free variable `exports`. */ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; - + /** Detect free variable `module`. */ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; - + /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; - + /** Built-in value references. */ var Buffer = moduleExports ? root.Buffer : undefined; - + /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; - + /** * Checks if `value` is a buffer. * @@ -38429,19 +38429,19 @@ * // => false */ var isBuffer = nativeIsBuffer || stubFalse; - + module.exports = isBuffer; - + },{"./_root":217,"./stubFalse":230}],223:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isObject = require('./isObject'); - + /** `Object#toString` result references. */ var asyncTag = '[object AsyncFunction]', funcTag = '[object Function]', genTag = '[object GeneratorFunction]', proxyTag = '[object Proxy]'; - + /** * Checks if `value` is classified as a `Function` object. * @@ -38468,13 +38468,13 @@ var tag = baseGetTag(value); return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; } - + module.exports = isFunction; - + },{"./_baseGetTag":203,"./isObject":225}],224:[function(require,module,exports){ /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; - + /** * Checks if `value` is a valid array-like length. * @@ -38505,9 +38505,9 @@ return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; } - + module.exports = isLength; - + },{}],225:[function(require,module,exports){ /** * Checks if `value` is the @@ -38538,9 +38538,9 @@ var type = typeof value; return value != null && (type == 'object' || type == 'function'); } - + module.exports = isObject; - + },{}],226:[function(require,module,exports){ /** * Checks if `value` is object-like. A value is object-like if it's not `null` @@ -38569,17 +38569,17 @@ function isObjectLike(value) { return value != null && typeof value == 'object'; } - + module.exports = isObjectLike; - + },{}],227:[function(require,module,exports){ var baseIsTypedArray = require('./_baseIsTypedArray'), baseUnary = require('./_baseUnary'), nodeUtil = require('./_nodeUtil'); - + /* Node.js helper references. */ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; - + /** * Checks if `value` is classified as a typed array. * @@ -38598,14 +38598,14 @@ * // => false */ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; - + module.exports = isTypedArray; - + },{"./_baseIsTypedArray":205,"./_baseUnary":208,"./_nodeUtil":214}],228:[function(require,module,exports){ var arrayLikeKeys = require('./_arrayLikeKeys'), baseKeys = require('./_baseKeys'), isArrayLike = require('./isArrayLike'); - + /** * Creates an array of the own enumerable property names of `object`. * @@ -38637,9 +38637,9 @@ function keys(object) { return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); } - + module.exports = keys; - + },{"./_arrayLikeKeys":202,"./_baseKeys":206,"./isArrayLike":221}],229:[function(require,module,exports){ /** * This method returns `undefined`. @@ -38656,9 +38656,9 @@ function noop() { // No operation performed. } - + module.exports = noop; - + },{}],230:[function(require,module,exports){ /** * This method returns `false`. @@ -38676,38 +38676,38 @@ function stubFalse() { return false; } - + module.exports = stubFalse; - + },{}],231:[function(require,module,exports){ (function (Buffer){ 'use strict' var inherits = require('inherits') var HashBase = require('hash-base') - + var ARRAY16 = new Array(16) - + function MD5 () { HashBase.call(this, 64) - + // state this._a = 0x67452301 this._b = 0xefcdab89 this._c = 0x98badcfe this._d = 0x10325476 } - + inherits(MD5, HashBase) - + MD5.prototype._update = function () { var M = ARRAY16 for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4) - + var a = this._a var b = this._b var c = this._c var d = this._d - + a = fnF(a, b, c, d, M[0], 0xd76aa478, 7) d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12) c = fnF(c, d, a, b, M[2], 0x242070db, 17) @@ -38724,7 +38724,7 @@ d = fnF(d, a, b, c, M[13], 0xfd987193, 12) c = fnF(c, d, a, b, M[14], 0xa679438e, 17) b = fnF(b, c, d, a, M[15], 0x49b40821, 22) - + a = fnG(a, b, c, d, M[1], 0xf61e2562, 5) d = fnG(d, a, b, c, M[6], 0xc040b340, 9) c = fnG(c, d, a, b, M[11], 0x265e5a51, 14) @@ -38741,7 +38741,7 @@ d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9) c = fnG(c, d, a, b, M[7], 0x676f02d9, 14) b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20) - + a = fnH(a, b, c, d, M[5], 0xfffa3942, 4) d = fnH(d, a, b, c, M[8], 0x8771f681, 11) c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16) @@ -38758,7 +38758,7 @@ d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11) c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16) b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23) - + a = fnI(a, b, c, d, M[0], 0xf4292244, 6) d = fnI(d, a, b, c, M[7], 0x432aff97, 10) c = fnI(c, d, a, b, M[14], 0xab9423a7, 15) @@ -38775,13 +38775,13 @@ d = fnI(d, a, b, c, M[11], 0xbd3af235, 10) c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15) b = fnI(b, c, d, a, M[9], 0xeb86d391, 21) - + this._a = (this._a + a) | 0 this._b = (this._b + b) | 0 this._c = (this._c + c) | 0 this._d = (this._d + d) | 0 } - + MD5.prototype._digest = function () { // create padding and handle blocks this._block[this._blockOffset++] = 0x80 @@ -38790,12 +38790,12 @@ this._update() this._blockOffset = 0 } - + this._block.fill(0, this._blockOffset, 56) this._block.writeUInt32LE(this._length[0], 56) this._block.writeUInt32LE(this._length[1], 60) this._update() - + // produce result var buffer = new Buffer(16) buffer.writeInt32LE(this._a, 0) @@ -38804,55 +38804,55 @@ buffer.writeInt32LE(this._d, 12) return buffer } - + function rotl (x, n) { return (x << n) | (x >>> (32 - n)) } - + function fnF (a, b, c, d, m, k, s) { return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 0 } - + function fnG (a, b, c, d, m, k, s) { return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 0 } - + function fnH (a, b, c, d, m, k, s) { return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 0 } - + function fnI (a, b, c, d, m, k, s) { return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 0 } - + module.exports = MD5 - + }).call(this,require("buffer").Buffer) },{"buffer":84,"hash-base":232,"inherits":180}],232:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer var Transform = require('stream').Transform var inherits = require('inherits') - + function throwIfNotStringOrBuffer (val, prefix) { if (!Buffer.isBuffer(val) && typeof val !== 'string') { throw new TypeError(prefix + ' must be a string or a buffer') } } - + function HashBase (blockSize) { Transform.call(this) - + this._block = Buffer.allocUnsafe(blockSize) this._blockSize = blockSize this._blockOffset = 0 this._length = [0, 0, 0, 0] - + this._finalized = false } - + inherits(HashBase, Transform) - + HashBase.prototype._transform = function (chunk, encoding, callback) { var error = null try { @@ -38860,10 +38860,10 @@ } catch (err) { error = err } - + callback(error) } - + HashBase.prototype._flush = function (callback) { var error = null try { @@ -38871,15 +38871,15 @@ } catch (err) { error = err } - + callback(error) } - + HashBase.prototype.update = function (data, encoding) { throwIfNotStringOrBuffer(data, 'Data') if (this._finalized) throw new Error('Digest already called') if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding) - + // consume data var block = this._block var offset = 0 @@ -38889,177 +38889,177 @@ this._blockOffset = 0 } while (offset < data.length) block[this._blockOffset++] = data[offset++] - + // update length for (var j = 0, carry = data.length * 8; carry > 0; ++j) { this._length[j] += carry carry = (this._length[j] / 0x0100000000) | 0 if (carry > 0) this._length[j] -= 0x0100000000 * carry } - + return this } - + HashBase.prototype._update = function () { throw new Error('_update is not implemented') } - + HashBase.prototype.digest = function (encoding) { if (this._finalized) throw new Error('Digest already called') this._finalized = true - + var digest = this._digest() if (encoding !== undefined) digest = digest.toString(encoding) - + // reset state this._block.fill(0) this._blockOffset = 0 for (var i = 0; i < 4; ++i) this._length[i] = 0 - + return digest } - + HashBase.prototype._digest = function () { throw new Error('_digest is not implemented') } - + module.exports = HashBase - + },{"inherits":180,"safe-buffer":290,"stream":311}],233:[function(require,module,exports){ var bn = require('bn.js'); var brorand = require('brorand'); - + function MillerRabin(rand) { this.rand = rand || new brorand.Rand(); } module.exports = MillerRabin; - + MillerRabin.create = function create(rand) { return new MillerRabin(rand); }; - + MillerRabin.prototype._randbelow = function _randbelow(n) { var len = n.bitLength(); var min_bytes = Math.ceil(len / 8); - + // Generage random bytes until a number less than n is found. // This ensures that 0..n-1 have an equal probability of being selected. do var a = new bn(this.rand.generate(min_bytes)); while (a.cmp(n) >= 0); - + return a; }; - + MillerRabin.prototype._randrange = function _randrange(start, stop) { // Generate a random number greater than or equal to start and less than stop. var size = stop.sub(start); return start.add(this._randbelow(size)); }; - + MillerRabin.prototype.test = function test(n, k, cb) { var len = n.bitLength(); var red = bn.mont(n); var rone = new bn(1).toRed(red); - + if (!k) k = Math.max(1, (len / 48) | 0); - + // Find d and s, (n - 1) = (2 ^ s) * d; var n1 = n.subn(1); for (var s = 0; !n1.testn(s); s++) {} var d = n.shrn(s); - + var rn1 = n1.toRed(red); - + var prime = true; for (; k > 0; k--) { var a = this._randrange(new bn(2), n1); if (cb) cb(a); - + var x = a.toRed(red).redPow(d); if (x.cmp(rone) === 0 || x.cmp(rn1) === 0) continue; - + for (var i = 1; i < s; i++) { x = x.redSqr(); - + if (x.cmp(rone) === 0) return false; if (x.cmp(rn1) === 0) break; } - + if (i === s) return false; } - + return prime; }; - + MillerRabin.prototype.getDivisor = function getDivisor(n, k) { var len = n.bitLength(); var red = bn.mont(n); var rone = new bn(1).toRed(red); - + if (!k) k = Math.max(1, (len / 48) | 0); - + // Find d and s, (n - 1) = (2 ^ s) * d; var n1 = n.subn(1); for (var s = 0; !n1.testn(s); s++) {} var d = n.shrn(s); - + var rn1 = n1.toRed(red); - + for (; k > 0; k--) { var a = this._randrange(new bn(2), n1); - + var g = n.gcd(a); if (g.cmpn(1) !== 0) return g; - + var x = a.toRed(red).redPow(d); if (x.cmp(rone) === 0 || x.cmp(rn1) === 0) continue; - + for (var i = 1; i < s; i++) { x = x.redSqr(); - + if (x.cmp(rone) === 0) return x.fromRed().subn(1).gcd(n); if (x.cmp(rn1) === 0) break; } - + if (i === s) { x = x.redSqr(); return x.fromRed().subn(1).gcd(n); } } - + return false; }; - + },{"bn.js":53,"brorand":54}],234:[function(require,module,exports){ module.exports = assert; - + function assert(val, msg) { if (!val) throw new Error(msg || 'Assertion failed'); } - + assert.equal = function assertEqual(l, r, msg) { if (l != r) throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); }; - + },{}],235:[function(require,module,exports){ 'use strict'; - + var utils = exports; - + function toArray(msg, enc) { if (Array.isArray(msg)) return msg.slice(); @@ -39091,7 +39091,7 @@ return res; } utils.toArray = toArray; - + function zero2(word) { if (word.length === 1) return '0' + word; @@ -39099,7 +39099,7 @@ return word; } utils.zero2 = zero2; - + function toHex(msg) { var res = ''; for (var i = 0; i < msg.length; i++) @@ -39107,20 +39107,20 @@ return res; } utils.toHex = toHex; - + utils.encode = function encode(arr, enc) { if (enc === 'hex') return toHex(arr); else return arr; }; - + },{}],236:[function(require,module,exports){ arguments[4][154][0].apply(exports,arguments) },{"dup":154}],237:[function(require,module,exports){ var BN = require('bn.js'); var stripHexPrefix = require('strip-hex-prefix'); - + /** * Returns a BN object, converts a number value to a BN * @param {String|Number|Object} `arg` input a string number, hex string number, number, BigNumber or BN object @@ -39138,13 +39138,13 @@ multiplier = new BN(-1, 10); } stringArg = stringArg === '' ? '0' : stringArg; - + if ((!stringArg.match(/^-?[0-9]+$/) && stringArg.match(/^[0-9A-Fa-f]+$/)) || stringArg.match(/^[a-fA-F]+$/) || (isHexPrefixed === true && stringArg.match(/^[0-9A-Fa-f]+$/))) { return new BN(stringArg, 16).mul(multiplier); } - + if ((stringArg.match(/^-?[0-9]+$/) || stringArg === '') && isHexPrefixed === false) { return new BN(stringArg, 10).mul(multiplier); } @@ -39153,46 +39153,46 @@ return new BN(arg.toString(10), 10); } } - + throw new Error('[number-to-bn] while converting number ' + JSON.stringify(arg) + ' to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.'); } - + },{"bn.js":236,"strip-hex-prefix":318}],238:[function(require,module,exports){ /* object-assign (c) Sindre Sorhus @license MIT */ - + 'use strict'; /* eslint-disable no-unused-vars */ var getOwnPropertySymbols = Object.getOwnPropertySymbols; var hasOwnProperty = Object.prototype.hasOwnProperty; var propIsEnumerable = Object.prototype.propertyIsEnumerable; - + function toObject(val) { if (val === null || val === undefined) { throw new TypeError('Object.assign cannot be called with null or undefined'); } - + return Object(val); } - + function shouldUseNative() { try { if (!Object.assign) { return false; } - + // Detect buggy property enumeration order in older V8 versions. - + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers test1[5] = 'de'; if (Object.getOwnPropertyNames(test1)[0] === '5') { return false; } - + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 var test2 = {}; for (var i = 0; i < 10; i++) { @@ -39204,7 +39204,7 @@ if (order2.join('') !== '0123456789') { return false; } - + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 var test3 = {}; 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { @@ -39214,28 +39214,28 @@ 'abcdefghijklmnopqrst') { return false; } - + return true; } catch (err) { // We don't expect any of the above to throw, but better to be safe. return false; } } - + module.exports = shouldUseNative() ? Object.assign : function (target, source) { var from; var to = toObject(target); var symbols; - + for (var s = 1; s < arguments.length; s++) { from = Object(arguments[s]); - + for (var key in from) { if (hasOwnProperty.call(from, key)) { to[key] = from[key]; } } - + if (getOwnPropertySymbols) { symbols = getOwnPropertySymbols(from); for (var i = 0; i < symbols.length; i++) { @@ -39245,36 +39245,36 @@ } } } - + return to; }; - + },{}],239:[function(require,module,exports){ // This file is the concatenation of many js files. // See http://github.com/jimhigson/oboe.js for the raw source - + // having a local undefined, window, Object etc allows slightly better minification: (function (window, Object, Array, Error, JSON, undefined ) { - + // v2.1.3 - + /* - + Copyright (c) 2013, Jim Higson - + All rights reserved. - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A @@ -39286,66 +39286,66 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + */ - - /** + + /** * Partially complete a function. - * + * * var add3 = partialComplete( function add(a,b){return a+b}, 3 ); - * + * * add3(4) // gives 7 - * + * * function wrap(left, right, cen){return left + " " + cen + " " + right;} - * + * * var pirateGreeting = partialComplete( wrap , "I'm", ", a mighty pirate!" ); - * - * pirateGreeting("Guybrush Threepwood"); + * + * pirateGreeting("Guybrush Threepwood"); * // gives "I'm Guybrush Threepwood, a mighty pirate!" */ var partialComplete = varArgs(function( fn, args ) { - + // this isn't the shortest way to write this but it does // avoid creating a new array each time to pass to fn.apply, - // otherwise could just call boundArgs.concat(callArgs) - + // otherwise could just call boundArgs.concat(callArgs) + var numBoundArgs = args.length; - + return varArgs(function( callArgs ) { - + for (var i = 0; i < callArgs.length; i++) { args[numBoundArgs + i] = callArgs[i]; } - - args.length = numBoundArgs + callArgs.length; - + + args.length = numBoundArgs + callArgs.length; + return fn.apply(this, args); - }); + }); }), - + /** * Compose zero or more functions: - * + * * compose(f1, f2, f3)(x) = f1(f2(f3(x)))) - * + * * The last (inner-most) function may take more than one parameter: - * + * * compose(f1, f2, f3)(x,y) = f1(f2(f3(x,y)))) */ compose = varArgs(function(fns) { - + var fnsList = arrayAsList(fns); - - function next(params, curFn) { - return [apply(params, curFn)]; + + function next(params, curFn) { + return [apply(params, curFn)]; } - + return varArgs(function(startParams){ - + return foldR(next, startParams, fnsList)[0]; }); }); - + /** * A more optimised version of compose that takes exactly two functions * @param f1 @@ -39356,141 +39356,141 @@ return f1.call(this,f2.apply(this,arguments)); } } - + /** * Generic form for a function to get a property from an object - * + * * var o = { * foo:'bar' * } - * + * * var getFoo = attr('foo') - * + * * fetFoo(o) // returns 'bar' - * + * * @param {String} key the property name */ function attr(key) { return function(o) { return o[key]; }; } - + /** - * Call a list of functions with the same args until one returns a + * Call a list of functions with the same args until one returns a * truthy result. Similar to the || operator. - * + * * So: * lazyUnion([f1,f2,f3 ... fn])( p1, p2 ... pn ) - * - * Is equivalent to: - * apply([p1, p2 ... pn], f1) || - * apply([p1, p2 ... pn], f2) || - * apply([p1, p2 ... pn], f3) ... apply(fn, [p1, p2 ... pn]) - * + * + * Is equivalent to: + * apply([p1, p2 ... pn], f1) || + * apply([p1, p2 ... pn], f2) || + * apply([p1, p2 ... pn], f3) ... apply(fn, [p1, p2 ... pn]) + * * @returns the first return value that is given that is truthy. */ var lazyUnion = varArgs(function(fns) { - + return varArgs(function(params){ - + var maybeValue; - + for (var i = 0; i < len(fns); i++) { - + maybeValue = apply(params, fns[i]); - + if( maybeValue ) { return maybeValue; } } }); - }); - + }); + /** * This file declares various pieces of functional programming. - * + * * This isn't a general purpose functional library, to keep things small it * has just the parts useful for Oboe.js. */ - - + + /** * Call a single function with the given arguments array. - * Basically, a functional-style version of the OO-style Function#apply for + * Basically, a functional-style version of the OO-style Function#apply for * when we don't care about the context ('this') of the call. - * + * * The order of arguments allows partial completion of the arguments array */ function apply(args, fn) { return fn.apply(undefined, args); } - + /** - * Define variable argument functions but cut out all that tedious messing about + * Define variable argument functions but cut out all that tedious messing about * with the arguments object. Delivers the variable-length part of the arguments * list as an array. - * + * * Eg: - * + * * var myFunction = varArgs( * function( fixedArgument, otherFixedArgument, variableNumberOfArguments ){ * console.log( variableNumberOfArguments ); * } * ) - * + * * myFunction('a', 'b', 1, 2, 3); // logs [1,2,3] - * + * * var myOtherFunction = varArgs(function( variableNumberOfArguments ){ * console.log( variableNumberOfArguments ); * }) - * + * * myFunction(1, 2, 3); // logs [1,2,3] - * + * */ function varArgs(fn){ - + var numberOfFixedArguments = fn.length -1, - slice = Array.prototype.slice; - - + slice = Array.prototype.slice; + + if( numberOfFixedArguments == 0 ) { - // an optimised case for when there are no fixed args: - + // an optimised case for when there are no fixed args: + return function(){ return fn.call(this, slice.call(arguments)); } - + } else if( numberOfFixedArguments == 1 ) { // an optimised case for when there are is one fixed args: - + return function(){ return fn.call(this, arguments[0], slice.call(arguments, 1)); } } - - // general case - + + // general case + // we know how many arguments fn will always take. Create a // fixed-size array to hold that many, to be re-used on // every call to the returned function - var argsHolder = Array(fn.length); - + var argsHolder = Array(fn.length); + return function(){ - + for (var i = 0; i < numberOfFixedArguments; i++) { - argsHolder[i] = arguments[i]; + argsHolder[i] = arguments[i]; } - - argsHolder[numberOfFixedArguments] = + + argsHolder[numberOfFixedArguments] = slice.call(arguments, numberOfFixedArguments); - - return fn.apply( this, argsHolder); - } + + return fn.apply( this, argsHolder); + } } - - + + /** * Swap the order of parameters to a binary function - * + * * A bit like this flip: http://zvon.org/other/haskell/Outputprelude/flip_f.html */ function flip(fn){ @@ -39498,38 +39498,38 @@ return fn(b,a); } } - - + + /** * Create a function which is the intersection of two other functions. - * + * * Like the && operator, if the first is truthy, the second is never called, * otherwise the return value from the second is returned. */ function lazyIntersection(fn1, fn2) { - + return function (param) { - + return fn1(param) && fn2(param); - }; + }; } - + /** * A function which does nothing */ function noop(){} - + /** * A function which is always happy */ function always(){return true} - + /** * Create a function which always returns the same * value - * + * * var return3 = functor(3); - * + * * return3() // gives 3 * return3() // still gives 3 * return3() // will always give 3 @@ -39539,58 +39539,58 @@ return val; } } - + /** - * This file defines some loosely associated syntactic sugar for - * Javascript programming + * This file defines some loosely associated syntactic sugar for + * Javascript programming */ - - + + /** * Returns true if the given candidate is of type T */ function isOfType(T, maybeSomething){ return maybeSomething && maybeSomething.constructor === T; } - - var len = attr('length'), + + var len = attr('length'), isString = partialComplete(isOfType, String); - - /** + + /** * I don't like saying this: - * + * * foo !=== undefined - * + * * because of the double-negative. I find this: - * + * * defined(foo) - * + * * easier to read. - */ + */ function defined( value ) { return value !== undefined; } - + /** - * Returns true if object o has a key named like every property in - * the properties array. Will give false if any are missing, or if o + * Returns true if object o has a key named like every property in + * the properties array. Will give false if any are missing, or if o * is not an object. */ function hasAllProperties(fieldList, o) { - - return (o instanceof Object) + + return (o instanceof Object) && - all(function (field) { - return (field in o); + all(function (field) { + return (field in o); }, fieldList); } /** * Like cons in Lisp */ function cons(x, xs) { - + /* Internally lists are linked 2-element Javascript arrays. - + Ideally the return here would be Object.freeze([x,xs]) so that bugs related to mutation are found fast. However, cons is right on the critical path for @@ -39600,218 +39600,218 @@ run faster) this should be considered for restoration. */ - + return [x,xs]; } - + /** * The empty list */ var emptyList = null, - + /** * Get the head of a list. - * + * * Ie, head(cons(a,b)) = a */ head = attr(0), - + /** * Get the tail of a list. - * + * * Ie, tail(cons(a,b)) = b */ tail = attr(1); - - - /** - * Converts an array to a list - * + + + /** + * Converts an array to a list + * * asList([a,b,c]) - * + * * is equivalent to: - * - * cons(a, cons(b, cons(c, emptyList))) + * + * cons(a, cons(b, cons(c, emptyList))) **/ function arrayAsList(inputArray){ - - return reverseList( + + return reverseList( inputArray.reduce( flip(cons), - emptyList + emptyList ) ); } - + /** * A varargs version of arrayAsList. Works a bit like list * in LISP. - * - * list(a,b,c) - * + * + * list(a,b,c) + * * is equivalent to: - * + * * cons(a, cons(b, cons(c, emptyList))) */ var list = varArgs(arrayAsList); - + /** * Convert a list back to a js native array */ function listAsArray(list){ - + return foldR( function(arraySoFar, listItem){ - + arraySoFar.unshift(listItem); return arraySoFar; - + }, [], list ); - + } - + /** - * Map a function over a list + * Map a function over a list */ function map(fn, list) { - + return list ? cons(fn(head(list)), map(fn,tail(list))) : emptyList ; } - + /** * foldR implementation. Reduce a list down to a single value. - * - * @pram {Function} fn (rightEval, curVal) -> result + * + * @pram {Function} fn (rightEval, curVal) -> result */ function foldR(fn, startValue, list) { - - return list + + return list ? fn(foldR(fn, startValue, tail(list)), head(list)) : startValue ; } - + /** * foldR implementation. Reduce a list down to a single value. - * - * @pram {Function} fn (rightEval, curVal) -> result + * + * @pram {Function} fn (rightEval, curVal) -> result */ function foldR1(fn, list) { - - return tail(list) + + return tail(list) ? fn(foldR1(fn, tail(list)), head(list)) : head(list) ; } - - + + /** - * Return a list like the one given but with the first instance equal - * to item removed + * Return a list like the one given but with the first instance equal + * to item removed */ function without(list, test, removedFn) { - + return withoutInner(list, removedFn || noop); - + function withoutInner(subList, removedFn) { - return subList - ? ( test(head(subList)) - ? (removedFn(head(subList)), tail(subList)) + return subList + ? ( test(head(subList)) + ? (removedFn(head(subList)), tail(subList)) : cons(head(subList), withoutInner(tail(subList), removedFn)) ) : emptyList ; - } + } } - - /** - * Returns true if the given function holds for every item in - * the list, false otherwise + + /** + * Returns true if the given function holds for every item in + * the list, false otherwise */ function all(fn, list) { - - return !list || + + return !list || ( fn(head(list)) && all(fn, tail(list)) ); } - + /** * Call every function in a list of functions with the same arguments - * - * This doesn't make any sense if we're doing pure functional because + * + * This doesn't make any sense if we're doing pure functional because * it doesn't return anything. Hence, this is only really useful if the - * functions being called have side-effects. + * functions being called have side-effects. */ function applyEach(fnList, args) { - - if( fnList ) { + + if( fnList ) { head(fnList).apply(null, args); - + applyEach(tail(fnList), args); } } - + /** * Reverse the order of a list */ - function reverseList(list){ - + function reverseList(list){ + // js re-implementation of 3rd solution from: // http://www.haskell.org/haskellwiki/99_questions/Solutions/5 function reverseInner( list, reversedAlready ) { if( !list ) { return reversedAlready; } - + return reverseInner(tail(list), cons(head(list), reversedAlready)) } - + return reverseInner(list, emptyList); } - + function first(test, list) { return list && - (test(head(list)) - ? head(list) - : first(test,tail(list))); - } - - /* - This is a slightly hacked-up browser only version of clarinet - - * some features removed to help keep browser Oboe under + (test(head(list)) + ? head(list) + : first(test,tail(list))); + } + + /* + This is a slightly hacked-up browser only version of clarinet + + * some features removed to help keep browser Oboe under the 5k micro-library limit * plug directly into event bus - + For the original go here: https://github.com/dscape/clarinet - + We receive the events: STREAM_DATA STREAM_END - + We emit the events: SAX_KEY SAX_VALUE_OPEN - SAX_VALUE_CLOSE - FAIL_EVENT + SAX_VALUE_CLOSE + FAIL_EVENT */ - + function clarinet(eventBus) { "use strict"; - - var + + var // shortcut some events on the bus emitSaxKey = eventBus(SAX_KEY).emit, emitValueOpen = eventBus(SAX_VALUE_OPEN).emit, emitValueClose = eventBus(SAX_VALUE_CLOSE).emit, emitFail = eventBus(FAIL_EVENT).emit, - + MAX_BUFFER_LENGTH = 64 * 1024 , stringTokenPattern = /[\\"\n]/g , _n = 0 - + // states , BEGIN = _n++ , VALUE = _n++ // general stuff @@ -39834,14 +39834,14 @@ , NULL3 = _n++ // l , NUMBER_DECIMAL_POINT = _n++ // . , NUMBER_DIGIT = _n // [0-9] - + // setup initial parser values , bufferCheckPosition = MAX_BUFFER_LENGTH - , latestError - , c - , p + , latestError + , c + , p , textNode = undefined - , numberNode = "" + , numberNode = "" , slashed = false , closed = false , state = BEGIN @@ -39853,11 +39853,11 @@ , column = 0 //mostly for error reporting , line = 1 ; - + function checkBufferLength () { - + var maxActual = 0; - + if (textNode !== undefined && textNode.length > MAX_BUFFER_LENGTH) { emitError("Max buffer length exceeded: textNode"); maxActual = Math.max(maxActual, textNode.length); @@ -39866,104 +39866,104 @@ emitError("Max buffer length exceeded: numberNode"); maxActual = Math.max(maxActual, numberNode.length); } - + bufferCheckPosition = (MAX_BUFFER_LENGTH - maxActual) + position; } - + eventBus(STREAM_DATA).on(handleData); - - /* At the end of the http content close the clarinet - This will provide an error if the total content provided was not + + /* At the end of the http content close the clarinet + This will provide an error if the total content provided was not valid json, ie if not all arrays, objects and Strings closed properly */ - eventBus(STREAM_END).on(handleStreamEnd); - + eventBus(STREAM_END).on(handleStreamEnd); + function emitError (errorString) { if (textNode !== undefined) { emitValueOpen(textNode); emitValueClose(); textNode = undefined; } - + latestError = Error(errorString + "\nLn: "+line+ "\nCol: "+column+ "\nChr: "+c); - + emitFail(errorReport(undefined, undefined, latestError)); } - + function handleStreamEnd() { if( state == BEGIN ) { // Handle the case where the stream closes without ever receiving // any input. This isn't an error - response bodies can be blank, // particularly for 204 http responses - + // Because of how Oboe is currently implemented, we parse a // completely empty stream as containing an empty object. // This is because Oboe's done event is only fired when the // root object of the JSON stream closes. - + // This should be decoupled and attached instead to the input stream // from the http (or whatever) resource ending. // If this decoupling could happen the SAX parser could simply emit // zero events on a completely empty input. emitValueOpen({}); emitValueClose(); - + closed = true; return; } - + if (state !== VALUE || depth !== 0) emitError("Unexpected end"); - + if (textNode !== undefined) { emitValueOpen(textNode); emitValueClose(); textNode = undefined; } - + closed = true; } - + function whitespace(c){ return c == '\r' || c == '\n' || c == ' ' || c == '\t'; } - + function handleData (chunk) { - + // this used to throw the error but inside Oboe we will have already // gotten the error when it was emitted. The important thing is to // not continue with the parse. if (latestError) return; - + if (closed) { return emitError("Cannot write after close"); } - + var i = 0; - c = chunk[0]; - + c = chunk[0]; + while (c) { p = c; c = chunk[i++]; if(!c) break; - + position ++; if (c == "\n") { line ++; column = 0; } else column ++; switch (state) { - + case BEGIN: if (c === "{") state = OPEN_OBJECT; else if (c === "[") state = OPEN_ARRAY; else if (!whitespace(c)) return emitError("Non-whitespace before {[."); continue; - + case OPEN_KEY: case OPEN_OBJECT: if (whitespace(c)) continue; @@ -39981,15 +39981,15 @@ else return emitError("Malformed object key should start with \" "); continue; - + case CLOSE_KEY: case CLOSE_OBJECT: if (whitespace(c)) continue; - + if(c===':') { if(state === CLOSE_OBJECT) { stack.push(CLOSE_OBJECT); - + if (textNode !== undefined) { // was previously (in upstream Clarinet) one event // - object open came with the text of the first @@ -40023,16 +40023,16 @@ textNode = undefined; } state = OPEN_KEY; - } else + } else return emitError('Bad object'); continue; - + case OPEN_ARRAY: // after an array there always a value case VALUE: if (whitespace(c)) continue; if(state===OPEN_ARRAY) { emitValueOpen([]); - depth++; + depth++; state = VALUE; if(c === ']') { emitValueClose(); @@ -40057,10 +40057,10 @@ } else if('123456789'.indexOf(c) !== -1) { numberNode += c; state = NUMBER_DIGIT; - } else + } else return emitError("Bad value"); continue; - + case CLOSE_ARRAY: if(c===',') { stack.push(CLOSE_ARRAY); @@ -40081,20 +40081,20 @@ state = stack.pop() || VALUE; } else if (whitespace(c)) continue; - else + else return emitError('Bad array'); continue; - + case STRING: if (textNode === undefined) { textNode = ""; } - + // thanks thejh, this is an about 50% performance improvement. var starti = i-1; - + STRING_BIGLOOP: while (true) { - + // zero means "no unicode active". 1-4 mean "parse some more". end after 4. while (unicodeI > 0) { unicodeS += c; @@ -40140,7 +40140,7 @@ if (!c) break; else continue; } - + stringTokenPattern.lastIndex = i; var reResult = stringTokenPattern.exec(chunk); if (!reResult) { @@ -40156,21 +40156,21 @@ } } continue; - + case TRUE: if (!c) continue; // strange buffers if (c==='r') state = TRUE2; else return emitError( 'Invalid true started with t'+ c); continue; - + case TRUE2: if (!c) continue; if (c==='u') state = TRUE3; else return emitError('Invalid true started with tr'+ c); continue; - + case TRUE3: if (!c) continue; if(c==='e') { @@ -40180,28 +40180,28 @@ } else return emitError('Invalid true started with tru'+ c); continue; - + case FALSE: if (!c) continue; if (c==='a') state = FALSE2; else return emitError('Invalid false started with f'+ c); continue; - + case FALSE2: if (!c) continue; if (c==='l') state = FALSE3; else return emitError('Invalid false started with fa'+ c); continue; - + case FALSE3: if (!c) continue; if (c==='s') state = FALSE4; else return emitError('Invalid false started with fal'+ c); continue; - + case FALSE4: if (!c) continue; if (c==='e') { @@ -40211,39 +40211,39 @@ } else return emitError('Invalid false started with fals'+ c); continue; - + case NULL: if (!c) continue; if (c==='u') state = NULL2; else return emitError('Invalid null started with n'+ c); continue; - + case NULL2: if (!c) continue; if (c==='l') state = NULL3; else return emitError('Invalid null started with nu'+ c); continue; - + case NULL3: if (!c) continue; if(c==='l') { emitValueOpen(null); emitValueClose(); state = stack.pop() || VALUE; - } else + } else return emitError('Invalid null started with nul'+ c); continue; - + case NUMBER_DECIMAL_POINT: if(c==='.') { numberNode += c; state = NUMBER_DIGIT; - } else + } else return emitError('Leading zero not followed by .'); continue; - + case NUMBER_DIGIT: if('0123456789'.indexOf(c) !== -1) numberNode += c; else if (c==='.') { @@ -40269,7 +40269,7 @@ state = stack.pop() || VALUE; } continue; - + default: return emitError("Unknown state: " + state); } @@ -40278,72 +40278,72 @@ checkBufferLength(); } } - - - /** + + + /** * A bridge used to assign stateless functions to listen to clarinet. - * + * * As well as the parameter from clarinet, each callback will also be passed * the result of the last callback. - * + * * This may also be used to clear all listeners by assigning zero handlers: - * + * * ascentManager( clarinet, {} ) */ function ascentManager(oboeBus, handlers){ "use strict"; - + var listenerId = {}, ascent; - + function stateAfter(handler) { return function(param){ ascent = handler( ascent, param); } } - + for( var eventName in handlers ) { - + oboeBus(eventName).on(stateAfter(handlers[eventName]), listenerId); } - + oboeBus(NODE_SWAP).on(function(newNode) { - + var oldHead = head(ascent), key = keyOf(oldHead), ancestors = tail(ascent), parentNode; - + if( ancestors ) { parentNode = nodeOf(head(ancestors)); parentNode[key] = newNode; } }); - + oboeBus(NODE_DROP).on(function() { - + var oldHead = head(ascent), key = keyOf(oldHead), ancestors = tail(ascent), parentNode; - + if( ancestors ) { parentNode = nodeOf(head(ancestors)); - + delete parentNode[key]; } }); - + oboeBus(ABORTING).on(function(){ - + for( var eventName in handlers ) { oboeBus(eventName).un(listenerId); } - }); + }); } - + // based on gist https://gist.github.com/monsur/706839 - + /** * XmlHttpRequest's getAllResponseHeaders() method returns a string of response * headers according to the format described here: @@ -40352,33 +40352,33 @@ */ function parseResponseHeaders(headerStr) { var headers = {}; - + headerStr && headerStr.split('\u000d\u000a') .forEach(function(headerPair){ - + // Can't use split() here because it does the wrong thing // if the header value has the string ": " in it. var index = headerPair.indexOf('\u003a\u0020'); - - headers[headerPair.substring(0, index)] + + headers[headerPair.substring(0, index)] = headerPair.substring(index + 2); }); - + return headers; } - + /** * Detect if a given URL is cross-origin in the scope of the * current page. - * + * * Browser only (since cross-origin has no meaning in Node.js) * * @param {Object} pageLocation - as in window.location - * @param {Object} ajaxHost - an object like window.location describing the + * @param {Object} ajaxHost - an object like window.location describing the * origin of the url that we want to ajax in */ function isCrossOrigin(pageLocation, ajaxHost) { - + /* * NB: defaultPort only knows http and https. * Returns undefined otherwise. @@ -40386,65 +40386,65 @@ function defaultPort(protocol) { return {'http:':80, 'https:':443}[protocol]; } - + function portOf(location) { // pageLocation should always have a protocol. ajaxHost if no port or // protocol is specified, should use the port of the containing page - + return location.port || defaultPort(location.protocol||pageLocation.protocol); } - + // if ajaxHost doesn't give a domain, port is the same as pageLocation // it can't give a protocol but not a domain // it can't give a port but not a domain - + return !!( (ajaxHost.protocol && (ajaxHost.protocol != pageLocation.protocol)) || (ajaxHost.host && (ajaxHost.host != pageLocation.host)) || (ajaxHost.host && (portOf(ajaxHost) != portOf(pageLocation))) ); } - + /* turn any url into an object like window.location */ function parseUrlOrigin(url) { // url could be domain-relative // url could give a domain - + // cross origin means: // same domain // same port // some protocol - // so, same everything up to the first (single) slash + // so, same everything up to the first (single) slash // if such is given // - // can ignore everything after that - + // can ignore everything after that + var URL_HOST_PATTERN = /(\w+:)?(?:\/\/)([\w.-]+)?(?::(\d+))?\/?/, - + // if no match, use an empty array so that // subexpressions 1,2,3 are all undefined // and will ultimately return all empty // strings as the parse result: urlHostMatch = URL_HOST_PATTERN.exec(url) || []; - + return { protocol: urlHostMatch[1] || '', host: urlHostMatch[2] || '', port: urlHostMatch[3] || '' }; } - + function httpTransport(){ return new XMLHttpRequest(); } - + /** - * A wrapper around the browser XmlHttpRequest object that raises an + * A wrapper around the browser XmlHttpRequest object that raises an * event whenever a new part of the response is available. - * - * In older browsers progressive reading is impossible so all the + * + * In older browsers progressive reading is impossible so all the * content is given in a single call. For newer ones several events * should be raised, allowing progressive interpretation of the response. - * + * * @param {Function} oboeBus an event bus local to this Oboe instance * @param {XMLHttpRequest} xhr the xhr to use as the transport. Under normal * operation, will have been created using httpTransport() above @@ -40456,61 +40456,61 @@ * @param {Object} [headers] the http request headers to send * @param {boolean} withCredentials the XHR withCredentials property will be * set to this value - */ + */ function streamingHttp(oboeBus, xhr, method, url, data, headers, withCredentials) { - + "use strict"; - + var emitStreamData = oboeBus(STREAM_DATA).emit, emitFail = oboeBus(FAIL_EVENT).emit, numberOfCharsAlreadyGivenToCallback = 0, stillToSendStartEvent = true; - - // When an ABORTING message is put on the event bus abort - // the ajax request + + // When an ABORTING message is put on the event bus abort + // the ajax request oboeBus( ABORTING ).on( function(){ - - // if we keep the onreadystatechange while aborting the XHR gives + + // if we keep the onreadystatechange while aborting the XHR gives // a callback like a successful call so first remove this listener // by assigning null: xhr.onreadystatechange = null; - + xhr.abort(); }); - - /** + + /** * Handle input from the underlying xhr: either a state change, * the progress event or the request being complete. */ function handleProgress() { - + var textSoFar = xhr.responseText, newText = textSoFar.substr(numberOfCharsAlreadyGivenToCallback); - - + + /* Raise the event for new text. - - On older browsers, the new text is the whole response. - On newer/better ones, the fragment part that we got since + + On older browsers, the new text is the whole response. + On newer/better ones, the fragment part that we got since last progress. */ - + if( newText ) { emitStreamData( newText ); - } - + } + numberOfCharsAlreadyGivenToCallback = len(textSoFar); } - - + + if('onprogress' in xhr){ // detect browser support for progressive delivery xhr.onprogress = handleProgress; } - + xhr.onreadystatechange = function() { - + function sendStartIfNotAlready() { // Internet Explorer is very unreliable as to when xhr.status etc can - // be read so has to be protected with try/catch and tried again on + // be read so has to be protected with try/catch and tried again on // the next readyState if it fails try{ stillToSendStartEvent && oboeBus( HTTP_START ).emit( @@ -40519,111 +40519,111 @@ stillToSendStartEvent = false; } catch(e){/* do nothing, will try again on next readyState*/} } - + switch( xhr.readyState ) { - + case 2: // HEADERS_RECEIVED case 3: // LOADING return sendStartIfNotAlready(); - + case 4: // DONE sendStartIfNotAlready(); // if xhr.status hasn't been available yet, it must be NOW, huh IE? - + // is this a 2xx http code? var successful = String(xhr.status)[0] == 2; - + if( successful ) { // In Chrome 29 (not 28) no onprogress is emitted when a response // is complete before the onload. We need to always do handleInput // in case we get the load but have not had a final progress event. // This looks like a bug and may change in future but let's take - // the safest approach and assume we might not have received a + // the safest approach and assume we might not have received a // progress event for each part of the response handleProgress(); - + oboeBus(STREAM_END).emit(); } else { - + emitFail( errorReport( - xhr.status, + xhr.status, xhr.responseText )); } } }; - + try{ - + xhr.open(method, url, true); - + for( var headerName in headers ){ xhr.setRequestHeader(headerName, headers[headerName]); } - + if( !isCrossOrigin(window.location, parseUrlOrigin(url)) ) { xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); } - + xhr.withCredentials = withCredentials; - + xhr.send(data); - + } catch( e ) { - + // To keep a consistent interface with Node, we can't emit an event here. // Node's streaming http adaptor receives the error as an asynchronous // event rather than as an exception. If we emitted now, the Oboe user // has had no chance to add a .fail listener so there is no way // the event could be useful. For both these reasons defer the - // firing to the next JS frame. + // firing to the next JS frame. window.setTimeout( partialComplete(emitFail, errorReport(undefined, undefined, e)) , 0 ); - } + } } - + var jsonPathSyntax = (function() { - + var - - /** - * Export a regular expression as a simple function by exposing just - * the Regex#exec. This allows regex tests to be used under the same + + /** + * Export a regular expression as a simple function by exposing just + * the Regex#exec. This allows regex tests to be used under the same * interface as differently implemented tests, or for a user of the * tests to not concern themselves with their implementation as regular * expressions. - * + * * This could also be expressed point-free as: * Function.prototype.bind.bind(RegExp.prototype.exec), - * - * But that's far too confusing! (and not even smaller once minified + * + * But that's far too confusing! (and not even smaller once minified * and gzipped) */ regexDescriptor = function regexDescriptor(regex) { return regex.exec.bind(regex); } - + /** * Join several regular expressions and express as a function. * This allows the token patterns to reuse component regular expressions * instead of being expressed in full using huge and confusing regular * expressions. - */ + */ , jsonPathClause = varArgs(function( componentRegexes ) { - - // The regular expressions all start with ^ because we - // only want to find matches at the start of the - // JSONPath fragment we are inspecting + + // The regular expressions all start with ^ because we + // only want to find matches at the start of the + // JSONPath fragment we are inspecting componentRegexes.unshift(/^/); - + return regexDescriptor( RegExp( componentRegexes.map(attr('source')).join('') ) ); }) - + , possiblyCapturing = /(\$?)/ , namedNode = /([\w-_]+|\*)/ , namePlaceholder = /()/ @@ -40631,388 +40631,388 @@ , numberedNodeInArrayNotation = /\[(\d+|\*)\]/ , fieldList = /{([\w ]*?)}/ , optionalFieldList = /(?:{([\w ]*?)})?/ - - - // foo or * - , jsonPathNamedNodeInObjectNotation = jsonPathClause( - possiblyCapturing, - namedNode, + + + // foo or * + , jsonPathNamedNodeInObjectNotation = jsonPathClause( + possiblyCapturing, + namedNode, optionalFieldList ) - - // ["foo"] - , jsonPathNamedNodeInArrayNotation = jsonPathClause( - possiblyCapturing, - nodeInArrayNotation, + + // ["foo"] + , jsonPathNamedNodeInArrayNotation = jsonPathClause( + possiblyCapturing, + nodeInArrayNotation, optionalFieldList - ) - - // [2] or [*] - , jsonPathNumberedNodeInArrayNotation = jsonPathClause( - possiblyCapturing, - numberedNodeInArrayNotation, + ) + + // [2] or [*] + , jsonPathNumberedNodeInArrayNotation = jsonPathClause( + possiblyCapturing, + numberedNodeInArrayNotation, optionalFieldList ) - - // {a b c} - , jsonPathPureDuckTyping = jsonPathClause( - possiblyCapturing, - namePlaceholder, + + // {a b c} + , jsonPathPureDuckTyping = jsonPathClause( + possiblyCapturing, + namePlaceholder, fieldList ) - + // .. - , jsonPathDoubleDot = jsonPathClause(/\.\./) - + , jsonPathDoubleDot = jsonPathClause(/\.\./) + // . - , jsonPathDot = jsonPathClause(/\./) - + , jsonPathDot = jsonPathClause(/\./) + // ! , jsonPathBang = jsonPathClause( - possiblyCapturing, + possiblyCapturing, /!/ - ) - + ) + // nada! - , emptyString = jsonPathClause(/$/) - + , emptyString = jsonPathClause(/$/) + ; - - - /* We export only a single function. When called, this function injects - into another function the descriptors from above. + + + /* We export only a single function. When called, this function injects + into another function the descriptors from above. */ - return function (fn){ - return fn( + return function (fn){ + return fn( lazyUnion( jsonPathNamedNodeInObjectNotation , jsonPathNamedNodeInArrayNotation , jsonPathNumberedNodeInArrayNotation - , jsonPathPureDuckTyping + , jsonPathPureDuckTyping ) , jsonPathDoubleDot , jsonPathDot , jsonPathBang - , emptyString + , emptyString ); - }; - + }; + }()); /** * Get a new key->node mapping - * + * * @param {String|Number} key * @param {Object|Array|String|Number|null} node a value found in the json */ function namedNode(key, node) { return {key:key, node:node}; } - + /** get the key of a namedNode */ var keyOf = attr('key'); - + /** get the node from a namedNode */ var nodeOf = attr('node'); - /** + /** * This file provides various listeners which can be used to build up * a changing ascent based on the callbacks provided by Clarinet. It listens * to the low-level events from Clarinet and emits higher-level ones. - * + * * The building up is stateless so to track a JSON file * ascentManager.js is required to store the ascent state * between calls. */ - - - - /** - * A special value to use in the path list to represent the path 'to' a root - * object (which doesn't really have any path). This prevents the need for - * special-casing detection of the root object and allows it to be treated - * like any other object. We might think of this as being similar to the - * 'unnamed root' domain ".", eg if I go to - * http://en.wikipedia.org./wiki/En/Main_page the dot after 'org' deliminates + + + + /** + * A special value to use in the path list to represent the path 'to' a root + * object (which doesn't really have any path). This prevents the need for + * special-casing detection of the root object and allows it to be treated + * like any other object. We might think of this as being similar to the + * 'unnamed root' domain ".", eg if I go to + * http://en.wikipedia.org./wiki/En/Main_page the dot after 'org' deliminates * the unnamed root of the DNS. - * - * This is kept as an object to take advantage that in Javascript's OO objects - * are guaranteed to be distinct, therefore no other object can possibly clash - * with this one. Strings, numbers etc provide no such guarantee. + * + * This is kept as an object to take advantage that in Javascript's OO objects + * are guaranteed to be distinct, therefore no other object can possibly clash + * with this one. Strings, numbers etc provide no such guarantee. **/ var ROOT_PATH = {}; - - + + /** - * Create a new set of handlers for clarinet's events, bound to the emit - * function given. - */ + * Create a new set of handlers for clarinet's events, bound to the emit + * function given. + */ function incrementalContentBuilder( oboeBus ) { - + var emitNodeOpened = oboeBus(NODE_OPENED).emit, emitNodeClosed = oboeBus(NODE_CLOSED).emit, emitRootOpened = oboeBus(ROOT_PATH_FOUND).emit, emitRootClosed = oboeBus(ROOT_NODE_FOUND).emit; - + function arrayIndicesAreKeys( possiblyInconsistentAscent, newDeepestNode) { - - /* for values in arrays we aren't pre-warned of the coming paths - (Clarinet gives no call to onkey like it does for values in objects) - so if we are in an array we need to create this path ourselves. The - key will be len(parentNode) because array keys are always sequential + + /* for values in arrays we aren't pre-warned of the coming paths + (Clarinet gives no call to onkey like it does for values in objects) + so if we are in an array we need to create this path ourselves. The + key will be len(parentNode) because array keys are always sequential numbers. */ - + var parentNode = nodeOf( head( possiblyInconsistentAscent)); - + return isOfType( Array, parentNode) ? - keyFound( possiblyInconsistentAscent, - len(parentNode), + keyFound( possiblyInconsistentAscent, + len(parentNode), newDeepestNode ) - : + : // nothing needed, return unchanged - possiblyInconsistentAscent + possiblyInconsistentAscent ; } - + function nodeOpened( ascent, newDeepestNode ) { - + if( !ascent ) { - // we discovered the root node, + // we discovered the root node, emitRootOpened( newDeepestNode); - - return keyFound( ascent, ROOT_PATH, newDeepestNode); + + return keyFound( ascent, ROOT_PATH, newDeepestNode); } - + // we discovered a non-root node - - var arrayConsistentAscent = arrayIndicesAreKeys( ascent, newDeepestNode), + + var arrayConsistentAscent = arrayIndicesAreKeys( ascent, newDeepestNode), ancestorBranches = tail( arrayConsistentAscent), previouslyUnmappedName = keyOf( head( arrayConsistentAscent)); - - appendBuiltContent( - ancestorBranches, - previouslyUnmappedName, - newDeepestNode + + appendBuiltContent( + ancestorBranches, + previouslyUnmappedName, + newDeepestNode ); - - return cons( - namedNode( previouslyUnmappedName, newDeepestNode ), + + return cons( + namedNode( previouslyUnmappedName, newDeepestNode ), ancestorBranches - ); + ); } - - + + /** * Add a new value to the object we are building up to represent the * parsed JSON */ function appendBuiltContent( ancestorBranches, key, node ){ - + nodeOf( head( ancestorBranches))[key] = node; } - - + + /** * For when we find a new key in the json. - * - * @param {String|Number|Object} newDeepestName the key. If we are in an - * array will be a number, otherwise a string. May take the special + * + * @param {String|Number|Object} newDeepestName the key. If we are in an + * array will be a number, otherwise a string. May take the special * value ROOT_PATH if the root node has just been found - * - * @param {String|Number|Object|Array|Null|undefined} [maybeNewDeepestNode] - * usually this won't be known so can be undefined. Can't use null + * + * @param {String|Number|Object|Array|Null|undefined} [maybeNewDeepestNode] + * usually this won't be known so can be undefined. Can't use null * to represent unknown because null is a valid value in JSON - **/ + **/ function keyFound(ascent, newDeepestName, maybeNewDeepestNode) { - + if( ascent ) { // if not root - + // If we have the key but (unless adding to an array) no known value - // yet. Put that key in the output but against no defined value: + // yet. Put that key in the output but against no defined value: appendBuiltContent( ascent, newDeepestName, maybeNewDeepestNode ); } - - var ascentWithNewPath = cons( - namedNode( newDeepestName, - maybeNewDeepestNode), + + var ascentWithNewPath = cons( + namedNode( newDeepestName, + maybeNewDeepestNode), ascent ); - + emitNodeOpened( ascentWithNewPath); - + return ascentWithNewPath; } - - + + /** * For when the current node ends. */ function nodeClosed( ascent ) { - + emitNodeClosed( ascent); - + return tail( ascent) || // If there are no nodes left in the ascent the root node - // just closed. Emit a special event for this: + // just closed. Emit a special event for this: emitRootClosed(nodeOf(head(ascent))); - } - + } + var contentBuilderHandlers = {}; contentBuilderHandlers[SAX_VALUE_OPEN] = nodeOpened; contentBuilderHandlers[SAX_VALUE_CLOSE] = nodeClosed; contentBuilderHandlers[SAX_KEY] = keyFound; return contentBuilderHandlers; } - + /** - * The jsonPath evaluator compiler used for Oboe.js. - * - * One function is exposed. This function takes a String JSONPath spec and + * The jsonPath evaluator compiler used for Oboe.js. + * + * One function is exposed. This function takes a String JSONPath spec and * returns a function to test candidate ascents for matches. - * + * * String jsonPath -> (List ascent) -> Boolean|Object * - * This file is coded in a pure functional style. That is, no function has - * side effects, every function evaluates to the same value for the same + * This file is coded in a pure functional style. That is, no function has + * side effects, every function evaluates to the same value for the same * arguments and no variables are reassigned. - */ - // the call to jsonPathSyntax injects the token syntaxes that are needed + */ + // the call to jsonPathSyntax injects the token syntaxes that are needed // inside the compiler - var jsonPathCompiler = jsonPathSyntax(function (pathNodeSyntax, - doubleDotSyntax, + var jsonPathCompiler = jsonPathSyntax(function (pathNodeSyntax, + doubleDotSyntax, dotSyntax, bangSyntax, emptySyntax ) { - + var CAPTURING_INDEX = 1; var NAME_INDEX = 2; var FIELD_LIST_INDEX = 3; - + var headKey = compose2(keyOf, head), headNode = compose2(nodeOf, head); - + /** * Create an evaluator function for a named path node, expressed in the * JSONPath like: * foo * ["bar"] - * [2] + * [2] */ function nameClause(previousExpr, detection ) { - + var name = detection[NAME_INDEX], - - matchesName = ( !name || name == '*' ) + + matchesName = ( !name || name == '*' ) ? always : function(ascent){return headKey(ascent) == name}; - - + + return lazyIntersection(matchesName, previousExpr); } - + /** * Create an evaluator function for a a duck-typed node, expressed like: - * + * * {spin, taste, colour} * .particle{spin, taste, colour} * *{spin, taste, colour} */ function duckTypeClause(previousExpr, detection) { - + var fieldListStr = detection[FIELD_LIST_INDEX]; - - if (!fieldListStr) - return previousExpr; // don't wrap at all, return given expr as-is - + + if (!fieldListStr) + return previousExpr; // don't wrap at all, return given expr as-is + var hasAllrequiredFields = partialComplete( - hasAllProperties, + hasAllProperties, arrayAsList(fieldListStr.split(/\W+/)) ), - - isMatch = compose2( - hasAllrequiredFields, + + isMatch = compose2( + hasAllrequiredFields, headNode ); - + return lazyIntersection(isMatch, previousExpr); } - + /** * Expression for $, returns the evaluator function */ function capture( previousExpr, detection ) { - - // extract meaning from the detection + + // extract meaning from the detection var capturing = !!detection[CAPTURING_INDEX]; - - if (!capturing) - return previousExpr; // don't wrap at all, return given expr as-is - + + if (!capturing) + return previousExpr; // don't wrap at all, return given expr as-is + return lazyIntersection(previousExpr, head); - - } - + + } + /** - * Create an evaluator function that moves onto the next item on the - * lists. This function is the place where the logic to move up a - * level in the ascent exists. - * + * Create an evaluator function that moves onto the next item on the + * lists. This function is the place where the logic to move up a + * level in the ascent exists. + * * Eg, for JSONPath ".foo" we need skip1(nameClause(always, [,'foo'])) */ function skip1(previousExpr) { - - + + if( previousExpr == always ) { - /* If there is no previous expression this consume command + /* If there is no previous expression this consume command is at the start of the jsonPath. - Since JSONPath specifies what we'd like to find but not + Since JSONPath specifies what we'd like to find but not necessarily everything leading down to it, when running out of JSONPath to check against we default to true */ return always; } - + /** return true if the ascent we have contains only the JSON root, * false otherwise */ function notAtRoot(ascent){ return headKey(ascent) != ROOT_PATH; } - + return lazyIntersection( - /* If we're already at the root but there are more + /* If we're already at the root but there are more expressions to satisfy, can't consume any more. No match. - - This check is why none of the other exprs have to be able - to handle empty lists; skip1 is the only evaluator that - moves onto the next token and it refuses to do so once it + + This check is why none of the other exprs have to be able + to handle empty lists; skip1 is the only evaluator that + moves onto the next token and it refuses to do so once it reaches the last item in the list. */ notAtRoot, - + /* We are not at the root of the ascent yet. - Move to the next level of the ascent by handing only - the tail to the previous expression */ - compose2(previousExpr, tail) + Move to the next level of the ascent by handing only + the tail to the previous expression */ + compose2(previousExpr, tail) ); - - } - + + } + /** * Create an evaluator function for the .. (double dot) token. Consumes * zero or more levels of the ascent, the fewest that are required to find * a match when given to previousExpr. - */ + */ function skipMany(previousExpr) { - + if( previousExpr == always ) { - /* If there is no previous expression this consume command + /* If there is no previous expression this consume command is at the start of the jsonPath. - Since JSONPath specifies what we'd like to find but not + Since JSONPath specifies what we'd like to find but not necessarily everything leading down to it, when running - out of JSONPath to check against we default to true */ + out of JSONPath to check against we default to true */ return always; } - - var + + var // In JSONPath .. is equivalent to !.. so if .. reaches the root // the match has succeeded. Ie, we might write ..foo or !..foo // and both should match identically. @@ -41021,303 +41021,303 @@ recursiveCase = skip1(function(ascent) { return cases(ascent); }), - + cases = lazyUnion( terminalCaseWhenArrivingAtRoot , terminalCaseWhenPreviousExpressionIsSatisfied - , recursiveCase + , recursiveCase ); - + return cases; - } - + } + /** * Generate an evaluator for ! - matches only the root element of the json - * and ignores any previous expressions since nothing may precede !. - */ + * and ignores any previous expressions since nothing may precede !. + */ function rootExpr() { - + return function(ascent){ return headKey(ascent) == ROOT_PATH; }; - } - + } + /** - * Generate a statement wrapper to sit around the outermost + * Generate a statement wrapper to sit around the outermost * clause evaluator. - * + * * Handles the case where the capturing is implicit because the JSONPath * did not contain a '$' by returning the last node. - */ + */ function statementExpr(lastClause) { - + return function(ascent) { - + // kick off the evaluation by passing through to the last clause var exprMatch = lastClause(ascent); - + return exprMatch === true ? head(ascent) : exprMatch; }; - } - + } + /** * For when a token has been found in the JSONPath input. * Compiles the parser for that token and returns in combination with the * parser already generated. - * + * * @param {Function} exprs a list of the clause evaluator generators for * the token that was found * @param {Function} parserGeneratedSoFar the parser already found - * @param {Array} detection the match given by the regex engine when + * @param {Array} detection the match given by the regex engine when * the feature was found */ function expressionsReader( exprs, parserGeneratedSoFar, detection ) { - - // if exprs is zero-length foldR will pass back the - // parserGeneratedSoFar as-is so we don't need to treat + + // if exprs is zero-length foldR will pass back the + // parserGeneratedSoFar as-is so we don't need to treat // this as a special case - - return foldR( + + return foldR( function( parserGeneratedSoFar, expr ){ - + return expr(parserGeneratedSoFar, detection); - }, - parserGeneratedSoFar, + }, + parserGeneratedSoFar, exprs - ); - + ); + } - - /** + + /** * If jsonPath matches the given detector function, creates a function which * evaluates against every clause in the clauseEvaluatorGenerators. The * created function is propagated to the onSuccess function, along with * the remaining unparsed JSONPath substring. - * + * * The intended use is to create a clauseMatcher by filling in * the first two arguments, thus providing a function that knows * some syntax to match and what kind of generator to create if it * finds it. The parameter list once completed is: - * + * * (jsonPath, parserGeneratedSoFar, onSuccess) - * - * onSuccess may be compileJsonPathToFunction, to recursively continue + * + * onSuccess may be compileJsonPathToFunction, to recursively continue * parsing after finding a match or returnFoundParser to stop here. */ function generateClauseReaderIfTokenFound ( - + tokenDetector, clauseEvaluatorGenerators, - + jsonPath, parserGeneratedSoFar, onSuccess) { - + var detected = tokenDetector(jsonPath); - + if(detected) { var compiledParser = expressionsReader( - clauseEvaluatorGenerators, - parserGeneratedSoFar, + clauseEvaluatorGenerators, + parserGeneratedSoFar, detected ), - - remainingUnparsedJsonPath = jsonPath.substr(len(detected[0])); - + + remainingUnparsedJsonPath = jsonPath.substr(len(detected[0])); + return onSuccess(remainingUnparsedJsonPath, compiledParser); - } + } } - + /** - * Partially completes generateClauseReaderIfTokenFound above. + * Partially completes generateClauseReaderIfTokenFound above. */ function clauseMatcher(tokenDetector, exprs) { - - return partialComplete( - generateClauseReaderIfTokenFound, - tokenDetector, - exprs + + return partialComplete( + generateClauseReaderIfTokenFound, + tokenDetector, + exprs ); } - + /** - * clauseForJsonPath is a function which attempts to match against + * clauseForJsonPath is a function which attempts to match against * several clause matchers in order until one matches. If non match the * jsonPath expression is invalid and an error is thrown. - * + * * The parameter list is the same as a single clauseMatcher: - * + * * (jsonPath, parserGeneratedSoFar, onSuccess) - */ + */ var clauseForJsonPath = lazyUnion( - - clauseMatcher(pathNodeSyntax , list( capture, - duckTypeClause, - nameClause, + + clauseMatcher(pathNodeSyntax , list( capture, + duckTypeClause, + nameClause, skip1 )) - + , clauseMatcher(doubleDotSyntax , list( skipMany)) - - // dot is a separator only (like whitespace in other languages) but - // rather than make it a special case, use an empty list of + + // dot is a separator only (like whitespace in other languages) but + // rather than make it a special case, use an empty list of // expressions when this token is found - , clauseMatcher(dotSyntax , list() ) - + , clauseMatcher(dotSyntax , list() ) + , clauseMatcher(bangSyntax , list( capture, rootExpr)) - + , clauseMatcher(emptySyntax , list( statementExpr)) - + , function (jsonPath) { - throw Error('"' + jsonPath + '" could not be tokenised') + throw Error('"' + jsonPath + '" could not be tokenised') } ); - - + + /** - * One of two possible values for the onSuccess argument of + * One of two possible values for the onSuccess argument of * generateClauseReaderIfTokenFound. - * - * When this function is used, generateClauseReaderIfTokenFound simply - * returns the compiledParser that it made, regardless of if there is + * + * When this function is used, generateClauseReaderIfTokenFound simply + * returns the compiledParser that it made, regardless of if there is * any remaining jsonPath to be compiled. */ - function returnFoundParser(_remainingJsonPath, compiledParser){ - return compiledParser - } - + function returnFoundParser(_remainingJsonPath, compiledParser){ + return compiledParser + } + /** * Recursively compile a JSONPath expression. - * - * This function serves as one of two possible values for the onSuccess + * + * This function serves as one of two possible values for the onSuccess * argument of generateClauseReaderIfTokenFound, meaning continue to * recursively compile. Otherwise, returnFoundParser is given and * compilation terminates. */ - function compileJsonPathToFunction( uncompiledJsonPath, + function compileJsonPathToFunction( uncompiledJsonPath, parserGeneratedSoFar ) { - + /** * On finding a match, if there is remaining text to be compiled - * we want to either continue parsing using a recursive call to - * compileJsonPathToFunction. Otherwise, we want to stop and return + * we want to either continue parsing using a recursive call to + * compileJsonPathToFunction. Otherwise, we want to stop and return * the parser that we have found so far. */ var onFind = uncompiledJsonPath - ? compileJsonPathToFunction + ? compileJsonPathToFunction : returnFoundParser; - - return clauseForJsonPath( - uncompiledJsonPath, - parserGeneratedSoFar, + + return clauseForJsonPath( + uncompiledJsonPath, + parserGeneratedSoFar, onFind - ); + ); } - + /** * This is the function that we expose to the rest of the library. */ return function(jsonPath){ - + try { - // Kick off the recursive parsing of the jsonPath + // Kick off the recursive parsing of the jsonPath return compileJsonPathToFunction(jsonPath, always); - + } catch( e ) { - throw Error( 'Could not compile "' + jsonPath + + throw Error( 'Could not compile "' + jsonPath + '" because ' + e.message ); } } - + }); - - /** - * A pub/sub which is responsible for a single event type. A + + /** + * A pub/sub which is responsible for a single event type. A * multi-event type event bus is created by pubSub by collecting * several of these. - * - * @param {String} eventType + * + * @param {String} eventType * the name of the events managed by this singleEventPubSub - * @param {singleEventPubSub} [newListener] + * @param {singleEventPubSub} [newListener] * place to notify of new listeners - * @param {singleEventPubSub} [removeListener] + * @param {singleEventPubSub} [removeListener] * place to notify of when listeners are removed */ function singleEventPubSub(eventType, newListener, removeListener){ - + /** we are optimised for emitting events over firing them. * As well as the tuple list which stores event ids and - * listeners there is a list with just the listeners which + * listeners there is a list with just the listeners which * can be iterated more quickly when we are emitting */ var listenerTupleList, listenerList; - + function hasId(id){ return function(tuple) { - return tuple.id == id; - }; + return tuple.id == id; + }; } - + return { - + /** * @param {Function} listener - * @param {*} listenerId - * an id that this listener can later by removed by. + * @param {*} listenerId + * an id that this listener can later by removed by. * Can be of any type, to be compared to other ids using == */ on:function( listener, listenerId ) { - + var tuple = { listener: listener , id: listenerId || listener // when no id is given use the // listener function as the id }; - + if( newListener ) { newListener.emit(eventType, listener, tuple.id); } - + listenerTupleList = cons( tuple, listenerTupleList ); listenerList = cons( listener, listenerList ); - + return this; // chaining }, - - emit:function () { + + emit:function () { applyEach( listenerList, arguments ); }, - + un: function( listenerId ) { - - var removed; - + + var removed; + listenerTupleList = without( listenerTupleList, hasId(listenerId), function(tuple){ removed = tuple; } - ); - + ); + if( removed ) { listenerList = without( listenerList, function(listener){ return listener == removed.listener; }); - + if( removeListener ) { removeListener.emit(eventType, removed.listener, removed.id); } } }, - + listeners: function(){ // differs from Node EventEmitter: returns list, not array return listenerList; }, - + hasListener: function(listenerId){ var test = listenerId? hasId(listenerId) : always; - + return defined(first( test, listenerTupleList)); } }; @@ -41325,227 +41325,227 @@ /** * pubSub is a curried interface for listening to and emitting * events. - * + * * If we get a bus: - * + * * var bus = pubSub(); - * + * * We can listen to event 'foo' like: - * + * * bus('foo').on(myCallback) - * + * * And emit event foo like: - * + * * bus('foo').emit() - * + * * or, with a parameter: - * + * * bus('foo').emit('bar') - * - * All functions can be cached and don't need to be + * + * All functions can be cached and don't need to be * bound. Ie: - * + * * var fooEmitter = bus('foo').emit * fooEmitter('bar'); // emit an event * fooEmitter('baz'); // emit another - * + * * There's also an uncurried[1] shortcut for .emit and .on: - * + * * bus.on('foo', callback) * bus.emit('foo', 'bar') - * + * * [1]: http://zvon.org/other/haskell/Outputprelude/uncurry_f.html */ function pubSub(){ - + var singles = {}, newListener = newSingle('newListener'), - removeListener = newSingle('removeListener'); - + removeListener = newSingle('removeListener'); + function newSingle(eventName) { return singles[eventName] = singleEventPubSub( - eventName, - newListener, + eventName, + newListener, removeListener - ); - } - + ); + } + /** pubSub instances are functions */ - function pubSubInstance( eventName ){ - - return singles[eventName] || newSingle( eventName ); + function pubSubInstance( eventName ){ + + return singles[eventName] || newSingle( eventName ); } - + // add convenience EventEmitter-style uncurried form of 'emit' and 'on' ['emit', 'on', 'un'].forEach(function(methodName){ - + pubSubInstance[methodName] = varArgs(function(eventName, parameters){ apply( parameters, pubSubInstance( eventName )[methodName]); - }); + }); }); - + return pubSubInstance; } - + /** * This file declares some constants to use as names for event types. */ - - var // the events which are never exported are kept as + + var // the events which are never exported are kept as // the smallest possible representation, in numbers: _S = 1, - + // fired whenever a new node starts in the JSON stream: NODE_OPENED = _S++, - + // fired whenever a node closes in the JSON stream: NODE_CLOSED = _S++, - - // called if a .node callback returns a value - + + // called if a .node callback returns a value - NODE_SWAP = _S++, NODE_DROP = _S++, - + FAIL_EVENT = 'fail', - + ROOT_NODE_FOUND = _S++, ROOT_PATH_FOUND = _S++, - + HTTP_START = 'start', STREAM_DATA = 'data', STREAM_END = 'end', ABORTING = _S++, - + // SAX events butchered from Clarinet SAX_KEY = _S++, SAX_VALUE_OPEN = _S++, SAX_VALUE_CLOSE = _S++; - + function errorReport(statusCode, body, error) { try{ var jsonBody = JSON.parse(body); }catch(e){} - + return { statusCode:statusCode, body:body, jsonBody:jsonBody, thrown:error }; - } - - /** + } + + /** * The pattern adaptor listens for newListener and removeListener * events. When patterns are added or removed it compiles the JSONPath * and wires them up. - * - * When nodes and paths are found it emits the fully-qualified match + * + * When nodes and paths are found it emits the fully-qualified match * events with parameters ready to ship to the outside world */ - + function patternAdapter(oboeBus, jsonPathCompiler) { - + var predicateEventMap = { node:oboeBus(NODE_CLOSED) , path:oboeBus(NODE_OPENED) }; - + function emitMatchingNode(emitMatch, node, ascent) { - - /* - We're now calling to the outside world where Lisp-style - lists will not be familiar. Convert to standard arrays. - - Also, reverse the order because it is more common to + + /* + We're now calling to the outside world where Lisp-style + lists will not be familiar. Convert to standard arrays. + + Also, reverse the order because it is more common to list paths "root to leaf" than "leaf to root" */ var descent = reverseList(ascent); - + emitMatch( node, - + // To make a path, strip off the last item which is the special - // ROOT_PATH token for the 'path' to the root node + // ROOT_PATH token for the 'path' to the root node listAsArray(tail(map(keyOf,descent))), // path - listAsArray(map(nodeOf, descent)) // ancestors - ); + listAsArray(map(nodeOf, descent)) // ancestors + ); } - - /* - * Set up the catching of events such as NODE_CLOSED and NODE_OPENED and, if - * matching the specified pattern, propagate to pattern-match events such as + + /* + * Set up the catching of events such as NODE_CLOSED and NODE_OPENED and, if + * matching the specified pattern, propagate to pattern-match events such as * oboeBus('node:!') - * - * - * - * @param {Function} predicateEvent + * + * + * + * @param {Function} predicateEvent * either oboeBus(NODE_CLOSED) or oboeBus(NODE_OPENED). - * @param {Function} compiledJsonPath + * @param {Function} compiledJsonPath */ function addUnderlyingListener( fullEventName, predicateEvent, compiledJsonPath ){ - + var emitMatch = oboeBus(fullEventName).emit; - + predicateEvent.on( function (ascent) { - + var maybeMatchingMapping = compiledJsonPath(ascent); - + /* Possible values for maybeMatchingMapping are now: - - false: - we did not match - - an object/array/string/number/null: + + false: + we did not match + + an object/array/string/number/null: we matched and have the node that matched. Because nulls are valid json values this can be null. - + undefined: we matched but don't have the matching node yet. - ie, we know there is an upcoming node that matches but we - can't say anything else about it. + ie, we know there is an upcoming node that matches but we + can't say anything else about it. */ if (maybeMatchingMapping !== false) { - + emitMatchingNode( - emitMatch, - nodeOf(maybeMatchingMapping), + emitMatch, + nodeOf(maybeMatchingMapping), ascent ); } }, fullEventName); - + oboeBus('removeListener').on( function(removedEventName){ - - // if the fully qualified match event listener is later removed, clean up + + // if the fully qualified match event listener is later removed, clean up // by removing the underlying listener if it was the last using that pattern: - + if( removedEventName == fullEventName ) { - + if( !oboeBus(removedEventName).listeners( )) { predicateEvent.un( fullEventName ); } } - }); + }); } - + oboeBus('newListener').on( function(fullEventName){ - + var match = /(node|path):(.*)/.exec(fullEventName); - + if( match ) { var predicateEvent = predicateEventMap[match[1]]; - - if( !predicateEvent.hasListener( fullEventName) ) { - + + if( !predicateEvent.hasListener( fullEventName) ) { + addUnderlyingListener( fullEventName, - predicateEvent, + predicateEvent, jsonPathCompiler( match[2] ) ); } - } + } }) - + } - + /** * The instance API is the thing that is returned when oboe() is called. * it allows: @@ -41554,74 +41554,74 @@ * - the http response header/headers to be read */ function instanceApi(oboeBus, contentSource){ - + var oboeApi, fullyQualifiedNamePattern = /^(node|path):./, rootNodeFinishedEvent = oboeBus(ROOT_NODE_FOUND), emitNodeDrop = oboeBus(NODE_DROP).emit, emitNodeSwap = oboeBus(NODE_SWAP).emit, - + /** * Add any kind of listener that the instance api exposes */ addListener = varArgs(function( eventId, parameters ){ - + if( oboeApi[eventId] ) { - + // for events added as .on(event, callback), if there is a // .event() equivalent with special behaviour , pass through // to that: apply(parameters, oboeApi[eventId]); } else { - + // we have a standard Node.js EventEmitter 2-argument call. // The first parameter is the listener. var event = oboeBus(eventId), listener = parameters[0]; - + if( fullyQualifiedNamePattern.test(eventId) ) { - + // allow fully-qualified node/path listeners // to be added addForgettableCallback(event, listener); } else { - + // the event has no special handling, pass through // directly onto the event bus: event.on( listener); } } - + return oboeApi; // chaining }), - + /** * Remove any kind of listener that the instance api exposes */ removeListener = function( eventId, p2, p3 ){ - + if( eventId == 'done' ) { - + rootNodeFinishedEvent.un(p2); - + } else if( eventId == 'node' || eventId == 'path' ) { - + // allow removal of node and path oboeBus.un(eventId + ':' + p2, p3); } else { - + // we have a standard Node.js EventEmitter 2-argument call. // The second parameter is the listener. This may be a call // to remove a fully-qualified node/path listener but requires // no special handling var listener = p2; - + oboeBus(eventId).un(listener); } - + return oboeApi; // chaining }; - + /** * Add a callback, wrapped in a try/catch so as to not break the * execution of Oboe if an exception is thrown (fail events are @@ -41634,39 +41634,39 @@ oboeBus(eventName).on(protectedCallback(callback), callback); return oboeApi; // chaining } - + /** * Add a callback where, if .forget() is called during the callback's * execution, the callback will be de-registered */ function addForgettableCallback(event, callback, listenerId) { - + // listenerId is optional and if not given, the original // callback will be used listenerId = listenerId || callback; - + var safeCallback = protectedCallback(callback); - + event.on( function() { - + var discard = false; - + oboeApi.forget = function(){ discard = true; }; - + apply( arguments, safeCallback ); - + delete oboeApi.forget; - + if( discard ) { event.un(listenerId); } }, listenerId); - + return oboeApi; // chaining } - + /** * wrap a callback so that if it throws, Oboe.js doesn't crash but instead * throw the error in another event loop @@ -41682,7 +41682,7 @@ } } } - + /** * Return the fully qualified event for when a pattern matches * either a node or a path @@ -41692,13 +41692,13 @@ function fullyQualifiedPatternMatchEvent(type, pattern) { return oboeBus(type + ':' + pattern); } - + function wrapCallbackToSwapNodeIfSomethingReturned( callback ) { return function() { var returnValueFromCallback = callback.apply(this, arguments); - + if( defined(returnValueFromCallback) ) { - + if( returnValueFromCallback == oboe.drop ) { emitNodeDrop(); } else { @@ -41707,69 +41707,69 @@ } } } - + function addSingleNodeOrPathListener(eventId, pattern, callback) { - + var effectiveCallback; - + if( eventId == 'node' ) { effectiveCallback = wrapCallbackToSwapNodeIfSomethingReturned(callback); } else { effectiveCallback = callback; } - + addForgettableCallback( fullyQualifiedPatternMatchEvent(eventId, pattern), effectiveCallback, callback ); } - + /** * Add several listeners at a time, from a map */ function addMultipleNodeOrPathListeners(eventId, listenerMap) { - + for( var pattern in listenerMap ) { addSingleNodeOrPathListener(eventId, pattern, listenerMap[pattern]); } } - + /** * implementation behind .onPath() and .onNode() */ function addNodeOrPathListenerApi( eventId, jsonPathOrListenerMap, callback ){ - + if( isString(jsonPathOrListenerMap) ) { addSingleNodeOrPathListener(eventId, jsonPathOrListenerMap, callback); - + } else { addMultipleNodeOrPathListeners(eventId, jsonPathOrListenerMap); } - + return oboeApi; // chaining } - - + + // some interface methods are only filled in after we receive // values and are noops before that: oboeBus(ROOT_PATH_FOUND).on( function(rootNode) { oboeApi.root = functor(rootNode); }); - + /** * When content starts make the headers readable through the * instance API */ oboeBus(HTTP_START).on( function(_statusCode, headers) { - + oboeApi.header = function(name) { return name ? headers[name] : headers ; } }); - + /** * Construct and return the public API of the Oboe instance to be * returned to the calling application @@ -41779,46 +41779,46 @@ addListener : addListener, removeListener : removeListener, emit : oboeBus.emit, - + node : partialComplete(addNodeOrPathListenerApi, 'node'), path : partialComplete(addNodeOrPathListenerApi, 'path'), - + done : partialComplete(addForgettableCallback, rootNodeFinishedEvent), start : partialComplete(addProtectedCallback, HTTP_START ), - + // fail doesn't use protectedCallback because // could lead to non-terminating loops fail : oboeBus(FAIL_EVENT).on, - + // public api calling abort fires the ABORTING event abort : oboeBus(ABORTING).emit, - + // initially return nothing for header and root header : noop, root : noop, - + source : contentSource }; } - + /** * This file sits just behind the API which is used to attain a new * Oboe instance. It creates the new components that are required * and introduces them to each other. */ - + function wire (httpMethodName, contentSource, body, headers, withCredentials){ - + var oboeBus = pubSub(); - + // Wire the input stream in if we are given a content source. // This will usually be the case. If not, the instance created // will have to be passed content from an external source. - + if( contentSource ) { - + streamingHttp( oboeBus, - httpTransport(), + httpTransport(), httpMethodName, contentSource, body, @@ -41826,76 +41826,76 @@ withCredentials ); } - + clarinet(oboeBus); - + ascentManager(oboeBus, incrementalContentBuilder(oboeBus)); - - patternAdapter(oboeBus, jsonPathCompiler); - + + patternAdapter(oboeBus, jsonPathCompiler); + return instanceApi(oboeBus, contentSource); } - + function applyDefaults( passthrough, url, httpMethodName, body, headers, withCredentials, cached ){ - + headers = headers ? // Shallow-clone the headers array. This allows it to be // modified without side effects to the caller. We don't // want to change objects that the user passes in. JSON.parse(JSON.stringify(headers)) : {}; - + if( body ) { if( !isString(body) ) { - + // If the body is not a string, stringify it. This allows objects to // be given which will be sent as JSON. body = JSON.stringify(body); - + // Default Content-Type to JSON unless given otherwise. headers['Content-Type'] = headers['Content-Type'] || 'application/json'; } } else { body = null; } - + // support cache busting like jQuery.ajax({cache:false}) function modifiedUrl(baseUrl, cached) { - + if( cached === false ) { - + if( baseUrl.indexOf('?') == -1 ) { baseUrl += '?'; } else { baseUrl += '&'; } - + baseUrl += '_=' + new Date().getTime(); } return baseUrl; } - + return passthrough( httpMethodName || 'GET', modifiedUrl(url, cached), body, headers, withCredentials || false ); } - + // export public API function oboe(arg1) { - + // We use duck-typing to detect if the parameter given is a stream, with the // below list of parameters. // Unpipe and unshift would normally be present on a stream but this breaks // compatibility with Request streams. // See https://github.com/jimhigson/oboe.js/issues/65 - + var nodeStreamMethodNames = list('resume', 'pause', 'pipe'), isStream = partialComplete( hasAllProperties , nodeStreamMethodNames ); - + if( arg1 ) { if (isStream(arg1) || isString(arg1)) { - + // simple version for GETs. Signature is: // oboe( url ) // or, under node: @@ -41904,12 +41904,12 @@ wire, arg1 // url ); - + } else { - + // method signature is: // oboe({method:m, url:u, body:b, headers:{...}}) - + return applyDefaults( wire, arg1.url, @@ -41919,23 +41919,23 @@ arg1.withCredentials, arg1.cached ); - + } } else { - // wire up a no-AJAX, no-stream Oboe. Will have to have content + // wire up a no-AJAX, no-stream Oboe. Will have to have content // fed in externally and using .emit. return wire(); } } - + /* oboe.drop is a special value. If a node callback returns this value the parsed node is deleted from the JSON */ oboe.drop = function() { return oboe.drop; }; - - + + if ( typeof define === "function" && define.amd ) { define( "oboe", [], function () { return oboe; } ); } else if (typeof exports === 'object') { @@ -41952,58 +41952,58 @@ return self; } }()), Object, Array, Error, JSON); - + },{}],240:[function(require,module,exports){ exports.endianness = function () { return 'LE' }; - + exports.hostname = function () { if (typeof location !== 'undefined') { return location.hostname } else return ''; }; - + exports.loadavg = function () { return [] }; - + exports.uptime = function () { return 0 }; - + exports.freemem = function () { return Number.MAX_VALUE; }; - + exports.totalmem = function () { return Number.MAX_VALUE; }; - + exports.cpus = function () { return [] }; - + exports.type = function () { return 'Browser' }; - + exports.release = function () { if (typeof navigator !== 'undefined') { return navigator.appVersion; } return ''; }; - + exports.networkInterfaces = exports.getNetworkInterfaces = function () { return {} }; - + exports.arch = function () { return 'javascript' }; - + exports.platform = function () { return 'browser' }; - + exports.tmpdir = exports.tmpDir = function () { return '/tmp'; }; - + exports.EOL = '\n'; - + exports.homedir = function () { return '/' }; - + },{}],241:[function(require,module,exports){ module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb", "2.16.840.1.101.3.4.1.2": "aes-128-cbc", @@ -42022,11 +42022,11 @@ // from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js // Fedor, you are amazing. 'use strict' - + var asn1 = require('asn1.js') - + exports.certificate = require('./certificate') - + var RSAPrivateKey = asn1.define('RSAPrivateKey', function () { this.seq().obj( this.key('version').int(), @@ -42041,7 +42041,7 @@ ) }) exports.RSAPrivateKey = RSAPrivateKey - + var RSAPublicKey = asn1.define('RSAPublicKey', function () { this.seq().obj( this.key('modulus').int(), @@ -42049,7 +42049,7 @@ ) }) exports.RSAPublicKey = RSAPublicKey - + var PublicKey = asn1.define('SubjectPublicKeyInfo', function () { this.seq().obj( this.key('algorithm').use(AlgorithmIdentifier), @@ -42057,7 +42057,7 @@ ) }) exports.PublicKey = PublicKey - + var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () { this.seq().obj( this.key('algorithm').objid(), @@ -42070,7 +42070,7 @@ ).optional() ) }) - + var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () { this.seq().obj( this.key('version').int(), @@ -42100,9 +42100,9 @@ this.key('subjectPrivateKey').octstr() ) }) - + exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo - + var DSAPrivateKey = asn1.define('DSAPrivateKey', function () { this.seq().obj( this.key('version').int(), @@ -42114,11 +42114,11 @@ ) }) exports.DSAPrivateKey = DSAPrivateKey - + exports.DSAparam = asn1.define('DSAparam', function () { this.int() }) - + var ECPrivateKey = asn1.define('ECPrivateKey', function () { this.seq().obj( this.key('version').int(), @@ -42128,77 +42128,77 @@ ) }) exports.ECPrivateKey = ECPrivateKey - + var ECParameters = asn1.define('ECParameters', function () { this.choice({ namedCurve: this.objid() }) }) - + exports.signature = asn1.define('signature', function () { this.seq().obj( this.key('r').int(), this.key('s').int() ) }) - + },{"./certificate":243,"asn1.js":5}],243:[function(require,module,exports){ // from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js // thanks to @Rantanen - + 'use strict' - + var asn = require('asn1.js') - + var Time = asn.define('Time', function () { this.choice({ utcTime: this.utctime(), generalTime: this.gentime() }) }) - + var AttributeTypeValue = asn.define('AttributeTypeValue', function () { this.seq().obj( this.key('type').objid(), this.key('value').any() ) }) - + var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () { this.seq().obj( this.key('algorithm').objid(), this.key('parameters').optional() ) }) - + var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () { this.seq().obj( this.key('algorithm').use(AlgorithmIdentifier), this.key('subjectPublicKey').bitstr() ) }) - + var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () { this.setof(AttributeTypeValue) }) - + var RDNSequence = asn.define('RDNSequence', function () { this.seqof(RelativeDistinguishedName) }) - + var Name = asn.define('Name', function () { this.choice({ rdnSequence: this.use(RDNSequence) }) }) - + var Validity = asn.define('Validity', function () { this.seq().obj( this.key('notBefore').use(Time), this.key('notAfter').use(Time) ) }) - + var Extension = asn.define('Extension', function () { this.seq().obj( this.key('extnID').objid(), @@ -42206,7 +42206,7 @@ this.key('extnValue').octstr() ) }) - + var TBSCertificate = asn.define('TBSCertificate', function () { this.seq().obj( this.key('version').explicit(0).int(), @@ -42221,7 +42221,7 @@ this.key('extensions').explicit(3).seqof(Extension).optional() ) }) - + var X509Certificate = asn.define('X509Certificate', function () { this.seq().obj( this.key('tbsCertificate').use(TBSCertificate), @@ -42229,9 +42229,9 @@ this.key('signatureValue').bitstr() ) }) - + module.exports = X509Certificate - + },{"asn1.js":5}],244:[function(require,module,exports){ (function (Buffer){ // adapted from https://github.com/apatil/pemstrip @@ -42264,7 +42264,7 @@ data: decrypted } } - + }).call(this,require("buffer").Buffer) },{"browserify-aes":58,"buffer":84,"evp_bytestokey":158}],245:[function(require,module,exports){ (function (Buffer){ @@ -42274,7 +42274,7 @@ var ciphers = require('browserify-aes') var compat = require('pbkdf2') module.exports = parseKeys - + function parseKeys (buffer) { var password if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) { @@ -42284,9 +42284,9 @@ if (typeof buffer === 'string') { buffer = new Buffer(buffer) } - + var stripped = fixProc(buffer, password) - + var type = stripped.tag var data = stripped.data var subtype, ndata @@ -42374,7 +42374,7 @@ out.push(cipher.final()) return Buffer.concat(out) } - + }).call(this,require("buffer").Buffer) },{"./aesid.json":241,"./asn1":242,"./fixProc":244,"browserify-aes":58,"buffer":84,"pbkdf2":247}],246:[function(require,module,exports){ var trim = require('trim') @@ -42382,20 +42382,20 @@ , isArray = function(arg) { return Object.prototype.toString.call(arg) === '[object Array]'; } - + module.exports = function (headers) { if (!headers) return {} - + var result = {} - + forEach( trim(headers).split('\n') , function (row) { var index = row.indexOf(':') , key = trim(row.slice(0, index)).toLowerCase() , value = trim(row.slice(index + 1)) - + if (typeof(result[key]) === 'undefined') { result[key] = value } else if (isArray(result[key])) { @@ -42405,22 +42405,22 @@ } } ) - + return result } },{"for-each":159,"trim":324}],247:[function(require,module,exports){ - + exports.pbkdf2 = require('./lib/async') - + exports.pbkdf2Sync = require('./lib/sync') - + },{"./lib/async":248,"./lib/sync":251}],248:[function(require,module,exports){ (function (process,global){ var checkParameters = require('./precondition') var defaultEncoding = require('./default-encoding') var sync = require('./sync') var Buffer = require('safe-buffer').Buffer - + var ZERO_BUF var subtle = global.crypto && global.crypto.subtle var toBrowser = { @@ -42485,14 +42485,14 @@ module.exports = function (password, salt, iterations, keylen, digest, callback) { if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding) if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding) - + checkParameters(iterations, keylen) if (typeof digest === 'function') { callback = digest digest = undefined } if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2') - + digest = digest || 'sha1' var algo = toBrowser[digest.toLowerCase()] if (!algo || typeof global.Promise !== 'function') { @@ -42514,7 +42514,7 @@ } }), callback) } - + }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"./default-encoding":249,"./precondition":250,"./sync":251,"_process":257,"safe-buffer":290}],249:[function(require,module,exports){ (function (process){ @@ -42524,11 +42524,11 @@ defaultEncoding = 'utf-8' } else { var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10) - + defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary' } module.exports = defaultEncoding - + }).call(this,require('_process')) },{"_process":257}],250:[function(require,module,exports){ var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs @@ -42536,25 +42536,25 @@ if (typeof iterations !== 'number') { throw new TypeError('Iterations not a number') } - + if (iterations < 0) { throw new TypeError('Bad iterations') } - + if (typeof keylen !== 'number') { throw new TypeError('Key length not a number') } - + if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */ throw new TypeError('Bad key length') } } - + },{}],251:[function(require,module,exports){ var md5 = require('create-hash/md5') var rmd160 = require('ripemd160') var sha = require('sha.js') - + var checkParameters = require('./precondition') var defaultEncoding = require('./default-encoding') var Buffer = require('safe-buffer').Buffer @@ -42569,24 +42569,24 @@ rmd160: 20, ripemd160: 20 } - + function Hmac (alg, key, saltLen) { var hash = getDigest(alg) var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64 - + if (key.length > blocksize) { key = hash(key) } else if (key.length < blocksize) { key = Buffer.concat([key, ZEROS], blocksize) } - + var ipad = Buffer.allocUnsafe(blocksize + sizes[alg]) var opad = Buffer.allocUnsafe(blocksize + sizes[alg]) for (var i = 0; i < blocksize; i++) { ipad[i] = key[i] ^ 0x36 opad[i] = key[i] ^ 0x5C } - + var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4) ipad.copy(ipad1, 0, 0, blocksize) this.ipad1 = ipad1 @@ -42597,149 +42597,149 @@ this.hash = hash this.size = sizes[alg] } - + Hmac.prototype.run = function (data, ipad) { data.copy(ipad, this.blocksize) var h = this.hash(ipad) h.copy(this.opad, this.blocksize) return this.hash(this.opad) } - + function getDigest (alg) { function shaFunc (data) { return sha(alg).update(data).digest() } - + if (alg === 'rmd160' || alg === 'ripemd160') return rmd160 if (alg === 'md5') return md5 return shaFunc } - + function pbkdf2 (password, salt, iterations, keylen, digest) { if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding) if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding) - + checkParameters(iterations, keylen) - + digest = digest || 'sha1' - + var hmac = new Hmac(digest, password, salt.length) - + var DK = Buffer.allocUnsafe(keylen) var block1 = Buffer.allocUnsafe(salt.length + 4) salt.copy(block1, 0, 0, salt.length) - + var destPos = 0 var hLen = sizes[digest] var l = Math.ceil(keylen / hLen) - + for (var i = 1; i <= l; i++) { block1.writeUInt32BE(i, salt.length) - + var T = hmac.run(block1, hmac.ipad1) var U = T - + for (var j = 1; j < iterations; j++) { U = hmac.run(U, hmac.ipad2) for (var k = 0; k < hLen; k++) T[k] ^= U[k] } - + T.copy(DK, destPos) destPos += hLen } - + return DK } - + module.exports = pbkdf2 - + },{"./default-encoding":249,"./precondition":250,"create-hash/md5":93,"ripemd160":288,"safe-buffer":290,"sha.js":304}],252:[function(require,module,exports){ 'use strict'; - + var processFn = function (fn, P, opts) { return function () { var that = this; var args = new Array(arguments.length); - + for (var i = 0; i < arguments.length; i++) { args[i] = arguments[i]; } - + return new P(function (resolve, reject) { args.push(function (err, result) { if (err) { reject(err); } else if (opts.multiArgs) { var results = new Array(arguments.length - 1); - + for (var i = 1; i < arguments.length; i++) { results[i - 1] = arguments[i]; } - + resolve(results); } else { resolve(result); } }); - + fn.apply(that, args); }); }; }; - + var pify = module.exports = function (obj, P, opts) { if (typeof P !== 'function') { opts = P; P = Promise; } - + opts = opts || {}; opts.exclude = opts.exclude || [/.+Sync$/]; - + var filter = function (key) { var match = function (pattern) { return typeof pattern === 'string' ? key === pattern : pattern.test(key); }; - + return opts.include ? opts.include.some(match) : !opts.exclude.some(match); }; - + var ret = typeof obj === 'function' ? function () { if (opts.excludeMain) { return obj.apply(this, arguments); } - + return processFn(obj, P, opts).apply(this, arguments); } : {}; - + return Object.keys(obj).reduce(function (ret, key) { var x = obj[key]; - + ret[key] = typeof x === 'function' && filter(key) ? processFn(x, P, opts) : x; - + return ret; }, ret); }; - + pify.all = pify; - + },{}],253:[function(require,module,exports){ /* * Copyright (c) 2012 Mathieu Turcotte * Licensed under the MIT license. */ - + module.exports = require('./lib/checks'); },{"./lib/checks":254}],254:[function(require,module,exports){ /* * Copyright (c) 2012 Mathieu Turcotte * Licensed under the MIT license. */ - + var util = require('util'); - + var errors = module.exports = require('./errors'); - + function failCheck(ExceptionConstructor, callee, messageFormat, formatArgs) { messageFormat = messageFormat || ''; var message = util.format.apply(this, [messageFormat].concat(formatArgs)); @@ -42747,50 +42747,50 @@ Error.captureStackTrace(error, callee); throw error; } - + function failArgumentCheck(callee, message, formatArgs) { failCheck(errors.IllegalArgumentError, callee, message, formatArgs); } - + function failStateCheck(callee, message, formatArgs) { failCheck(errors.IllegalStateError, callee, message, formatArgs); } - + module.exports.checkArgument = function(value, message) { if (!value) { failArgumentCheck(arguments.callee, message, Array.prototype.slice.call(arguments, 2)); } }; - + module.exports.checkState = function(value, message) { if (!value) { failStateCheck(arguments.callee, message, Array.prototype.slice.call(arguments, 2)); } }; - + module.exports.checkIsDef = function(value, message) { if (value !== undefined) { return value; } - + failArgumentCheck(arguments.callee, message || 'Expected value to be defined but was undefined.', Array.prototype.slice.call(arguments, 2)); }; - + module.exports.checkIsDefAndNotNull = function(value, message) { // Note that undefined == null. if (value != null) { return value; } - + failArgumentCheck(arguments.callee, message || 'Expected value to be defined and not null but got "' + typeOf(value) + '".', Array.prototype.slice.call(arguments, 2)); }; - + // Fixed version of the typeOf operator which returns 'null' for null values // and 'array' for arrays. function typeOf(value) { @@ -42804,58 +42804,58 @@ } return s; } - + function typeCheck(expect) { return function(value, message) { var type = typeOf(value); - + if (type == expect) { return value; } - + failArgumentCheck(arguments.callee, message || 'Expected "' + expect + '" but got "' + type + '".', Array.prototype.slice.call(arguments, 2)); }; } - + module.exports.checkIsString = typeCheck('string'); module.exports.checkIsArray = typeCheck('array'); module.exports.checkIsNumber = typeCheck('number'); module.exports.checkIsBoolean = typeCheck('boolean'); module.exports.checkIsFunction = typeCheck('function'); module.exports.checkIsObject = typeCheck('object'); - + },{"./errors":255,"util":333}],255:[function(require,module,exports){ /* * Copyright (c) 2012 Mathieu Turcotte * Licensed under the MIT license. */ - + var util = require('util'); - + function IllegalArgumentError(message) { Error.call(this, message); this.message = message; } util.inherits(IllegalArgumentError, Error); - + IllegalArgumentError.prototype.name = 'IllegalArgumentError'; - + function IllegalStateError(message) { Error.call(this, message); this.message = message; } util.inherits(IllegalStateError, Error); - + IllegalStateError.prototype.name = 'IllegalStateError'; - + module.exports.IllegalStateError = IllegalStateError; module.exports.IllegalArgumentError = IllegalArgumentError; },{"util":333}],256:[function(require,module,exports){ (function (process){ 'use strict'; - + if (!process.version || process.version.indexOf('v0.') === 0 || process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { @@ -42863,7 +42863,7 @@ } else { module.exports = process } - + function nextTick(fn, arg1, arg2, arg3) { if (typeof fn !== 'function') { throw new TypeError('"callback" argument must be a function'); @@ -42897,21 +42897,21 @@ }); } } - - + + }).call(this,require('_process')) },{"_process":257}],257:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; - + // cached from whatever global is present so that test runners that stub it // don't break things. But we need to wrap it in a try catch in case it is // wrapped in strict mode code which doesn't define any globals. It's inside a // function because try/catches deoptimize in certain engines. - + var cachedSetTimeout; var cachedClearTimeout; - + function defaultSetTimout() { throw new Error('setTimeout has not been defined'); } @@ -42960,8 +42960,8 @@ return cachedSetTimeout.call(this, fun, 0); } } - - + + } function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { @@ -42986,15 +42986,15 @@ return cachedClearTimeout.call(this, marker); } } - - - + + + } var queue = []; var draining = false; var currentQueue; var queueIndex = -1; - + function cleanUpNextTick() { if (!draining || !currentQueue) { return; @@ -43009,14 +43009,14 @@ drainQueue(); } } - + function drainQueue() { if (draining) { return; } var timeout = runTimeout(cleanUpNextTick); draining = true; - + var len = queue.length; while(len) { currentQueue = queue; @@ -43033,7 +43033,7 @@ draining = false; runClearTimeout(timeout); } - + process.nextTick = function (fun) { var args = new Array(arguments.length - 1); if (arguments.length > 1) { @@ -43046,7 +43046,7 @@ runTimeout(drainQueue); } }; - + // v8 likes predictible objects function Item(fun, array) { this.fun = fun; @@ -43061,9 +43061,9 @@ process.argv = []; process.version = ''; // empty string to avoid regexp issues process.versions = {}; - + function noop() {} - + process.on = noop; process.addListener = noop; process.once = noop; @@ -43073,29 +43073,29 @@ process.emit = noop; process.prependListener = noop; process.prependOnceListener = noop; - + process.listeners = function (name) { return [] } - + process.binding = function (name) { throw new Error('process.binding is not supported'); }; - + process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; - + },{}],258:[function(require,module,exports){ 'use strict'; var isFn = require('is-fn'); var setImmediate = require('set-immediate-shim'); - + module.exports = function (promise) { if (!isFn(promise.then)) { throw new TypeError('Expected a promise'); } - + return function (cb) { promise.then(function (data) { setImmediate(cb, null, data); @@ -43104,15 +43104,15 @@ }); }; }; - + },{"is-fn":183,"set-immediate-shim":302}],259:[function(require,module,exports){ exports.publicEncrypt = require('./publicEncrypt'); exports.privateDecrypt = require('./privateDecrypt'); - + exports.privateEncrypt = function privateEncrypt(key, buf) { return exports.publicEncrypt(key, buf, true); }; - + exports.publicDecrypt = function publicDecrypt(key, buf) { return exports.privateDecrypt(key, buf, true); }; @@ -43128,7 +43128,7 @@ } return t.slice(0, len); }; - + function i2ops(c) { var out = new Buffer(4); out.writeUInt32BE(c,0); @@ -43153,7 +43153,7 @@ } else { padding = 4; } - + var key = parseKeys(private_key); var k = key.modulus.byteLength(); if (enc.length > k || new bn(enc).cmp(key.modulus) >= 0) { @@ -43178,7 +43178,7 @@ throw new Error('unknown padding'); } }; - + function oaep(key, msg){ var n = key.modulus; var k = key.modulus.byteLength(); @@ -43205,7 +43205,7 @@ } return db.slice(i); } - + function pkcs1(key, msg, reverse){ var p1 = msg.slice(0, 2); var i = 2; @@ -43218,7 +43218,7 @@ } var ps = msg.slice(2, i - 1); var p2 = msg.slice(i - 1, i); - + if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)){ status++; } @@ -43256,13 +43256,13 @@ var bn = require('bn.js'); var withPublic = require('./withPublic'); var crt = require('browserify-rsa'); - + var constants = { RSA_PKCS1_OAEP_PADDING: 4, RSA_PKCS1_PADDIN: 1, RSA_NO_PADDING: 3 }; - + module.exports = function publicEncrypt(public_key, msg, reverse) { var padding; if (public_key.padding) { @@ -43292,7 +43292,7 @@ return withPublic(paddedMsg, key); } }; - + function oaep(key, msg){ var k = key.modulus.byteLength(); var mLen = msg.length; @@ -43354,7 +43354,7 @@ .fromRed() .toArray()); } - + module.exports = withPublic; }).call(this,require("buffer").Buffer) },{"bn.js":53,"buffer":84}],264:[function(require,module,exports){ @@ -43370,7 +43370,7 @@ (function (global){ /*! https://mths.be/punycode v1.4.1 by @mathias */ ;(function(root) { - + /** Detect free variables */ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; @@ -43384,17 +43384,17 @@ ) { root = freeGlobal; } - + /** * The `punycode` object. * @name punycode * @type Object */ var punycode, - + /** Highest positive signed 32-bit float value */ maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 - + /** Bootstring parameters */ base = 36, tMin = 1, @@ -43404,29 +43404,29 @@ initialBias = 72, initialN = 128, // 0x80 delimiter = '-', // '\x2D' - + /** Regular expressions */ regexPunycode = /^xn--/, regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators - + /** Error messages */ errors = { 'overflow': 'Overflow: input needs wider integers to process', 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', 'invalid-input': 'Invalid input' }, - + /** Convenience shortcuts */ baseMinusTMin = base - tMin, floor = Math.floor, stringFromCharCode = String.fromCharCode, - + /** Temporary variable */ key; - + /*--------------------------------------------------------------------------*/ - + /** * A generic error utility function. * @private @@ -43436,7 +43436,7 @@ function error(type) { throw new RangeError(errors[type]); } - + /** * A generic `Array#map` utility function. * @private @@ -43453,7 +43453,7 @@ } return result; } - + /** * A simple `Array#map`-like wrapper to work with domain name strings or email * addresses. @@ -43479,7 +43479,7 @@ var encoded = map(labels, fn).join('.'); return result + encoded; } - + /** * Creates an array containing the numeric code points of each Unicode * character in the string. While JavaScript uses UCS-2 internally, @@ -43518,7 +43518,7 @@ } return output; } - + /** * Creates a string based on an array of numeric code points. * @see `punycode.ucs2.decode` @@ -43539,7 +43539,7 @@ return output; }).join(''); } - + /** * Converts a basic code point into a digit/integer. * @see `digitToBasic()` @@ -43561,7 +43561,7 @@ } return base; } - + /** * Converts a digit/integer into a basic code point. * @see `basicToDigit()` @@ -43578,7 +43578,7 @@ // 26..35 map to ASCII 0..9 return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); } - + /** * Bias adaptation function as per section 3.4 of RFC 3492. * https://tools.ietf.org/html/rfc3492#section-3.4 @@ -43593,7 +43593,7 @@ } return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); } - + /** * Converts a Punycode string of ASCII-only symbols to a string of Unicode * symbols. @@ -43619,16 +43619,16 @@ t, /** Cached calculation results */ baseMinusT; - + // Handle the basic code points: let `basic` be the number of input code // points before the last delimiter, or `0` if there is none, then copy // the first basic code points to the output. - + basic = input.lastIndexOf(delimiter); if (basic < 0) { basic = 0; } - + for (j = 0; j < basic; ++j) { // if it's not a basic code point if (input.charCodeAt(j) >= 0x80) { @@ -43636,65 +43636,65 @@ } output.push(input.charCodeAt(j)); } - + // Main decoding loop: start just after the last delimiter if any basic code // points were copied; start at the beginning otherwise. - + for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { - + // `index` is the index of the next character to be consumed. // Decode a generalized variable-length integer into `delta`, // which gets added to `i`. The overflow checking is easier // if we increase `i` as we go, then subtract off its starting // value at the end to obtain `delta`. for (oldi = i, w = 1, k = base; /* no condition */; k += base) { - + if (index >= inputLength) { error('invalid-input'); } - + digit = basicToDigit(input.charCodeAt(index++)); - + if (digit >= base || digit > floor((maxInt - i) / w)) { error('overflow'); } - + i += digit * w; t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - + if (digit < t) { break; } - + baseMinusT = base - t; if (w > floor(maxInt / baseMinusT)) { error('overflow'); } - + w *= baseMinusT; - + } - + out = output.length + 1; bias = adapt(i - oldi, out, oldi == 0); - + // `i` was supposed to wrap around from `out` to `0`, // incrementing `n` each time, so we'll fix that now: if (floor(i / out) > maxInt - n) { error('overflow'); } - + n += floor(i / out); i %= out; - + // Insert `n` at position `i` of the output output.splice(i++, 0, n); - + } - + return ucs2encode(output); } - + /** * Converts a string of Unicode symbols (e.g. a domain name label) to a * Punycode string of ASCII-only symbols. @@ -43721,18 +43721,18 @@ handledCPCountPlusOne, baseMinusT, qMinusT; - + // Convert the input in UCS-2 to Unicode input = ucs2decode(input); - + // Cache the length inputLength = input.length; - + // Initialize the state n = initialN; delta = 0; bias = initialBias; - + // Handle the basic code points for (j = 0; j < inputLength; ++j) { currentValue = input[j]; @@ -43740,20 +43740,20 @@ output.push(stringFromCharCode(currentValue)); } } - + handledCPCount = basicLength = output.length; - + // `handledCPCount` is the number of code points that have been handled; // `basicLength` is the number of basic code points. - + // Finish the basic string - if it is not empty - with a delimiter if (basicLength) { output.push(delimiter); } - + // Main encoding loop: while (handledCPCount < inputLength) { - + // All non-basic code points < n have been handled already. Find the next // larger one: for (m = maxInt, j = 0; j < inputLength; ++j) { @@ -43762,24 +43762,24 @@ m = currentValue; } } - + // Increase `delta` enough to advance the decoder's state to , // but guard against overflow handledCPCountPlusOne = handledCPCount + 1; if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { error('overflow'); } - + delta += (m - n) * handledCPCountPlusOne; n = m; - + for (j = 0; j < inputLength; ++j) { currentValue = input[j]; - + if (currentValue < n && ++delta > maxInt) { error('overflow'); } - + if (currentValue == n) { // Represent delta as a generalized variable-length integer for (q = delta, k = base; /* no condition */; k += base) { @@ -43794,21 +43794,21 @@ ); q = floor(qMinusT / baseMinusT); } - + output.push(stringFromCharCode(digitToBasic(q, 0))); bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); delta = 0; ++handledCPCount; } } - + ++delta; ++n; - + } return output.join(''); } - + /** * Converts a Punycode string representing a domain name or an email address * to Unicode. Only the Punycoded parts of the input will be converted, i.e. @@ -43827,7 +43827,7 @@ : string; }); } - + /** * Converts a Unicode string representing a domain name or an email address to * Punycode. Only the non-ASCII parts of the domain name will be converted, @@ -43846,9 +43846,9 @@ : string; }); } - + /*--------------------------------------------------------------------------*/ - + /** Define the public API */ punycode = { /** @@ -43873,7 +43873,7 @@ 'toASCII': toASCII, 'toUnicode': toUnicode }; - + /** Expose `punycode` */ // Some AMD build optimizers, like r.js, check for specific condition patterns // like the following: @@ -43899,16 +43899,16 @@ // in Rhino or a web browser root.punycode = punycode; } - + }(this)); - + }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],266:[function(require,module,exports){ 'use strict'; var strictUriEncode = require('strict-uri-encode'); var objectAssign = require('object-assign'); var decodeComponent = require('decode-uri-component'); - + function encoderForArrayFormat(opts) { switch (opts.arrayFormat) { case 'index': @@ -43926,7 +43926,7 @@ encode(value, opts) ].join(''); }; - + case 'bracket': return function (key, value) { return value === null ? encode(key, opts) : [ @@ -43935,7 +43935,7 @@ encode(value, opts) ].join(''); }; - + default: return function (key, value) { return value === null ? encode(key, opts) : [ @@ -43946,34 +43946,34 @@ }; } } - + function parserForArrayFormat(opts) { var result; - + switch (opts.arrayFormat) { case 'index': return function (key, value, accumulator) { result = /\[(\d*)\]$/.exec(key); - + key = key.replace(/\[\d*\]$/, ''); - + if (!result) { accumulator[key] = value; return; } - + if (accumulator[key] === undefined) { accumulator[key] = {}; } - + accumulator[key][result[1]] = value; }; - + case 'bracket': return function (key, value, accumulator) { result = /(\[\])$/.exec(key); key = key.replace(/\[\]$/, ''); - + if (!result) { accumulator[key] = value; return; @@ -43981,30 +43981,30 @@ accumulator[key] = [value]; return; } - + accumulator[key] = [].concat(accumulator[key], value); }; - + default: return function (key, value, accumulator) { if (accumulator[key] === undefined) { accumulator[key] = value; return; } - + accumulator[key] = [].concat(accumulator[key], value); }; } } - + function encode(value, opts) { if (opts.encode) { return opts.strict ? strictUriEncode(value) : encodeURIComponent(value); } - + return value; } - + function keysSorter(input) { if (Array.isArray(input)) { return input.sort(); @@ -44015,10 +44015,10 @@ return input[key]; }); } - + return input; } - + function extract(str) { var queryStart = str.indexOf('?'); if (queryStart === -1) { @@ -44026,40 +44026,40 @@ } return str.slice(queryStart + 1); } - + function parse(str, opts) { opts = objectAssign({arrayFormat: 'none'}, opts); - + var formatter = parserForArrayFormat(opts); - + // Create an object with no prototype // https://github.com/sindresorhus/query-string/issues/47 var ret = Object.create(null); - + if (typeof str !== 'string') { return ret; } - + str = str.trim().replace(/^[?#&]/, ''); - + if (!str) { return ret; } - + str.split('&').forEach(function (param) { var parts = param.replace(/\+/g, ' ').split('='); // Firefox (pre 40) decodes `%3D` to `=` // https://github.com/sindresorhus/query-string/pull/37 var key = parts.shift(); var val = parts.length > 0 ? parts.join('=') : undefined; - + // missing `=` should be `null`: // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters val = val === undefined ? null : decodeComponent(val); - + formatter(decodeComponent(key), val, ret); }); - + return Object.keys(ret).sort().reduce(function (result, key) { var val = ret[key]; if (Boolean(val) && typeof val === 'object' && !Array.isArray(val)) { @@ -44068,67 +44068,67 @@ } else { result[key] = val; } - + return result; }, Object.create(null)); } - + exports.extract = extract; exports.parse = parse; - + exports.stringify = function (obj, opts) { var defaults = { encode: true, strict: true, arrayFormat: 'none' }; - + opts = objectAssign(defaults, opts); - + if (opts.sort === false) { opts.sort = function () {}; } - + var formatter = encoderForArrayFormat(opts); - + return obj ? Object.keys(obj).sort(opts.sort).map(function (key) { var val = obj[key]; - + if (val === undefined) { return ''; } - + if (val === null) { return encode(key, opts); } - + if (Array.isArray(val)) { var result = []; - + val.slice().forEach(function (val2) { if (val2 === undefined) { return; } - + result.push(formatter(key, val2, result.length)); }); - + return result.join('&'); } - + return encode(key, opts) + '=' + encode(val, opts); }).filter(function (x) { return x.length > 0; }).join('&') : ''; }; - + exports.parseUrl = function (str, opts) { return { url: str.split('?')[0] || '', query: parse(extract(str), opts) }; }; - + },{"decode-uri-component":98,"object-assign":238,"strict-uri-encode":316}],267:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // @@ -44150,44 +44150,44 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - + 'use strict'; - + // If obj.hasOwnProperty has been overridden, then calling // obj.hasOwnProperty(prop) will break. // See: https://github.com/joyent/node/issues/1707 function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } - + module.exports = function(qs, sep, eq, options) { sep = sep || '&'; eq = eq || '='; var obj = {}; - + if (typeof qs !== 'string' || qs.length === 0) { return obj; } - + var regexp = /\+/g; qs = qs.split(sep); - + var maxKeys = 1000; if (options && typeof options.maxKeys === 'number') { maxKeys = options.maxKeys; } - + var len = qs.length; // maxKeys <= 0 means that we should not limit keys count if (maxKeys > 0 && len > maxKeys) { len = maxKeys; } - + for (var i = 0; i < len; ++i) { var x = qs[i].replace(regexp, '%20'), idx = x.indexOf(eq), kstr, vstr, k, v; - + if (idx >= 0) { kstr = x.substr(0, idx); vstr = x.substr(idx + 1); @@ -44195,10 +44195,10 @@ kstr = x; vstr = ''; } - + k = decodeURIComponent(kstr); v = decodeURIComponent(vstr); - + if (!hasOwnProperty(obj, k)) { obj[k] = v; } else if (isArray(obj[k])) { @@ -44207,14 +44207,14 @@ obj[k] = [obj[k], v]; } } - + return obj; }; - + var isArray = Array.isArray || function (xs) { return Object.prototype.toString.call(xs) === '[object Array]'; }; - + },{}],268:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // @@ -44236,32 +44236,32 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - + 'use strict'; - + var stringifyPrimitive = function(v) { switch (typeof v) { case 'string': return v; - + case 'boolean': return v ? 'true' : 'false'; - + case 'number': return isFinite(v) ? v : ''; - + default: return ''; } }; - + module.exports = function(obj, sep, eq, name) { sep = sep || '&'; eq = eq || '='; if (obj === null) { obj = undefined; } - + if (typeof obj === 'object') { return map(objectKeys(obj), function(k) { var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; @@ -44273,18 +44273,18 @@ return ks + encodeURIComponent(stringifyPrimitive(obj[k])); } }).join(sep); - + } - + if (!name) return ''; return encodeURIComponent(stringifyPrimitive(name)) + eq + encodeURIComponent(stringifyPrimitive(obj)); }; - + var isArray = Array.isArray || function (xs) { return Object.prototype.toString.call(xs) === '[object Array]'; }; - + function map (xs, f) { if (xs.map) return xs.map(f); var res = []; @@ -44293,7 +44293,7 @@ } return res; } - + var objectKeys = Object.keys || function (obj) { var res = []; for (var key in obj) { @@ -44301,59 +44301,59 @@ } return res; }; - + },{}],269:[function(require,module,exports){ 'use strict'; - + exports.decode = exports.parse = require('./decode'); exports.encode = exports.stringify = require('./encode'); - + },{"./decode":267,"./encode":268}],270:[function(require,module,exports){ (function (process,global){ 'use strict' - + function oldBrowser () { throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11') } - + var Buffer = require('safe-buffer').Buffer var crypto = global.crypto || global.msCrypto - + if (crypto && crypto.getRandomValues) { module.exports = randomBytes } else { module.exports = oldBrowser } - + function randomBytes (size, cb) { // phantomjs needs to throw if (size > 65536) throw new Error('requested too many random bytes') // in case browserify isn't using the Uint8Array version var rawBytes = new global.Uint8Array(size) - + // This will not work in older browsers. // See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues if (size > 0) { // getRandomValues fails on IE if size == 0 crypto.getRandomValues(rawBytes) } - + // XXX: phantomjs doesn't like a buffer being passed here var bytes = Buffer.from(rawBytes.buffer) - + if (typeof cb === 'function') { return process.nextTick(function () { cb(null, bytes) }) } - + return bytes } - + }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"_process":257,"safe-buffer":290}],271:[function(require,module,exports){ (function (process,global){ 'use strict' - + function oldBrowser () { throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11') } @@ -44367,25 +44367,25 @@ if (typeof offset !== 'number' || offset !== offset) { // eslint-disable-line no-self-compare throw new TypeError('offset must be a number') } - + if (offset > kMaxUint32 || offset < 0) { throw new TypeError('offset must be a uint32') } - + if (offset > kBufferMaxLength || offset > length) { throw new RangeError('offset out of range') } } - + function assertSize (size, offset, length) { if (typeof size !== 'number' || size !== size) { // eslint-disable-line no-self-compare throw new TypeError('size must be a number') } - + if (size > kMaxUint32 || size < 0) { throw new TypeError('size must be a uint32') } - + if (size + offset > length || size > kBufferMaxLength) { throw new RangeError('buffer too small') } @@ -44401,7 +44401,7 @@ if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) { throw new TypeError('"buf" argument must be a Buffer or Uint8Array') } - + if (typeof offset === 'function') { cb = offset offset = 0 @@ -44416,7 +44416,7 @@ assertSize(size, offset, buf.length) return actualFill(buf, offset, size, cb) } - + function actualFill (buf, offset, size, cb) { if (process.browser) { var ourBuf = buf.buffer @@ -44451,16 +44451,16 @@ if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) { throw new TypeError('"buf" argument must be a Buffer or Uint8Array') } - + assertOffset(offset, buf.length) - + if (size === undefined) size = buf.length - offset - + assertSize(size, offset, buf.length) - + return actualFill(buf, offset, size) } - + }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"_process":257,"randombytes":270,"safe-buffer":290}],272:[function(require,module,exports){ module.exports = window.crypto; @@ -44470,8 +44470,8 @@ var randomHex = function(size, callback) { var crypto = require('./crypto.js'); var isCallback = (typeof callback === 'function'); - - + + if (size > 65536) { if(isCallback) { callback(new Error('Requested too many random bytes.')); @@ -44479,11 +44479,11 @@ throw new Error('Requested too many random bytes.'); } }; - - + + // is node if (typeof crypto !== 'undefined' && crypto.randomBytes) { - + if(isCallback) { crypto.randomBytes(size, function(err, result){ if(!err) { @@ -44495,31 +44495,31 @@ } else { return '0x'+ crypto.randomBytes(size).toString('hex'); } - + // is browser } else { var cryptoLib; - + if (typeof crypto !== 'undefined') { cryptoLib = crypto; } else if(typeof msCrypto !== 'undefined') { cryptoLib = msCrypto; } - + if (cryptoLib && cryptoLib.getRandomValues) { var randomBytes = cryptoLib.getRandomValues(new Uint8Array(size)); var returnValue = '0x'+ Array.from(randomBytes).map(function(arr){ return arr.toString(16); }).join(''); - + if(isCallback) { callback(null, returnValue); } else { return returnValue; } - + // not crypto object } else { var error = new Error('No "crypto" object available. This Browser doesn\'t support generating secure random bytes.'); - + if(isCallback) { callback(error); } else { @@ -44528,13 +44528,13 @@ } } }; - - + + module.exports = randomHex; - + },{"./crypto.js":273}],275:[function(require,module,exports){ module.exports = require('./lib/_stream_duplex.js'); - + },{"./lib/_stream_duplex.js":276}],276:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // @@ -44556,19 +44556,19 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - + // a duplex stream is just a stream that is both readable and writable. // Since JS doesn't have multiple prototypal inheritance, this class // prototypally inherits from Readable, and then parasitically from // Writable. - + 'use strict'; - + /**/ - + var processNextTick = require('process-nextick-args').nextTick; /**/ - + /**/ var objectKeys = Object.keys || function (obj) { var keys = []; @@ -44577,56 +44577,56 @@ }return keys; }; /**/ - + module.exports = Duplex; - + /**/ var util = require('core-util-is'); util.inherits = require('inherits'); /**/ - + var Readable = require('./_stream_readable'); var Writable = require('./_stream_writable'); - + util.inherits(Duplex, Readable); - + var keys = objectKeys(Writable.prototype); for (var v = 0; v < keys.length; v++) { var method = keys[v]; if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; } - + function Duplex(options) { if (!(this instanceof Duplex)) return new Duplex(options); - + Readable.call(this, options); Writable.call(this, options); - + if (options && options.readable === false) this.readable = false; - + if (options && options.writable === false) this.writable = false; - + this.allowHalfOpen = true; if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; - + this.once('end', onend); } - + // the no-half-open enforcer function onend() { // if we allow half-open state, or if the writable side ended, // then we're ok. if (this.allowHalfOpen || this._writableState.ended) return; - + // no more data can be written. // But allow more writes to happen in this tick. processNextTick(onEndNT, this); } - + function onEndNT(self) { self.end(); } - + Object.defineProperty(Duplex.prototype, 'destroyed', { get: function () { if (this._readableState === undefined || this._writableState === undefined) { @@ -44640,21 +44640,21 @@ if (this._readableState === undefined || this._writableState === undefined) { return; } - + // backward compatibility, the user is explicitly // managing destroyed this._readableState.destroyed = value; this._writableState.destroyed = value; } }); - + Duplex.prototype._destroy = function (err, cb) { this.push(null); this.end(); - + processNextTick(cb, err); }; - + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xs[i], i); @@ -44681,30 +44681,30 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - + // a passthrough stream. // basically just the most minimal sort of Transform stream. // Every written chunk gets output as-is. - + 'use strict'; - + module.exports = PassThrough; - + var Transform = require('./_stream_transform'); - + /**/ var util = require('core-util-is'); util.inherits = require('inherits'); /**/ - + util.inherits(PassThrough, Transform); - + function PassThrough(options) { if (!(this instanceof PassThrough)) return new PassThrough(options); - + Transform.call(this, options); } - + PassThrough.prototype._transform = function (chunk, encoding, cb) { cb(null, chunk); }; @@ -44730,40 +44730,40 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - + 'use strict'; - + /**/ - + var processNextTick = require('process-nextick-args').nextTick; /**/ - + module.exports = Readable; - + /**/ var isArray = require('isarray'); /**/ - + /**/ var Duplex; /**/ - + Readable.ReadableState = ReadableState; - + /**/ var EE = require('events').EventEmitter; - + var EElistenerCount = function (emitter, type) { return emitter.listeners(type).length; }; /**/ - + /**/ var Stream = require('./internal/streams/stream'); /**/ - + /**/ - + var Buffer = require('safe-buffer').Buffer; var OurUint8Array = global.Uint8Array || function () {}; function _uint8ArrayToBuffer(chunk) { @@ -44772,14 +44772,14 @@ function _isUint8Array(obj) { return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; } - + /**/ - + /**/ var util = require('core-util-is'); util.inherits = require('inherits'); /**/ - + /**/ var debugUtil = require('util'); var debug = void 0; @@ -44789,56 +44789,56 @@ debug = function () {}; } /**/ - + var BufferList = require('./internal/streams/BufferList'); var destroyImpl = require('./internal/streams/destroy'); var StringDecoder; - + util.inherits(Readable, Stream); - + var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; - + function prependListener(emitter, event, fn) { // Sadly this is not cacheable as some libraries bundle their own // event emitter implementation with them. if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); - + // This is a hack to make sure that our error handler is attached before any // userland ones. NEVER DO THIS. This is here only because this code needs // to continue to work with older versions of Node.js that do not include // the prependListener() method. The goal is to eventually remove this hack. if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; } - + function ReadableState(options, stream) { Duplex = Duplex || require('./_stream_duplex'); - + options = options || {}; - + // Duplex streams are both readable and writable, but share // the same options object. // However, some cases require setting options to different // values for the readable and the writable sides of the duplex stream. // These options can be provided separately as readableXXX and writableXXX. var isDuplex = stream instanceof Duplex; - + // object stream flag. Used to make read(n) ignore n and to // make all the buffer merging and length checks go away this.objectMode = !!options.objectMode; - + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; - + // the point at which it stops calling _read() to fill the buffer // Note: 0 is a valid value, means "don't call _read preemptively ever" var hwm = options.highWaterMark; var readableHwm = options.readableHighWaterMark; var defaultHwm = this.objectMode ? 16 : 16 * 1024; - + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; - + // cast to ints. this.highWaterMark = Math.floor(this.highWaterMark); - + // A linked list is used to store data chunks instead of an array because the // linked list can remove elements from the beginning faster than // array.shift() @@ -44850,34 +44850,34 @@ this.ended = false; this.endEmitted = false; this.reading = false; - + // a flag to be able to tell if the event 'readable'/'data' is emitted // immediately, or on a later tick. We set this to true at first, because // any actions that shouldn't happen until "later" should generally also // not happen before the first read call. this.sync = true; - + // whenever we return null, then we set a flag to say // that we're awaiting a 'readable' event emission. this.needReadable = false; this.emittedReadable = false; this.readableListening = false; this.resumeScheduled = false; - + // has it been destroyed this.destroyed = false; - + // Crypto is kind of old and crusty. Historically, its default string // encoding is 'binary' so we have to make this configurable. // Everything else in the universe uses 'utf8', though. this.defaultEncoding = options.defaultEncoding || 'utf8'; - + // the number of writers that are awaiting a drain event in .pipe()s this.awaitDrain = 0; - + // if true, a maybeReadMore has been scheduled this.readingMore = false; - + this.decoder = null; this.encoding = null; if (options.encoding) { @@ -44886,26 +44886,26 @@ this.encoding = options.encoding; } } - + function Readable(options) { Duplex = Duplex || require('./_stream_duplex'); - + if (!(this instanceof Readable)) return new Readable(options); - + this._readableState = new ReadableState(options, this); - + // legacy this.readable = true; - + if (options) { if (typeof options.read === 'function') this._read = options.read; - + if (typeof options.destroy === 'function') this._destroy = options.destroy; } - + Stream.call(this); } - + Object.defineProperty(Readable.prototype, 'destroyed', { get: function () { if (this._readableState === undefined) { @@ -44919,20 +44919,20 @@ if (!this._readableState) { return; } - + // backward compatibility, the user is explicitly // managing destroyed this._readableState.destroyed = value; } }); - + Readable.prototype.destroy = destroyImpl.destroy; Readable.prototype._undestroy = destroyImpl.undestroy; Readable.prototype._destroy = function (err, cb) { this.push(null); cb(err); }; - + // Manually shove something into the read() buffer. // This returns true if the highWaterMark has not been hit yet, // similar to how Writable.write() returns true if you should @@ -44940,7 +44940,7 @@ Readable.prototype.push = function (chunk, encoding) { var state = this._readableState; var skipChunkCheck; - + if (!state.objectMode) { if (typeof chunk === 'string') { encoding = encoding || state.defaultEncoding; @@ -44953,15 +44953,15 @@ } else { skipChunkCheck = true; } - + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); }; - + // Unshift should *always* be something directly out of read() Readable.prototype.unshift = function (chunk) { return readableAddChunk(this, chunk, null, true, false); }; - + function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { var state = stream._readableState; if (chunk === null) { @@ -44976,7 +44976,7 @@ if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { chunk = _uint8ArrayToBuffer(chunk); } - + if (addToFront) { if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); } else if (state.ended) { @@ -44994,10 +44994,10 @@ state.reading = false; } } - + return needMoreData(state); } - + function addChunk(stream, state, chunk, addToFront) { if (state.flowing && state.length === 0 && !state.sync) { stream.emit('data', chunk); @@ -45006,12 +45006,12 @@ // update the buffer info. state.length += state.objectMode ? 1 : chunk.length; if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); - + if (state.needReadable) emitReadable(stream); } maybeReadMore(stream, state); } - + function chunkInvalid(state, chunk) { var er; if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { @@ -45019,7 +45019,7 @@ } return er; } - + // if it's past the high water mark, we can push in some more. // Also, if we have no data yet, we can stand some // more bytes. This is to work around cases where hwm=0, @@ -45030,11 +45030,11 @@ function needMoreData(state) { return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); } - + Readable.prototype.isPaused = function () { return this._readableState.flowing === false; }; - + // backwards compatibility. Readable.prototype.setEncoding = function (enc) { if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; @@ -45042,7 +45042,7 @@ this._readableState.encoding = enc; return this; }; - + // Don't raise the hwm > 8MB var MAX_HWM = 0x800000; function computeNewHighWaterMark(n) { @@ -45061,7 +45061,7 @@ } return n; } - + // This function is designed to be inlinable, so please take care when making // changes to the function body. function howMuchToRead(n, state) { @@ -45081,16 +45081,16 @@ } return state.length; } - + // you can override either this method, or the async _read(n) below. Readable.prototype.read = function (n) { debug('read', n); n = parseInt(n, 10); var state = this._readableState; var nOrig = n; - + if (n !== 0) state.emittedReadable = false; - + // if we're doing read(0) to trigger a readable event, but we // already have a bunch of data in the buffer, then just trigger // the 'readable' event and move on. @@ -45099,15 +45099,15 @@ if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); return null; } - + n = howMuchToRead(n, state); - + // if we've ended, and we're now clear, then finish it up. if (n === 0 && state.ended) { if (state.length === 0) endReadable(this); return null; } - + // All the actual chunk generation logic needs to be // *below* the call to _read. The reason is that in certain // synthetic stream cases, such as passthrough streams, _read @@ -45129,17 +45129,17 @@ // 'readable' etc. // // 3. Actually pull the requested chunks out of the buffer and return. - + // if we need a readable event, then we need to do some reading. var doRead = state.needReadable; debug('need readable', doRead); - + // if we currently have less than the highWaterMark, then also read some if (state.length === 0 || state.length - n < state.highWaterMark) { doRead = true; debug('length less than watermark', doRead); } - + // however, if we've ended, then there's no point, and if we're already // reading, then it's unnecessary. if (state.ended || state.reading) { @@ -45158,31 +45158,31 @@ // and we need to re-evaluate how much data we can return to the user. if (!state.reading) n = howMuchToRead(nOrig, state); } - + var ret; if (n > 0) ret = fromList(n, state);else ret = null; - + if (ret === null) { state.needReadable = true; n = 0; } else { state.length -= n; } - + if (state.length === 0) { // If we have nothing in the buffer, then we want to know // as soon as we *do* get something into the buffer. if (!state.ended) state.needReadable = true; - + // If we tried to read() past the EOF, then emit end on the next tick. if (nOrig !== n && state.ended) endReadable(this); } - + if (ret !== null) this.emit('data', ret); - + return ret; }; - + function onEofChunk(stream, state) { if (state.ended) return; if (state.decoder) { @@ -45193,11 +45193,11 @@ } } state.ended = true; - + // emit 'readable' now to make sure it gets picked up. emitReadable(stream); } - + // Don't emit readable right away in sync mode, because this can trigger // another read() call => stack overflow. This way, it might trigger // a nextTick recursion warning, but that's not so bad. @@ -45210,13 +45210,13 @@ if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream); } } - + function emitReadable_(stream) { debug('emit readable'); stream.emit('readable'); flow(stream); } - + // at this point, the user has presumably seen the 'readable' event, // and called read() to consume some data. that may have triggered // in turn another _read(n) call, in which case reading = true if @@ -45229,7 +45229,7 @@ processNextTick(maybeReadMore_, stream, state); } } - + function maybeReadMore_(stream, state) { var len = state.length; while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { @@ -45241,7 +45241,7 @@ } state.readingMore = false; } - + // abstract method. to be overridden in specific implementation classes. // call cb(er, data) where data is <= n in length. // for virtual (non-string, non-buffer) streams, "length" is somewhat @@ -45249,11 +45249,11 @@ Readable.prototype._read = function (n) { this.emit('error', new Error('_read() is not implemented')); }; - + Readable.prototype.pipe = function (dest, pipeOpts) { var src = this; var state = this._readableState; - + switch (state.pipesCount) { case 0: state.pipes = dest; @@ -45267,12 +45267,12 @@ } state.pipesCount += 1; debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); - + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; - + var endFn = doEnd ? onend : unpipe; if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn); - + dest.on('unpipe', onunpipe); function onunpipe(readable, unpipeInfo) { debug('onunpipe'); @@ -45283,19 +45283,19 @@ } } } - + function onend() { debug('onend'); dest.end(); } - + // when the dest drains, it reduces the awaitDrain counter // on the source. This would be more elegant with a .once() // handler in flow(), but adding and removing repeatedly is // too slow. var ondrain = pipeOnDrain(src); dest.on('drain', ondrain); - + var cleanedUp = false; function cleanup() { debug('cleanup'); @@ -45308,9 +45308,9 @@ src.removeListener('end', onend); src.removeListener('end', unpipe); src.removeListener('data', ondata); - + cleanedUp = true; - + // if the reader is waiting for a drain event from this // specific writer, then it would cause it to never start // flowing again. @@ -45318,7 +45318,7 @@ // If we don't know, then assume that we are waiting for one. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); } - + // If the user pushes more data while we're writing to dest then we'll end up // in ondata again. However, we only want to increase awaitDrain once because // dest will only emit one 'drain' event for the multiple writes. @@ -45342,7 +45342,7 @@ src.pause(); } } - + // if the dest has an error, then stop piping into it. // however, don't suppress the throwing behavior for this. function onerror(er) { @@ -45351,10 +45351,10 @@ dest.removeListener('error', onerror); if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); } - + // Make sure our error handler is attached before userland ones. prependListener(dest, 'error', onerror); - + // Both close and finish should trigger unpipe, but only once. function onclose() { dest.removeListener('finish', onfinish); @@ -45367,24 +45367,24 @@ unpipe(); } dest.once('finish', onfinish); - + function unpipe() { debug('unpipe'); src.unpipe(dest); } - + // tell the dest that it's being piped to dest.emit('pipe', src); - + // start the flow if it hasn't been started already. if (!state.flowing) { debug('pipe resume'); src.resume(); } - + return dest; }; - + function pipeOnDrain(src) { return function () { var state = src._readableState; @@ -45396,21 +45396,21 @@ } }; } - + Readable.prototype.unpipe = function (dest) { var state = this._readableState; var unpipeInfo = { hasUnpiped: false }; - + // if we're not piping anywhere, then do nothing. if (state.pipesCount === 0) return this; - + // just one destination. most common case. if (state.pipesCount === 1) { // passed in one, but it's not the right one. if (dest && dest !== state.pipes) return this; - + if (!dest) dest = state.pipes; - + // got a match. state.pipes = null; state.pipesCount = 0; @@ -45418,9 +45418,9 @@ if (dest) dest.emit('unpipe', this, unpipeInfo); return this; } - + // slow case. multiple pipe destinations. - + if (!dest) { // remove all. var dests = state.pipes; @@ -45428,30 +45428,30 @@ state.pipes = null; state.pipesCount = 0; state.flowing = false; - + for (var i = 0; i < len; i++) { dests[i].emit('unpipe', this, unpipeInfo); }return this; } - + // try to find the right one. var index = indexOf(state.pipes, dest); if (index === -1) return this; - + state.pipes.splice(index, 1); state.pipesCount -= 1; if (state.pipesCount === 1) state.pipes = state.pipes[0]; - + dest.emit('unpipe', this, unpipeInfo); - + return this; }; - + // set up data events if they are asked for // Ensure readable listeners eventually get something Readable.prototype.on = function (ev, fn) { var res = Stream.prototype.on.call(this, ev, fn); - + if (ev === 'data') { // Start flowing on next tick if stream isn't explicitly paused if (this._readableState.flowing !== false) this.resume(); @@ -45467,16 +45467,16 @@ } } } - + return res; }; Readable.prototype.addListener = Readable.prototype.on; - + function nReadingNextTick(self) { debug('readable nexttick read 0'); self.read(0); } - + // pause() and resume() are remnants of the legacy readable stream API // If the user uses them, then switch into old mode. Readable.prototype.resume = function () { @@ -45488,27 +45488,27 @@ } return this; }; - + function resume(stream, state) { if (!state.resumeScheduled) { state.resumeScheduled = true; processNextTick(resume_, stream, state); } } - + function resume_(stream, state) { if (!state.reading) { debug('resume read 0'); stream.read(0); } - + state.resumeScheduled = false; state.awaitDrain = 0; stream.emit('resume'); flow(stream); if (state.flowing && !state.reading) stream.read(0); } - + Readable.prototype.pause = function () { debug('call pause flowing=%j', this._readableState.flowing); if (false !== this._readableState.flowing) { @@ -45518,46 +45518,46 @@ } return this; }; - + function flow(stream) { var state = stream._readableState; debug('flow', state.flowing); while (state.flowing && stream.read() !== null) {} } - + // wrap an old-style stream as the async data source. // This is *not* part of the readable stream interface. // It is an ugly unfortunate mess of history. Readable.prototype.wrap = function (stream) { var _this = this; - + var state = this._readableState; var paused = false; - + stream.on('end', function () { debug('wrapped end'); if (state.decoder && !state.ended) { var chunk = state.decoder.end(); if (chunk && chunk.length) _this.push(chunk); } - + _this.push(null); }); - + stream.on('data', function (chunk) { debug('wrapped data'); if (state.decoder) chunk = state.decoder.write(chunk); - + // don't skip over falsy values in objectMode if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; - + var ret = _this.push(chunk); if (!ret) { paused = true; stream.pause(); } }); - + // proxy all the other methods. // important when wrapping filters and duplexes. for (var i in stream) { @@ -45569,12 +45569,12 @@ }(i); } } - + // proxy certain important events. for (var n = 0; n < kProxyEvents.length; n++) { stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); } - + // when we try to consume some more bytes, simply unpause the // underlying stream. this._read = function (n) { @@ -45584,13 +45584,13 @@ stream.resume(); } }; - + return this; }; - + // exposed for testing purposes only. Readable._fromList = fromList; - + // Pluck off n bytes from an array of buffers. // Length is the combined lengths of all the buffers in the list. // This function is designed to be inlinable, so please take care when making @@ -45598,7 +45598,7 @@ function fromList(n, state) { // nothing buffered if (state.length === 0) return null; - + var ret; if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { // read it all, truncate the list @@ -45608,10 +45608,10 @@ // read part of list ret = fromListPartial(n, state.buffer, state.decoder); } - + return ret; } - + // Extracts only enough buffered data to satisfy the amount requested. // This function is designed to be inlinable, so please take care when making // changes to the function body. @@ -45630,7 +45630,7 @@ } return ret; } - + // Copies a specified amount of characters from the list of buffered data // chunks. // This function is designed to be inlinable, so please take care when making @@ -45660,7 +45660,7 @@ list.length -= c; return ret; } - + // Copies a specified amount of bytes from the list of buffered data chunks. // This function is designed to be inlinable, so please take care when making // changes to the function body. @@ -45690,20 +45690,20 @@ list.length -= c; return ret; } - + function endReadable(stream) { var state = stream._readableState; - + // If we get here before consuming all the bytes, then that is a // bug in node. Should never happen. if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); - + if (!state.endEmitted) { state.ended = true; processNextTick(endReadableNT, state, stream); } } - + function endReadableNT(state, stream) { // Check that we didn't get one last unshift. if (!state.endEmitted && state.length === 0) { @@ -45712,13 +45712,13 @@ stream.emit('end'); } } - + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xs[i], i); } } - + function indexOf(xs, x) { for (var i = 0, l = xs.length; i < l; i++) { if (xs[i] === x) return i; @@ -45747,7 +45747,7 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - + // a transform stream is a readable/writable stream where you do // something with the data. Sometimes it's called a "filter", // but that's not a great name for it, since that implies a thing where @@ -45789,50 +45789,50 @@ // However, even in such a pathological case, only a single written chunk // would be consumed, and then the rest would wait (un-transformed) until // the results of the previous transformed chunk were consumed. - + 'use strict'; - + module.exports = Transform; - + var Duplex = require('./_stream_duplex'); - + /**/ var util = require('core-util-is'); util.inherits = require('inherits'); /**/ - + util.inherits(Transform, Duplex); - + function afterTransform(er, data) { var ts = this._transformState; ts.transforming = false; - + var cb = ts.writecb; - + if (!cb) { return this.emit('error', new Error('write callback called multiple times')); } - + ts.writechunk = null; ts.writecb = null; - + if (data != null) // single equals check for both `null` and `undefined` this.push(data); - + cb(er); - + var rs = this._readableState; rs.reading = false; if (rs.needReadable || rs.length < rs.highWaterMark) { this._read(rs.highWaterMark); } } - + function Transform(options) { if (!(this instanceof Transform)) return new Transform(options); - + Duplex.call(this, options); - + this._transformState = { afterTransform: afterTransform.bind(this), needTransform: false, @@ -45841,28 +45841,28 @@ writechunk: null, writeencoding: null }; - + // start out asking for a readable event once data is transformed. this._readableState.needReadable = true; - + // we have implemented the _read method, and done the other things // that Readable wants before the first _read call, so unset the // sync guard flag. this._readableState.sync = false; - + if (options) { if (typeof options.transform === 'function') this._transform = options.transform; - + if (typeof options.flush === 'function') this._flush = options.flush; } - + // When the writable side finishes, then flush out anything remaining. this.on('prefinish', prefinish); } - + function prefinish() { var _this = this; - + if (typeof this._flush === 'function') { this._flush(function (er, data) { done(_this, er, data); @@ -45871,12 +45871,12 @@ done(this, null, null); } } - + Transform.prototype.push = function (chunk, encoding) { this._transformState.needTransform = false; return Duplex.prototype.push.call(this, chunk, encoding); }; - + // This is the part where you do stuff! // override this function in implementation classes. // 'chunk' is an input chunk. @@ -45890,7 +45890,7 @@ Transform.prototype._transform = function (chunk, encoding, cb) { throw new Error('_transform() is not implemented'); }; - + Transform.prototype._write = function (chunk, encoding, cb) { var ts = this._transformState; ts.writecb = cb; @@ -45901,13 +45901,13 @@ if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); } }; - + // Doesn't matter what the args are here. // _transform does all the work. // That we got here means that the readable side wants more data. Transform.prototype._read = function (n) { var ts = this._transformState; - + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { ts.transforming = true; this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); @@ -45917,28 +45917,28 @@ ts.needTransform = true; } }; - + Transform.prototype._destroy = function (err, cb) { var _this2 = this; - + Duplex.prototype._destroy.call(this, err, function (err2) { cb(err2); _this2.emit('close'); }); }; - + function done(stream, er, data) { if (er) return stream.emit('error', er); - + if (data != null) // single equals check for both `null` and `undefined` stream.push(data); - + // if there's nothing in the write buffer, then that means // that nothing more will ever be provided if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); - + if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); - + return stream.push(null); } },{"./_stream_duplex":276,"core-util-is":89,"inherits":180}],280:[function(require,module,exports){ @@ -45963,20 +45963,20 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - + // A bit simpler than readable streams. // Implement an async ._write(chunk, encoding, cb), and it'll handle all // the drain event emission and buffering. - + 'use strict'; - + /**/ - + var processNextTick = require('process-nextick-args').nextTick; /**/ - + module.exports = Writable; - + /* */ function WriteReq(chunk, encoding, cb) { this.chunk = chunk; @@ -45984,12 +45984,12 @@ this.callback = cb; this.next = null; } - + // It seems a linked list but it is not // there will be only 2 of these for each stream function CorkedRequest(state) { var _this = this; - + this.next = null; this.entry = null; this.finish = function () { @@ -45997,34 +45997,34 @@ }; } /* */ - + /**/ var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick; /**/ - + /**/ var Duplex; /**/ - + Writable.WritableState = WritableState; - + /**/ var util = require('core-util-is'); util.inherits = require('inherits'); /**/ - + /**/ var internalUtil = { deprecate: require('util-deprecate') }; /**/ - + /**/ var Stream = require('./internal/streams/stream'); /**/ - + /**/ - + var Buffer = require('safe-buffer').Buffer; var OurUint8Array = global.Uint8Array || function () {}; function _uint8ArrayToBuffer(chunk) { @@ -46033,48 +46033,48 @@ function _isUint8Array(obj) { return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; } - + /**/ - + var destroyImpl = require('./internal/streams/destroy'); - + util.inherits(Writable, Stream); - + function nop() {} - + function WritableState(options, stream) { Duplex = Duplex || require('./_stream_duplex'); - + options = options || {}; - + // Duplex streams are both readable and writable, but share // the same options object. // However, some cases require setting options to different // values for the readable and the writable sides of the duplex stream. // These options can be provided separately as readableXXX and writableXXX. var isDuplex = stream instanceof Duplex; - + // object stream flag to indicate whether or not this stream // contains buffers or objects. this.objectMode = !!options.objectMode; - + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; - + // the point at which write() starts returning false // Note: 0 is a valid value, means that we always return false if // the entire buffer is not flushed immediately on write() var hwm = options.highWaterMark; var writableHwm = options.writableHighWaterMark; var defaultHwm = this.objectMode ? 16 : 16 * 1024; - + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; - + // cast to ints. this.highWaterMark = Math.floor(this.highWaterMark); - + // if _final has been called this.finalCalled = false; - + // drain event flag. this.needDrain = false; // at the start of calling end() @@ -46083,76 +46083,76 @@ this.ended = false; // when 'finish' is emitted this.finished = false; - + // has it been destroyed this.destroyed = false; - + // should we decode strings into buffers before passing to _write? // this is here so that some node-core streams can optimize string // handling at a lower level. var noDecode = options.decodeStrings === false; this.decodeStrings = !noDecode; - + // Crypto is kind of old and crusty. Historically, its default string // encoding is 'binary' so we have to make this configurable. // Everything else in the universe uses 'utf8', though. this.defaultEncoding = options.defaultEncoding || 'utf8'; - + // not an actual buffer we keep track of, but a measurement // of how much we're waiting to get pushed to some underlying // socket or file. this.length = 0; - + // a flag to see when we're in the middle of a write. this.writing = false; - + // when true all writes will be buffered until .uncork() call this.corked = 0; - + // a flag to be able to tell if the onwrite cb is called immediately, // or on a later tick. We set this to true at first, because any // actions that shouldn't happen until "later" should generally also // not happen before the first write call. this.sync = true; - + // a flag to know if we're processing previously buffered items, which // may call the _write() callback in the same tick, so that we don't // end up in an overlapped onwrite situation. this.bufferProcessing = false; - + // the callback that's passed to _write(chunk,cb) this.onwrite = function (er) { onwrite(stream, er); }; - + // the callback that the user supplies to write(chunk,encoding,cb) this.writecb = null; - + // the amount that is being written when _write is called. this.writelen = 0; - + this.bufferedRequest = null; this.lastBufferedRequest = null; - + // number of pending user-supplied write callbacks // this must be 0 before 'finish' can be emitted this.pendingcb = 0; - + // emit prefinish if the only thing we're waiting for is _write cbs // This is relevant for synchronous Transform streams this.prefinished = false; - + // True if the error was already emitted and should not be thrown again this.errorEmitted = false; - + // count buffered requests this.bufferedRequestCount = 0; - + // allocate the first CorkedRequest, there is always // one allocated and free to use, and we maintain at most two this.corkedRequestsFree = new CorkedRequest(this); } - + WritableState.prototype.getBuffer = function getBuffer() { var current = this.bufferedRequest; var out = []; @@ -46162,7 +46162,7 @@ } return out; }; - + (function () { try { Object.defineProperty(WritableState.prototype, 'buffer', { @@ -46172,7 +46172,7 @@ }); } catch (_) {} })(); - + // Test _writableState for inheritance to account for Duplex streams, // whose prototype chain only points to Readable. var realHasInstance; @@ -46182,7 +46182,7 @@ value: function (object) { if (realHasInstance.call(this, object)) return true; if (this !== Writable) return false; - + return object && object._writableState instanceof WritableState; } }); @@ -46191,58 +46191,58 @@ return object instanceof this; }; } - + function Writable(options) { Duplex = Duplex || require('./_stream_duplex'); - + // Writable ctor is applied to Duplexes, too. // `realHasInstance` is necessary because using plain `instanceof` // would return false, as no `_writableState` property is attached. - + // Trying to use the custom `instanceof` for Writable here will also break the // Node.js LazyTransform implementation, which has a non-trivial getter for // `_writableState` that would lead to infinite recursion. if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { return new Writable(options); } - + this._writableState = new WritableState(options, this); - + // legacy. this.writable = true; - + if (options) { if (typeof options.write === 'function') this._write = options.write; - + if (typeof options.writev === 'function') this._writev = options.writev; - + if (typeof options.destroy === 'function') this._destroy = options.destroy; - + if (typeof options.final === 'function') this._final = options.final; } - + Stream.call(this); } - + // Otherwise people can pipe Writable streams, which is just wrong. Writable.prototype.pipe = function () { this.emit('error', new Error('Cannot pipe, not readable')); }; - + function writeAfterEnd(stream, cb) { var er = new Error('write after end'); // TODO: defer error events consistently everywhere, not just the cb stream.emit('error', er); processNextTick(cb, er); } - + // Checks that a user-supplied chunk is valid, especially for the particular // mode the stream is in. Currently this means that `null` is never accepted // and undefined/non-string values are only allowed in object mode. function validChunk(stream, state, chunk, cb) { var valid = true; var er = false; - + if (chunk === null) { er = new TypeError('May not write null values to stream'); } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { @@ -46255,49 +46255,49 @@ } return valid; } - + Writable.prototype.write = function (chunk, encoding, cb) { var state = this._writableState; var ret = false; var isBuf = !state.objectMode && _isUint8Array(chunk); - + if (isBuf && !Buffer.isBuffer(chunk)) { chunk = _uint8ArrayToBuffer(chunk); } - + if (typeof encoding === 'function') { cb = encoding; encoding = null; } - + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; - + if (typeof cb !== 'function') cb = nop; - + if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { state.pendingcb++; ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); } - + return ret; }; - + Writable.prototype.cork = function () { var state = this._writableState; - + state.corked++; }; - + Writable.prototype.uncork = function () { var state = this._writableState; - + if (state.corked) { state.corked--; - + if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); } }; - + Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { // node::ParseEncoding() requires lower case. if (typeof encoding === 'string') encoding = encoding.toLowerCase(); @@ -46305,14 +46305,14 @@ this._writableState.defaultEncoding = encoding; return this; }; - + function decodeChunk(state, chunk, encoding) { if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { chunk = Buffer.from(chunk, encoding); } return chunk; } - + // if we're already writing something, then just put this // in the queue, and wait our turn. Otherwise, call _write // If we return false, then we need a drain event, so set that flag. @@ -46326,13 +46326,13 @@ } } var len = state.objectMode ? 1 : chunk.length; - + state.length += len; - + var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false. if (!ret) state.needDrain = true; - + if (state.writing || state.corked) { var last = state.lastBufferedRequest; state.lastBufferedRequest = { @@ -46351,10 +46351,10 @@ } else { doWrite(stream, state, false, len, chunk, encoding, cb); } - + return ret; } - + function doWrite(stream, state, writev, len, chunk, encoding, cb) { state.writelen = len; state.writecb = cb; @@ -46363,10 +46363,10 @@ if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); state.sync = false; } - + function onwriteError(stream, state, sync, er, cb) { --state.pendingcb; - + if (sync) { // defer the callback if we are being called synchronously // to avoid piling up things on the stack @@ -46387,29 +46387,29 @@ finishMaybe(stream, state); } } - + function onwriteStateUpdate(state) { state.writing = false; state.writecb = null; state.length -= state.writelen; state.writelen = 0; } - + function onwrite(stream, er) { var state = stream._writableState; var sync = state.sync; var cb = state.writecb; - + onwriteStateUpdate(state); - + if (er) onwriteError(stream, state, sync, er, cb);else { // Check if we're actually ready to finish, but don't emit yet var finished = needFinish(state); - + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { clearBuffer(stream, state); } - + if (sync) { /**/ asyncWrite(afterWrite, stream, state, finished, cb); @@ -46419,14 +46419,14 @@ } } } - + function afterWrite(stream, state, finished, cb) { if (!finished) onwriteDrain(stream, state); state.pendingcb--; cb(); finishMaybe(stream, state); } - + // Must force callback to be called on nextTick, so that we don't // emit 'drain' before the write() consumer gets the 'false' return // value, and has a chance to attach a 'drain' listener. @@ -46436,19 +46436,19 @@ stream.emit('drain'); } } - + // if there's something in the buffer waiting, then process it function clearBuffer(stream, state) { state.bufferProcessing = true; var entry = state.bufferedRequest; - + if (stream._writev && entry && entry.next) { // Fast case, write everything using _writev() var l = state.bufferedRequestCount; var buffer = new Array(l); var holder = state.corkedRequestsFree; holder.entry = entry; - + var count = 0; var allBuffers = true; while (entry) { @@ -46458,9 +46458,9 @@ count += 1; } buffer.allBuffers = allBuffers; - + doWrite(stream, state, true, state.length, buffer, '', holder.finish); - + // doWrite is almost always async, defer these to save a bit of time // as the hot path ends with doWrite state.pendingcb++; @@ -46479,7 +46479,7 @@ var encoding = entry.encoding; var cb = entry.callback; var len = state.objectMode ? 1 : chunk.length; - + doWrite(stream, state, false, len, chunk, encoding, cb); entry = entry.next; state.bufferedRequestCount--; @@ -46491,23 +46491,23 @@ break; } } - + if (entry === null) state.lastBufferedRequest = null; } - + state.bufferedRequest = entry; state.bufferProcessing = false; } - + Writable.prototype._write = function (chunk, encoding, cb) { cb(new Error('_write() is not implemented')); }; - + Writable.prototype._writev = null; - + Writable.prototype.end = function (chunk, encoding, cb) { var state = this._writableState; - + if (typeof chunk === 'function') { cb = chunk; chunk = null; @@ -46516,19 +46516,19 @@ cb = encoding; encoding = null; } - + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); - + // .end() fully uncorks if (state.corked) { state.corked = 1; this.uncork(); } - + // ignore unnecessary end() calls. if (!state.ending && !state.finished) endWritable(this, state, cb); }; - + function needFinish(state) { return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; } @@ -46555,7 +46555,7 @@ } } } - + function finishMaybe(stream, state) { var need = needFinish(state); if (need) { @@ -46567,7 +46567,7 @@ } return need; } - + function endWritable(stream, state, cb) { state.ending = true; finishMaybe(stream, state); @@ -46577,7 +46577,7 @@ state.ended = true; stream.writable = false; } - + function onCorkedFinish(corkReq, state, err) { var entry = corkReq.entry; corkReq.entry = null; @@ -46593,7 +46593,7 @@ state.corkedRequestsFree = corkReq; } } - + Object.defineProperty(Writable.prototype, 'destroyed', { get: function () { if (this._writableState === undefined) { @@ -46607,13 +46607,13 @@ if (!this._writableState) { return; } - + // backward compatibility, the user is explicitly // managing destroyed this._writableState.destroyed = value; } }); - + Writable.prototype.destroy = destroyImpl.destroy; Writable.prototype._undestroy = destroyImpl.undestroy; Writable.prototype._destroy = function (err, cb) { @@ -46623,39 +46623,39 @@ }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"./_stream_duplex":276,"./internal/streams/destroy":282,"./internal/streams/stream":283,"_process":257,"core-util-is":89,"inherits":180,"process-nextick-args":256,"safe-buffer":290,"util-deprecate":330}],281:[function(require,module,exports){ 'use strict'; - + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - + var Buffer = require('safe-buffer').Buffer; var util = require('util'); - + function copyBuffer(src, target, offset) { src.copy(target, offset); } - + module.exports = function () { function BufferList() { _classCallCheck(this, BufferList); - + this.head = null; this.tail = null; this.length = 0; } - + BufferList.prototype.push = function push(v) { var entry = { data: v, next: null }; if (this.length > 0) this.tail.next = entry;else this.head = entry; this.tail = entry; ++this.length; }; - + BufferList.prototype.unshift = function unshift(v) { var entry = { data: v, next: this.head }; if (this.length === 0) this.tail = entry; this.head = entry; ++this.length; }; - + BufferList.prototype.shift = function shift() { if (this.length === 0) return; var ret = this.head.data; @@ -46663,12 +46663,12 @@ --this.length; return ret; }; - + BufferList.prototype.clear = function clear() { this.head = this.tail = null; this.length = 0; }; - + BufferList.prototype.join = function join(s) { if (this.length === 0) return ''; var p = this.head; @@ -46677,7 +46677,7 @@ ret += s + p.data; }return ret; }; - + BufferList.prototype.concat = function concat(n) { if (this.length === 0) return Buffer.alloc(0); if (this.length === 1) return this.head.data; @@ -46691,10 +46691,10 @@ } return ret; }; - + return BufferList; }(); - + if (util && util.inspect && util.inspect.custom) { module.exports.prototype[util.inspect.custom] = function () { var obj = util.inspect({ length: this.length }); @@ -46703,19 +46703,19 @@ } },{"safe-buffer":290,"util":55}],282:[function(require,module,exports){ 'use strict'; - + /**/ - + var processNextTick = require('process-nextick-args').nextTick; /**/ - + // undocumented cb() API, needed for core, not for public API function destroy(err, cb) { var _this = this; - + var readableDestroyed = this._readableState && this._readableState.destroyed; var writableDestroyed = this._writableState && this._writableState.destroyed; - + if (readableDestroyed || writableDestroyed) { if (cb) { cb(err); @@ -46724,19 +46724,19 @@ } return this; } - + // we set destroyed to true before firing error callbacks in order // to make it re-entrance safe in case destroy() is called within callbacks - + if (this._readableState) { this._readableState.destroyed = true; } - + // if this is a duplex stream mark the writable part as destroyed as well if (this._writableState) { this._writableState.destroyed = true; } - + this._destroy(err || null, function (err) { if (!cb && err) { processNextTick(emitErrorNT, _this, err); @@ -46747,10 +46747,10 @@ cb(err); } }); - + return this; } - + function undestroy() { if (this._readableState) { this._readableState.destroyed = false; @@ -46758,7 +46758,7 @@ this._readableState.ended = false; this._readableState.endEmitted = false; } - + if (this._writableState) { this._writableState.destroyed = false; this._writableState.ended = false; @@ -46767,21 +46767,21 @@ this._writableState.errorEmitted = false; } } - + function emitErrorNT(self, err) { self.emit('error', err); } - + module.exports = { destroy: destroy, undestroy: undestroy }; },{"process-nextick-args":256}],283:[function(require,module,exports){ module.exports = require('events').EventEmitter; - + },{"events":157}],284:[function(require,module,exports){ module.exports = require('./readable').PassThrough - + },{"./readable":285}],285:[function(require,module,exports){ exports = module.exports = require('./lib/_stream_readable.js'); exports.Stream = exports; @@ -46790,22 +46790,22 @@ exports.Duplex = require('./lib/_stream_duplex.js'); exports.Transform = require('./lib/_stream_transform.js'); exports.PassThrough = require('./lib/_stream_passthrough.js'); - + },{"./lib/_stream_duplex.js":276,"./lib/_stream_passthrough.js":277,"./lib/_stream_readable.js":278,"./lib/_stream_transform.js":279,"./lib/_stream_writable.js":280}],286:[function(require,module,exports){ module.exports = require('./readable').Transform - + },{"./readable":285}],287:[function(require,module,exports){ module.exports = require('./lib/_stream_writable.js'); - + },{"./lib/_stream_writable.js":280}],288:[function(require,module,exports){ (function (Buffer){ 'use strict' var inherits = require('inherits') var HashBase = require('hash-base') - + function RIPEMD160 () { HashBase.call(this, 64) - + // state this._a = 0x67452301 this._b = 0xefcdab89 @@ -46813,19 +46813,19 @@ this._d = 0x10325476 this._e = 0xc3d2e1f0 } - + inherits(RIPEMD160, HashBase) - + RIPEMD160.prototype._update = function () { var m = new Array(16) for (var i = 0; i < 16; ++i) m[i] = this._block.readInt32LE(i * 4) - + var al = this._a var bl = this._b var cl = this._c var dl = this._d var el = this._e - + // Mj = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 // K = 0x00000000 // Sj = 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8 @@ -46845,7 +46845,7 @@ cl = fn1(cl, dl, el, al, bl, m[13], 0x00000000, 7); el = rotl(el, 10) bl = fn1(bl, cl, dl, el, al, m[14], 0x00000000, 9); dl = rotl(dl, 10) al = fn1(al, bl, cl, dl, el, m[15], 0x00000000, 8); cl = rotl(cl, 10) - + // Mj = 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8 // K = 0x5a827999 // Sj = 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12 @@ -46865,7 +46865,7 @@ bl = fn2(bl, cl, dl, el, al, m[14], 0x5a827999, 7); dl = rotl(dl, 10) al = fn2(al, bl, cl, dl, el, m[11], 0x5a827999, 13); cl = rotl(cl, 10) el = fn2(el, al, bl, cl, dl, m[8], 0x5a827999, 12); bl = rotl(bl, 10) - + // Mj = 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12 // K = 0x6ed9eba1 // Sj = 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5 @@ -46885,7 +46885,7 @@ al = fn3(al, bl, cl, dl, el, m[11], 0x6ed9eba1, 12); cl = rotl(cl, 10) el = fn3(el, al, bl, cl, dl, m[5], 0x6ed9eba1, 7); bl = rotl(bl, 10) dl = fn3(dl, el, al, bl, cl, m[12], 0x6ed9eba1, 5); al = rotl(al, 10) - + // Mj = 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2 // K = 0x8f1bbcdc // Sj = 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12 @@ -46905,7 +46905,7 @@ el = fn4(el, al, bl, cl, dl, m[5], 0x8f1bbcdc, 6); bl = rotl(bl, 10) dl = fn4(dl, el, al, bl, cl, m[6], 0x8f1bbcdc, 5); al = rotl(al, 10) cl = fn4(cl, dl, el, al, bl, m[2], 0x8f1bbcdc, 12); el = rotl(el, 10) - + // Mj = 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 // K = 0xa953fd4e // Sj = 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 @@ -46925,13 +46925,13 @@ dl = fn5(dl, el, al, bl, cl, m[6], 0xa953fd4e, 8); al = rotl(al, 10) cl = fn5(cl, dl, el, al, bl, m[15], 0xa953fd4e, 5); el = rotl(el, 10) bl = fn5(bl, cl, dl, el, al, m[13], 0xa953fd4e, 6); dl = rotl(dl, 10) - + var ar = this._a var br = this._b var cr = this._c var dr = this._d var er = this._e - + // M'j = 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12 // K' = 0x50a28be6 // S'j = 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6 @@ -46951,7 +46951,7 @@ cr = fn5(cr, dr, er, ar, br, m[10], 0x50a28be6, 14); er = rotl(er, 10) br = fn5(br, cr, dr, er, ar, m[3], 0x50a28be6, 12); dr = rotl(dr, 10) ar = fn5(ar, br, cr, dr, er, m[12], 0x50a28be6, 6); cr = rotl(cr, 10) - + // M'j = 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2 // K' = 0x5c4dd124 // S'j = 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11 @@ -46971,7 +46971,7 @@ br = fn4(br, cr, dr, er, ar, m[9], 0x5c4dd124, 15); dr = rotl(dr, 10) ar = fn4(ar, br, cr, dr, er, m[1], 0x5c4dd124, 13); cr = rotl(cr, 10) er = fn4(er, ar, br, cr, dr, m[2], 0x5c4dd124, 11); br = rotl(br, 10) - + // M'j = 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13 // K' = 0x6d703ef3 // S'j = 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5 @@ -46991,7 +46991,7 @@ ar = fn3(ar, br, cr, dr, er, m[0], 0x6d703ef3, 13); cr = rotl(cr, 10) er = fn3(er, ar, br, cr, dr, m[4], 0x6d703ef3, 7); br = rotl(br, 10) dr = fn3(dr, er, ar, br, cr, m[13], 0x6d703ef3, 5); ar = rotl(ar, 10) - + // M'j = 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14 // K' = 0x7a6d76e9 // S'j = 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8 @@ -47011,7 +47011,7 @@ er = fn2(er, ar, br, cr, dr, m[7], 0x7a6d76e9, 5); br = rotl(br, 10) dr = fn2(dr, er, ar, br, cr, m[10], 0x7a6d76e9, 15); ar = rotl(ar, 10) cr = fn2(cr, dr, er, ar, br, m[14], 0x7a6d76e9, 8); er = rotl(er, 10) - + // M'j = 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 // K' = 0x00000000 // S'j = 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 @@ -47031,7 +47031,7 @@ dr = fn1(dr, er, ar, br, cr, m[3], 0x00000000, 13); ar = rotl(ar, 10) cr = fn1(cr, dr, er, ar, br, m[9], 0x00000000, 11); er = rotl(er, 10) br = fn1(br, cr, dr, er, ar, m[11], 0x00000000, 11); dr = rotl(dr, 10) - + // change state var t = (this._b + cl + dr) | 0 this._b = (this._c + dl + er) | 0 @@ -47040,7 +47040,7 @@ this._e = (this._a + bl + cr) | 0 this._a = t } - + RIPEMD160.prototype._digest = function () { // create padding and handle blocks this._block[this._blockOffset++] = 0x80 @@ -47049,12 +47049,12 @@ this._update() this._blockOffset = 0 } - + this._block.fill(0, this._blockOffset, 56) this._block.writeUInt32LE(this._length[0], 56) this._block.writeUInt32LE(this._length[1], 60) this._update() - + // produce result var buffer = new Buffer(20) buffer.writeInt32LE(this._a, 0) @@ -47064,33 +47064,33 @@ buffer.writeInt32LE(this._e, 16) return buffer } - + function rotl (x, n) { return (x << n) | (x >>> (32 - n)) } - + function fn1 (a, b, c, d, e, m, k, s) { return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0 } - + function fn2 (a, b, c, d, e, m, k, s) { return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 0 } - + function fn3 (a, b, c, d, e, m, k, s) { return (rotl((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 0 } - + function fn4 (a, b, c, d, e, m, k, s) { return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 0 } - + function fn5 (a, b, c, d, e, m, k, s) { return (rotl((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 0 } - + module.exports = RIPEMD160 - + }).call(this,require("buffer").Buffer) },{"buffer":84,"hash-base":161,"inherits":180}],289:[function(require,module,exports){ const assert = require('assert') @@ -47119,15 +47119,15 @@ } } } - + function safeParseInt (v, base) { if (v.slice(0, 2) === '00') { throw (new Error('invalid RLP: extra zeros')) } - + return parseInt(v, base) } - + function encodeLength (len, offset) { if (len < 56) { return Buffer.from([len + offset]) @@ -47138,7 +47138,7 @@ return Buffer.from(firstByte + hexLength, 'hex') } } - + /** * RLP Decoding based on: {@link https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-RLP|RLP} * @param {Buffer,String,Integer,Array} data - will be converted to buffer @@ -47148,23 +47148,23 @@ if (!input || input.length === 0) { return Buffer.from([]) } - + input = toBuffer(input) var decoded = _decode(input) - + if (stream) { return decoded } - + assert.equal(decoded.remainder.length, 0, 'invalid remainder') return decoded.data } - + exports.getLength = function (input) { if (!input || input.length === 0) { return Buffer.from([]) } - + input = toBuffer(input) var firstByte = input[0] if (firstByte <= 0x7f) { @@ -47183,12 +47183,12 @@ return llength + length } } - + function _decode (input) { var length, llength, data, innerRemainder, d var decoded = [] var firstByte = input[0] - + if (firstByte <= 0x7f) { // a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding. return { @@ -47199,18 +47199,18 @@ // string is 0-55 bytes long. A single byte with value 0x80 plus the length of the string followed by the string // The range of the first byte is [0x80, 0xb7] length = firstByte - 0x7f - + // set 0x80 null to 0 if (firstByte === 0x80) { data = Buffer.from([]) } else { data = input.slice(1, length) } - + if (length === 2 && data[0] < 0x80) { throw new Error('invalid rlp encoding: byte must be less 0x80') } - + return { data: data, remainder: input.slice(length) @@ -47222,7 +47222,7 @@ if (data.length < length) { throw (new Error('invalid RLP')) } - + return { data: data, remainder: input.slice(length + llength) @@ -47236,7 +47236,7 @@ decoded.push(d.data) innerRemainder = d.remainder } - + return { data: decoded, remainder: input.slice(length) @@ -47249,12 +47249,12 @@ if (totalLength > input.length) { throw new Error('invalid rlp: total length is larger than the data') } - + innerRemainder = input.slice(llength, totalLength) if (innerRemainder.length === 0) { throw new Error('invalid rlp, List has a invalid length') } - + while (innerRemainder.length) { d = _decode(innerRemainder) decoded.push(d.data) @@ -47266,11 +47266,11 @@ } } } - + function isHexPrefixed (str) { return str.slice(0, 2) === '0x' } - + // Removes 0x from a given String function stripHexPrefix (str) { if (typeof str !== 'string') { @@ -47278,26 +47278,26 @@ } return isHexPrefixed(str) ? str.slice(2) : str } - + function intToHex (i) { var hex = i.toString(16) if (hex.length % 2) { hex = '0' + hex } - + return hex } - + function padToEven (a) { if (a.length % 2) a = '0' + a return a } - + function intToBuffer (i) { var hex = intToHex(i) return Buffer.from(hex, 'hex') } - + function toBuffer (v) { if (!Buffer.isBuffer(v)) { if (typeof v === 'string') { @@ -47323,12 +47323,12 @@ } return v } - + },{"assert":19,"safe-buffer":290}],290:[function(require,module,exports){ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') var Buffer = buffer.Buffer - + // alternative to using Object.keys for old browsers function copyProps (src, dst) { for (var key in src) { @@ -47342,21 +47342,21 @@ copyProps(buffer, exports) exports.Buffer = SafeBuffer } - + function SafeBuffer (arg, encodingOrOffset, length) { return Buffer(arg, encodingOrOffset, length) } - + // Copy static methods from Buffer copyProps(Buffer, SafeBuffer) - + SafeBuffer.from = function (arg, encodingOrOffset, length) { if (typeof arg === 'number') { throw new TypeError('Argument must not be a number') } return Buffer(arg, encodingOrOffset, length) } - + SafeBuffer.alloc = function (size, fill, encoding) { if (typeof size !== 'number') { throw new TypeError('Argument must be a number') @@ -47373,54 +47373,54 @@ } return buf } - + SafeBuffer.allocUnsafe = function (size) { if (typeof size !== 'number') { throw new TypeError('Argument must be a number') } return Buffer(size) } - + SafeBuffer.allocUnsafeSlow = function (size) { if (typeof size !== 'number') { throw new TypeError('Argument must be a number') } return buffer.SlowBuffer(size) } - + },{"buffer":84}],291:[function(require,module,exports){ const util = require('util') const EventEmitter = require('events/') - + var R = typeof Reflect === 'object' ? Reflect : null var ReflectApply = R && typeof R.apply === 'function' ? R.apply : function ReflectApply(target, receiver, args) { return Function.prototype.apply.call(target, receiver, args); } - + module.exports = SafeEventEmitter - - + + function SafeEventEmitter() { EventEmitter.call(this) } - + util.inherits(SafeEventEmitter, EventEmitter) - + SafeEventEmitter.prototype.emit = function (type) { // copied from https://github.com/Gozala/events/blob/master/events.js // modified lines are commented with "edited:" var args = []; for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); var doError = (type === 'error'); - + var events = this._events; if (events !== undefined) doError = (doError && events.error === undefined); else if (!doError) return false; - + // If there is no 'error' event listener then throw. if (doError) { var er; @@ -47436,12 +47436,12 @@ err.context = er; throw err; // Unhandled 'error' event } - + var handler = events[type]; - + if (handler === undefined) return false; - + if (typeof handler === 'function') { // edited: using safeApply safeApply(handler, this, args); @@ -47452,10 +47452,10 @@ // edited: using safeApply safeApply(listeners[i], this, args); } - + return true; } - + function safeApply(handler, context, args) { try { ReflectApply(handler, context, args) @@ -47466,14 +47466,14 @@ }) } } - + function arrayClone(arr, n) { var copy = new Array(n); for (var i = 0; i < n; ++i) copy[i] = arr[i]; return copy; } - + },{"events/":292,"util":333}],292:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // @@ -47495,16 +47495,16 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - + 'use strict'; - + var R = typeof Reflect === 'object' ? Reflect : null var ReflectApply = R && typeof R.apply === 'function' ? R.apply : function ReflectApply(target, receiver, args) { return Function.prototype.apply.call(target, receiver, args); } - + var ReflectOwnKeys if (R && typeof R.ownKeys === 'function') { ReflectOwnKeys = R.ownKeys @@ -47518,31 +47518,31 @@ return Object.getOwnPropertyNames(target); }; } - + function ProcessEmitWarning(warning) { if (console && console.warn) console.warn(warning); } - + var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) { return value !== value; } - + function EventEmitter() { EventEmitter.init.call(this); } module.exports = EventEmitter; - + // Backwards-compat with node 0.10.x EventEmitter.EventEmitter = EventEmitter; - + EventEmitter.prototype._events = undefined; EventEmitter.prototype._eventsCount = 0; EventEmitter.prototype._maxListeners = undefined; - + // By default EventEmitters will print a warning if more than 10 listeners are // added to it. This is a useful default which helps finding memory leaks. var defaultMaxListeners = 10; - + Object.defineProperty(EventEmitter, 'defaultMaxListeners', { enumerable: true, get: function() { @@ -47555,18 +47555,18 @@ defaultMaxListeners = arg; } }); - + EventEmitter.init = function() { - + if (this._events === undefined || this._events === Object.getPrototypeOf(this)._events) { this._events = Object.create(null); this._eventsCount = 0; } - + this._maxListeners = this._maxListeners || undefined; }; - + // Obviously not all Emitters should be limited to 10. This function allows // that to be increased. Set to zero for unlimited. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { @@ -47576,28 +47576,28 @@ this._maxListeners = n; return this; }; - + function $getMaxListeners(that) { if (that._maxListeners === undefined) return EventEmitter.defaultMaxListeners; return that._maxListeners; } - + EventEmitter.prototype.getMaxListeners = function getMaxListeners() { return $getMaxListeners(this); }; - + EventEmitter.prototype.emit = function emit(type) { var args = []; for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); var doError = (type === 'error'); - + var events = this._events; if (events !== undefined) doError = (doError && events.error === undefined); else if (!doError) return false; - + // If there is no 'error' event listener then throw. if (doError) { var er; @@ -47613,12 +47613,12 @@ err.context = er; throw err; // Unhandled 'error' event } - + var handler = events[type]; - + if (handler === undefined) return false; - + if (typeof handler === 'function') { ReflectApply(handler, this, args); } else { @@ -47627,19 +47627,19 @@ for (var i = 0; i < len; ++i) ReflectApply(listeners[i], this, args); } - + return true; }; - + function _addListener(target, type, listener, prepend) { var m; var events; var existing; - + if (typeof listener !== 'function') { throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); } - + events = target._events; if (events === undefined) { events = target._events = Object.create(null); @@ -47650,14 +47650,14 @@ if (events.newListener !== undefined) { target.emit('newListener', type, listener.listener ? listener.listener : listener); - + // Re-assign `events` because a newListener handler could have caused the // this._events to be assigned to a new object events = target._events; } existing = events[type]; } - + if (existing === undefined) { // Optimize the case of one listener. Don't need the extra array object. existing = events[type] = listener; @@ -47673,7 +47673,7 @@ } else { existing.push(listener); } - + // Check for listener leak m = $getMaxListeners(target); if (m > 0 && existing.length > m && !existing.warned) { @@ -47691,21 +47691,21 @@ ProcessEmitWarning(w); } } - + return target; } - + EventEmitter.prototype.addListener = function addListener(type, listener) { return _addListener(this, type, listener, false); }; - + EventEmitter.prototype.on = EventEmitter.prototype.addListener; - + EventEmitter.prototype.prependListener = function prependListener(type, listener) { return _addListener(this, type, listener, true); }; - + function onceWrapper() { var args = []; for (var i = 0; i < arguments.length; i++) args.push(arguments[i]); @@ -47715,7 +47715,7 @@ ReflectApply(this.listener, this.target, args); } } - + function _onceWrap(target, type, listener) { var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; var wrapped = onceWrapper.bind(state); @@ -47723,7 +47723,7 @@ state.wrapFn = wrapped; return wrapped; } - + EventEmitter.prototype.once = function once(type, listener) { if (typeof listener !== 'function') { throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); @@ -47731,7 +47731,7 @@ this.on(type, _onceWrap(this, type, listener)); return this; }; - + EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) { if (typeof listener !== 'function') { @@ -47740,24 +47740,24 @@ this.prependListener(type, _onceWrap(this, type, listener)); return this; }; - + // Emits a 'removeListener' event if and only if the listener was removed. EventEmitter.prototype.removeListener = function removeListener(type, listener) { var list, events, position, i, originalListener; - + if (typeof listener !== 'function') { throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); } - + events = this._events; if (events === undefined) return this; - + list = events[type]; if (list === undefined) return this; - + if (list === listener || list.listener === listener) { if (--this._eventsCount === 0) this._events = Object.create(null); @@ -47768,7 +47768,7 @@ } } else if (typeof list !== 'function') { position = -1; - + for (i = list.length - 1; i >= 0; i--) { if (list[i] === listener || list[i].listener === listener) { originalListener = list[i].listener; @@ -47776,36 +47776,36 @@ break; } } - + if (position < 0) return this; - + if (position === 0) list.shift(); else { spliceOne(list, position); } - + if (list.length === 1) events[type] = list[0]; - + if (events.removeListener !== undefined) this.emit('removeListener', type, originalListener || listener); } - + return this; }; - + EventEmitter.prototype.off = EventEmitter.prototype.removeListener; - + EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) { var listeners, events, i; - + events = this._events; if (events === undefined) return this; - + // not listening for removeListener, no need to emit if (events.removeListener === undefined) { if (arguments.length === 0) { @@ -47819,7 +47819,7 @@ } return this; } - + // emit removeListener for all listeners on all events if (arguments.length === 0) { var keys = Object.keys(events); @@ -47834,9 +47834,9 @@ this._eventsCount = 0; return this; } - + listeners = events[type]; - + if (typeof listeners === 'function') { this.removeListener(type, listeners); } else if (listeners !== undefined) { @@ -47845,35 +47845,35 @@ this.removeListener(type, listeners[i]); } } - + return this; }; - + function _listeners(target, type, unwrap) { var events = target._events; - + if (events === undefined) return []; - + var evlistener = events[type]; if (evlistener === undefined) return []; - + if (typeof evlistener === 'function') return unwrap ? [evlistener.listener || evlistener] : [evlistener]; - + return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); } - + EventEmitter.prototype.listeners = function listeners(type) { return _listeners(this, type, true); }; - + EventEmitter.prototype.rawListeners = function rawListeners(type) { return _listeners(this, type, false); }; - + EventEmitter.listenerCount = function(emitter, type) { if (typeof emitter.listenerCount === 'function') { return emitter.listenerCount(type); @@ -47881,41 +47881,41 @@ return listenerCount.call(emitter, type); } }; - + EventEmitter.prototype.listenerCount = listenerCount; function listenerCount(type) { var events = this._events; - + if (events !== undefined) { var evlistener = events[type]; - + if (typeof evlistener === 'function') { return 1; } else if (evlistener !== undefined) { return evlistener.length; } } - + return 0; } - + EventEmitter.prototype.eventNames = function eventNames() { return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; }; - + function arrayClone(arr, n) { var copy = new Array(n); for (var i = 0; i < n; ++i) copy[i] = arr[i]; return copy; } - + function spliceOne(list, index) { for (; index + 1 < list.length; index++) list[index] = list[index + 1]; list.pop(); } - + function unwrapListeners(arr) { var ret = new Array(arr.length); for (var i = 0; i < ret.length; ++i) { @@ -47923,42 +47923,42 @@ } return ret; } - + },{}],293:[function(require,module,exports){ module.exports = require('scryptsy') - + },{"scryptsy":294}],294:[function(require,module,exports){ (function (Buffer){ var pbkdf2Sync = require('pbkdf2').pbkdf2Sync - + var MAX_VALUE = 0x7fffffff - + // N = Cpu cost, r = Memory cost, p = parallelization cost function scrypt (key, salt, N, r, p, dkLen, progressCallback) { if (N === 0 || (N & (N - 1)) !== 0) throw Error('N must be > 0 and a power of 2') - + if (N > MAX_VALUE / 128 / r) throw Error('Parameter N is too large') if (r > MAX_VALUE / 128 / p) throw Error('Parameter r is too large') - + var XY = new Buffer(256 * r) var V = new Buffer(128 * r * N) - + // pseudo global var B32 = new Int32Array(16) // salsa20_8 var x = new Int32Array(16) // salsa20_8 var _X = new Buffer(64) // blockmix_salsa8 - + // pseudo global var B = pbkdf2Sync(key, salt, 1, p * 128 * r, 'sha256') - + var tickCallback if (progressCallback) { var totalOps = p * N * 2 var currentOp = 0 - + tickCallback = function () { ++currentOp - + // send progress notifications once every 1,000 ops if (currentOp % 1000 === 0) { progressCallback({ @@ -47969,69 +47969,69 @@ } } } - + for (var i = 0; i < p; i++) { smix(B, i * 128 * r, r, N, V, XY) } - + return pbkdf2Sync(key, B, 1, dkLen, 'sha256') - + // all of these functions are actually moved to the top // due to function hoisting - + function smix (B, Bi, r, N, V, XY) { var Xi = 0 var Yi = 128 * r var i - + B.copy(XY, Xi, Bi, Bi + Yi) - + for (i = 0; i < N; i++) { XY.copy(V, i * Yi, Xi, Xi + Yi) blockmix_salsa8(XY, Xi, Yi, r) - + if (tickCallback) tickCallback() } - + for (i = 0; i < N; i++) { var offset = Xi + (2 * r - 1) * 64 var j = XY.readUInt32LE(offset) & (N - 1) blockxor(V, j * Yi, XY, Xi, Yi) blockmix_salsa8(XY, Xi, Yi, r) - + if (tickCallback) tickCallback() } - + XY.copy(B, Bi, Xi, Xi + Yi) } - + function blockmix_salsa8 (BY, Bi, Yi, r) { var i - + arraycopy(BY, Bi + (2 * r - 1) * 64, _X, 0, 64) - + for (i = 0; i < 2 * r; i++) { blockxor(BY, i * 64, _X, 0, 64) salsa20_8(_X) arraycopy(_X, 0, BY, Yi + (i * 64), 64) } - + for (i = 0; i < r; i++) { arraycopy(BY, Yi + (i * 2) * 64, BY, Bi + (i * 64), 64) } - + for (i = 0; i < r; i++) { arraycopy(BY, Yi + (i * 2 + 1) * 64, BY, Bi + (i + r) * 64, 64) } } - + function R (a, b) { return (a << b) | (a >>> (32 - b)) } - + function salsa20_8 (B) { var i - + for (i = 0; i < 16; i++) { B32[i] = (B[i * 4 + 0] & 0xff) << 0 B32[i] |= (B[i * 4 + 1] & 0xff) << 8 @@ -48039,9 +48039,9 @@ B32[i] |= (B[i * 4 + 3] & 0xff) << 24 // B32[i] = B.readUInt32LE(i*4) <--- this is signficantly slower even in Node.js } - + arraycopy(B32, 0, x, 0, 16) - + for (i = 8; i > 0; i -= 2) { x[ 4] ^= R(x[ 0] + x[12], 7) x[ 8] ^= R(x[ 4] + x[ 0], 9) @@ -48076,9 +48076,9 @@ x[14] ^= R(x[13] + x[12], 13) x[15] ^= R(x[14] + x[13], 18) } - + for (i = 0; i < 16; ++i) B32[i] = x[i] + B32[i] - + for (i = 0; i < 16; i++) { var bi = i * 4 B[bi + 0] = (B32[i] >> 0 & 0xff) @@ -48088,7 +48088,7 @@ // B.writeInt32LE(B32[i], i*4) //<--- this is signficantly slower even in Node.js } } - + // naive approach... going back to loop unrolling may yield additional performance function blockxor (S, Si, D, Di, len) { for (var i = 0; i < len; i++) { @@ -48096,7 +48096,7 @@ } } } - + function arraycopy (src, srcPos, dest, destPos, length) { if (Buffer.isBuffer(src) && Buffer.isBuffer(dest)) { src.copy(dest, destPos, srcPos, srcPos + length) @@ -48106,67 +48106,67 @@ } } } - + module.exports = scrypt - + }).call(this,require("buffer").Buffer) },{"buffer":84,"pbkdf2":247}],295:[function(require,module,exports){ 'use strict' module.exports = require('./lib')(require('./lib/elliptic')) - + },{"./lib":299,"./lib/elliptic":298}],296:[function(require,module,exports){ (function (Buffer){ 'use strict' var toString = Object.prototype.toString - + // TypeError exports.isArray = function (value, message) { if (!Array.isArray(value)) throw TypeError(message) } - + exports.isBoolean = function (value, message) { if (toString.call(value) !== '[object Boolean]') throw TypeError(message) } - + exports.isBuffer = function (value, message) { if (!Buffer.isBuffer(value)) throw TypeError(message) } - + exports.isFunction = function (value, message) { if (toString.call(value) !== '[object Function]') throw TypeError(message) } - + exports.isNumber = function (value, message) { if (toString.call(value) !== '[object Number]') throw TypeError(message) } - + exports.isObject = function (value, message) { if (toString.call(value) !== '[object Object]') throw TypeError(message) } - + // RangeError exports.isBufferLength = function (buffer, length, message) { if (buffer.length !== length) throw RangeError(message) } - + exports.isBufferLength2 = function (buffer, length1, length2, message) { if (buffer.length !== length1 && buffer.length !== length2) throw RangeError(message) } - + exports.isLengthGTZero = function (value, message) { if (value.length === 0) throw RangeError(message) } - + exports.isNumberInInterval = function (number, x, y, message) { if (number <= x || number >= y) throw RangeError(message) } - + }).call(this,{"isBuffer":require("../../is-buffer/index.js")}) },{"../../is-buffer/index.js":181}],297:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer var bip66 = require('bip66') - + var EC_PRIVKEY_EXPORT_DER_COMPRESSED = Buffer.from([ // begin 0x30, 0x81, 0xd3, 0x02, 0x01, 0x01, 0x04, 0x20, @@ -48188,7 +48188,7 @@ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]) - + var EC_PRIVKEY_EXPORT_DER_UNCOMPRESSED = Buffer.from([ // begin 0x30, 0x82, 0x01, 0x13, 0x02, 0x01, 0x01, 0x04, 0x20, @@ -48214,35 +48214,35 @@ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]) - + exports.privateKeyExport = function (privateKey, publicKey, compressed) { var result = Buffer.from(compressed ? EC_PRIVKEY_EXPORT_DER_COMPRESSED : EC_PRIVKEY_EXPORT_DER_UNCOMPRESSED) privateKey.copy(result, compressed ? 8 : 9) publicKey.copy(result, compressed ? 181 : 214) return result } - + exports.privateKeyImport = function (privateKey) { var length = privateKey.length - + // sequence header var index = 0 if (length < index + 1 || privateKey[index] !== 0x30) return index += 1 - + // sequence length constructor if (length < index + 1 || !(privateKey[index] & 0x80)) return - + var lenb = privateKey[index] & 0x7f index += 1 if (lenb < 1 || lenb > 2) return if (length < index + lenb) return - + // sequence length var len = privateKey[index + lenb - 1] | (lenb > 1 ? privateKey[index + lenb - 2] << 8 : 0) index += lenb if (length < index + len) return - + // sequence element 0: version number (=1) if (length < index + 3 || privateKey[index] !== 0x02 || @@ -48251,7 +48251,7 @@ return } index += 3 - + // sequence element 1: octet string, up to 32 bytes if (length < index + 2 || privateKey[index] !== 0x04 || @@ -48259,24 +48259,24 @@ length < index + 2 + privateKey[index + 1]) { return } - + return privateKey.slice(index + 2, index + 2 + privateKey[index + 1]) } - + exports.signatureExport = function (sigObj) { var r = Buffer.concat([Buffer.from([0]), sigObj.r]) for (var lenR = 33, posR = 0; lenR > 1 && r[posR] === 0x00 && !(r[posR + 1] & 0x80); --lenR, ++posR); - + var s = Buffer.concat([Buffer.from([0]), sigObj.s]) for (var lenS = 33, posS = 0; lenS > 1 && s[posS] === 0x00 && !(s[posS + 1] & 0x80); --lenS, ++posS); - + return bip66.encode(r.slice(posR), s.slice(posS)) } - + exports.signatureImport = function (sig) { var r = Buffer.alloc(32, 0) var s = Buffer.alloc(32, 0) - + try { var sigObj = bip66.decode(sig) if (sigObj.r.length === 33 && sigObj.r[0] === 0x00) sigObj.r = sigObj.r.slice(1) @@ -48286,33 +48286,33 @@ } catch (err) { return } - + sigObj.r.copy(r, 32 - sigObj.r.length) sigObj.s.copy(s, 32 - sigObj.s.length) - + return { r: r, s: s } } - + exports.signatureImportLax = function (sig) { var r = Buffer.alloc(32, 0) var s = Buffer.alloc(32, 0) - + var length = sig.length var index = 0 - + // sequence tag byte if (sig[index++] !== 0x30) return - + // sequence length byte var lenbyte = sig[index++] if (lenbyte & 0x80) { index += lenbyte - 0x80 if (index > length) return } - + // sequence tag byte for r if (sig[index++] !== 0x02) return - + // length for r var rlen = sig[index++] if (rlen & 0x80) { @@ -48324,10 +48324,10 @@ if (rlen > length - index) return var rindex = index index += rlen - + // sequence tag byte for s if (sig[index++] !== 0x02) return - + // length for s var slen = sig[index++] if (slen & 0x80) { @@ -48339,70 +48339,70 @@ if (slen > length - index) return var sindex = index index += slen - + // ignore leading zeros in r for (; rlen > 0 && sig[rindex] === 0x00; rlen -= 1, rindex += 1); // copy r value if (rlen > 32) return var rvalue = sig.slice(rindex, rindex + rlen) rvalue.copy(r, 32 - rvalue.length) - + // ignore leading zeros in s for (; slen > 0 && sig[sindex] === 0x00; slen -= 1, sindex += 1); // copy s value if (slen > 32) return var svalue = sig.slice(sindex, sindex + slen) svalue.copy(s, 32 - svalue.length) - + return { r: r, s: s } } - + },{"bip66":52,"safe-buffer":290}],298:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer var createHash = require('create-hash') var BN = require('bn.js') var EC = require('elliptic').ec - + var messages = require('../messages.json') - + var ec = new EC('secp256k1') var ecparams = ec.curve - + function loadCompressedPublicKey (first, xBuffer) { var x = new BN(xBuffer) - + // overflow if (x.cmp(ecparams.p) >= 0) return null x = x.toRed(ecparams.red) - + // compute corresponding Y var y = x.redSqr().redIMul(x).redIAdd(ecparams.b).redSqrt() if ((first === 0x03) !== y.isOdd()) y = y.redNeg() - + return ec.keyPair({ pub: { x: x, y: y } }) } - + function loadUncompressedPublicKey (first, xBuffer, yBuffer) { var x = new BN(xBuffer) var y = new BN(yBuffer) - + // overflow if (x.cmp(ecparams.p) >= 0 || y.cmp(ecparams.p) >= 0) return null - + x = x.toRed(ecparams.red) y = y.toRed(ecparams.red) - + // is odd flag if ((first === 0x06 || first === 0x07) && y.isOdd() !== (first === 0x07)) return null - + // x*x*x + b = y*y var x3 = x.redSqr().redIMul(x) if (!y.redSqr().redISub(x3.redIAdd(ecparams.b)).isZero()) return null - + return ec.keyPair({ pub: { x: x, y: y } }) } - + function loadPublicKey (publicKey) { var first = publicKey[0] switch (first) { @@ -48419,150 +48419,150 @@ return null } } - + exports.privateKeyVerify = function (privateKey) { var bn = new BN(privateKey) return bn.cmp(ecparams.n) < 0 && !bn.isZero() } - + exports.privateKeyExport = function (privateKey, compressed) { var d = new BN(privateKey) if (d.cmp(ecparams.n) >= 0 || d.isZero()) throw new Error(messages.EC_PRIVATE_KEY_EXPORT_DER_FAIL) - + return Buffer.from(ec.keyFromPrivate(privateKey).getPublic(compressed, true)) } - + exports.privateKeyNegate = function (privateKey) { var bn = new BN(privateKey) return bn.isZero() ? Buffer.alloc(32) : ecparams.n.sub(bn).umod(ecparams.n).toArrayLike(Buffer, 'be', 32) } - + exports.privateKeyModInverse = function (privateKey) { var bn = new BN(privateKey) if (bn.cmp(ecparams.n) >= 0 || bn.isZero()) throw new Error(messages.EC_PRIVATE_KEY_RANGE_INVALID) - + return bn.invm(ecparams.n).toArrayLike(Buffer, 'be', 32) } - + exports.privateKeyTweakAdd = function (privateKey, tweak) { var bn = new BN(tweak) if (bn.cmp(ecparams.n) >= 0) throw new Error(messages.EC_PRIVATE_KEY_TWEAK_ADD_FAIL) - + bn.iadd(new BN(privateKey)) if (bn.cmp(ecparams.n) >= 0) bn.isub(ecparams.n) if (bn.isZero()) throw new Error(messages.EC_PRIVATE_KEY_TWEAK_ADD_FAIL) - + return bn.toArrayLike(Buffer, 'be', 32) } - + exports.privateKeyTweakMul = function (privateKey, tweak) { var bn = new BN(tweak) if (bn.cmp(ecparams.n) >= 0 || bn.isZero()) throw new Error(messages.EC_PRIVATE_KEY_TWEAK_MUL_FAIL) - + bn.imul(new BN(privateKey)) if (bn.cmp(ecparams.n)) bn = bn.umod(ecparams.n) - + return bn.toArrayLike(Buffer, 'be', 32) } - + exports.publicKeyCreate = function (privateKey, compressed) { var d = new BN(privateKey) if (d.cmp(ecparams.n) >= 0 || d.isZero()) throw new Error(messages.EC_PUBLIC_KEY_CREATE_FAIL) - + return Buffer.from(ec.keyFromPrivate(privateKey).getPublic(compressed, true)) } - + exports.publicKeyConvert = function (publicKey, compressed) { var pair = loadPublicKey(publicKey) if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL) - + return Buffer.from(pair.getPublic(compressed, true)) } - + exports.publicKeyVerify = function (publicKey) { return loadPublicKey(publicKey) !== null } - + exports.publicKeyTweakAdd = function (publicKey, tweak, compressed) { var pair = loadPublicKey(publicKey) if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL) - + tweak = new BN(tweak) if (tweak.cmp(ecparams.n) >= 0) throw new Error(messages.EC_PUBLIC_KEY_TWEAK_ADD_FAIL) - + return Buffer.from(ecparams.g.mul(tweak).add(pair.pub).encode(true, compressed)) } - + exports.publicKeyTweakMul = function (publicKey, tweak, compressed) { var pair = loadPublicKey(publicKey) if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL) - + tweak = new BN(tweak) if (tweak.cmp(ecparams.n) >= 0 || tweak.isZero()) throw new Error(messages.EC_PUBLIC_KEY_TWEAK_MUL_FAIL) - + return Buffer.from(pair.pub.mul(tweak).encode(true, compressed)) } - + exports.publicKeyCombine = function (publicKeys, compressed) { var pairs = new Array(publicKeys.length) for (var i = 0; i < publicKeys.length; ++i) { pairs[i] = loadPublicKey(publicKeys[i]) if (pairs[i] === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL) } - + var point = pairs[0].pub for (var j = 1; j < pairs.length; ++j) point = point.add(pairs[j].pub) if (point.isInfinity()) throw new Error(messages.EC_PUBLIC_KEY_COMBINE_FAIL) - + return Buffer.from(point.encode(true, compressed)) } - + exports.signatureNormalize = function (signature) { var r = new BN(signature.slice(0, 32)) var s = new BN(signature.slice(32, 64)) if (r.cmp(ecparams.n) >= 0 || s.cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL) - + var result = Buffer.from(signature) if (s.cmp(ec.nh) === 1) ecparams.n.sub(s).toArrayLike(Buffer, 'be', 32).copy(result, 32) - + return result } - + exports.signatureExport = function (signature) { var r = signature.slice(0, 32) var s = signature.slice(32, 64) if (new BN(r).cmp(ecparams.n) >= 0 || new BN(s).cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL) - + return { r: r, s: s } } - + exports.signatureImport = function (sigObj) { var r = new BN(sigObj.r) if (r.cmp(ecparams.n) >= 0) r = new BN(0) - + var s = new BN(sigObj.s) if (s.cmp(ecparams.n) >= 0) s = new BN(0) - + return Buffer.concat([ r.toArrayLike(Buffer, 'be', 32), s.toArrayLike(Buffer, 'be', 32) ]) } - + exports.sign = function (message, privateKey, noncefn, data) { if (typeof noncefn === 'function') { var getNonce = noncefn noncefn = function (counter) { var nonce = getNonce(message, privateKey, null, data, counter) if (!Buffer.isBuffer(nonce) || nonce.length !== 32) throw new Error(messages.ECDSA_SIGN_FAIL) - + return new BN(nonce) } } - + var d = new BN(privateKey) if (d.cmp(ecparams.n) >= 0 || d.isZero()) throw new Error(messages.ECDSA_SIGN_FAIL) - + var result = ec.sign(message, privateKey, { canonical: true, k: noncefn, pers: data }) return { signature: Buffer.concat([ @@ -48572,173 +48572,173 @@ recovery: result.recoveryParam } } - + exports.verify = function (message, signature, publicKey) { var sigObj = {r: signature.slice(0, 32), s: signature.slice(32, 64)} - + var sigr = new BN(sigObj.r) var sigs = new BN(sigObj.s) if (sigr.cmp(ecparams.n) >= 0 || sigs.cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL) if (sigs.cmp(ec.nh) === 1 || sigr.isZero() || sigs.isZero()) return false - + var pair = loadPublicKey(publicKey) if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL) - + return ec.verify(message, sigObj, {x: pair.pub.x, y: pair.pub.y}) } - + exports.recover = function (message, signature, recovery, compressed) { var sigObj = {r: signature.slice(0, 32), s: signature.slice(32, 64)} - + var sigr = new BN(sigObj.r) var sigs = new BN(sigObj.s) if (sigr.cmp(ecparams.n) >= 0 || sigs.cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL) - + try { if (sigr.isZero() || sigs.isZero()) throw new Error() - + var point = ec.recoverPubKey(message, sigObj, recovery) return Buffer.from(point.encode(true, compressed)) } catch (err) { throw new Error(messages.ECDSA_RECOVER_FAIL) } } - + exports.ecdh = function (publicKey, privateKey) { var shared = exports.ecdhUnsafe(publicKey, privateKey, true) return createHash('sha256').update(shared).digest() } - + exports.ecdhUnsafe = function (publicKey, privateKey, compressed) { var pair = loadPublicKey(publicKey) if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL) - + var scalar = new BN(privateKey) if (scalar.cmp(ecparams.n) >= 0 || scalar.isZero()) throw new Error(messages.ECDH_FAIL) - + return Buffer.from(pair.pub.mul(scalar).encode(true, compressed)) } - + },{"../messages.json":300,"bn.js":53,"create-hash":91,"elliptic":109,"safe-buffer":290}],299:[function(require,module,exports){ 'use strict' var assert = require('./assert') var der = require('./der') var messages = require('./messages.json') - + function initCompressedValue (value, defaultValue) { if (value === undefined) return defaultValue - + assert.isBoolean(value, messages.COMPRESSED_TYPE_INVALID) return value } - + module.exports = function (secp256k1) { return { privateKeyVerify: function (privateKey) { assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID) return privateKey.length === 32 && secp256k1.privateKeyVerify(privateKey) }, - + privateKeyExport: function (privateKey, compressed) { assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID) assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID) - + compressed = initCompressedValue(compressed, true) var publicKey = secp256k1.privateKeyExport(privateKey, compressed) - + return der.privateKeyExport(privateKey, publicKey, compressed) }, - + privateKeyImport: function (privateKey) { assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID) - + privateKey = der.privateKeyImport(privateKey) if (privateKey && privateKey.length === 32 && secp256k1.privateKeyVerify(privateKey)) return privateKey - + throw new Error(messages.EC_PRIVATE_KEY_IMPORT_DER_FAIL) }, - + privateKeyNegate: function (privateKey) { assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID) assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID) - + return secp256k1.privateKeyNegate(privateKey) }, - + privateKeyModInverse: function (privateKey) { assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID) assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID) - + return secp256k1.privateKeyModInverse(privateKey) }, - + privateKeyTweakAdd: function (privateKey, tweak) { assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID) assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID) - + assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID) assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID) - + return secp256k1.privateKeyTweakAdd(privateKey, tweak) }, - + privateKeyTweakMul: function (privateKey, tweak) { assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID) assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID) - + assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID) assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID) - + return secp256k1.privateKeyTweakMul(privateKey, tweak) }, - + publicKeyCreate: function (privateKey, compressed) { assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID) assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID) - + compressed = initCompressedValue(compressed, true) - + return secp256k1.publicKeyCreate(privateKey, compressed) }, - + publicKeyConvert: function (publicKey, compressed) { assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID) assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID) - + compressed = initCompressedValue(compressed, true) - + return secp256k1.publicKeyConvert(publicKey, compressed) }, - + publicKeyVerify: function (publicKey) { assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID) return secp256k1.publicKeyVerify(publicKey) }, - + publicKeyTweakAdd: function (publicKey, tweak, compressed) { assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID) assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID) - + assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID) assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID) - + compressed = initCompressedValue(compressed, true) - + return secp256k1.publicKeyTweakAdd(publicKey, tweak, compressed) }, - + publicKeyTweakMul: function (publicKey, tweak, compressed) { assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID) assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID) - + assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID) assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID) - + compressed = initCompressedValue(compressed, true) - + return secp256k1.publicKeyTweakMul(publicKey, tweak, compressed) }, - + publicKeyCombine: function (publicKeys, compressed) { assert.isArray(publicKeys, messages.EC_PUBLIC_KEYS_TYPE_INVALID) assert.isLengthGTZero(publicKeys, messages.EC_PUBLIC_KEYS_LENGTH_INVALID) @@ -48746,126 +48746,126 @@ assert.isBuffer(publicKeys[i], messages.EC_PUBLIC_KEY_TYPE_INVALID) assert.isBufferLength2(publicKeys[i], 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID) } - + compressed = initCompressedValue(compressed, true) - + return secp256k1.publicKeyCombine(publicKeys, compressed) }, - + signatureNormalize: function (signature) { assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID) assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID) - + return secp256k1.signatureNormalize(signature) }, - + signatureExport: function (signature) { assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID) assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID) - + var sigObj = secp256k1.signatureExport(signature) return der.signatureExport(sigObj) }, - + signatureImport: function (sig) { assert.isBuffer(sig, messages.ECDSA_SIGNATURE_TYPE_INVALID) assert.isLengthGTZero(sig, messages.ECDSA_SIGNATURE_LENGTH_INVALID) - + var sigObj = der.signatureImport(sig) if (sigObj) return secp256k1.signatureImport(sigObj) - + throw new Error(messages.ECDSA_SIGNATURE_PARSE_DER_FAIL) }, - + signatureImportLax: function (sig) { assert.isBuffer(sig, messages.ECDSA_SIGNATURE_TYPE_INVALID) assert.isLengthGTZero(sig, messages.ECDSA_SIGNATURE_LENGTH_INVALID) - + var sigObj = der.signatureImportLax(sig) if (sigObj) return secp256k1.signatureImport(sigObj) - + throw new Error(messages.ECDSA_SIGNATURE_PARSE_DER_FAIL) }, - + sign: function (message, privateKey, options) { assert.isBuffer(message, messages.MSG32_TYPE_INVALID) assert.isBufferLength(message, 32, messages.MSG32_LENGTH_INVALID) - + assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID) assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID) - + var data = null var noncefn = null if (options !== undefined) { assert.isObject(options, messages.OPTIONS_TYPE_INVALID) - + if (options.data !== undefined) { assert.isBuffer(options.data, messages.OPTIONS_DATA_TYPE_INVALID) assert.isBufferLength(options.data, 32, messages.OPTIONS_DATA_LENGTH_INVALID) data = options.data } - + if (options.noncefn !== undefined) { assert.isFunction(options.noncefn, messages.OPTIONS_NONCEFN_TYPE_INVALID) noncefn = options.noncefn } } - + return secp256k1.sign(message, privateKey, noncefn, data) }, - + verify: function (message, signature, publicKey) { assert.isBuffer(message, messages.MSG32_TYPE_INVALID) assert.isBufferLength(message, 32, messages.MSG32_LENGTH_INVALID) - + assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID) assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID) - + assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID) assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID) - + return secp256k1.verify(message, signature, publicKey) }, - + recover: function (message, signature, recovery, compressed) { assert.isBuffer(message, messages.MSG32_TYPE_INVALID) assert.isBufferLength(message, 32, messages.MSG32_LENGTH_INVALID) - + assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID) assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID) - + assert.isNumber(recovery, messages.RECOVERY_ID_TYPE_INVALID) assert.isNumberInInterval(recovery, -1, 4, messages.RECOVERY_ID_VALUE_INVALID) - + compressed = initCompressedValue(compressed, true) - + return secp256k1.recover(message, signature, recovery, compressed) }, - + ecdh: function (publicKey, privateKey) { assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID) assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID) - + assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID) assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID) - + return secp256k1.ecdh(publicKey, privateKey) }, - + ecdhUnsafe: function (publicKey, privateKey, compressed) { assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID) assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID) - + assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID) assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID) - + compressed = initCompressedValue(compressed, true) - + return secp256k1.ecdhUnsafe(publicKey, privateKey, compressed) } } } - + },{"./assert":296,"./der":297,"./messages.json":300}],300:[function(require,module,exports){ module.exports={ "COMPRESSED_TYPE_INVALID": "compressed should be a boolean", @@ -48904,26 +48904,26 @@ "TWEAK_TYPE_INVALID": "tweak should be a Buffer", "TWEAK_LENGTH_INVALID": "tweak length is invalid" } - + },{}],301:[function(require,module,exports){ (function (process){ ;(function(global) { - + 'use strict'; - + var nextTick = function (fn) { setTimeout(fn, 0); } if (typeof process != 'undefined' && process && typeof process.nextTick == 'function') { // node.js and the like nextTick = process.nextTick; } - + function semaphore(capacity) { var semaphore = { capacity: capacity || 1, current: 0, queue: [], firstHere: false, - + take: function() { if (semaphore.firstHere === false) { semaphore.current++; @@ -48933,21 +48933,21 @@ var isFirst = 0; } var item = { n: 1 }; - + if (typeof arguments[0] == 'function') { item.task = arguments[0]; } else { item.n = arguments[0]; } - + if (arguments.length >= 2) { if (typeof arguments[1] == 'function') item.task = arguments[1]; else item.n = arguments[1]; } - + var task = item.task; item.task = function() { task(semaphore.leave); }; - + if (semaphore.current + item.n - isFirst > semaphore.capacity) { if (isFirst === 1) { semaphore.current--; @@ -48955,46 +48955,46 @@ } return semaphore.queue.push(item); } - + semaphore.current += item.n - isFirst; item.task(semaphore.leave); if (isFirst === 1) semaphore.firstHere = false; }, - + leave: function(n) { n = n || 1; - + semaphore.current -= n; - + if (!semaphore.queue.length) { if (semaphore.current < 0) { throw new Error('leave called too many times.'); } - + return; } - + var item = semaphore.queue[0]; - + if (item.n + semaphore.current > semaphore.capacity) { return; } - + semaphore.queue.shift(); semaphore.current += item.n; - + nextTick(item.task); }, - + available: function(n) { n = n || 1; return(semaphore.current + n <= semaphore.capacity); } }; - + return semaphore; }; - + if (typeof exports === 'object') { // node export module.exports = semaphore; @@ -49008,7 +49008,7 @@ global.semaphore = semaphore; } }(this)); - + }).call(this,require('_process')) },{"_process":257}],302:[function(require,module,exports){ 'use strict'; @@ -49018,10 +49018,10 @@ args.splice(1, 0, 0); setTimeout.apply(null, args); }; - + },{}],303:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer - + // prototype class for hash functions function Hash (blockSize, finalSize) { this._block = Buffer.alloc(blockSize) @@ -49029,96 +49029,96 @@ this._blockSize = blockSize this._len = 0 } - + Hash.prototype.update = function (data, enc) { if (typeof data === 'string') { enc = enc || 'utf8' data = Buffer.from(data, enc) } - + var block = this._block var blockSize = this._blockSize var length = data.length var accum = this._len - + for (var offset = 0; offset < length;) { var assigned = accum % blockSize var remainder = Math.min(length - offset, blockSize - assigned) - + for (var i = 0; i < remainder; i++) { block[assigned + i] = data[offset + i] } - + accum += remainder offset += remainder - + if ((accum % blockSize) === 0) { this._update(block) } } - + this._len += length return this } - + Hash.prototype.digest = function (enc) { var rem = this._len % this._blockSize - + this._block[rem] = 0x80 - + // zero (rem + 1) trailing bits, where (rem + 1) is the smallest // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize this._block.fill(0, rem + 1) - + if (rem >= this._finalSize) { this._update(this._block) this._block.fill(0) } - + var bits = this._len * 8 - + // uint32 if (bits <= 0xffffffff) { this._block.writeUInt32BE(bits, this._blockSize - 4) - + // uint64 } else { var lowBits = (bits & 0xffffffff) >>> 0 var highBits = (bits - lowBits) / 0x100000000 - + this._block.writeUInt32BE(highBits, this._blockSize - 8) this._block.writeUInt32BE(lowBits, this._blockSize - 4) } - + this._update(this._block) var hash = this._hash() - + return enc ? hash.toString(enc) : hash } - + Hash.prototype._update = function () { throw new Error('_update must be implemented by subclass') } - + module.exports = Hash - + },{"safe-buffer":290}],304:[function(require,module,exports){ var exports = module.exports = function SHA (algorithm) { algorithm = algorithm.toLowerCase() - + var Algorithm = exports[algorithm] if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)') - + return new Algorithm() } - + exports.sha = require('./sha') exports.sha1 = require('./sha1') exports.sha224 = require('./sha224') exports.sha256 = require('./sha256') exports.sha384 = require('./sha384') exports.sha512 = require('./sha512') - + },{"./sha":305,"./sha1":306,"./sha224":307,"./sha256":308,"./sha384":309,"./sha512":310}],305:[function(require,module,exports){ /* * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined @@ -49127,94 +49127,94 @@ * The difference between SHA-0 and SHA-1 is just a bitwise rotate left * operation was added. */ - + var inherits = require('inherits') var Hash = require('./hash') var Buffer = require('safe-buffer').Buffer - + var K = [ 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 ] - + var W = new Array(80) - + function Sha () { this.init() this._w = W - + Hash.call(this, 64, 56) } - + inherits(Sha, Hash) - + Sha.prototype.init = function () { this._a = 0x67452301 this._b = 0xefcdab89 this._c = 0x98badcfe this._d = 0x10325476 this._e = 0xc3d2e1f0 - + return this } - + function rotl5 (num) { return (num << 5) | (num >>> 27) } - + function rotl30 (num) { return (num << 30) | (num >>> 2) } - + function ft (s, b, c, d) { if (s === 0) return (b & c) | ((~b) & d) if (s === 2) return (b & c) | (b & d) | (c & d) return b ^ c ^ d } - + Sha.prototype._update = function (M) { var W = this._w - + var a = this._a | 0 var b = this._b | 0 var c = this._c | 0 var d = this._d | 0 var e = this._e | 0 - + for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16] - + for (var j = 0; j < 80; ++j) { var s = ~~(j / 20) var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0 - + e = d d = c c = rotl30(b) b = a a = t } - + this._a = (a + this._a) | 0 this._b = (b + this._b) | 0 this._c = (c + this._c) | 0 this._d = (d + this._d) | 0 this._e = (e + this._e) | 0 } - + Sha.prototype._hash = function () { var H = Buffer.allocUnsafe(20) - + H.writeInt32BE(this._a | 0, 0) H.writeInt32BE(this._b | 0, 4) H.writeInt32BE(this._c | 0, 8) H.writeInt32BE(this._d | 0, 12) H.writeInt32BE(this._e | 0, 16) - + return H } - + module.exports = Sha - + },{"./hash":303,"inherits":180,"safe-buffer":290}],306:[function(require,module,exports){ /* * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined @@ -49224,98 +49224,98 @@ * Distributed under the BSD License * See http://pajhome.org.uk/crypt/md5 for details. */ - + var inherits = require('inherits') var Hash = require('./hash') var Buffer = require('safe-buffer').Buffer - + var K = [ 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 ] - + var W = new Array(80) - + function Sha1 () { this.init() this._w = W - + Hash.call(this, 64, 56) } - + inherits(Sha1, Hash) - + Sha1.prototype.init = function () { this._a = 0x67452301 this._b = 0xefcdab89 this._c = 0x98badcfe this._d = 0x10325476 this._e = 0xc3d2e1f0 - + return this } - + function rotl1 (num) { return (num << 1) | (num >>> 31) } - + function rotl5 (num) { return (num << 5) | (num >>> 27) } - + function rotl30 (num) { return (num << 30) | (num >>> 2) } - + function ft (s, b, c, d) { if (s === 0) return (b & c) | ((~b) & d) if (s === 2) return (b & c) | (b & d) | (c & d) return b ^ c ^ d } - + Sha1.prototype._update = function (M) { var W = this._w - + var a = this._a | 0 var b = this._b | 0 var c = this._c | 0 var d = this._d | 0 var e = this._e | 0 - + for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]) - + for (var j = 0; j < 80; ++j) { var s = ~~(j / 20) var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0 - + e = d d = c c = rotl30(b) b = a a = t } - + this._a = (a + this._a) | 0 this._b = (b + this._b) | 0 this._c = (c + this._c) | 0 this._d = (d + this._d) | 0 this._e = (e + this._e) | 0 } - + Sha1.prototype._hash = function () { var H = Buffer.allocUnsafe(20) - + H.writeInt32BE(this._a | 0, 0) H.writeInt32BE(this._b | 0, 4) H.writeInt32BE(this._c | 0, 8) H.writeInt32BE(this._d | 0, 12) H.writeInt32BE(this._e | 0, 16) - + return H } - + module.exports = Sha1 - + },{"./hash":303,"inherits":180,"safe-buffer":290}],307:[function(require,module,exports){ /** * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined @@ -49324,24 +49324,24 @@ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet * */ - + var inherits = require('inherits') var Sha256 = require('./sha256') var Hash = require('./hash') var Buffer = require('safe-buffer').Buffer - + var W = new Array(64) - + function Sha224 () { this.init() - + this._w = W // new Array(64) - + Hash.call(this, 64, 56) } - + inherits(Sha224, Sha256) - + Sha224.prototype.init = function () { this._a = 0xc1059ed8 this._b = 0x367cd507 @@ -49351,13 +49351,13 @@ this._f = 0x68581511 this._g = 0x64f98fa7 this._h = 0xbefa4fa4 - + return this } - + Sha224.prototype._hash = function () { var H = Buffer.allocUnsafe(28) - + H.writeInt32BE(this._a, 0) H.writeInt32BE(this._b, 4) H.writeInt32BE(this._c, 8) @@ -49365,12 +49365,12 @@ H.writeInt32BE(this._e, 16) H.writeInt32BE(this._f, 20) H.writeInt32BE(this._g, 24) - + return H } - + module.exports = Sha224 - + },{"./hash":303,"./sha256":308,"inherits":180,"safe-buffer":290}],308:[function(require,module,exports){ /** * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined @@ -49379,11 +49379,11 @@ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet * */ - + var inherits = require('inherits') var Hash = require('./hash') var Buffer = require('safe-buffer').Buffer - + var K = [ 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, @@ -49402,19 +49402,19 @@ 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2 ] - + var W = new Array(64) - + function Sha256 () { this.init() - + this._w = W // new Array(64) - + Hash.call(this, 64, 56) } - + inherits(Sha256, Hash) - + Sha256.prototype.init = function () { this._a = 0x6a09e667 this._b = 0xbb67ae85 @@ -49424,37 +49424,37 @@ this._f = 0x9b05688c this._g = 0x1f83d9ab this._h = 0x5be0cd19 - + return this } - + function ch (x, y, z) { return z ^ (x & (y ^ z)) } - + function maj (x, y, z) { return (x & y) | (z & (x | y)) } - + function sigma0 (x) { return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10) } - + function sigma1 (x) { return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7) } - + function gamma0 (x) { return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3) } - + function gamma1 (x) { return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10) } - + Sha256.prototype._update = function (M) { var W = this._w - + var a = this._a | 0 var b = this._b | 0 var c = this._c | 0 @@ -49463,14 +49463,14 @@ var f = this._f | 0 var g = this._g | 0 var h = this._h | 0 - + for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0 - + for (var j = 0; j < 64; ++j) { var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0 var T2 = (sigma0(a) + maj(a, b, c)) | 0 - + h = g g = f f = e @@ -49480,7 +49480,7 @@ b = a a = (T1 + T2) | 0 } - + this._a = (a + this._a) | 0 this._b = (b + this._b) | 0 this._c = (c + this._c) | 0 @@ -49490,10 +49490,10 @@ this._g = (g + this._g) | 0 this._h = (h + this._h) | 0 } - + Sha256.prototype._hash = function () { var H = Buffer.allocUnsafe(32) - + H.writeInt32BE(this._a, 0) H.writeInt32BE(this._b, 4) H.writeInt32BE(this._c, 8) @@ -49502,29 +49502,29 @@ H.writeInt32BE(this._f, 20) H.writeInt32BE(this._g, 24) H.writeInt32BE(this._h, 28) - + return H } - + module.exports = Sha256 - + },{"./hash":303,"inherits":180,"safe-buffer":290}],309:[function(require,module,exports){ var inherits = require('inherits') var SHA512 = require('./sha512') var Hash = require('./hash') var Buffer = require('safe-buffer').Buffer - + var W = new Array(160) - + function Sha384 () { this.init() this._w = W - + Hash.call(this, 128, 112) } - + inherits(Sha384, SHA512) - + Sha384.prototype.init = function () { this._ah = 0xcbbb9d5d this._bh = 0x629a292a @@ -49534,7 +49534,7 @@ this._fh = 0x8eb44a87 this._gh = 0xdb0c2e0d this._hh = 0x47b5481d - + this._al = 0xc1059ed8 this._bl = 0x367cd507 this._cl = 0x3070dd17 @@ -49543,35 +49543,35 @@ this._fl = 0x68581511 this._gl = 0x64f98fa7 this._hl = 0xbefa4fa4 - + return this } - + Sha384.prototype._hash = function () { var H = Buffer.allocUnsafe(48) - + function writeInt64BE (h, l, offset) { H.writeInt32BE(h, offset) H.writeInt32BE(l, offset + 4) } - + writeInt64BE(this._ah, this._al, 0) writeInt64BE(this._bh, this._bl, 8) writeInt64BE(this._ch, this._cl, 16) writeInt64BE(this._dh, this._dl, 24) writeInt64BE(this._eh, this._el, 32) writeInt64BE(this._fh, this._fl, 40) - + return H } - + module.exports = Sha384 - + },{"./hash":303,"./sha512":310,"inherits":180,"safe-buffer":290}],310:[function(require,module,exports){ var inherits = require('inherits') var Hash = require('./hash') var Buffer = require('safe-buffer').Buffer - + var K = [ 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, @@ -49614,18 +49614,18 @@ 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 ] - + var W = new Array(160) - + function Sha512 () { this.init() this._w = W - + Hash.call(this, 128, 112) } - + inherits(Sha512, Hash) - + Sha512.prototype.init = function () { this._ah = 0x6a09e667 this._bh = 0xbb67ae85 @@ -49635,7 +49635,7 @@ this._fh = 0x9b05688c this._gh = 0x1f83d9ab this._hh = 0x5be0cd19 - + this._al = 0xf3bcc908 this._bl = 0x84caa73b this._cl = 0xfe94f82b @@ -49644,49 +49644,49 @@ this._fl = 0x2b3e6c1f this._gl = 0xfb41bd6b this._hl = 0x137e2179 - + return this } - + function Ch (x, y, z) { return z ^ (x & (y ^ z)) } - + function maj (x, y, z) { return (x & y) | (z & (x | y)) } - + function sigma0 (x, xl) { return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25) } - + function sigma1 (x, xl) { return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23) } - + function Gamma0 (x, xl) { return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7) } - + function Gamma0l (x, xl) { return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25) } - + function Gamma1 (x, xl) { return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6) } - + function Gamma1l (x, xl) { return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26) } - + function getCarry (a, b) { return (a >>> 0) < (b >>> 0) ? 1 : 0 } - + Sha512.prototype._update = function (M) { var W = this._w - + var ah = this._ah | 0 var bh = this._bh | 0 var ch = this._ch | 0 @@ -49695,7 +49695,7 @@ var fh = this._fh | 0 var gh = this._gh | 0 var hh = this._hh | 0 - + var al = this._al | 0 var bl = this._bl | 0 var cl = this._cl | 0 @@ -49704,7 +49704,7 @@ var fl = this._fl | 0 var gl = this._gl | 0 var hl = this._hl | 0 - + for (var i = 0; i < 32; i += 2) { W[i] = M.readInt32BE(i * 4) W[i + 1] = M.readInt32BE(i * 4 + 4) @@ -49714,49 +49714,49 @@ var xl = W[i - 15 * 2 + 1] var gamma0 = Gamma0(xh, xl) var gamma0l = Gamma0l(xl, xh) - + xh = W[i - 2 * 2] xl = W[i - 2 * 2 + 1] var gamma1 = Gamma1(xh, xl) var gamma1l = Gamma1l(xl, xh) - + // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] var Wi7h = W[i - 7 * 2] var Wi7l = W[i - 7 * 2 + 1] - + var Wi16h = W[i - 16 * 2] var Wi16l = W[i - 16 * 2 + 1] - + var Wil = (gamma0l + Wi7l) | 0 var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0 Wil = (Wil + gamma1l) | 0 Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0 Wil = (Wil + Wi16l) | 0 Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0 - + W[i] = Wih W[i + 1] = Wil } - + for (var j = 0; j < 160; j += 2) { Wih = W[j] Wil = W[j + 1] - + var majh = maj(ah, bh, ch) var majl = maj(al, bl, cl) - + var sigma0h = sigma0(ah, al) var sigma0l = sigma0(al, ah) var sigma1h = sigma1(eh, el) var sigma1l = sigma1(el, eh) - + // t1 = h + sigma1 + ch + K[j] + W[j] var Kih = K[j] var Kil = K[j + 1] - + var chh = Ch(eh, fh, gh) var chl = Ch(el, fl, gl) - + var t1l = (hl + sigma1l) | 0 var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0 t1l = (t1l + chl) | 0 @@ -49765,11 +49765,11 @@ t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0 t1l = (t1l + Wil) | 0 t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0 - + // t2 = sigma0 + maj var t2l = (sigma0l + majl) | 0 var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0 - + hh = gh hl = gl gh = fh @@ -49787,7 +49787,7 @@ al = (t1l + t2l) | 0 ah = (t1h + t2h + getCarry(al, t1l)) | 0 } - + this._al = (this._al + al) | 0 this._bl = (this._bl + bl) | 0 this._cl = (this._cl + cl) | 0 @@ -49796,7 +49796,7 @@ this._fl = (this._fl + fl) | 0 this._gl = (this._gl + gl) | 0 this._hl = (this._hl + hl) | 0 - + this._ah = (this._ah + ah + getCarry(this._al, al)) | 0 this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0 this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0 @@ -49806,15 +49806,15 @@ this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0 this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0 } - + Sha512.prototype._hash = function () { var H = Buffer.allocUnsafe(64) - + function writeInt64BE (h, l, offset) { H.writeInt32BE(h, offset) H.writeInt32BE(l, offset + 4) } - + writeInt64BE(this._ah, this._al, 0) writeInt64BE(this._bh, this._bl, 8) writeInt64BE(this._ch, this._cl, 16) @@ -49823,12 +49823,12 @@ writeInt64BE(this._fh, this._fl, 40) writeInt64BE(this._gh, this._gl, 48) writeInt64BE(this._hh, this._hl, 56) - + return H } - + module.exports = Sha512 - + },{"./hash":303,"inherits":180,"safe-buffer":290}],311:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // @@ -49850,34 +49850,34 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - + module.exports = Stream; - + var EE = require('events').EventEmitter; var inherits = require('inherits'); - + inherits(Stream, EE); Stream.Readable = require('readable-stream/readable.js'); Stream.Writable = require('readable-stream/writable.js'); Stream.Duplex = require('readable-stream/duplex.js'); Stream.Transform = require('readable-stream/transform.js'); Stream.PassThrough = require('readable-stream/passthrough.js'); - + // Backwards-compat with node 0.4.x Stream.Stream = Stream; - - - + + + // old-style streams. Note that the pipe method (the only relevant // part of this class) is overridden in the Readable class. - + function Stream() { EE.call(this); } - + Stream.prototype.pipe = function(dest, options) { var source = this; - + function ondata(chunk) { if (dest.writable) { if (false === dest.write(chunk) && source.pause) { @@ -49885,40 +49885,40 @@ } } } - + source.on('data', ondata); - + function ondrain() { if (source.readable && source.resume) { source.resume(); } } - + dest.on('drain', ondrain); - + // If the 'end' option is not supplied, dest.end() will be called when // source gets the 'end' or 'close' events. Only dest.end() once. if (!dest._isStdio && (!options || options.end !== false)) { source.on('end', onend); source.on('close', onclose); } - + var didOnEnd = false; function onend() { if (didOnEnd) return; didOnEnd = true; - + dest.end(); } - - + + function onclose() { if (didOnEnd) return; didOnEnd = true; - + if (typeof dest.destroy === 'function') dest.destroy(); } - + // don't leave dangling pipes when there are errors. function onerror(er) { cleanup(); @@ -49926,38 +49926,38 @@ throw er; // Unhandled stream error in pipe. } } - + source.on('error', onerror); dest.on('error', onerror); - + // remove all the event listeners that were added. function cleanup() { source.removeListener('data', ondata); dest.removeListener('drain', ondrain); - + source.removeListener('end', onend); source.removeListener('close', onclose); - + source.removeListener('error', onerror); dest.removeListener('error', onerror); - + source.removeListener('end', cleanup); source.removeListener('close', cleanup); - + dest.removeListener('close', cleanup); } - + source.on('end', cleanup); source.on('close', cleanup); - + dest.on('close', cleanup); - + dest.emit('pipe', source); - + // Allow for unix-like usage: A.pipe(B).pipe(C) return dest; }; - + },{"events":157,"inherits":180,"readable-stream/duplex.js":275,"readable-stream/passthrough.js":284,"readable-stream/readable.js":285,"readable-stream/transform.js":286,"readable-stream/writable.js":287}],312:[function(require,module,exports){ (function (global){ var ClientRequest = require('./lib/request') @@ -49965,56 +49965,56 @@ var extend = require('xtend') var statusCodes = require('builtin-status-codes') var url = require('url') - + var http = exports - + http.request = function (opts, cb) { if (typeof opts === 'string') opts = url.parse(opts) else opts = extend(opts) - + // Normally, the page is loaded from http or https, so not specifying a protocol // will result in a (valid) protocol-relative url. However, this won't work if // the protocol is something else, like 'file:' var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : '' - + var protocol = opts.protocol || defaultProtocol var host = opts.hostname || opts.host var port = opts.port var path = opts.path || '/' - + // Necessary for IPv6 addresses if (host && host.indexOf(':') !== -1) host = '[' + host + ']' - + // This may be a relative url. The browser should always be able to interpret it correctly. opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path opts.method = (opts.method || 'GET').toUpperCase() opts.headers = opts.headers || {} - + // Also valid opts.auth, opts.mode - + var req = new ClientRequest(opts) if (cb) req.on('response', cb) return req } - + http.get = function get (opts, cb) { var req = http.request(opts, cb) req.end() return req } - + http.ClientRequest = ClientRequest http.IncomingMessage = IncomingMessage - + http.Agent = function () {} http.Agent.defaultMaxSockets = 4 - + http.STATUS_CODES = statusCodes - + http.METHODS = [ 'CHECKOUT', 'CONNECT', @@ -50047,17 +50047,17 @@ },{"./lib/request":314,"./lib/response":315,"builtin-status-codes":85,"url":327,"xtend":423}],313:[function(require,module,exports){ (function (global){ exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream) - + exports.writableStream = isFunction(global.WritableStream) - + exports.abortController = isFunction(global.AbortController) - + exports.blobConstructor = false try { new Blob([new ArrayBuffer(1)]) exports.blobConstructor = true } catch (e) {} - + // The xhr request to example.com may violate some restrictive CSP configurations, // so if we're running in a browser that supports `fetch`, avoid calling getXHR() // and assume support for certain features below. @@ -50065,7 +50065,7 @@ function getXHR () { // Cache the xhr value if (xhr !== undefined) return xhr - + if (global.XMLHttpRequest) { xhr = new global.XMLHttpRequest() // If XDomainRequest is available (ie only, where xhr might not work @@ -50082,7 +50082,7 @@ } return xhr } - + function checkTypeSupport (type) { var xhr = getXHR() if (!xhr) return false @@ -50092,34 +50092,34 @@ } catch (e) {} return false } - + // For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'. // Safari 7.1 appears to have fixed this bug. var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined' var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice) - + // If fetch is supported, then arraybuffer will be supported too. Skip calling // checkTypeSupport(), since that calls getXHR(). exports.arraybuffer = exports.fetch || (haveArrayBuffer && checkTypeSupport('arraybuffer')) - + // These next two tests unavoidably show warnings in Chrome. Since fetch will always // be used if it's available, just return false for these to avoid the warnings. exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream') exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer && checkTypeSupport('moz-chunked-arraybuffer') - + // If fetch is supported, then overrideMimeType will be supported too. Skip calling // getXHR(). exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false) - + exports.vbArray = isFunction(global.VBArray) - + function isFunction (value) { return typeof value === 'function' } - + xhr = null // Help gc - + }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],314:[function(require,module,exports){ (function (process,global,Buffer){ @@ -50128,10 +50128,10 @@ var response = require('./response') var stream = require('readable-stream') var toArrayBuffer = require('to-arraybuffer') - + var IncomingMessage = response.IncomingMessage var rStates = response.readyStates - + function decideMode (preferBinary, useFetch) { if (capability.fetch && useFetch) { return 'fetch' @@ -50147,11 +50147,11 @@ return 'text' } } - + var ClientRequest = module.exports = function (opts) { var self = this stream.Writable.call(self) - + self._opts = opts self._body = [] self._headers = {} @@ -50160,7 +50160,7 @@ Object.keys(opts.headers).forEach(function (name) { self.setHeader(name, opts.headers[name]) }) - + var preferBinary var useFetch = true if (opts.mode === 'disable-fetch' || ('requestTimeout' in opts && !capability.abortController)) { @@ -50181,14 +50181,14 @@ throw new Error('Invalid value for opts.mode') } self._mode = decideMode(preferBinary, useFetch) - + self.on('finish', function () { self._onFinish() }) } - + inherits(ClientRequest, stream.Writable) - + ClientRequest.prototype.setHeader = function (name, value) { var self = this var lowerName = name.toLowerCase() @@ -50197,32 +50197,32 @@ // http-browserify did it, so I will too. if (unsafeHeaders.indexOf(lowerName) !== -1) return - + self._headers[lowerName] = { name: name, value: value } } - + ClientRequest.prototype.getHeader = function (name) { var header = this._headers[name.toLowerCase()] if (header) return header.value return null } - + ClientRequest.prototype.removeHeader = function (name) { var self = this delete self._headers[name.toLowerCase()] } - + ClientRequest.prototype._onFinish = function () { var self = this - + if (self._destroyed) return var opts = self._opts - + var headersObj = self._headers var body = null if (opts.method !== 'GET' && opts.method !== 'HEAD') { @@ -50239,7 +50239,7 @@ body = Buffer.concat(self._body).toString() } } - + // create flattened list of headers var headersList = [] Object.keys(headersObj).forEach(function (keyName) { @@ -50253,14 +50253,14 @@ headersList.push([name, value]) } }) - + if (self._mode === 'fetch') { var signal = null if (capability.abortController) { var controller = new AbortController() signal = controller.signal self._fetchAbortController = controller - + if ('requestTimeout' in opts && opts.requestTimeout !== 0) { global.setTimeout(function () { self.emit('requestTimeout') @@ -50269,7 +50269,7 @@ }, opts.requestTimeout) } } - + global.fetch(self._opts.url, { method: self._opts.method, headers: headersList, @@ -50293,28 +50293,28 @@ }) return } - + // Can't set responseType on really old browsers if ('responseType' in xhr) xhr.responseType = self._mode.split(':')[0] - + if ('withCredentials' in xhr) xhr.withCredentials = !!opts.withCredentials - + if (self._mode === 'text' && 'overrideMimeType' in xhr) xhr.overrideMimeType('text/plain; charset=x-user-defined') - + if ('requestTimeout' in opts) { xhr.timeout = opts.requestTimeout xhr.ontimeout = function () { self.emit('requestTimeout') } } - + headersList.forEach(function (header) { xhr.setRequestHeader(header[0], header[1]) }) - + self._response = null xhr.onreadystatechange = function () { switch (xhr.readyState) { @@ -50331,13 +50331,13 @@ self._onXHRProgress() } } - + xhr.onerror = function () { if (self._destroyed) return self.emit('error', new Error('XHR error')) } - + try { xhr.send(body) } catch (err) { @@ -50348,7 +50348,7 @@ } } } - + /** * Checks if xhr.status is readable and non-zero, indicating no error. * Even though the spec says it should be available in readyState 3, @@ -50362,40 +50362,40 @@ return false } } - + ClientRequest.prototype._onXHRProgress = function () { var self = this - + if (!statusValid(self._xhr) || self._destroyed) return - + if (!self._response) self._connect() - + self._response._onXHRProgress() } - + ClientRequest.prototype._connect = function () { var self = this - + if (self._destroyed) return - + self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode) self._response.on('error', function(err) { self.emit('error', err) }) - + self.emit('response', self._response) } - + ClientRequest.prototype._write = function (chunk, encoding, cb) { var self = this - + self._body.push(chunk) cb() } - + ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () { var self = this self._destroyed = true @@ -50406,22 +50406,22 @@ else if (self._fetchAbortController) self._fetchAbortController.abort() } - + ClientRequest.prototype.end = function (data, encoding, cb) { var self = this if (typeof data === 'function') { cb = data data = undefined } - + stream.Writable.prototype.end.call(self, data, encoding, cb) } - + ClientRequest.prototype.flushHeaders = function () {} ClientRequest.prototype.setTimeout = function () {} ClientRequest.prototype.setNoDelay = function () {} ClientRequest.prototype.setSocketKeepAlive = function () {} - + // Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method var unsafeHeaders = [ 'accept-charset', @@ -50446,14 +50446,14 @@ 'user-agent', 'via' ] - + }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) },{"./capability":313,"./response":315,"_process":257,"buffer":84,"inherits":180,"readable-stream":285,"to-arraybuffer":323}],315:[function(require,module,exports){ (function (process,global,Buffer){ var capability = require('./capability') var inherits = require('inherits') var stream = require('readable-stream') - + var rStates = exports.readyStates = { UNSENT: 0, OPENED: 1, @@ -50461,17 +50461,17 @@ LOADING: 3, DONE: 4 } - + var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode) { var self = this stream.Readable.call(self) - + self._mode = mode self.headers = {} self.rawHeaders = [] self.trailers = {} self.rawTrailers = [] - + // Fake the 'close' event, but only once 'end' fires self.on('end', function () { // The nextTick is necessary to prevent the 'request' module from causing an infinite loop @@ -50479,19 +50479,19 @@ self.emit('close') }) }) - + if (mode === 'fetch') { self._fetchResponse = response - + self.url = response.url self.statusCode = response.status self.statusMessage = response.statusText - + response.headers.forEach(function (header, key){ self.headers[key.toLowerCase()] = header self.rawHeaders.push(key, header) }) - + if (capability.writableStream) { var writable = new WritableStream({ write: function (chunk) { @@ -50514,7 +50514,7 @@ self.emit('error', err) } }) - + try { response.body.pipeTo(writable) return @@ -50541,7 +50541,7 @@ } else { self._xhr = xhr self._pos = 0 - + self.url = xhr.responseURL self.statusCode = xhr.status self.statusMessage = xhr.statusText @@ -50563,7 +50563,7 @@ self.rawHeaders.push(matches[1], matches[2]) } }) - + self._charset = 'x-user-defined' if (!capability.overrideMimeType) { var mimeType = self.rawHeaders['mime-type'] @@ -50578,24 +50578,24 @@ } } } - + inherits(IncomingMessage, stream.Readable) - + IncomingMessage.prototype._read = function () { var self = this - + var resolve = self._resumeFetch if (resolve) { self._resumeFetch = null resolve() } } - + IncomingMessage.prototype._onXHRProgress = function () { var self = this - + var xhr = self._xhr - + var response = null switch (self._mode) { case 'text:vbarray': // For IE9 @@ -50609,7 +50609,7 @@ self.push(new Buffer(response)) break } - // Falls through in IE8 + // Falls through in IE8 case 'text': try { // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4 response = xhr.responseText @@ -50623,7 +50623,7 @@ var buffer = new Buffer(newData.length) for (var i = 0; i < newData.length; i++) buffer[i] = newData.charCodeAt(i) & 0xff - + self.push(buffer) } else { self.push(newData, self._charset) @@ -50661,13 +50661,13 @@ reader.readAsArrayBuffer(response) break } - + // The ms-stream case handles end separately in reader.onload() if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') { self.push(null) } } - + }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) },{"./capability":313,"_process":257,"buffer":84,"inherits":180,"readable-stream":285}],316:[function(require,module,exports){ 'use strict'; @@ -50676,12 +50676,12 @@ return '%' + c.charCodeAt(0).toString(16).toUpperCase(); }); }; - + },{}],317:[function(require,module,exports){ 'use strict'; - + var Buffer = require('safe-buffer').Buffer; - + var isEncoding = Buffer.isEncoding || function (encoding) { encoding = '' + encoding; switch (encoding && encoding.toLowerCase()) { @@ -50691,7 +50691,7 @@ return false; } }; - + function _normalizeEncoding(enc) { if (!enc) return 'utf8'; var retried; @@ -50719,7 +50719,7 @@ } } }; - + // Do not cache `Buffer.isEncoding` when checking encoding names as some // modules monkey-patch it to support additional encodings function normalizeEncoding(enc) { @@ -50727,7 +50727,7 @@ if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); return nenc || enc; } - + // StringDecoder provides an interface for efficiently splitting a series of // buffers into a series of JS strings without breaking apart multi-byte // characters. @@ -50759,7 +50759,7 @@ this.lastTotal = 0; this.lastChar = Buffer.allocUnsafe(nb); } - + StringDecoder.prototype.write = function (buf) { if (buf.length === 0) return ''; var r; @@ -50775,12 +50775,12 @@ if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); return r || ''; }; - + StringDecoder.prototype.end = utf8End; - + // Returns only complete characters in a Buffer StringDecoder.prototype.text = utf8Text; - + // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer StringDecoder.prototype.fillLast = function (buf) { if (this.lastNeed <= buf.length) { @@ -50790,14 +50790,14 @@ buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); this.lastNeed -= buf.length; }; - + // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a // continuation byte. function utf8CheckByte(byte) { if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; return -1; } - + // Checks at most 3 bytes at the end of a Buffer in order to detect an // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) // needed to complete the UTF-8 character (if applicable) are returned. @@ -50825,7 +50825,7 @@ } return 0; } - + // Validates as many continuation bytes for a multi-byte UTF-8 character as // needed or are available. If we see a non-continuation byte where we expect // one, we "replace" the validated continuation bytes we've seen so far with @@ -50852,7 +50852,7 @@ } } } - + // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. function utf8FillLast(buf) { var p = this.lastTotal - this.lastNeed; @@ -50865,7 +50865,7 @@ buf.copy(this.lastChar, p, 0, buf.length); this.lastNeed -= buf.length; } - + // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a // partial character, the character's bytes are buffered until the required // number of bytes are available. @@ -50877,7 +50877,7 @@ buf.copy(this.lastChar, 0, end); return buf.toString('utf8', i, end); } - + // For UTF-8, a replacement character for each buffered byte of a (partial) // character needs to be added to the output. function utf8End(buf) { @@ -50885,7 +50885,7 @@ if (this.lastNeed) return r + '\ufffd'.repeat(this.lastTotal - this.lastNeed); return r; } - + // UTF-16LE typically needs two bytes per character, but even if we have an even // number of bytes available, we need to check if we end on a leading/high // surrogate. In that case, we need to wait for the next two bytes in order to @@ -50910,7 +50910,7 @@ this.lastChar[0] = buf[buf.length - 1]; return buf.toString('utf16le', i, buf.length - 1); } - + // For UTF-16LE we do not explicitly append special replacement characters if we // end on a partial character, we simply let v8 handle that. function utf16End(buf) { @@ -50921,7 +50921,7 @@ } return r; } - + function base64Text(buf, i) { var n = (buf.length - i) % 3; if (n === 0) return buf.toString('base64', i); @@ -50935,24 +50935,24 @@ } return buf.toString('base64', i, buf.length - n); } - + function base64End(buf) { var r = buf && buf.length ? this.write(buf) : ''; if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); return r; } - + // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) function simpleWrite(buf) { return buf.toString(this.encoding); } - + function simpleEnd(buf) { return buf && buf.length ? this.write(buf) : ''; } },{"safe-buffer":290}],318:[function(require,module,exports){ var isHexPrefixed = require('is-hex-prefixed'); - + /** * Removes '0x' from a given `String` is present * @param {String} str the string value @@ -50962,15 +50962,15 @@ if (typeof str !== 'string') { return str; } - + return isHexPrefixed(str) ? str.slice(2) : str; } - + },{"is-hex-prefixed":185}],319:[function(require,module,exports){ var unavailable = function unavailable() { throw "This swarm.js function isn't available on the browser."; }; - + var fsp = { readFile: unavailable }; var files = { download: unavailable, safeDownloadArchived: unavailable, directoryTree: unavailable }; var os = { platform: unavailable, arch: unavailable }; @@ -50984,7 +50984,7 @@ var hash = require("./swarm-hash.js"); var pick = require("./pick.js"); var swarm = require("./swarm"); - + module.exports = swarm({ fsp: fsp, files: files, @@ -51028,7 +51028,7 @@ reader.readAsArrayBuffer(file); }); }; - + var fileInput = void 0; if (type === "directory") { fileInput = document.createElement("input"); @@ -51044,14 +51044,14 @@ fileInput.addEventListener("change", fileLoader); fileInput.type = "file"; }; - + var mouseEvent = document.createEvent("MouseEvents"); mouseEvent.initEvent("click", true, false); fileInput.dispatchEvent(mouseEvent); }); }; }; - + module.exports = { data: picker("data"), file: picker("file"), @@ -51059,16 +51059,16 @@ }; },{}],321:[function(require,module,exports){ // Thanks https://github.com/axic/swarmhash - + var keccak = require("eth-lib/lib/hash").keccak256; var Bytes = require("eth-lib/lib/bytes"); - + var swarmHashBlock = function swarmHashBlock(length, data) { var lengthEncoded = Bytes.reverse(Bytes.pad(6, Bytes.fromNumber(length))); var bytes = Bytes.flatten([lengthEncoded, "0x0000", data]); return keccak(bytes).slice(2); }; - + // (Bytes | Uint8Array | String) -> String var swarmHash = function swarmHash(data) { if (typeof data === "string" && data.slice(0, 2) !== "0x") { @@ -51076,27 +51076,27 @@ } else if (typeof data !== "string" && data.length !== undefined) { data = Bytes.fromUint8Array(data); } - + var length = Bytes.length(data); - + if (length <= 4096) { return swarmHashBlock(length, data); } - + var maxSize = 4096; while (maxSize * (4096 / 32) < length) { maxSize *= 4096 / 32; } - + var innerNodes = []; for (var i = 0; i < length; i += maxSize) { var size = maxSize < length - i ? maxSize : length - i; innerNodes.push(swarmHash(Bytes.slice(data, i, i + size))); } - + return swarmHashBlock(length, Bytes.flatten(innerNodes)); }; - + module.exports = swarmHash; },{"eth-lib/lib/bytes":133,"eth-lib/lib/hash":134}],322:[function(require,module,exports){ // TODO: this is a temporary fix to hide those libraries from the browser. A @@ -51116,8 +51116,8 @@ bytes = _ref.bytes, hash = _ref.hash, pick = _ref.pick; - - + + // ∀ a . String -> JSON -> Map String a -o Map String a // Inserts a key/val pair in an object impurely. var impureInsert = function impureInsert(key) { @@ -51127,7 +51127,7 @@ }; }; }; - + // String -> JSON -> Map String JSON // Merges an array of keys and an array of vals into an object. var toMap = function toMap(keys) { @@ -51138,7 +51138,7 @@ }return map; }; }; - + // ∀ a . Map String a -> Map String a -> Map String a // Merges two maps into one. var merge = function merge(a) { @@ -51151,7 +51151,7 @@ }return map; }; }; - + // ∀ a . [a] -> [a] -> Bool var equals = function equals(a) { return function (b) { @@ -51165,14 +51165,14 @@ return true; }; }; - + // String -> String -> String var rawUrl = function rawUrl(swarmUrl) { return function (hash) { return swarmUrl + "/bzzr:/" + hash; }; }; - + // String -> String -> Promise Uint8Array // Gets the raw contents of a Swarm hash address. var downloadData = function downloadData(swarmUrl) { @@ -51185,10 +51185,10 @@ }); }; }; - + // type Entry = {"type": String, "hash": String} // type File = {"type": String, "data": Uint8Array} - + // String -> String -> Promise (Map String Entry) // Solves the manifest of a Swarm address recursively. // Returns a map from full paths to entries. @@ -51203,7 +51203,7 @@ type: entry.contentType, hash: entry.hash }; }; - + // To download a single entry: // if type is bzz-manifest, go deeper // if not, add it to the routing table @@ -51214,7 +51214,7 @@ return entry.contentType === "application/bzz-manifest+json" ? search(entry.hash)(path + entry.path)(routes) : Promise.resolve(impureInsert(path + entry.path)(format(entry))(routes)); } }; - + // Downloads the initial manifest and then each entry. return downloadData(swarmUrl)(hash).then(function (text) { return JSON.parse(toString(text)).entries; @@ -51226,11 +51226,11 @@ }; }; }; - + return search(hash)("")({}); }; }; - + // String -> String -> Promise (Map String String) // Same as `downloadEntries`, but returns only hashes (no types). var downloadRoutes = function downloadRoutes(swarmUrl) { @@ -51242,7 +51242,7 @@ }); }; }; - + // String -> String -> Promise (Map String File) // Gets the entire directory tree in a Swarm address. // Returns a promise mapping paths to file contents. @@ -51268,7 +51268,7 @@ }); }; }; - + // String -> String -> String -> Promise String // Gets the raw contents of a Swarm hash address. // Returns a promise with the downloaded file path. @@ -51279,7 +51279,7 @@ }; }; }; - + // String -> String -> String -> Promise (Map String String) // Gets the entire directory tree in a Swarm address. // Returns a promise mapping paths to file contents. @@ -51301,7 +51301,7 @@ }; }; }; - + // String -> Uint8Array -> Promise String // Uploads raw data to Swarm. // Returns a promise with the uploaded hash. @@ -51312,7 +51312,7 @@ method: "POST" }); }; }; - + // String -> String -> String -> File -> Promise String // Uploads a file to the Swarm manifest at a given hash, under a specific // route. Returns a promise containing the uploaded hash. @@ -51343,14 +51343,14 @@ }; }; }; - + // String -> {type: String, data: Uint8Array} -> Promise String var uploadFile = function uploadFile(swarmUrl) { return function (file) { return uploadDirectory(swarmUrl)({ "": file }); }; }; - + // String -> String -> Promise String var uploadFileFromDisk = function uploadFileFromDisk(swarmUrl) { return function (filePath) { @@ -51359,7 +51359,7 @@ }); }; }; - + // String -> Map String File -> Promise String // Uploads a directory to Swarm. The directory is // represented as a map of routes and files. @@ -51379,14 +51379,14 @@ }); }; }; - + // String -> Promise String var uploadDataFromDisk = function uploadDataFromDisk(swarmUrl) { return function (filePath) { return fsp.readFile(filePath).then(uploadData(swarmUrl)); }; }; - + // String -> Nullable String -> String -> Promise String var uploadDirectoryFromDisk = function uploadDirectoryFromDisk(swarmUrl) { return function (defaultPath) { @@ -51411,7 +51411,7 @@ }; }; }; - + // String -> UploadInfo -> Promise String // Simplified multi-type upload which calls the correct // one based on the type of the argument given. @@ -51420,15 +51420,15 @@ // Upload raw data from browser if (arg.pick === "data") { return pick.data().then(uploadData(swarmUrl)); - + // Upload a file from browser } else if (arg.pick === "file") { return pick.file().then(uploadFile(swarmUrl)); - + // Upload a directory from browser } else if (arg.pick === "directory") { return pick.directory().then(uploadDirectory(swarmUrl)); - + // Upload directory/file from disk } else if (arg.path) { switch (arg.kind) { @@ -51439,20 +51439,20 @@ case "directory": return uploadDirectoryFromDisk(swarmUrl)(arg.defaultFile)(arg.path); }; - + // Upload UTF-8 string or raw data (buffer) } else if (arg.length || typeof arg === "string") { return uploadData(swarmUrl)(arg); - + // Upload directory with JSON } else if (arg instanceof Object) { return uploadDirectory(swarmUrl)(arg); } - + return Promise.reject(new Error("Bad arguments")); }; }; - + // String -> String -> Nullable String -> Promise (String | Uint8Array | Map String Uint8Array) // Simplified multi-type download which calls the correct function based on // the type of the argument given, and on whether the Swwarm address has a @@ -51470,7 +51470,7 @@ }; }; }; - + // String -> Promise String // Downloads the Swarm binaries into a path. Returns a promise that only // resolves when the exact Swarm file is there, and verified to be correct. @@ -51483,7 +51483,7 @@ var binaryMD5 = archive.binaryMD5; return files.safeDownloadArchived(archiveUrl)(archiveMD5)(binaryMD5)(path); }; - + // type SwarmSetup = { // account : String, // password : String, @@ -51497,14 +51497,14 @@ // archiveMD5: String // }] // } - + // SwarmSetup ~> Promise Process // Starts the Swarm process. var startProcess = function startProcess(swarmSetup) { return new Promise(function (resolve, reject) { var spawn = child_process.spawn; - - + + var hasString = function hasString(str) { return function (buffer) { return ('' + buffer).indexOf(str) !== -1; @@ -51515,19 +51515,19 @@ dataDir = swarmSetup.dataDir, ensApi = swarmSetup.ensApi, privateKey = swarmSetup.privateKey; - - + + var STARTUP_TIMEOUT_SECS = 3; var WAITING_PASSWORD = 0; var STARTING = 1; var LISTENING = 2; var PASSWORD_PROMPT_HOOK = "Passphrase"; var LISTENING_HOOK = "Swarm http proxy started"; - + var state = WAITING_PASSWORD; - + var swarmProcess = spawn(swarmSetup.binPath, ['--bzzaccount', account || privateKey, '--datadir', dataDir, '--ens-api', ensApi]); - + var handleProcessOutput = function handleProcessOutput(data) { if (state === WAITING_PASSWORD && hasString(PASSWORD_PROMPT_HOOK)(data)) { setTimeout(function () { @@ -51540,11 +51540,11 @@ resolve(swarmProcess); } }; - + swarmProcess.stdout.on('data', handleProcessOutput); swarmProcess.stderr.on('data', handleProcessOutput); //swarmProcess.on('close', () => setTimeout(restart, 2000)); - + var restart = function restart() { return startProcess(swarmSetup).then(resolve).catch(reject); }; @@ -51554,7 +51554,7 @@ var timeout = setTimeout(error, 20000); }); }; - + // Process ~> Promise () // Stops the Swarm process. var stopProcess = function stopProcess(process) { @@ -51565,18 +51565,18 @@ process.removeAllListeners('error'); process.removeAllListeners('exit'); process.kill('SIGINT'); - + var killTimeout = setTimeout(function () { return process.kill('SIGKILL'); }, 8000); - + process.once('close', function () { clearTimeout(killTimeout); resolve(); }); }); }; - + // SwarmSetup -> (SwarmAPI -> Promise ()) -> Promise () // Receives a Swarm configuration object and a callback function. It then // checks if a local Swarm node is running. If no local Swarm is found, it @@ -51602,7 +51602,7 @@ }); }; }; - + // String ~> Promise Bool // Returns true if Swarm is available on `url`. // Perfoms a test upload to determine that. @@ -51616,7 +51616,7 @@ return false; }); }; - + // String -> String ~> Promise Bool // Returns a Promise which is true if that Swarm address is a directory. // Determines that by checking that it (i) is a JSON, (ii) has a .entries. @@ -51632,7 +51632,7 @@ }); }; }; - + // Uncurries a function; used to allow the f(x,y,z) style on exports. var uncurry = function uncurry(f) { return function (a, b, c, d, e) { @@ -51646,23 +51646,23 @@ return p; }; }; - + // () -> Promise Bool // Not sure how to mock Swarm to test it properly. Ideas? var test = function test() { return Promise.resolve(true); }; - + // Uint8Array -> String var toString = function toString(uint8Array) { return bytes.toString(bytes.fromUint8Array(uint8Array)); }; - + // String -> Uint8Array var fromString = function fromString(string) { return bytes.toUint8Array(bytes.fromString(string)); }; - + // String -> SwarmAPI // Fixes the `swarmUrl`, returning an API where you don't have to pass it. var at = function at(swarmUrl) { @@ -51695,7 +51695,7 @@ toString: toString }; }; - + return { at: at, local: local, @@ -51724,10 +51724,10 @@ toString: toString }; }; - + },{}],323:[function(require,module,exports){ var Buffer = require('buffer').Buffer - + module.exports = function (buf) { // If the buffer is backed by a Uint8Array, a faster version will work if (buf instanceof Uint8Array) { @@ -51739,7 +51739,7 @@ return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength) } } - + if (Buffer.isBuffer(buf)) { // This is the slow version that will work with any Buffer // implementation (even in old browsers) @@ -51753,50 +51753,50 @@ throw new Error('Argument must be a Buffer') } } - + },{"buffer":84}],324:[function(require,module,exports){ - + exports = module.exports = trim; - + function trim(str){ return str.replace(/^\s*|\s*$/g, ''); } - + exports.left = function(str){ return str.replace(/^\s*/, ''); }; - + exports.right = function(str){ return str.replace(/\s*$/, ''); }; - + },{}],325:[function(require,module,exports){ // Underscore.js 1.8.3 // http://underscorejs.org // (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors // Underscore may be freely distributed under the MIT license. - + (function() { - + // Baseline setup // -------------- - + // Establish the root object, `window` in the browser, or `exports` on the server. var root = this; - + // Save the previous value of the `_` variable. var previousUnderscore = root._; - + // Save bytes in the minified (but not gzipped) version: var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; - + // Create quick reference variables for speed access to core prototypes. var push = ArrayProto.push, slice = ArrayProto.slice, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty; - + // All **ECMAScript 5** native function implementations that we hope to use // are declared here. var @@ -51804,17 +51804,17 @@ nativeKeys = Object.keys, nativeBind = FuncProto.bind, nativeCreate = Object.create; - + // Naked function reference for surrogate-prototype-swapping. var Ctor = function(){}; - + // Create a safe reference to the Underscore object for use below. var _ = function(obj) { if (obj instanceof _) return obj; if (!(this instanceof _)) return new _(obj); this._wrapped = obj; }; - + // Export the Underscore object for **Node.js**, with // backwards-compatibility for the old `require()` API. If we're in // the browser, add `_` as a global object. @@ -51826,10 +51826,10 @@ } else { root._ = _; } - + // Current version. _.VERSION = '1.8.3'; - + // Internal function that returns an efficient (for current engines) version // of the passed-in callback, to be repeatedly applied in other Underscore // functions. @@ -51853,7 +51853,7 @@ return func.apply(context, arguments); }; }; - + // A mostly-internal function to generate callbacks that can be applied // to each element in a collection, returning the desired result — either // identity, an arbitrary callback, a property matcher, or a property accessor. @@ -51866,7 +51866,7 @@ _.iteratee = function(value, context) { return cb(value, context, Infinity); }; - + // An internal function for creating assigner functions. var createAssigner = function(keysFunc, undefinedOnly) { return function(obj) { @@ -51884,7 +51884,7 @@ return obj; }; }; - + // An internal function for creating a new object that inherits from another. var baseCreate = function(prototype) { if (!_.isObject(prototype)) return {}; @@ -51894,13 +51894,13 @@ Ctor.prototype = null; return result; }; - + var property = function(key) { return function(obj) { return obj == null ? void 0 : obj[key]; }; }; - + // Helper for collection methods to determine whether a collection // should be iterated as an array or as an object // Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength @@ -51911,10 +51911,10 @@ var length = getLength(collection); return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX; }; - + // Collection Functions // -------------------- - + // The cornerstone, an `each` implementation, aka `forEach`. // Handles raw objects in addition to array-likes. Treats all // sparse array-likes as if they were dense. @@ -51933,7 +51933,7 @@ } return obj; }; - + // Return the results of applying the iteratee to each element. _.map = _.collect = function(obj, iteratee, context) { iteratee = cb(iteratee, context); @@ -51946,7 +51946,7 @@ } return results; }; - + // Create a reducing function iterating left or right. function createReduce(dir) { // Optimized iterator function as using arguments.length @@ -51958,7 +51958,7 @@ } return memo; } - + return function(obj, iteratee, memo, context) { iteratee = optimizeCb(iteratee, context, 4); var keys = !isArrayLike(obj) && _.keys(obj), @@ -51972,14 +51972,14 @@ return iterator(obj, iteratee, memo, keys, index, length); }; } - + // **Reduce** builds up a single result from a list of values, aka `inject`, // or `foldl`. _.reduce = _.foldl = _.inject = createReduce(1); - + // The right-associative version of reduce, also known as `foldr`. _.reduceRight = _.foldr = createReduce(-1); - + // Return the first value which passes a truth test. Aliased as `detect`. _.find = _.detect = function(obj, predicate, context) { var key; @@ -51990,7 +51990,7 @@ } if (key !== void 0 && key !== -1) return obj[key]; }; - + // Return all the elements that pass a truth test. // Aliased as `select`. _.filter = _.select = function(obj, predicate, context) { @@ -52001,12 +52001,12 @@ }); return results; }; - + // Return all the elements for which a truth test fails. _.reject = function(obj, predicate, context) { return _.filter(obj, _.negate(cb(predicate)), context); }; - + // Determine whether all of the elements match a truth test. // Aliased as `all`. _.every = _.all = function(obj, predicate, context) { @@ -52019,7 +52019,7 @@ } return true; }; - + // Determine if at least one element in the object matches a truth test. // Aliased as `any`. _.some = _.any = function(obj, predicate, context) { @@ -52032,7 +52032,7 @@ } return false; }; - + // Determine if the array or object contains a given item (using `===`). // Aliased as `includes` and `include`. _.contains = _.includes = _.include = function(obj, item, fromIndex, guard) { @@ -52040,7 +52040,7 @@ if (typeof fromIndex != 'number' || guard) fromIndex = 0; return _.indexOf(obj, item, fromIndex) >= 0; }; - + // Invoke a method (with arguments) on every item in a collection. _.invoke = function(obj, method) { var args = slice.call(arguments, 2); @@ -52050,24 +52050,24 @@ return func == null ? func : func.apply(value, args); }); }; - + // Convenience version of a common use case of `map`: fetching a property. _.pluck = function(obj, key) { return _.map(obj, _.property(key)); }; - + // Convenience version of a common use case of `filter`: selecting only objects // containing specific `key:value` pairs. _.where = function(obj, attrs) { return _.filter(obj, _.matcher(attrs)); }; - + // Convenience version of a common use case of `find`: getting the first object // containing specific `key:value` pairs. _.findWhere = function(obj, attrs) { return _.find(obj, _.matcher(attrs)); }; - + // Return the maximum element (or element-based computation). _.max = function(obj, iteratee, context) { var result = -Infinity, lastComputed = -Infinity, @@ -52092,7 +52092,7 @@ } return result; }; - + // Return the minimum element (or element-based computation). _.min = function(obj, iteratee, context) { var result = Infinity, lastComputed = Infinity, @@ -52117,7 +52117,7 @@ } return result; }; - + // Shuffle a collection, using the modern version of the // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). _.shuffle = function(obj) { @@ -52131,7 +52131,7 @@ } return shuffled; }; - + // Sample **n** random values from a collection. // If **n** is not specified, returns a single random element. // The internal `guard` argument allows it to work with `map`. @@ -52142,7 +52142,7 @@ } return _.shuffle(obj).slice(0, Math.max(0, n)); }; - + // Sort the object's values by a criterion produced by an iteratee. _.sortBy = function(obj, iteratee, context) { iteratee = cb(iteratee, context); @@ -52162,7 +52162,7 @@ return left.index - right.index; }), 'value'); }; - + // An internal function used for aggregate "group by" operations. var group = function(behavior) { return function(obj, iteratee, context) { @@ -52175,26 +52175,26 @@ return result; }; }; - + // Groups the object's values by a criterion. Pass either a string attribute // to group by, or a function that returns the criterion. _.groupBy = group(function(result, value, key) { if (_.has(result, key)) result[key].push(value); else result[key] = [value]; }); - + // Indexes the object's values by a criterion, similar to `groupBy`, but for // when you know that your index values will be unique. _.indexBy = group(function(result, value, key) { result[key] = value; }); - + // Counts instances of an object that group by a certain criterion. Pass // either a string attribute to count by, or a function that returns the // criterion. _.countBy = group(function(result, value, key) { if (_.has(result, key)) result[key]++; else result[key] = 1; }); - + // Safely create a real, live array from anything iterable. _.toArray = function(obj) { if (!obj) return []; @@ -52202,13 +52202,13 @@ if (isArrayLike(obj)) return _.map(obj, _.identity); return _.values(obj); }; - + // Return the number of elements in an object. _.size = function(obj) { if (obj == null) return 0; return isArrayLike(obj) ? obj.length : _.keys(obj).length; }; - + // Split a collection into two arrays: one whose elements all satisfy the given // predicate, and one whose elements all do not satisfy the predicate. _.partition = function(obj, predicate, context) { @@ -52219,10 +52219,10 @@ }); return [pass, fail]; }; - + // Array Functions // --------------- - + // Get the first element of an array. Passing **n** will return the first N // values in the array. Aliased as `head` and `take`. The **guard** check // allows it to work with `_.map`. @@ -52231,14 +52231,14 @@ if (n == null || guard) return array[0]; return _.initial(array, array.length - n); }; - + // Returns everything but the last entry of the array. Especially useful on // the arguments object. Passing **n** will return all the values in // the array, excluding the last N. _.initial = function(array, n, guard) { return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); }; - + // Get the last element of an array. Passing **n** will return the last N // values in the array. _.last = function(array, n, guard) { @@ -52246,19 +52246,19 @@ if (n == null || guard) return array[array.length - 1]; return _.rest(array, Math.max(0, array.length - n)); }; - + // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. // Especially useful on the arguments object. Passing an **n** will return // the rest N values in the array. _.rest = _.tail = _.drop = function(array, n, guard) { return slice.call(array, n == null || guard ? 1 : n); }; - + // Trim out all falsy values from an array. _.compact = function(array) { return _.filter(array, _.identity); }; - + // Internal implementation of a recursive `flatten` function. var flatten = function(input, shallow, strict, startIndex) { var output = [], idx = 0; @@ -52278,17 +52278,17 @@ } return output; }; - + // Flatten out an array, either recursively (by default), or just one level. _.flatten = function(array, shallow) { return flatten(array, shallow, false); }; - + // Return a version of the array that does not contain the specified value(s). _.without = function(array) { return _.difference(array, slice.call(arguments, 1)); }; - + // Produce a duplicate-free version of the array. If the array has already // been sorted, you have the option of using a faster algorithm. // Aliased as `unique`. @@ -52318,13 +52318,13 @@ } return result; }; - + // Produce an array that contains the union: each distinct element from all of // the passed-in arrays. _.union = function() { return _.uniq(flatten(arguments, true, true)); }; - + // Produce an array that contains every item shared between all the // passed-in arrays. _.intersection = function(array) { @@ -52340,7 +52340,7 @@ } return result; }; - + // Take the difference between one array and a number of other arrays. // Only the elements present in just the first array will remain. _.difference = function(array) { @@ -52349,25 +52349,25 @@ return !_.contains(rest, value); }); }; - + // Zip together multiple lists into a single array -- elements that share // an index go together. _.zip = function() { return _.unzip(arguments); }; - + // Complement of _.zip. Unzip accepts an array of arrays and groups // each array's elements on shared indices _.unzip = function(array) { var length = array && _.max(array, getLength).length || 0; var result = Array(length); - + for (var index = 0; index < length; index++) { result[index] = _.pluck(array, index); } return result; }; - + // Converts lists into objects. Pass either a single array of `[key, value]` // pairs, or two parallel arrays of the same length -- one of keys, and one of // the corresponding values. @@ -52382,7 +52382,7 @@ } return result; }; - + // Generator function to create the findIndex and findLastIndex functions function createPredicateIndexFinder(dir) { return function(array, predicate, context) { @@ -52395,11 +52395,11 @@ return -1; }; } - + // Returns the first index on an array-like that passes a predicate test _.findIndex = createPredicateIndexFinder(1); _.findLastIndex = createPredicateIndexFinder(-1); - + // Use a comparator function to figure out the smallest index at which // an object should be inserted so as to maintain order. Uses binary search. _.sortedIndex = function(array, obj, iteratee, context) { @@ -52412,7 +52412,7 @@ } return low; }; - + // Generator function to create the indexOf and lastIndexOf functions function createIndexFinder(dir, predicateFind, sortedIndex) { return function(array, item, idx) { @@ -52437,14 +52437,14 @@ return -1; }; } - + // Return the position of the first occurrence of an item in an array, // or -1 if the item is not included in the array. // If the array is large and already in sort order, pass `true` // for **isSorted** to use binary search. _.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex); _.lastIndexOf = createIndexFinder(-1, _.findLastIndex); - + // Generate an integer Array containing an arithmetic progression. A port of // the native Python `range()` function. See // [the Python documentation](http://docs.python.org/library/functions.html#range). @@ -52454,20 +52454,20 @@ start = 0; } step = step || 1; - + var length = Math.max(Math.ceil((stop - start) / step), 0); var range = Array(length); - + for (var idx = 0; idx < length; idx++, start += step) { range[idx] = start; } - + return range; }; - + // Function (ahem) Functions // ------------------ - + // Determines whether to execute a function as a constructor // or a normal function with the provided arguments var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) { @@ -52477,7 +52477,7 @@ if (_.isObject(result)) return result; return self; }; - + // Create a function bound to a given object (assigning `this`, and arguments, // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if // available. @@ -52490,7 +52490,7 @@ }; return bound; }; - + // Partially apply a function by creating a version that has had some of its // arguments pre-filled, without changing its dynamic `this` context. _ acts // as a placeholder, allowing any combination of arguments to be pre-filled. @@ -52507,7 +52507,7 @@ }; return bound; }; - + // Bind a number of an object's methods to that object. Remaining arguments // are the method names to be bound. Useful for ensuring that all callbacks // defined on an object belong to it. @@ -52520,7 +52520,7 @@ } return obj; }; - + // Memoize an expensive function by storing its results. _.memoize = function(func, hasher) { var memoize = function(key) { @@ -52532,7 +52532,7 @@ memoize.cache = {}; return memoize; }; - + // Delays a function for the given number of milliseconds, and then calls // it with the arguments supplied. _.delay = function(func, wait) { @@ -52541,11 +52541,11 @@ return func.apply(null, args); }, wait); }; - + // Defers a function, scheduling it to run after the current call stack has // cleared. _.defer = _.partial(_.delay, _, 1); - + // Returns a function, that, when invoked, will only be triggered at most once // during a given window of time. Normally, the throttled function will run // as much as it can, without ever going more than once per `wait` duration; @@ -52582,17 +52582,17 @@ return result; }; }; - + // Returns a function, that, as long as it continues to be invoked, will not // be triggered. The function will be called after it stops being called for // N milliseconds. If `immediate` is passed, trigger the function on the // leading edge, instead of the trailing. _.debounce = function(func, wait, immediate) { var timeout, args, context, timestamp, result; - + var later = function() { var last = _.now() - timestamp; - + if (last < wait && last >= 0) { timeout = setTimeout(later, wait - last); } else { @@ -52603,7 +52603,7 @@ } } }; - + return function() { context = this; args = arguments; @@ -52614,25 +52614,25 @@ result = func.apply(context, args); context = args = null; } - + return result; }; }; - + // Returns the first function passed as an argument to the second, // allowing you to adjust arguments, run code before and after, and // conditionally execute the original function. _.wrap = function(func, wrapper) { return _.partial(wrapper, func); }; - + // Returns a negated version of the passed-in predicate. _.negate = function(predicate) { return function() { return !predicate.apply(this, arguments); }; }; - + // Returns a function that is the composition of a list of functions, each // consuming the return value of the function that follows. _.compose = function() { @@ -52645,7 +52645,7 @@ return result; }; }; - + // Returns a function that will only be executed on and after the Nth call. _.after = function(times, func) { return function() { @@ -52654,7 +52654,7 @@ } }; }; - + // Returns a function that will only be executed up to (but not including) the Nth call. _.before = function(times, func) { var memo; @@ -52666,28 +52666,28 @@ return memo; }; }; - + // Returns a function that will be executed at most one time, no matter how // often you call it. Useful for lazy initialization. _.once = _.partial(_.before, 2); - + // Object Functions // ---------------- - + // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed. var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString'); var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; - + function collectNonEnumProps(obj, keys) { var nonEnumIdx = nonEnumerableProps.length; var constructor = obj.constructor; var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto; - + // Constructor is a special case. var prop = 'constructor'; if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop); - + while (nonEnumIdx--) { prop = nonEnumerableProps[nonEnumIdx]; if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) { @@ -52695,7 +52695,7 @@ } } } - + // Retrieve the names of an object's own properties. // Delegates to **ECMAScript 5**'s native `Object.keys` _.keys = function(obj) { @@ -52707,7 +52707,7 @@ if (hasEnumBug) collectNonEnumProps(obj, keys); return keys; }; - + // Retrieve all the property names of an object. _.allKeys = function(obj) { if (!_.isObject(obj)) return []; @@ -52717,7 +52717,7 @@ if (hasEnumBug) collectNonEnumProps(obj, keys); return keys; }; - + // Retrieve the values of an object's properties. _.values = function(obj) { var keys = _.keys(obj); @@ -52728,7 +52728,7 @@ } return values; }; - + // Returns the results of applying the iteratee to each element of the object // In contrast to _.map it returns an object _.mapObject = function(obj, iteratee, context) { @@ -52743,7 +52743,7 @@ } return results; }; - + // Convert an object into a list of `[key, value]` pairs. _.pairs = function(obj) { var keys = _.keys(obj); @@ -52754,7 +52754,7 @@ } return pairs; }; - + // Invert the keys and values of an object. The values must be serializable. _.invert = function(obj) { var result = {}; @@ -52764,7 +52764,7 @@ } return result; }; - + // Return a sorted list of the function names available on the object. // Aliased as `methods` _.functions = _.methods = function(obj) { @@ -52774,14 +52774,14 @@ } return names.sort(); }; - + // Extend a given object with all the properties in passed-in object(s). _.extend = createAssigner(_.allKeys); - + // Assigns a given object with all the own properties in the passed-in object(s) // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) _.extendOwn = _.assign = createAssigner(_.keys); - + // Returns the first key on an object that passes a predicate test _.findKey = function(obj, predicate, context) { predicate = cb(predicate, context); @@ -52791,7 +52791,7 @@ if (predicate(obj[key], key, obj)) return key; } }; - + // Return a copy of the object only containing the whitelisted properties. _.pick = function(object, oiteratee, context) { var result = {}, obj = object, iteratee, keys; @@ -52811,7 +52811,7 @@ } return result; }; - + // Return a copy of the object without the blacklisted properties. _.omit = function(obj, iteratee, context) { if (_.isFunction(iteratee)) { @@ -52824,10 +52824,10 @@ } return _.pick(obj, iteratee, context); }; - + // Fill in a given object with default properties. _.defaults = createAssigner(_.allKeys, true); - + // Creates an object that inherits from the given prototype object. // If additional properties are provided then they will be added to the // created object. @@ -52836,13 +52836,13 @@ if (props) _.extendOwn(result, props); return result; }; - + // Create a (shallow-cloned) duplicate of an object. _.clone = function(obj) { if (!_.isObject(obj)) return obj; return _.isArray(obj) ? obj.slice() : _.extend({}, obj); }; - + // Invokes interceptor with the obj, and then returns obj. // The primary purpose of this method is to "tap into" a method chain, in // order to perform operations on intermediate results within the chain. @@ -52850,7 +52850,7 @@ interceptor(obj); return obj; }; - + // Returns whether an object has a given set of `key:value` pairs. _.isMatch = function(object, attrs) { var keys = _.keys(attrs), length = keys.length; @@ -52862,8 +52862,8 @@ } return true; }; - - + + // Internal recursive comparison function for `isEqual`. var eq = function(a, b, aStack, bStack) { // Identical objects are equal. `0 === -0`, but they aren't identical. @@ -52898,11 +52898,11 @@ // of `NaN` are not equivalent. return +a === +b; } - + var areArrays = className === '[object Array]'; if (!areArrays) { if (typeof a != 'object' || typeof b != 'object') return false; - + // Objects with different constructors are not equivalent, but `Object`s or `Array`s // from different frames are. var aCtor = a.constructor, bCtor = b.constructor; @@ -52914,7 +52914,7 @@ } // Assume equality for cyclic structures. The algorithm for detecting cyclic // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. - + // Initializing stack of traversed objects. // It's done here since we only need them for objects and arrays comparison. aStack = aStack || []; @@ -52925,11 +52925,11 @@ // unique nested structures. if (aStack[length] === a) return bStack[length] === b; } - + // Add the first object to the stack of traversed objects. aStack.push(a); bStack.push(b); - + // Recursively compare objects and arrays. if (areArrays) { // Compare array lengths to determine if a deep comparison is necessary. @@ -52956,12 +52956,12 @@ bStack.pop(); return true; }; - + // Perform a deep comparison to check if two objects are equal. _.isEqual = function(a, b) { return eq(a, b); }; - + // Is a given array, string, or object empty? // An "empty" object has no enumerable own-properties. _.isEmpty = function(obj) { @@ -52969,31 +52969,31 @@ if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0; return _.keys(obj).length === 0; }; - + // Is a given value a DOM element? _.isElement = function(obj) { return !!(obj && obj.nodeType === 1); }; - + // Is a given value an array? // Delegates to ECMA5's native Array.isArray _.isArray = nativeIsArray || function(obj) { return toString.call(obj) === '[object Array]'; }; - + // Is a given variable an object? _.isObject = function(obj) { var type = typeof obj; return type === 'function' || type === 'object' && !!obj; }; - + // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError. _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) { _['is' + name] = function(obj) { return toString.call(obj) === '[object ' + name + ']'; }; }); - + // Define a fallback version of the method in browsers (ahem, IE < 9), where // there isn't any inspectable "Arguments" type. if (!_.isArguments(arguments)) { @@ -53001,7 +53001,7 @@ return _.has(obj, 'callee'); }; } - + // Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8, // IE 11 (#1621), and in Safari 8 (#1929). if (typeof /./ != 'function' && typeof Int8Array != 'object') { @@ -53009,71 +53009,71 @@ return typeof obj == 'function' || false; }; } - + // Is a given object a finite number? _.isFinite = function(obj) { return isFinite(obj) && !isNaN(parseFloat(obj)); }; - + // Is the given value `NaN`? (NaN is the only number which does not equal itself). _.isNaN = function(obj) { return _.isNumber(obj) && obj !== +obj; }; - + // Is a given value a boolean? _.isBoolean = function(obj) { return obj === true || obj === false || toString.call(obj) === '[object Boolean]'; }; - + // Is a given value equal to null? _.isNull = function(obj) { return obj === null; }; - + // Is a given variable undefined? _.isUndefined = function(obj) { return obj === void 0; }; - + // Shortcut function for checking if an object has a given property directly // on itself (in other words, not on a prototype). _.has = function(obj, key) { return obj != null && hasOwnProperty.call(obj, key); }; - + // Utility Functions // ----------------- - + // Run Underscore.js in *noConflict* mode, returning the `_` variable to its // previous owner. Returns a reference to the Underscore object. _.noConflict = function() { root._ = previousUnderscore; return this; }; - + // Keep the identity function around for default iteratees. _.identity = function(value) { return value; }; - + // Predicate-generating functions. Often useful outside of Underscore. _.constant = function(value) { return function() { return value; }; }; - + _.noop = function(){}; - + _.property = property; - + // Generates a function for a given object that returns a given property. _.propertyOf = function(obj) { return obj == null ? function(){} : function(key) { return obj[key]; }; }; - + // Returns a predicate for checking whether an object has a given set of // `key:value` pairs. _.matcher = _.matches = function(attrs) { @@ -53082,7 +53082,7 @@ return _.isMatch(obj, attrs); }; }; - + // Run a function **n** times. _.times = function(n, iteratee, context) { var accum = Array(Math.max(0, n)); @@ -53090,7 +53090,7 @@ for (var i = 0; i < n; i++) accum[i] = iteratee(i); return accum; }; - + // Return a random integer between min and max (inclusive). _.random = function(min, max) { if (max == null) { @@ -53099,12 +53099,12 @@ } return min + Math.floor(Math.random() * (max - min + 1)); }; - + // A (possibly faster) way to get the current timestamp as an integer. _.now = Date.now || function() { return new Date().getTime(); }; - + // List of HTML entities for escaping. var escapeMap = { '&': '&', @@ -53115,7 +53115,7 @@ '`': '`' }; var unescapeMap = _.invert(escapeMap); - + // Functions for escaping and unescaping strings to/from HTML interpolation. var createEscaper = function(map) { var escaper = function(match) { @@ -53132,7 +53132,7 @@ }; _.escape = createEscaper(escapeMap); _.unescape = createEscaper(unescapeMap); - + // If the value of the named `property` is a function then invoke it with the // `object` as context; otherwise, return it. _.result = function(object, property, fallback) { @@ -53142,7 +53142,7 @@ } return _.isFunction(value) ? value.call(object) : value; }; - + // Generate a unique integer id (unique within the entire client session). // Useful for temporary DOM ids. var idCounter = 0; @@ -53150,7 +53150,7 @@ var id = ++idCounter + ''; return prefix ? prefix + id : id; }; - + // By default, Underscore uses ERB-style template delimiters, change the // following template settings to use alternative delimiters. _.templateSettings = { @@ -53158,12 +53158,12 @@ interpolate : /<%=([\s\S]+?)%>/g, escape : /<%-([\s\S]+?)%>/g }; - + // When customizing `templateSettings`, if you don't want to define an // interpolation, evaluation or escaping regex, we need one that is // guaranteed not to match. var noMatch = /(.)^/; - + // Certain characters need to be escaped so that they can be put into a // string literal. var escapes = { @@ -53174,13 +53174,13 @@ '\u2028': 'u2028', '\u2029': 'u2029' }; - + var escaper = /\\|'|\r|\n|\u2028|\u2029/g; - + var escapeChar = function(match) { return '\\' + escapes[match]; }; - + // JavaScript micro-templating, similar to John Resig's implementation. // Underscore templating handles arbitrary delimiters, preserves whitespace, // and correctly escapes quotes within interpolated code. @@ -53188,21 +53188,21 @@ _.template = function(text, settings, oldSettings) { if (!settings && oldSettings) settings = oldSettings; settings = _.defaults({}, settings, _.templateSettings); - + // Combine delimiters into one regular expression via alternation. var matcher = RegExp([ (settings.escape || noMatch).source, (settings.interpolate || noMatch).source, (settings.evaluate || noMatch).source ].join('|') + '|$', 'g'); - + // Compile the template source, escaping string literals appropriately. var index = 0; var source = "__p+='"; text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { source += text.slice(index, offset).replace(escaper, escapeChar); index = offset + match.length; - + if (escape) { source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; } else if (interpolate) { @@ -53210,55 +53210,55 @@ } else if (evaluate) { source += "';\n" + evaluate + "\n__p+='"; } - + // Adobe VMs need the match returned to produce the correct offest. return match; }); source += "';\n"; - + // If a variable is not specified, place data values in local scope. if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; - + source = "var __t,__p='',__j=Array.prototype.join," + "print=function(){__p+=__j.call(arguments,'');};\n" + source + 'return __p;\n'; - + try { var render = new Function(settings.variable || 'obj', '_', source); } catch (e) { e.source = source; throw e; } - + var template = function(data) { return render.call(this, data, _); }; - + // Provide the compiled source as a convenience for precompilation. var argument = settings.variable || 'obj'; template.source = 'function(' + argument + '){\n' + source + '}'; - + return template; }; - + // Add a "chain" function. Start chaining a wrapped Underscore object. _.chain = function(obj) { var instance = _(obj); instance._chain = true; return instance; }; - + // OOP // --------------- // If Underscore is called as a function, it returns a wrapped object that // can be used OO-style. This wrapper holds altered versions of all the // underscore functions. Wrapped objects may be chained. - + // Helper function to continue chaining intermediate results. var result = function(instance, obj) { return instance._chain ? _(obj).chain() : obj; }; - + // Add your own custom functions to the Underscore object. _.mixin = function(obj) { _.each(_.functions(obj), function(name) { @@ -53270,10 +53270,10 @@ }; }); }; - + // Add all of the Underscore functions to the wrapper object. _.mixin(_); - + // Add all mutator Array functions to the wrapper. _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { var method = ArrayProto[name]; @@ -53284,7 +53284,7 @@ return result(this, obj); }; }); - + // Add all accessor Array functions to the wrapper. _.each(['concat', 'join', 'slice'], function(name) { var method = ArrayProto[name]; @@ -53292,20 +53292,20 @@ return result(this, method.apply(this._wrapped, arguments)); }; }); - + // Extracts the result from a wrapped and chained object. _.prototype.value = function() { return this._wrapped; }; - + // Provide unwrapping proxy for some methods used in engine operations // such as arithmetic and JSON stringification. _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; - + _.prototype.toString = function() { return '' + this._wrapped; }; - + // AMD registration happens at the end for compatibility with AMD loaders // that may not enforce next-turn semantics on modules. Even though general // practice for AMD registration is to be anonymous, underscore registers @@ -53319,17 +53319,17 @@ }); } }.call(this)); - + },{}],326:[function(require,module,exports){ module.exports = urlSetQuery function urlSetQuery (url, query) { if (query) { // remove optional leading symbols query = query.trim().replace(/^(\?|#|&)/, '') - + // don't append empty query query = query ? ('?' + query) : query - + var parts = url.split(/[\?\#]/) var start = parts[0] if (query && /\:\/\/[^\/]*$/.test(start)) { @@ -53344,7 +53344,7 @@ } return url } - + },{}],327:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // @@ -53366,19 +53366,19 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - + 'use strict'; - + var punycode = require('punycode'); var util = require('./util'); - + exports.parse = urlParse; exports.resolve = urlResolve; exports.resolveObject = urlResolveObject; exports.format = urlFormat; - + exports.Url = Url; - + function Url() { this.protocol = null; this.slashes = null; @@ -53393,24 +53393,24 @@ this.path = null; this.href = null; } - + // Reference: RFC 3986, RFC 1808, RFC 2396 - + // define these here so at least they only have to be // compiled once on the first module load. var protocolPattern = /^([a-z0-9.+-]+:)/i, portPattern = /:[0-9]*$/, - + // Special case for a simple path URL simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/, - + // RFC 2396: characters reserved for delimiting URLs. // We actually just auto-escape these. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'], - + // RFC 2396: characters not allowed for various reasons. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims), - + // Allowed by RFCs, but cause of XSS attacks. Always escape these. autoEscape = ['\''].concat(unwise), // Characters that are never ever allowed in a hostname. @@ -53446,20 +53446,20 @@ 'file:': true }, querystring = require('querystring'); - + function urlParse(url, parseQueryString, slashesDenoteHost) { if (url && util.isObject(url) && url instanceof Url) return url; - + var u = new Url; u.parse(url, parseQueryString, slashesDenoteHost); return u; } - + Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { if (!util.isString(url)) { throw new TypeError("Parameter 'url' must be a string, not " + typeof url); } - + // Copy chrome, IE, opera backslash-handling behavior. // Back slashes before the query string get converted to forward slashes // See: https://code.google.com/p/chromium/issues/detail?id=25916 @@ -53470,13 +53470,13 @@ slashRegex = /\\/g; uSplit[0] = uSplit[0].replace(slashRegex, '/'); url = uSplit.join(splitter); - + var rest = url; - + // trim before proceeding. // This is to support parse stuff like " http://foo.com \n" rest = rest.trim(); - + if (!slashesDenoteHost && url.split('#').length === 1) { // Try fast path regexp var simplePath = simplePathPattern.exec(rest); @@ -53498,7 +53498,7 @@ return this; } } - + var proto = protocolPattern.exec(rest); if (proto) { proto = proto[0]; @@ -53506,7 +53506,7 @@ this.protocol = lowerProto; rest = rest.substr(proto.length); } - + // figure out if it's got a host // user@server is *always* interpreted as a hostname, and url // resolution will treat //foo/bar as host=foo,path=bar because that's @@ -53518,10 +53518,10 @@ this.slashes = true; } } - + if (!hostlessProtocol[proto] && (slashes || (proto && !slashedProtocol[proto]))) { - + // there's a hostname. // the first instance of /, ?, ;, or # ends the host. // @@ -53533,10 +53533,10 @@ // ex: // http://a@b@c/ => user:a@b host:c // http://a@b?@c => user:a host:c path:/?@c - + // v0.12 TODO(isaacs): This is not quite how Chrome does things. // Review our test case against browsers more comprehensively. - + // find the first instance of any hostEndingChars var hostEnd = -1; for (var i = 0; i < hostEndingChars.length; i++) { @@ -53544,7 +53544,7 @@ if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) hostEnd = hec; } - + // at this point, either we have an explicit point where the // auth portion cannot go past, or the last @ char is the decider. var auth, atSign; @@ -53556,7 +53556,7 @@ // http://a@b/c@d => host:b auth:a path:/c@d atSign = rest.lastIndexOf('@', hostEnd); } - + // Now we have a portion which is definitely the auth. // Pull that off. if (atSign !== -1) { @@ -53564,7 +53564,7 @@ rest = rest.slice(atSign + 1); this.auth = decodeURIComponent(auth); } - + // the host is the remaining to the left of the first non-host char hostEnd = -1; for (var i = 0; i < nonHostChars.length; i++) { @@ -53575,22 +53575,22 @@ // if we still have not hit it, then the entire thing is a host. if (hostEnd === -1) hostEnd = rest.length; - + this.host = rest.slice(0, hostEnd); rest = rest.slice(hostEnd); - + // pull out port. this.parseHost(); - + // we've indicated that there is a hostname, // so even if it's empty, it has to be present. this.hostname = this.hostname || ''; - + // if hostname begins with [ and ends with ] // assume that it's an IPv6 address. var ipv6Hostname = this.hostname[0] === '[' && this.hostname[this.hostname.length - 1] === ']'; - + // validate a little. if (!ipv6Hostname) { var hostparts = this.hostname.split(/\./); @@ -53627,14 +53627,14 @@ } } } - + if (this.hostname.length > hostnameMaxLen) { this.hostname = ''; } else { // hostnames are always lower case. this.hostname = this.hostname.toLowerCase(); } - + if (!ipv6Hostname) { // IDNA Support: Returns a punycoded representation of "domain". // It only converts parts of the domain name that @@ -53642,12 +53642,12 @@ // you call it with a domain that already is ASCII-only. this.hostname = punycode.toASCII(this.hostname); } - + var p = this.port ? ':' + this.port : ''; var h = this.hostname || ''; this.host = h + p; this.href += this.host; - + // strip [ and ] from the hostname // the host field still retains them, though if (ipv6Hostname) { @@ -53657,11 +53657,11 @@ } } } - + // now rest is set to the post-host stuff. // chop off any delim chars. if (!unsafeProtocol[lowerProto]) { - + // First, make 100% sure that any "autoEscape" chars get // escaped, even if encodeURIComponent doesn't think they // need to be. @@ -53676,8 +53676,8 @@ rest = rest.split(ae).join(esc); } } - - + + // chop off from the tail first. var hash = rest.indexOf('#'); if (hash !== -1) { @@ -53703,19 +53703,19 @@ this.hostname && !this.pathname) { this.pathname = '/'; } - + //to support http.request if (this.pathname || this.search) { var p = this.pathname || ''; var s = this.search || ''; this.path = p + s; } - + // finally, reconstruct the href based on what has been validated. this.href = this.format(); return this; }; - + // format a parsed object into a url string function urlFormat(obj) { // ensure it's an object, and not a string url. @@ -53726,7 +53726,7 @@ if (!(obj instanceof Url)) return Url.prototype.format.call(obj); return obj.format(); } - + Url.prototype.format = function() { var auth = this.auth || ''; if (auth) { @@ -53734,13 +53734,13 @@ auth = auth.replace(/%3A/i, ':'); auth += '@'; } - + var protocol = this.protocol || '', pathname = this.pathname || '', hash = this.hash || '', host = false, query = ''; - + if (this.host) { host = auth + this.host; } else if (this.hostname) { @@ -53751,17 +53751,17 @@ host += ':' + this.port; } } - + if (this.query && util.isObject(this.query) && Object.keys(this.query).length) { query = querystring.stringify(this.query); } - + var search = this.search || (query && ('?' + query)) || ''; - + if (protocol && protocol.substr(-1) !== ':') protocol += ':'; - + // only the slashedProtocols get the //. Not mailto:, xmpp:, etc. // unless they had them to begin with. if (this.slashes || @@ -53771,55 +53771,55 @@ } else if (!host) { host = ''; } - + if (hash && hash.charAt(0) !== '#') hash = '#' + hash; if (search && search.charAt(0) !== '?') search = '?' + search; - + pathname = pathname.replace(/[?#]/g, function(match) { return encodeURIComponent(match); }); search = search.replace('#', '%23'); - + return protocol + host + pathname + search + hash; }; - + function urlResolve(source, relative) { return urlParse(source, false, true).resolve(relative); } - + Url.prototype.resolve = function(relative) { return this.resolveObject(urlParse(relative, false, true)).format(); }; - + function urlResolveObject(source, relative) { if (!source) return relative; return urlParse(source, false, true).resolveObject(relative); } - + Url.prototype.resolveObject = function(relative) { if (util.isString(relative)) { var rel = new Url(); rel.parse(relative, false, true); relative = rel; } - + var result = new Url(); var tkeys = Object.keys(this); for (var tk = 0; tk < tkeys.length; tk++) { var tkey = tkeys[tk]; result[tkey] = this[tkey]; } - + // hash is always overridden, no matter what. // even href="" will remove it. result.hash = relative.hash; - + // if the relative url is empty, then there's nothing left to do here. if (relative.href === '') { result.href = result.format(); return result; } - + // hrefs like //foo/bar always cut to the protocol. if (relative.slashes && !relative.protocol) { // take everything except the protocol from relative @@ -53829,17 +53829,17 @@ if (rkey !== 'protocol') result[rkey] = relative[rkey]; } - + //urlParse appends trailing / to urls like http://www.example.com if (slashedProtocol[result.protocol] && result.hostname && !result.pathname) { result.path = result.pathname = '/'; } - + result.href = result.format(); return result; } - + if (relative.protocol && relative.protocol !== result.protocol) { // if it's a known url protocol, then changing // the protocol does weird things @@ -53858,7 +53858,7 @@ result.href = result.format(); return result; } - + result.protocol = relative.protocol; if (!relative.host && !hostlessProtocol[relative.protocol]) { var relPath = (relative.pathname || '').split('/'); @@ -53887,7 +53887,7 @@ result.href = result.format(); return result; } - + var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'), isRelAbs = ( relative.host || @@ -53899,7 +53899,7 @@ srcPath = result.pathname && result.pathname.split('/') || [], relPath = relative.pathname && relative.pathname.split('/') || [], psychotic = result.protocol && !slashedProtocol[result.protocol]; - + // if the url is a non-slashed url, then relative // links like ../.. should be able // to crawl up to the hostname, as well. This is strange. @@ -53924,7 +53924,7 @@ } mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === ''); } - + if (isRelAbs) { // it's absolute. result.host = (relative.host || relative.host === '') ? @@ -53969,7 +53969,7 @@ result.href = result.format(); return result; } - + if (!srcPath.length) { // no path at all. easy. // we've already handled the other stuff above. @@ -53983,7 +53983,7 @@ result.href = result.format(); return result; } - + // if a url ENDs in . or .., then it must get a trailing slash. // however, if it ends in anything else non-slashy, // then it must NOT get a trailing slash. @@ -53991,7 +53991,7 @@ var hasTrailingSlash = ( (result.host || relative.host || srcPath.length > 1) && (last === '.' || last === '..') || last === ''); - + // strip single dots, resolve double dots to parent dir // if the path tries to go above the root, `up` ends up > 0 var up = 0; @@ -54007,26 +54007,26 @@ up--; } } - + // if the path is allowed to go above the root, restore leading ..s if (!mustEndAbs && !removeAllDots) { for (; up--; up) { srcPath.unshift('..'); } } - + if (mustEndAbs && srcPath[0] !== '' && (!srcPath[0] || srcPath[0].charAt(0) !== '/')) { srcPath.unshift(''); } - + if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { srcPath.push(''); } - + var isAbsolute = srcPath[0] === '' || (srcPath[0] && srcPath[0].charAt(0) === '/'); - + // put the host back if (psychotic) { result.hostname = result.host = isAbsolute ? '' : @@ -54041,20 +54041,20 @@ result.host = result.hostname = authInHost.shift(); } } - + mustEndAbs = mustEndAbs || (result.host && srcPath.length); - + if (mustEndAbs && !isAbsolute) { srcPath.unshift(''); } - + if (!srcPath.length) { result.pathname = null; result.path = null; } else { result.pathname = srcPath.join('/'); } - + //to support request.http if (!util.isNull(result.pathname) || !util.isNull(result.search)) { result.path = (result.pathname ? result.pathname : '') + @@ -54065,7 +54065,7 @@ result.href = result.format(); return result; }; - + Url.prototype.parseHost = function() { var host = this.host; var port = portPattern.exec(host); @@ -54078,10 +54078,10 @@ } if (host) this.hostname = host; }; - + },{"./util":328,"punycode":265,"querystring":269}],328:[function(require,module,exports){ 'use strict'; - + module.exports = { isString: function(arg) { return typeof(arg) === 'string'; @@ -54096,30 +54096,30 @@ return arg == null; } }; - + },{}],329:[function(require,module,exports){ (function (global){ /*! https://mths.be/utf8js v2.0.0 by @mathias */ ;(function(root) { - + // Detect free variables `exports` var freeExports = typeof exports == 'object' && exports; - + // Detect free variable `module` var freeModule = typeof module == 'object' && module && module.exports == freeExports && module; - + // Detect free variable `global`, from Node.js or Browserified code, // and use it as `root` var freeGlobal = typeof global == 'object' && global; if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { root = freeGlobal; } - + /*--------------------------------------------------------------------------*/ - + var stringFromCharCode = String.fromCharCode; - + // Taken from https://mths.be/punycode function ucs2decode(string) { var output = []; @@ -54146,7 +54146,7 @@ } return output; } - + // Taken from https://mths.be/punycode function ucs2encode(array) { var length = array.length; @@ -54164,7 +54164,7 @@ } return output; } - + function checkScalarValue(codePoint) { if (codePoint >= 0xD800 && codePoint <= 0xDFFF) { throw Error( @@ -54174,11 +54174,11 @@ } } /*--------------------------------------------------------------------------*/ - + function createByte(codePoint, shift) { return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80); } - + function encodeCodePoint(codePoint) { if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence return stringFromCharCode(codePoint); @@ -54200,7 +54200,7 @@ symbol += stringFromCharCode((codePoint & 0x3F) | 0x80); return symbol; } - + function utf8encode(string) { var codePoints = ucs2decode(string); var length = codePoints.length; @@ -54213,49 +54213,49 @@ } return byteString; } - + /*--------------------------------------------------------------------------*/ - + function readContinuationByte() { if (byteIndex >= byteCount) { throw Error('Invalid byte index'); } - + var continuationByte = byteArray[byteIndex] & 0xFF; byteIndex++; - + if ((continuationByte & 0xC0) == 0x80) { return continuationByte & 0x3F; } - + // If we end up here, it’s not a continuation byte throw Error('Invalid continuation byte'); } - + function decodeSymbol() { var byte1; var byte2; var byte3; var byte4; var codePoint; - + if (byteIndex > byteCount) { throw Error('Invalid byte index'); } - + if (byteIndex == byteCount) { return false; } - + // Read first byte byte1 = byteArray[byteIndex] & 0xFF; byteIndex++; - + // 1-byte sequence (no continuation bytes) if ((byte1 & 0x80) == 0) { return byte1; } - + // 2-byte sequence if ((byte1 & 0xE0) == 0xC0) { var byte2 = readContinuationByte(); @@ -54266,7 +54266,7 @@ throw Error('Invalid continuation byte'); } } - + // 3-byte sequence (may include unpaired surrogates) if ((byte1 & 0xF0) == 0xE0) { byte2 = readContinuationByte(); @@ -54279,7 +54279,7 @@ throw Error('Invalid continuation byte'); } } - + // 4-byte sequence if ((byte1 & 0xF8) == 0xF0) { byte2 = readContinuationByte(); @@ -54291,10 +54291,10 @@ return codePoint; } } - + throw Error('Invalid UTF-8 detected'); } - + var byteArray; var byteCount; var byteIndex; @@ -54309,15 +54309,15 @@ } return ucs2encode(codePoints); } - + /*--------------------------------------------------------------------------*/ - + var utf8 = { 'version': '2.0.0', 'encode': utf8encode, 'decode': utf8decode }; - + // Some AMD build optimizers, like r.js, check for specific condition patterns // like the following: if ( @@ -54341,19 +54341,19 @@ } else { // in Rhino or a web browser root.utf8 = utf8; } - + }(this)); - + }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],330:[function(require,module,exports){ (function (global){ - + /** * Module exports. */ - + module.exports = deprecate; - + /** * Mark that a method should not be used. * Returns a modified function which warns once by default. @@ -54371,12 +54371,12 @@ * @returns {Function} a new "deprecated" version of `fn` * @api public */ - + function deprecate (fn, msg) { if (config('noDeprecation')) { return fn; } - + var warned = false; function deprecated() { if (!warned) { @@ -54391,10 +54391,10 @@ } return fn.apply(this, arguments); } - + return deprecated; } - + /** * Checks `localStorage` for boolean values for the given `name`. * @@ -54402,7 +54402,7 @@ * @returns {Boolean} * @api private */ - + function config (name) { // accessing global.localStorage can trigger a DOMException in sandboxed iframes try { @@ -54414,7 +54414,7 @@ if (null == val) return false; return String(val).toLowerCase() === 'true'; } - + }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],331:[function(require,module,exports){ arguments[4][180][0].apply(exports,arguments) @@ -54447,7 +54447,7 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - + var formatRegExp = /%[sdj%]/g; exports.format = function(f) { if (!isString(f)) { @@ -54457,7 +54457,7 @@ } return objects.join(' '); } - + var i = 1; var args = arguments; var len = args.length; @@ -54486,8 +54486,8 @@ } return str; }; - - + + // Mark that a method should not be used. // Returns a modified function which warns once by default. // If --no-deprecation is set, then it is a no-op. @@ -54498,11 +54498,11 @@ return exports.deprecate(fn, msg).apply(this, arguments); }; } - + if (process.noDeprecation === true) { return fn; } - + var warned = false; function deprecated() { if (!warned) { @@ -54517,11 +54517,11 @@ } return fn.apply(this, arguments); } - + return deprecated; }; - - + + var debugs = {}; var debugEnviron; exports.debuglog = function(set) { @@ -54541,8 +54541,8 @@ } return debugs[set]; }; - - + + /** * Echos the value of a value. Trys to print the value out * in the best way possible given the different types. @@ -54576,8 +54576,8 @@ return formatValue(ctx, obj, ctx.depth); } exports.inspect = inspect; - - + + // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics inspect.colors = { 'bold' : [1, 22], @@ -54594,7 +54594,7 @@ 'red' : [31, 39], 'yellow' : [33, 39] }; - + // Don't use 'blue' not visible on cmd.exe inspect.styles = { 'special': 'cyan', @@ -54607,11 +54607,11 @@ // "name": intentionally not styling 'regexp': 'red' }; - - + + function stylizeWithColor(str, styleType) { var style = inspect.styles[styleType]; - + if (style) { return '\u001b[' + inspect.colors[style][0] + 'm' + str + '\u001b[' + inspect.colors[style][1] + 'm'; @@ -54619,24 +54619,24 @@ return str; } } - - + + function stylizeNoColor(str, styleType) { return str; } - - + + function arrayToHash(array) { var hash = {}; - + array.forEach(function(val, idx) { hash[val] = true; }); - + return hash; } - - + + function formatValue(ctx, value, recurseTimes) { // Provide a hook for user-specified inspect functions. // Check that value is an object with an inspect function on it @@ -54653,28 +54653,28 @@ } return ret; } - + // Primitive types cannot have properties var primitive = formatPrimitive(ctx, value); if (primitive) { return primitive; } - + // Look up the keys of the object. var keys = Object.keys(value); var visibleKeys = arrayToHash(keys); - + if (ctx.showHidden) { keys = Object.getOwnPropertyNames(value); } - + // IE doesn't make error fields non-enumerable // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx if (isError(value) && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { return formatError(value); } - + // Some type of object without properties can be shortcutted. if (keys.length === 0) { if (isFunction(value)) { @@ -54691,40 +54691,40 @@ return formatError(value); } } - + var base = '', array = false, braces = ['{', '}']; - + // Make Array say that they are Array if (isArray(value)) { array = true; braces = ['[', ']']; } - + // Make functions say that they are functions if (isFunction(value)) { var n = value.name ? ': ' + value.name : ''; base = ' [Function' + n + ']'; } - + // Make RegExps say that they are RegExps if (isRegExp(value)) { base = ' ' + RegExp.prototype.toString.call(value); } - + // Make dates with properties first say the date if (isDate(value)) { base = ' ' + Date.prototype.toUTCString.call(value); } - + // Make error with message first say the error if (isError(value)) { base = ' ' + formatError(value); } - + if (keys.length === 0 && (!array || value.length == 0)) { return braces[0] + base + braces[1]; } - + if (recurseTimes < 0) { if (isRegExp(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); @@ -54732,9 +54732,9 @@ return ctx.stylize('[Object]', 'special'); } } - + ctx.seen.push(value); - + var output; if (array) { output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); @@ -54743,13 +54743,13 @@ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); }); } - + ctx.seen.pop(); - + return reduceToSingleString(output, base, braces); } - - + + function formatPrimitive(ctx, value) { if (isUndefined(value)) return ctx.stylize('undefined', 'undefined'); @@ -54767,13 +54767,13 @@ if (isNull(value)) return ctx.stylize('null', 'null'); } - - + + function formatError(value) { return '[' + Error.prototype.toString.call(value) + ']'; } - - + + function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { var output = []; for (var i = 0, l = value.length; i < l; ++i) { @@ -54792,8 +54792,8 @@ }); return output; } - - + + function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { var name, str, desc; desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; @@ -54848,11 +54848,11 @@ name = ctx.stylize(name, 'string'); } } - + return name + ': ' + str; } - - + + function reduceToSingleString(output, base, braces) { var numLinesEst = 0; var length = output.reduce(function(prev, cur) { @@ -54860,7 +54860,7 @@ if (cur.indexOf('\n') >= 0) numLinesEst++; return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; }, 0); - + if (length > 60) { return braces[0] + (base === '' ? '' : base + '\n ') + @@ -54869,79 +54869,79 @@ ' ' + braces[1]; } - + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; } - - + + // NOTE: These type checking functions intentionally don't use `instanceof` // because it is fragile and can be easily faked with `Object.create()`. function isArray(ar) { return Array.isArray(ar); } exports.isArray = isArray; - + function isBoolean(arg) { return typeof arg === 'boolean'; } exports.isBoolean = isBoolean; - + function isNull(arg) { return arg === null; } exports.isNull = isNull; - + function isNullOrUndefined(arg) { return arg == null; } exports.isNullOrUndefined = isNullOrUndefined; - + function isNumber(arg) { return typeof arg === 'number'; } exports.isNumber = isNumber; - + function isString(arg) { return typeof arg === 'string'; } exports.isString = isString; - + function isSymbol(arg) { return typeof arg === 'symbol'; } exports.isSymbol = isSymbol; - + function isUndefined(arg) { return arg === void 0; } exports.isUndefined = isUndefined; - + function isRegExp(re) { return isObject(re) && objectToString(re) === '[object RegExp]'; } exports.isRegExp = isRegExp; - + function isObject(arg) { return typeof arg === 'object' && arg !== null; } exports.isObject = isObject; - + function isDate(d) { return isObject(d) && objectToString(d) === '[object Date]'; } exports.isDate = isDate; - + function isError(e) { return isObject(e) && (objectToString(e) === '[object Error]' || e instanceof Error); } exports.isError = isError; - + function isFunction(arg) { return typeof arg === 'function'; } exports.isFunction = isFunction; - + function isPrimitive(arg) { return arg === null || typeof arg === 'boolean' || @@ -54951,22 +54951,22 @@ typeof arg === 'undefined'; } exports.isPrimitive = isPrimitive; - + exports.isBuffer = require('./support/isBuffer'); - + function objectToString(o) { return Object.prototype.toString.call(o); } - - + + function pad(n) { return n < 10 ? '0' + n.toString(10) : n.toString(10); } - - + + var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; - + // 26 Feb 16:19:34 function timestamp() { var d = new Date(); @@ -54975,14 +54975,14 @@ pad(d.getSeconds())].join(':'); return [d.getDate(), months[d.getMonth()], time].join(' '); } - - + + // log is just a thin wrapper to console.log that prepends a timestamp exports.log = function() { console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); }; - - + + /** * Inherit the prototype methods from one constructor into another. * @@ -54997,11 +54997,11 @@ * @param {function} superCtor Constructor function to inherit prototype from. */ exports.inherits = require('inherits'); - + exports._extend = function(origin, add) { // Don't do anything if add isn't an object if (!add || !isObject(add)) return origin; - + var keys = Object.keys(add); var i = keys.length; while (i--) { @@ -55009,15 +55009,15 @@ } return origin; }; - + function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } - + }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"./support/isBuffer":332,"_process":257,"inherits":331}],334:[function(require,module,exports){ var indexOf = require('indexof'); - + var Object_keys = function (obj) { if (Object.keys) return Object.keys(obj) else { @@ -55026,14 +55026,14 @@ return res; } }; - + var forEach = function (xs, fn) { if (xs.forEach) return xs.forEach(fn) else for (var i = 0; i < xs.length; i++) { fn(xs[i], i, xs); } }; - + var defineProp = (function() { try { Object.defineProperty({}, '_', {}); @@ -55051,41 +55051,41 @@ }; } }()); - + var globals = ['Array', 'Boolean', 'Date', 'Error', 'EvalError', 'Function', 'Infinity', 'JSON', 'Math', 'NaN', 'Number', 'Object', 'RangeError', 'ReferenceError', 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError', 'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape', 'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'undefined', 'unescape']; - + function Context() {} Context.prototype = {}; - + var Script = exports.Script = function NodeScript (code) { if (!(this instanceof Script)) return new Script(code); this.code = code; }; - + Script.prototype.runInContext = function (context) { if (!(context instanceof Context)) { throw new TypeError("needs a 'context' argument."); } - + var iframe = document.createElement('iframe'); if (!iframe.style) iframe.style = {}; iframe.style.display = 'none'; - + document.body.appendChild(iframe); - + var win = iframe.contentWindow; var wEval = win.eval, wExecScript = win.execScript; - + if (!wEval && wExecScript) { // win.eval() magically appears when this is called in IE: wExecScript.call(win, 'null'); wEval = win.eval; } - + forEach(Object_keys(context), function (key) { win[key] = context[key]; }); @@ -55094,11 +55094,11 @@ win[key] = context[key]; } }); - + var winKeys = Object_keys(win); - + var res = wEval.call(win, this.code); - + forEach(Object_keys(win), function (key) { // Avoid copying circular objects like `top` and `window` by only // updating existing context properties or new properties in the `win` @@ -55107,44 +55107,44 @@ context[key] = win[key]; } }); - + forEach(globals, function (key) { if (!(key in context)) { defineProp(context, key, win[key]); } }); - + document.body.removeChild(iframe); - + return res; }; - + Script.prototype.runInThisContext = function () { return eval(this.code); // maybe... }; - + Script.prototype.runInNewContext = function (context) { var ctx = Script.createContext(context); var res = this.runInContext(ctx); - + forEach(Object_keys(ctx), function (key) { context[key] = ctx[key]; }); - + return res; }; - + forEach(Object_keys(Script.prototype), function (name) { exports[name] = Script[name] = function (code) { var s = Script(code); return s[name].apply(s, [].slice.call(arguments, 1)); }; }); - + exports.createScript = function (code) { return exports.Script(code); }; - + exports.createContext = Script.createContext = function (context) { var copy = new Context(); if(typeof context === 'object') { @@ -55154,21 +55154,21 @@ } return copy; }; - + },{"indexof":179}],335:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -55177,29 +55177,29 @@ * @author Fabian Vogelsteller * @date 2017 */ - + "use strict"; - + var _ = require('underscore'); var swarm = require("swarm-js"); - - + + var Bzz = function Bzz(provider) { - + this.givenProvider = Bzz.givenProvider; - + if (provider && provider._requestManager) { provider = provider.currentProvider; } - + // only allow file picker when in browser if(typeof document !== 'undefined') { this.pick = swarm.pick; } - + this.setProvider(provider); }; - + // set default ethereum provider /* jshint ignore:start */ Bzz.givenProvider = null; @@ -55207,7 +55207,7 @@ Bzz.givenProvider = ethereumProvider.bzz; } /* jshint ignore:end */ - + Bzz.prototype.setProvider = function(provider) { // is ethereum provider if(_.isObject(provider) && _.isString(provider.bzz)) { @@ -55217,48 +55217,48 @@ // else if(!_.isString(provider)) { // provider = 'http://swarm-gateways.net'; // default to gateway // } - - + + if(_.isString(provider)) { this.currentProvider = provider; } else { this.currentProvider = null; - + var noProviderError = new Error('No provider set, please set one using bzz.setProvider().'); - + this.download = this.upload = this.isAvailable = function(){ throw noProviderError; }; - + return false; } - + // add functions this.download = swarm.at(provider).download; this.upload = swarm.at(provider).upload; this.isAvailable = swarm.at(provider).isAvailable; - + return true; }; - - + + module.exports = Bzz; - - + + },{"swarm-js":319,"underscore":325}],336:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -55268,9 +55268,9 @@ * @author Marek Kotewicz * @date 2017 */ - + "use strict"; - + module.exports = { ErrorResponse: function (result) { var message = !!result && !!result.error && !!result.error.message ? result.error.message : JSON.stringify(result); @@ -55293,21 +55293,21 @@ return new Error('CONNECTION TIMEOUT: timeout of ' + ms + ' ms achived'); } }; - + },{}],337:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -55317,14 +55317,14 @@ * @author Marek Kotewicz * @date 2017 */ - + "use strict"; - - + + var _ = require('underscore'); var utils = require('web3-utils'); var Iban = require('web3-eth-iban'); - + /** * Should the format output to a big number * @@ -55335,11 +55335,11 @@ var outputBigNumberFormatter = function (number) { return utils.toBN(number).toString(10); }; - + var isPredefinedBlockNumber = function (blockNumber) { return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest'; }; - + var inputDefaultBlockNumberFormatter = function (blockNumber) { if (this && (blockNumber === undefined || blockNumber === null)) { return this.defaultBlock; @@ -55349,7 +55349,7 @@ } return inputBlockNumberFormatter(blockNumber); }; - + var inputBlockNumberFormatter = function (blockNumber) { if (blockNumber === undefined) { return undefined; @@ -55358,7 +55358,7 @@ } return (utils.isHexStrict(blockNumber)) ? ((_.isString(blockNumber)) ? blockNumber.toLowerCase() : blockNumber) : utils.numberToHex(blockNumber); }; - + /** * Formats the input of a transaction and converts all values to HEX * @@ -55367,38 +55367,38 @@ * @returns object */ var _txInputFormatter = function (options){ - + if (options.to) { // it might be contract creation options.to = inputAddressFormatter(options.to); } - + if (options.data && options.input) { throw new Error('You can\'t have "data" and "input" as properties of transactions at the same time, please use either "data" or "input" instead.'); } - + if (!options.data && options.input) { options.data = options.input; delete options.input; } - + if(options.data && !utils.isHex(options.data)) { throw new Error('The data field must be HEX encoded data.'); } - + // allow both if (options.gas || options.gasLimit) { options.gas = options.gas || options.gasLimit; } - + ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) { return options[key] !== undefined; }).forEach(function(key){ options[key] = utils.numberToHex(options[key]); }); - + return options; }; - + /** * Formats the input of a transaction and converts all values to HEX * @@ -55407,19 +55407,19 @@ * @returns object */ var inputCallFormatter = function (options){ - + options = _txInputFormatter(options); - + var from = options.from || (this ? this.defaultAccount : null); - + if (from) { options.from = inputAddressFormatter(from); } - - + + return options; }; - + /** * Formats the input of a transaction and converts all values to HEX * @@ -55428,23 +55428,23 @@ * @returns object */ var inputTransactionFormatter = function (options) { - + options = _txInputFormatter(options); - + // check from, only if not number, or object if (!_.isNumber(options.from) && !_.isObject(options.from)) { options.from = options.from || (this ? this.defaultAccount : null); - + if (!options.from && !_.isNumber(options.from)) { throw new Error('The send transactions "from" field must be defined!'); } - + options.from = inputAddressFormatter(options.from); } - + return options; }; - + /** * Hex encodes the data passed to eth_sign and personal_sign * @@ -55455,7 +55455,7 @@ var inputSignFormatter = function (data) { return (utils.isHexStrict(data)) ? data : utils.utf8ToHex(data); }; - + /** * Formats the output of a transaction to its proper values * @@ -55472,20 +55472,20 @@ tx.gas = utils.hexToNumber(tx.gas); tx.gasPrice = outputBigNumberFormatter(tx.gasPrice); tx.value = outputBigNumberFormatter(tx.value); - + if(tx.to && utils.isAddress(tx.to)) { // tx.to could be `0x0` or `null` while contract creation tx.to = utils.toChecksumAddress(tx.to); } else { tx.to = null; // set to `null` if invalid address } - + if(tx.from) { tx.from = utils.toChecksumAddress(tx.from); } - + return tx; }; - + /** * Formats the output of a transaction receipt to its proper values * @@ -55497,29 +55497,29 @@ if(typeof receipt !== 'object') { throw new Error('Received receipt is invalid: '+ receipt); } - + if(receipt.blockNumber !== null) receipt.blockNumber = utils.hexToNumber(receipt.blockNumber); if(receipt.transactionIndex !== null) receipt.transactionIndex = utils.hexToNumber(receipt.transactionIndex); receipt.cumulativeGasUsed = utils.hexToNumber(receipt.cumulativeGasUsed); receipt.gasUsed = utils.hexToNumber(receipt.gasUsed); - + if(_.isArray(receipt.logs)) { receipt.logs = receipt.logs.map(outputLogFormatter); } - + if(receipt.contractAddress) { receipt.contractAddress = utils.toChecksumAddress(receipt.contractAddress); } - + if(typeof receipt.status !== 'undefined') { receipt.status = Boolean(parseInt(receipt.status)); } - + return receipt; }; - + /** * Formats the output of a block to its proper values * @@ -55528,7 +55528,7 @@ * @returns {Object} */ var outputBlockFormatter = function(block) { - + // transform to number block.gasLimit = utils.hexToNumber(block.gasLimit); block.gasUsed = utils.hexToNumber(block.gasUsed); @@ -55536,25 +55536,25 @@ block.timestamp = utils.hexToNumber(block.timestamp); if (block.number !== null) block.number = utils.hexToNumber(block.number); - + if(block.difficulty) block.difficulty = outputBigNumberFormatter(block.difficulty); if(block.totalDifficulty) block.totalDifficulty = outputBigNumberFormatter(block.totalDifficulty); - + if (_.isArray(block.transactions)) { block.transactions.forEach(function(item){ if(!_.isString(item)) return outputTransactionFormatter(item); }); } - + if (block.miner) block.miner = utils.toChecksumAddress(block.miner); - + return block; }; - + /** * Formats the input of a log * @@ -55564,42 +55564,42 @@ */ var inputLogFormatter = function(options) { var toTopic = function(value){ - + if(value === null || typeof value === 'undefined') return null; - + value = String(value); - + if(value.indexOf('0x') === 0) return value; else return utils.fromUtf8(value); }; - + if (options.fromBlock) options.fromBlock = inputBlockNumberFormatter(options.fromBlock); - + if (options.toBlock) options.toBlock = inputBlockNumberFormatter(options.toBlock); - - + + // make sure topics, get converted to hex options.topics = options.topics || []; options.topics = options.topics.map(function(topic){ return (_.isArray(topic)) ? topic.map(toTopic) : toTopic(topic); }); - + toTopic = null; - + if (options.address) { options.address = (_.isArray(options.address)) ? options.address.map(function (addr) { return inputAddressFormatter(addr); }) : inputAddressFormatter(options.address); } - + return options; }; - + /** * Formats the output of a log * @@ -55608,7 +55608,7 @@ * @returns {Object} log */ var outputLogFormatter = function(log) { - + // generate a custom log id if(typeof log.blockHash === 'string' && typeof log.transactionHash === 'string' && @@ -55618,21 +55618,21 @@ } else if(!log.id) { log.id = null; } - + if (log.blockNumber !== null) log.blockNumber = utils.hexToNumber(log.blockNumber); if (log.transactionIndex !== null) log.transactionIndex = utils.hexToNumber(log.transactionIndex); if (log.logIndex !== null) log.logIndex = utils.hexToNumber(log.logIndex); - + if (log.address) { log.address = utils.toChecksumAddress(log.address); } - + return log; }; - + /** * Formats the input of a whisper post and converts all values to HEX * @@ -55641,30 +55641,30 @@ * @returns {Object} */ var inputPostFormatter = function(post) { - + // post.payload = utils.toHex(post.payload); - + if (post.ttl) post.ttl = utils.numberToHex(post.ttl); if (post.workToProve) post.workToProve = utils.numberToHex(post.workToProve); if (post.priority) post.priority = utils.numberToHex(post.priority); - + // fallback if (!_.isArray(post.topics)) { post.topics = post.topics ? [post.topics] : []; } - + // format the following options post.topics = post.topics.map(function(topic){ // convert only if not hex return (topic.indexOf('0x') === 0) ? topic : utils.fromUtf8(topic); }); - + return post; }; - + /** * Formats the output of a received post message * @@ -55673,18 +55673,18 @@ * @returns {Object} */ var outputPostFormatter = function(post){ - + post.expiry = utils.hexToNumber(post.expiry); post.sent = utils.hexToNumber(post.sent); post.ttl = utils.hexToNumber(post.ttl); post.workProved = utils.hexToNumber(post.workProved); // post.payloadRaw = post.payload; // post.payload = utils.hexToAscii(post.payload); - + // if (utils.isJson(post.payload)) { // post.payload = JSON.parse(post.payload); // } - + // format the following options if (!post.topics) { post.topics = []; @@ -55692,10 +55692,10 @@ post.topics = post.topics.map(function(topic){ return utils.toUtf8(topic); }); - + return post; }; - + var inputAddressFormatter = function (address) { var iban = new Iban(address); if (iban.isValid() && iban.isDirect()) { @@ -55705,10 +55705,10 @@ } throw new Error('Provided address "'+ address +'" is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can\'t be converted.'); }; - - + + var outputSyncingFormatter = function(result) { - + result.startingBlock = utils.hexToNumber(result.startingBlock); result.currentBlock = utils.hexToNumber(result.currentBlock); result.highestBlock = utils.hexToNumber(result.highestBlock); @@ -55716,10 +55716,10 @@ result.knownStates = utils.hexToNumber(result.knownStates); result.pulledStates = utils.hexToNumber(result.pulledStates); } - + return result; }; - + module.exports = { inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter, inputBlockNumberFormatter: inputBlockNumberFormatter, @@ -55737,22 +55737,22 @@ outputPostFormatter: outputPostFormatter, outputSyncingFormatter: outputSyncingFormatter }; - - + + },{"underscore":325,"web3-eth-iban":368,"web3-utils":403}],338:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -55761,32 +55761,32 @@ * @author Fabian Vogelsteller * @date 2017 */ - + "use strict"; - + var errors = require('./errors'); var formatters = require('./formatters'); - + module.exports = { errors: errors, formatters: formatters }; - - + + },{"./errors":336,"./formatters":337}],339:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -55796,26 +55796,26 @@ * @author Marek Kotewicz * @date 2017 */ - + "use strict"; - + var _ = require('underscore'); var errors = require('web3-core-helpers').errors; var formatters = require('web3-core-helpers').formatters; var utils = require('web3-utils'); var promiEvent = require('web3-core-promievent'); var Subscriptions = require('web3-core-subscriptions').subscriptions; - + var TIMEOUTBLOCK = 50; var POLLINGTIMEOUT = 15 * TIMEOUTBLOCK; // ~average block time (seconds) * TIMEOUTBLOCK var CONFIRMATIONBLOCKS = 24; - + var Method = function Method(options) { - + if(!options.call || !options.name) { throw new Error('When creating a method you need to provide at least the "name" and "call" property.'); } - + this.name = options.name; this.call = options.call; this.params = options.params || 0; @@ -55823,35 +55823,35 @@ this.outputFormatter = options.outputFormatter; this.transformPayload = options.transformPayload; this.extraFormatters = options.extraFormatters; - + this.requestManager = options.requestManager; - + // reference to eth.accounts this.accounts = options.accounts; - + this.defaultBlock = options.defaultBlock || 'latest'; this.defaultAccount = options.defaultAccount || null; }; - + Method.prototype.setRequestManager = function (requestManager, accounts) { this.requestManager = requestManager; - + // reference to eth.accounts if (accounts) { this.accounts = accounts; } - + }; - + Method.prototype.createFunction = function (requestManager, accounts) { var func = this.buildCall(); func.call = this.call; - + this.setRequestManager(requestManager || this.requestManager, accounts || this.accounts); - + return func; }; - + Method.prototype.attachToObject = function (obj) { var func = this.buildCall(); func.call = this.call; @@ -55863,7 +55863,7 @@ obj[name[0]] = func; } }; - + /** * Should be used to determine name of the jsonrpc method based on arguments * @@ -55874,7 +55874,7 @@ Method.prototype.getCall = function (args) { return _.isFunction(this.call) ? this.call(args) : this.call; }; - + /** * Should be used to extract callback from array of arguments. Modifies input param * @@ -55887,7 +55887,7 @@ return args.pop(); // modify the args array! } }; - + /** * Should be called to check if the number of arguments is correct * @@ -55900,7 +55900,7 @@ throw errors.InvalidNumberOfParams(args.length, this.params, this.name); } }; - + /** * Should be called to format input args of method * @@ -55910,17 +55910,17 @@ */ Method.prototype.formatInput = function (args) { var _this = this; - + if (!this.inputFormatter) { return args; } - + return this.inputFormatter.map(function (formatter, index) { // bind this for defaultBlock, and defaultAccount return formatter ? formatter.call(_this, args[index]) : args[index]; }); }; - + /** * Should be called to format output(result) of method * @@ -55930,7 +55930,7 @@ */ Method.prototype.formatOutput = function (result) { var _this = this; - + if(_.isArray(result)) { return result.map(function(res){ return _this.outputFormatter && res ? _this.outputFormatter(res) : res; @@ -55939,7 +55939,7 @@ return this.outputFormatter && result ? this.outputFormatter(result) : result; } }; - + /** * Should create payload from given input args * @@ -55952,21 +55952,21 @@ var callback = this.extractCallback(args); var params = this.formatInput(args); this.validateArgs(params); - + var payload = { method: call, params: params, callback: callback }; - + if (this.transformPayload) { payload = this.transformPayload(payload); } - + return payload; }; - - + + Method.prototype._confirmTransaction = function (defer, result, payload) { var method = this, promiseResolved = false, @@ -55980,7 +55980,7 @@ payload.params[0].data && payload.params[0].from && !payload.params[0].to; - + // add custom send Methods var _ethereumCalls = [ new Method({ @@ -56014,8 +56014,8 @@ mthd.attachToObject(_ethereumCall); mthd.requestManager = method.requestManager; // assign rather than call setRequestManager() }); - - + + // fire "receipt" and confirmation events and resolve after var checkConfirmation = function (existingReceipt, isPolling, err, blockHeader, sub) { if (!err) { @@ -56040,100 +56040,100 @@ if (!receipt || !receipt.blockHash) { throw new Error('Receipt missing or blockHash null'); } - + // apply extra formatters if (method.extraFormatters && method.extraFormatters.receiptFormatter) { receipt = method.extraFormatters.receiptFormatter(receipt); } - + // check if confirmation listener exists if (defer.eventEmitter.listeners('confirmation').length > 0) { - + // If there was an immediately retrieved receipt, it's already // been confirmed by the direct call to checkConfirmation needed // for parity instant-seal if (existingReceipt === undefined || confirmationCount !== 0){ defer.eventEmitter.emit('confirmation', confirmationCount, receipt); } - + canUnsubscribe = false; confirmationCount++; - + if (confirmationCount === CONFIRMATIONBLOCKS + 1) { // add 1 so we account for conf 0 sub.unsubscribe(); defer.eventEmitter.removeAllListeners(); } } - + return receipt; }) // CHECK for CONTRACT DEPLOYMENT .then(function(receipt) { - + if (isContractDeployment && !promiseResolved) { - + if (!receipt.contractAddress) { - + if (canUnsubscribe) { sub.unsubscribe(); promiseResolved = true; } - + utils._fireError(new Error('The transaction receipt didn\'t contain a contract address.'), defer.eventEmitter, defer.reject); return; } - + _ethereumCall.getCode(receipt.contractAddress, function (e, code) { - + if (!code) { return; } - - + + if (code.length > 2) { defer.eventEmitter.emit('receipt', receipt); - + // if contract, return instance instead of receipt if (method.extraFormatters && method.extraFormatters.contractDeployFormatter) { defer.resolve(method.extraFormatters.contractDeployFormatter(receipt)); } else { defer.resolve(receipt); } - + // need to remove listeners, as they aren't removed automatically when succesfull if (canUnsubscribe) { defer.eventEmitter.removeAllListeners(); } - + } else { utils._fireError(new Error('The contract code couldn\'t be stored, please check your gas limit.'), defer.eventEmitter, defer.reject); } - + if (canUnsubscribe) { sub.unsubscribe(); } promiseResolved = true; }); } - + return receipt; }) // CHECK for normal tx check for receipt only .then(function(receipt) { - + if (!isContractDeployment && !promiseResolved) { - + if(!receipt.outOfGas && (!gasProvided || gasProvided !== receipt.gasUsed) && (receipt.status === true || receipt.status === '0x1' || typeof receipt.status === 'undefined')) { defer.eventEmitter.emit('receipt', receipt); defer.resolve(receipt); - + // need to remove listeners, as they aren't removed automatically when succesfull if (canUnsubscribe) { defer.eventEmitter.removeAllListeners(); } - + } else { receiptJSON = JSON.stringify(receipt, null, 2); if (receipt.status === false || receipt.status === '0x0') { @@ -56145,18 +56145,18 @@ defer.eventEmitter, defer.reject); } } - + if (canUnsubscribe) { sub.unsubscribe(); } promiseResolved = true; } - + }) // time out the transaction if not mined after 50 blocks .catch(function () { timeoutCount++; - + // check to see if we are http polling if(!!isPolling) { // polling timeout is different than TIMEOUTBLOCK blocks since we are triggering every second @@ -56173,15 +56173,15 @@ } } }); - - + + } else { sub.unsubscribe(); promiseResolved = true; utils._fireError({message: 'Failed to subscribe to new newBlockHeaders to confirm the transaction receipts.', data: err}, defer.eventEmitter, defer.reject); } }; - + // start watching for confirmation depending on the support features of the provider var startWatching = function(existingReceipt) { // if provider allows PUB/SUB @@ -56191,8 +56191,8 @@ intervalId = setInterval(checkConfirmation.bind(null, existingReceipt, true), 1000); } }.bind(this); - - + + // first check if we already have a confirmed transaction _ethereumCall.getTransactionReceipt(result) .then(function(receipt) { @@ -56202,7 +56202,7 @@ startWatching(receipt); } checkConfirmation(receipt, false); - + } else if (!promiseResolved) { startWatching(); } @@ -56210,39 +56210,39 @@ .catch(function(){ if (!promiseResolved) startWatching(); }); - + }; - - + + var getWallet = function(from, accounts) { var wallet = null; - + // is index given if (_.isNumber(from)) { wallet = accounts.wallet[from]; - + // is account given } else if (_.isObject(from) && from.address && from.privateKey) { wallet = from; - + // search in wallet for address } else { wallet = accounts.wallet[from.toLowerCase()]; } - + return wallet; }; - + Method.prototype.buildCall = function() { var method = this, isSendTx = (method.call === 'eth_sendTransaction' || method.call === 'eth_sendRawTransaction'); // || method.call === 'personal_sendTransaction' - + // actual send function var send = function () { var defer = promiEvent(!isSendTx), payload = method.toPayload(Array.prototype.slice.call(arguments)); - - + + // CALLBACK function var sendTxCallback = function (err, result) { try { @@ -56250,11 +56250,11 @@ } catch(e) { err = e; } - + if (result instanceof Error) { err = result; } - + if (!err) { if (payload.callback) { payload.callback(null, result); @@ -56263,111 +56263,111 @@ if(err.error) { err = err.error; } - + return utils._fireError(err, defer.eventEmitter, defer.reject, payload.callback); } - + // return PROMISE if (!isSendTx) { - + if (!err) { defer.resolve(result); - + } - + // return PROMIEVENT } else { defer.eventEmitter.emit('transactionHash', result); - + method._confirmTransaction(defer, result, payload); } - + }; - + // SENDS the SIGNED SIGNATURE var sendSignedTx = function(sign){ - + var signedPayload = _.extend({}, payload, { method: 'eth_sendRawTransaction', params: [sign.rawTransaction] }); - + method.requestManager.send(signedPayload, sendTxCallback); }; - - + + var sendRequest = function(payload, method) { - + if (method && method.accounts && method.accounts.wallet && method.accounts.wallet.length) { var wallet; - + // ETH_SENDTRANSACTION if (payload.method === 'eth_sendTransaction') { var tx = payload.params[0]; wallet = getWallet((_.isObject(tx)) ? tx.from : null, method.accounts); - - + + // If wallet was found, sign tx, and send using sendRawTransaction if (wallet && wallet.privateKey) { return method.accounts.signTransaction(_.omit(tx, 'from'), wallet.privateKey).then(sendSignedTx); } - + // ETH_SIGN } else if (payload.method === 'eth_sign') { var data = payload.params[1]; wallet = getWallet(payload.params[0], method.accounts); - + // If wallet was found, sign tx, and send using sendRawTransaction if (wallet && wallet.privateKey) { var sign = method.accounts.sign(data, wallet.privateKey); - + if (payload.callback) { payload.callback(null, sign.signature); } - + defer.resolve(sign.signature); return; } - - + + } } - + return method.requestManager.send(payload, sendTxCallback); }; - + // Send the actual transaction if(isSendTx && _.isObject(payload.params[0]) && typeof payload.params[0].gasPrice === 'undefined') { - + var getGasPrice = (new Method({ name: 'getGasPrice', call: 'eth_gasPrice', params: 0 })).createFunction(method.requestManager); - + getGasPrice(function (err, gasPrice) { - + if (gasPrice) { payload.params[0].gasPrice = gasPrice; } sendRequest(payload, method); }); - + } else { sendRequest(payload, method); } - - + + return defer.eventEmitter; }; - + // necessary to attach things to the method send.method = method; // necessary for batch requests send.request = this.request.bind(this); return send; }; - + /** * Should be called to create the pure JSONRPC request which can be used in a batch request * @@ -56379,23 +56379,23 @@ payload.format = this.formatOutput.bind(this); return payload; }; - + module.exports = Method; - + },{"underscore":325,"web3-core-helpers":338,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-utils":403}],340:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -56404,12 +56404,12 @@ * @author Fabian Vogelsteller * @date 2016 */ - + "use strict"; - + var EventEmitter = require('eventemitter3'); var Promise = require("any-promise"); - + /** * This function generates a defer promise and adds eventEmitter functionality to it * @@ -56421,7 +56421,7 @@ resolve = arguments[0]; reject = arguments[1]; }); - + if(justPromise) { return { resolve: resolve, @@ -56429,10 +56429,10 @@ eventEmitter: eventEmitter }; } - + // get eventEmitter var emitter = new EventEmitter(); - + // add eventEmitter to the promise eventEmitter._events = emitter._events; eventEmitter.emit = emitter.emit; @@ -56443,36 +56443,36 @@ eventEmitter.addListener = emitter.addListener; eventEmitter.removeListener = emitter.removeListener; eventEmitter.removeAllListeners = emitter.removeAllListeners; - + return { resolve: resolve, reject: reject, eventEmitter: eventEmitter }; }; - + PromiEvent.resolve = function(value) { var promise = PromiEvent(true); promise.resolve(value); return promise.eventEmitter; }; - + module.exports = PromiEvent; - + },{"any-promise":2,"eventemitter3":156}],341:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -56481,17 +56481,17 @@ * @author Marek Kotewicz * @date 2015 */ - + "use strict"; - + var Jsonrpc = require('./jsonrpc'); var errors = require('web3-core-helpers').errors; - + var Batch = function (requestManager) { this.requestManager = requestManager; this.requests = []; }; - + /** * Should be called to add create new request to batch request * @@ -56501,7 +56501,7 @@ Batch.prototype.add = function (request) { this.requests.push(request); }; - + /** * Should be called to execute batch request * @@ -56518,11 +56518,11 @@ if (result && result.error) { return requests[index].callback(errors.ErrorResponse(result)); } - + if (!Jsonrpc.isValidResponse(result)) { return requests[index].callback(errors.InvalidResponse(result)); } - + try { requests[index].callback(null, requests[index].format ? requests[index].format(result.result) : result.result); } catch (err) { @@ -56532,24 +56532,24 @@ }); }); }; - + module.exports = Batch; - - + + },{"./jsonrpc":344,"web3-core-helpers":338}],342:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -56558,85 +56558,85 @@ * @author Fabian Vogelsteller * @date 2017 */ - + "use strict"; - + var givenProvider = null; - + // ADD GIVEN PROVIDER /* jshint ignore:start */ var global = window; // EthereumProvider if(typeof global.ethereumProvider !== 'undefined') { givenProvider = global.ethereumProvider; - + // Legacy web3.currentProvider } else if(typeof global.web3 !== 'undefined' && global.web3.currentProvider) { - + if(global.web3.currentProvider.sendAsync) { global.web3.currentProvider.send = global.web3.currentProvider.sendAsync; delete global.web3.currentProvider.sendAsync; } - + // if connection is 'ipcProviderWrapper', add subscription support if(!global.web3.currentProvider.on && global.web3.currentProvider.connection && global.web3.currentProvider.connection.constructor.name === 'ipcProviderWrapper') { - + global.web3.currentProvider.on = function (type, callback) { - + if(typeof callback !== 'function') throw new Error('The second parameter callback must be a function.'); - + switch(type){ case 'data': this.connection.on('data', function(data) { var result = ''; - + data = data.toString(); - + try { result = JSON.parse(data); } catch(e) { return callback(new Error('Couldn\'t parse response data'+ data)); } - + // notification if(!result.id && result.method.indexOf('_subscription') !== -1) { callback(null, result); } - + }); break; - + default: this.connection.on(type, callback); break; } }; } - + givenProvider = global.web3.currentProvider; } /* jshint ignore:end */ - - + + module.exports = givenProvider; - + },{}],343:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -56645,18 +56645,18 @@ * @author Fabian Vogelsteller * @date 2017 */ - + "use strict"; - - + + var _ = require('underscore'); var errors = require('web3-core-helpers').errors; var Jsonrpc = require('./jsonrpc.js'); var BatchManager = require('./batch.js'); var givenProvider = require('./givenProvider.js'); - - - + + + /** * It's responsible for passing messages to providers * It's also responsible for polling the ethereum node for incoming messages @@ -56666,23 +56666,23 @@ var RequestManager = function RequestManager(provider) { this.provider = null; this.providers = RequestManager.providers; - + this.setProvider(provider); this.subscriptions = {}; }; - - - + + + RequestManager.givenProvider = givenProvider; - + RequestManager.providers = { WebsocketProvider: require('web3-providers-ws'), HttpProvider: require('web3-providers-http'), IpcProvider: require('web3-providers-ipc') }; - - - + + + /** * Should be used to set provider of request manager * @@ -56691,39 +56691,39 @@ */ RequestManager.prototype.setProvider = function (p, net) { var _this = this; - + // autodetect provider if(p && typeof p === 'string' && this.providers) { - + // HTTP if(/^http(s)?:\/\//i.test(p)) { p = new this.providers.HttpProvider(p); - + // WS } else if(/^ws(s)?:\/\//i.test(p)) { p = new this.providers.WebsocketProvider(p); - + // IPC } else if(p && typeof net === 'object' && typeof net.connect === 'function') { p = new this.providers.IpcProvider(p, net); - + } else if(p) { throw new Error('Can\'t autodetect provider for "'+ p +'"'); } } - + // reset the old one before changing, if still connected if(this.provider && this.provider.connected) this.clearSubscriptions(); - - + + this.provider = p || null; - + // listen to incoming notifications if(this.provider && this.provider.on) { this.provider.on('data', function requestManagerNotification(result, deprecatedResult){ result = result || deprecatedResult; // this is for possible old providers, which may had the error first handler - + // check for result.method, to prevent old providers errors to pass as result if(result.method && _this.subscriptions[result.params.subscription] && _this.subscriptions[result.params.subscription].callback) { _this.subscriptions[result.params.subscription].callback(null, result.params.result); @@ -56738,8 +56738,8 @@ // } } }; - - + + /** * Should be used to asynchronously send request * @@ -56749,31 +56749,31 @@ */ RequestManager.prototype.send = function (data, callback) { callback = callback || function(){}; - + if (!this.provider) { return callback(errors.InvalidProvider()); } - + var payload = Jsonrpc.toPayload(data.method, data.params); this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](payload, function (err, result) { if(result && result.id && payload.id !== result.id) return callback(new Error('Wrong response id "'+ result.id +'" (expected: "'+ payload.id +'") in '+ JSON.stringify(payload))); - + if (err) { return callback(err); } - + if (result && result.error) { return callback(errors.ErrorResponse(result)); } - + if (!Jsonrpc.isValidResponse(result)) { return callback(errors.InvalidResponse(result)); } - + callback(null, result.result); }); }; - + /** * Should be called to asynchronously send batch request * @@ -56785,22 +56785,22 @@ if (!this.provider) { return callback(errors.InvalidProvider()); } - + var payload = Jsonrpc.toBatchPayload(data); this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](payload, function (err, results) { if (err) { return callback(err); } - + if (!_.isArray(results)) { return callback(errors.InvalidResponse(results)); } - + callback(null, results); }); }; - - + + /** * Waits for notifications * @@ -56817,12 +56817,12 @@ type: type, name: name }; - + } else { throw new Error('The provider doesn\'t support subscriptions: '+ this.provider.constructor.name); } }; - + /** * Waits for notifications * @@ -56832,19 +56832,19 @@ */ RequestManager.prototype.removeSubscription = function (id, callback) { var _this = this; - + if(this.subscriptions[id]) { - + this.send({ method: this.subscriptions[id].type + '_unsubscribe', params: [id] }, callback); - + // remove subscription delete _this.subscriptions[id]; } }; - + /** * Should be called to reset the subscriptions * @@ -56852,39 +56852,39 @@ */ RequestManager.prototype.clearSubscriptions = function (keepIsSyncing) { var _this = this; - - + + // uninstall all subscriptions Object.keys(this.subscriptions).forEach(function(id){ if(!keepIsSyncing || _this.subscriptions[id].name !== 'syncing') _this.removeSubscription(id); }); - - + + // reset notification callbacks etc. if(this.provider.reset) this.provider.reset(); }; - + module.exports = { Manager: RequestManager, BatchManager: BatchManager }; - + },{"./batch.js":341,"./givenProvider.js":342,"./jsonrpc.js":344,"underscore":325,"web3-core-helpers":338,"web3-providers-http":398,"web3-providers-ipc":399,"web3-providers-ws":400}],344:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -56895,14 +56895,14 @@ * Aaron Kumavis * @date 2015 */ - + "use strict"; - + // Initialize Jsonrpc as a simple object with utility functions. var Jsonrpc = { messageId: 0 }; - + /** * Should be called to valid json create payload object * @@ -56915,10 +56915,10 @@ if (!method) { throw new Error('JSONRPC method should be specified for params: "'+ JSON.stringify(params) +'"!'); } - + // advance message ID Jsonrpc.messageId++; - + return { jsonrpc: '2.0', id: Jsonrpc.messageId, @@ -56926,7 +56926,7 @@ params: params || [] }; }; - + /** * Should be called to check if jsonrpc response is valid * @@ -56936,7 +56936,7 @@ */ Jsonrpc.isValidResponse = function (response) { return Array.isArray(response) ? response.every(validateSingleMessage) : validateSingleMessage(response); - + function validateSingleMessage(message){ return !!message && !message.error && @@ -56945,7 +56945,7 @@ message.result !== undefined; // only undefined is not valid json object } }; - + /** * Should be called to create batch payload object * @@ -56958,24 +56958,24 @@ return Jsonrpc.toPayload(message.method, message.params); }); }; - + module.exports = Jsonrpc; - - + + },{}],345:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -56984,25 +56984,25 @@ * @author Fabian Vogelsteller * @date 2017 */ - + "use strict"; - + var Subscription = require('./subscription.js'); - - + + var Subscriptions = function Subscriptions(options) { this.name = options.name; this.type = options.type; this.subscriptions = options.subscriptions || {}; this.requestManager = null; }; - - + + Subscriptions.prototype.setRequestManager = function (rm) { this.requestManager = rm; }; - - + + Subscriptions.prototype.attachToObject = function (obj) { var func = this.buildCall(); var name = this.name.split('.'); @@ -57013,46 +57013,46 @@ obj[name[0]] = func; } }; - - + + Subscriptions.prototype.buildCall = function() { var _this = this; - + return function(){ if(!_this.subscriptions[arguments[0]]) { console.warn('Subscription '+ JSON.stringify(arguments[0]) +' doesn\'t exist. Subscribing anyway.'); } - + var subscription = new Subscription({ subscription: _this.subscriptions[arguments[0]], requestManager: _this.requestManager, type: _this.type }); - + return subscription.subscribe.apply(subscription, arguments); }; }; - - + + module.exports = { subscriptions: Subscriptions, subscription: Subscription }; - + },{"./subscription.js":346}],346:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -57061,33 +57061,33 @@ * @author Fabian Vogelsteller * @date 2017 */ - + "use strict"; - + var _ = require('underscore'); var errors = require('web3-core-helpers').errors; var EventEmitter = require('eventemitter3'); - + function Subscription(options) { EventEmitter.call(this); - + this.id = null; this.callback = _.identity; this.arguments = null; this._reconnectIntervalId = null; - + this.options = { subscription: options.subscription, type: options.type, requestManager: options.requestManager }; } - + // INHERIT Subscription.prototype = Object.create(EventEmitter.prototype); Subscription.prototype.constructor = Subscription; - - + + /** * Should be used to extract callback from array of arguments. Modifies input param * @@ -57095,13 +57095,13 @@ * @param {Array} arguments * @return {Function|Null} callback, if exists */ - + Subscription.prototype._extractCallback = function (args) { if (_.isFunction(args[args.length - 1])) { return args.pop(); // modify the args array! } }; - + /** * Should be called to check if the number of arguments is correct * @@ -57109,21 +57109,21 @@ * @param {Array} arguments * @throws {Error} if it is not */ - + Subscription.prototype._validateArgs = function (args) { var subscription = this.options.subscription; - + if(!subscription) subscription = {}; - + if(!subscription.params) subscription.params = 0; - + if (args.length !== subscription.params) { throw errors.InvalidNumberOfParams(args.length, subscription.params + 1, args[0]); } }; - + /** * Should be called to format input args of method * @@ -57131,25 +57131,25 @@ * @param {Array} * @return {Array} */ - + Subscription.prototype._formatInput = function (args) { var subscription = this.options.subscription; - + if (!subscription) { return args; } - + if (!subscription.inputFormatter) { return args; } - + var formattedArgs = subscription.inputFormatter.map(function (formatter, index) { return formatter ? formatter(args[index]) : args[index]; }); - + return formattedArgs; }; - + /** * Should be called to format output(result) of method * @@ -57157,13 +57157,13 @@ * @param {Object} * @return {Object} */ - + Subscription.prototype._formatOutput = function (result) { var subscription = this.options.subscription; - + return (subscription && subscription.outputFormatter && result) ? subscription.outputFormatter(result) : result; }; - + /** * Should create payload from given input args * @@ -57174,38 +57174,38 @@ Subscription.prototype._toPayload = function (args) { var params = []; this.callback = this._extractCallback(args) || _.identity; - + if (!this.subscriptionMethod) { this.subscriptionMethod = args.shift(); - + // replace subscription with given name if (this.options.subscription.subscriptionName) { this.subscriptionMethod = this.options.subscription.subscriptionName; } } - + if (!this.arguments) { this.arguments = this._formatInput(args); this._validateArgs(this.arguments); args = []; // make empty after validation - + } - + // re-add subscriptionName params.push(this.subscriptionMethod); params = params.concat(this.arguments); - - + + if (args.length) { throw new Error('Only a callback is allowed as parameter on an already instantiated subscription.'); } - + return { method: this.options.type + '_subscribe', params: params }; }; - + /** * Unsubscribes and clears callbacks * @@ -57218,7 +57218,7 @@ this.removeAllListeners(); clearInterval(this._reconnectIntervalId); }; - + /** * Subscribes and watches for changes * @@ -57231,18 +57231,18 @@ var _this = this; var args = Array.prototype.slice.call(arguments); var payload = this._toPayload(args); - + if(!payload) { return this; } - + if(!this.options.requestManager.provider) { var err1 = new Error('No provider set.'); this.callback(err1, null, this); this.emit('error', err1); return this; } - + // throw error, if provider doesnt support subscriptions if(!this.options.requestManager.provider.on) { var err2 = new Error('The current provider doesn\'t support subscriptions: '+ this.options.requestManager.provider.constructor.name); @@ -57250,15 +57250,15 @@ this.emit('error', err2); return this; } - + // if id is there unsubscribe first if (this.id) { this.unsubscribe(); } - + // store the params in the options object this.options.params = payload.params[1]; - + // get past logs, if fromBlock is available if(payload.params[0] === 'logs' && _.isObject(payload.params[1]) && payload.params[1].hasOwnProperty('fromBlock') && isFinite(payload.params[1].fromBlock)) { // send the subscription request @@ -57272,50 +57272,50 @@ _this.callback(null, output, _this); _this.emit('data', output); }); - + // TODO subscribe here? after the past logs? - + } else { _this.callback(err, null, _this); _this.emit('error', err); } }); } - + // create subscription // TODO move to separate function? so that past logs can go first? - + if(typeof payload.params[1] === 'object') delete payload.params[1].fromBlock; - + this.options.requestManager.send(payload, function (err, result) { if(!err && result) { _this.id = result; - + // call callback on notifications _this.options.requestManager.addSubscription(_this.id, payload.params[0] , _this.options.type, function(err, result) { - + if (!err) { if (!_.isArray(result)) { result = [result]; } - + result.forEach(function(resultItem) { var output = _this._formatOutput(resultItem); - + if (_.isFunction(_this.options.subscription.subscriptionHandler)) { return _this.options.subscription.subscriptionHandler.call(_this, output); } else { _this.emit('data', output); } - + // call the callback, last so that unsubscribe there won't affect the emit above _this.callback(null, output, _this); }); } else { // unsubscribe, but keep listeners _this.options.requestManager.removeSubscription(_this.id); - + // re-subscribe, if connection fails if(_this.options.requestManager.provider.once) { _this._reconnectIntervalId = setInterval(function () { @@ -57324,14 +57324,14 @@ _this.options.requestManager.provider.reconnect(); } }, 500); - + _this.options.requestManager.provider.once('connect', function () { clearInterval(_this._reconnectIntervalId); _this.subscribe(_this.callback); }); } _this.emit('error', err); - + // call the callback, last so that unsubscribe there won't affect the emit above _this.callback(err, null, _this); } @@ -57341,27 +57341,27 @@ _this.emit('error', err); } }); - + // return an object to cancel the subscription return this; }; - + module.exports = Subscription; - + },{"eventemitter3":156,"underscore":325,"web3-core-helpers":338}],347:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -57370,19 +57370,19 @@ * @author Fabian Vogelsteller * @date 2017 */ - + "use strict"; - - + + var formatters = require('web3-core-helpers').formatters; var Method = require('web3-core-method'); var utils = require('web3-utils'); - - + + var extend = function (pckg) { /* jshint maxcomplexity:5 */ var ex = function (extension) { - + var extendedObject; if (extension.property) { if (!pckg[extension.property]) { @@ -57392,47 +57392,47 @@ } else { extendedObject = pckg; } - + if (extension.methods) { extension.methods.forEach(function (method) { if(!(method instanceof Method)) { method = new Method(method); } - + method.attachToObject(extendedObject); method.setRequestManager(pckg._requestManager); }); } - + return pckg; }; - + ex.formatters = formatters; ex.utils = utils; ex.Method = Method; - + return ex; }; - - - + + + module.exports = extend; - - + + },{"web3-core-helpers":338,"web3-core-method":339,"web3-utils":403}],348:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -57441,22 +57441,22 @@ * @author Fabian Vogelsteller * @date 2017 */ - + "use strict"; - - + + var requestManager = require('web3-core-requestmanager'); var extend = require('./extend.js'); - + module.exports = { packageInit: function (pkg, args) { args = Array.prototype.slice.call(args); - + if (!pkg) { throw new Error('You need to instantiate using the "new" keyword.'); } - - + + // make property of pkg._provider, which can properly set providers Object.defineProperty(pkg, 'currentProvider', { get: function () { @@ -57468,23 +57468,23 @@ enumerable: true, configurable: true }); - + // inherit from web3 umbrella package if (args[0] && args[0]._requestManager) { pkg._requestManager = new requestManager.Manager(args[0].currentProvider); - + // set requestmanager on package } else { pkg._requestManager = new requestManager.Manager(); pkg._requestManager.setProvider(args[0], args[1]); } - + // add givenProvider pkg.givenProvider = requestManager.Manager.givenProvider; pkg.providers = requestManager.Manager.providers; - + pkg._provider = pkg._requestManager.provider; - + // add SETPROVIDER function (don't overwrite if already existing) if (!pkg.setProvider) { pkg.setProvider = function (provider, net) { @@ -57493,10 +57493,10 @@ return true; }; } - + // attach batch request creation pkg.BatchRequest = requestManager.BatchManager.bind(null, pkg._requestManager); - + // attach extend function pkg.extend = extend(pkg); }, @@ -57505,22 +57505,22 @@ pkg.providers = requestManager.Manager.providers; } }; - - + + },{"./extend.js":347,"web3-core-requestmanager":343}],349:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -57530,10 +57530,10 @@ * @author Fabian Vogelsteller * @date 2018 */ - + var _ = require('underscore'); var utils = require('web3-utils'); - + var EthersAbi = require('ethers/utils/abi-coder').AbiCoder; var ethersAbiCoder = new EthersAbi(function (type, value) { if (type.match(/^u?int/) && !_.isArray(value) && (!_.isObject(value) || value.constructor.name !== 'BN')) { @@ -57541,17 +57541,17 @@ } return value; }); - + // result method function Result() { } - + /** * ABICoder prototype should be used to encode/decode solidity params of any type */ var ABICoder = function () { }; - + /** * Encodes the function name to its ABI representation, which are the first 4 bytes of the sha3 of the function name including types. * @@ -57563,10 +57563,10 @@ if (_.isObject(functionName)) { functionName = utils._jsonInterfaceMethodToString(functionName); } - + return utils.sha3(functionName).slice(0, 10); }; - + /** * Encodes the function name to its ABI representation, which are the first 4 bytes of the sha3 of the function name including types. * @@ -57578,10 +57578,10 @@ if (_.isObject(functionName)) { functionName = utils._jsonInterfaceMethodToString(functionName); } - + return utils.sha3(functionName); }; - + /** * Should be used to encode plain param * @@ -57593,7 +57593,7 @@ ABICoder.prototype.encodeParameter = function (type, param) { return this.encodeParameters([type], [param]); }; - + /** * Should be used to encode list of params * @@ -57605,7 +57605,7 @@ ABICoder.prototype.encodeParameters = function (types, params) { return ethersAbiCoder.encode(this.mapTypes(types), params); }; - + /** * Map types if simplified format is used * @@ -57627,16 +57627,16 @@ } ) ); - + return; } - + mappedTypes.push(type); }); - + return mappedTypes; }; - + /** * Check if type is simplified struct format * @@ -57647,7 +57647,7 @@ ABICoder.prototype.isSimplifiedStructFormat = function (type) { return typeof type === 'object' && typeof type.components === 'undefined' && typeof type.name === 'undefined'; }; - + /** * Maps the correct tuple type and name when the simplified format in encode/decodeParameter is used * @@ -57657,15 +57657,15 @@ */ ABICoder.prototype.mapStructNameAndType = function (structName) { var type = 'tuple'; - + if (structName.indexOf('[]') > -1) { type = 'tuple[]'; structName = structName.slice(0, -2); } - + return {type: type, name: structName}; }; - + /** * Maps the simplified format in to the expected format of the ABICoder * @@ -57686,19 +57686,19 @@ } ) ); - + return; } - + components.push({ name: key, type: struct[key] }); }); - + return components; }; - + /** * Encodes a function call from its json interface and parameters. * @@ -57710,7 +57710,7 @@ ABICoder.prototype.encodeFunctionCall = function (jsonInterface, params) { return this.encodeFunctionSignature(jsonInterface) + this.encodeParameters(jsonInterface.inputs, params).replace('0x', ''); }; - + /** * Should be used to decode bytes to plain param * @@ -57722,7 +57722,7 @@ ABICoder.prototype.decodeParameter = function (type, bytes) { return this.decodeParameters([type], bytes)[0]; }; - + /** * Should be used to decode list of params * @@ -57735,27 +57735,27 @@ if (!bytes || bytes === '0x' || bytes === '0X') { throw new Error('Returned values aren\'t valid, did it run Out of Gas?'); } - + var res = ethersAbiCoder.decode(this.mapTypes(outputs), '0x' + bytes.replace(/0x/i, '')); var returnValue = new Result(); returnValue.__length__ = 0; - + outputs.forEach(function (output, i) { var decodedValue = res[returnValue.__length__]; decodedValue = (decodedValue === '0x') ? null : decodedValue; - + returnValue[i] = decodedValue; - + if (_.isObject(output) && output.name) { returnValue[output.name] = decodedValue; } - + returnValue.__length__++; }); - + return returnValue; }; - + /** * Decodes events non- and indexed parameters. * @@ -57768,15 +57768,15 @@ ABICoder.prototype.decodeLog = function (inputs, data, topics) { var _this = this; topics = _.isArray(topics) ? topics : [topics]; - + data = data || ''; - + var notIndexedInputs = []; var indexedParams = []; var topicCount = 0; - + // TODO check for anonymous logs? - + inputs.forEach(function (input, i) { if (input.indexed) { indexedParams[i] = (['bool', 'int', 'uint', 'address', 'fixed', 'ufixed'].find(function (staticType) { @@ -57787,60 +57787,60 @@ notIndexedInputs[i] = input; } }); - - + + var nonIndexedData = data; var notIndexedParams = (nonIndexedData) ? this.decodeParameters(notIndexedInputs, nonIndexedData) : []; - + var returnValue = new Result(); returnValue.__length__ = 0; - - + + inputs.forEach(function (res, i) { returnValue[i] = (res.type === 'string') ? '' : null; - + if (typeof notIndexedParams[i] !== 'undefined') { returnValue[i] = notIndexedParams[i]; } if (typeof indexedParams[i] !== 'undefined') { returnValue[i] = indexedParams[i]; } - + if (res.name) { returnValue[res.name] = returnValue[i]; } - + returnValue.__length__++; }); - + return returnValue; }; - + var coder = new ABICoder(); - + module.exports = coder; - + },{"ethers/utils/abi-coder":143,"underscore":325,"web3-utils":403}],350:[function(require,module,exports){ (function (Buffer){ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); - + var Bytes = require("./bytes"); var Nat = require("./nat"); var elliptic = require("elliptic"); var rlp = require("./rlp"); var secp256k1 = new elliptic.ec("secp256k1"); // eslint-disable-line - + var _require = require("./hash"), keccak256 = _require.keccak256, keccak256s = _require.keccak256s; - + var create = function create(entropy) { var innerHex = keccak256(Bytes.concat(Bytes.random(32), entropy || Bytes.random(32))); var middleHex = Bytes.concat(Bytes.concat(Bytes.random(32), innerHex), Bytes.random(32)); var outerHex = keccak256(middleHex); return fromPrivate(outerHex); }; - + var toChecksum = function toChecksum(address) { var addressHash = keccak256s(address.slice(2)); var checksumAddress = "0x"; @@ -57848,7 +57848,7 @@ checksumAddress += parseInt(addressHash[i + 2], 16) > 7 ? address[i + 2].toUpperCase() : address[i + 2]; }return checksumAddress; }; - + var fromPrivate = function fromPrivate(privateKey) { var buffer = new Buffer(privateKey.slice(2), "hex"); var ecKey = secp256k1.keyFromPrivate(buffer); @@ -57860,29 +57860,29 @@ privateKey: privateKey }; }; - + var encodeSignature = function encodeSignature(_ref) { var _ref2 = _slicedToArray(_ref, 3), v = _ref2[0], r = Bytes.pad(32, _ref2[1]), s = Bytes.pad(32, _ref2[2]); - + return Bytes.flatten([r, s, v]); }; - + var decodeSignature = function decodeSignature(hex) { return [Bytes.slice(64, Bytes.length(hex), hex), Bytes.slice(0, 32, hex), Bytes.slice(32, 64, hex)]; }; - + var makeSigner = function makeSigner(addToV) { return function (hash, privateKey) { var signature = secp256k1.keyFromPrivate(new Buffer(privateKey.slice(2), "hex")).sign(new Buffer(hash.slice(2), "hex"), { canonical: true }); return encodeSignature([Nat.fromString(Bytes.fromNumber(addToV + signature.recoveryParam)), Bytes.pad(32, Bytes.fromNat("0x" + signature.r.toString(16))), Bytes.pad(32, Bytes.fromNat("0x" + signature.s.toString(16)))]); }; }; - + var sign = makeSigner(27); // v=27|28 instead of 0|1... - + var recover = function recover(hash, signature) { var vals = decodeSignature(signature); var vrs = { v: Bytes.toNumber(vals[0]), r: vals[1].slice(2), s: vals[2].slice(2) }; @@ -57892,7 +57892,7 @@ var address = toChecksum("0x" + publicHash.slice(-40)); return address; }; - + module.exports = { create: create, toChecksum: toChecksum, @@ -57913,55 +57913,55 @@ },{"dup":134}],354:[function(require,module,exports){ var BN = require("bn.js"); var Bytes = require("./bytes"); - + var fromBN = function fromBN(bn) { return "0x" + bn.toString("hex"); }; - + var toBN = function toBN(str) { return new BN(str.slice(2), 16); }; - + var fromString = function fromString(str) { var bn = "0x" + (str.slice(0, 2) === "0x" ? new BN(str.slice(2), 16) : new BN(str, 10)).toString("hex"); return bn === "0x0" ? "0x" : bn; }; - + var toEther = function toEther(wei) { return toNumber(div(wei, fromString("10000000000"))) / 100000000; }; - + var fromEther = function fromEther(eth) { return mul(fromNumber(Math.floor(eth * 100000000)), fromString("10000000000")); }; - + var toString = function toString(a) { return toBN(a).toString(10); }; - + var fromNumber = function fromNumber(a) { return typeof a === "string" ? /^0x/.test(a) ? a : "0x" + a : "0x" + new BN(a).toString("hex"); }; - + var toNumber = function toNumber(a) { return toBN(a).toNumber(); }; - + var toUint256 = function toUint256(a) { return Bytes.pad(32, a); }; - + var bin = function bin(method) { return function (a, b) { return fromBN(toBN(a)[method](toBN(b))); }; }; - + var add = bin("add"); var mul = bin("mul"); var div = bin("div"); var sub = bin("sub"); - + module.exports = { toString: toString, fromString: fromString, @@ -57985,20 +57985,20 @@ // | 184 to 191 | HEX(length_of_length_of_leaf + 128 + 55) + HEX(length_of_leaf) + HEX(leaf) | // | 192 to 247 | HEX(length_of_node + 192) + HEX(node) | // | 248 to 255 | HEX(length_of_length_of_node + 128 + 55) + HEX(length_of_node) + HEX(node) | - + var encode = function encode(tree) { var padEven = function padEven(str) { return str.length % 2 === 0 ? str : "0" + str; }; - + var uint = function uint(num) { return padEven(num.toString(16)); }; - + var length = function length(len, add) { return len < 56 ? uint(add + len) : uint(add + uint(len).length / 2 + 55) + uint(len); }; - + var dataTree = function dataTree(tree) { if (typeof tree === "string") { var hex = tree.slice(2); @@ -58010,29 +58010,29 @@ return _pre + _hex; } }; - + return "0x" + dataTree(tree); }; - + var decode = function decode(hex) { var i = 2; - + var parseTree = function parseTree() { if (i >= hex.length) throw ""; var head = hex.slice(i, i + 2); return head < "80" ? (i += 2, "0x" + head) : head < "c0" ? parseHex() : parseList(); }; - + var parseLength = function parseLength() { var len = parseInt(hex.slice(i, i += 2), 16) % 64; return len < 56 ? len : parseInt(hex.slice(i, i += (len - 55) * 2), 16); }; - + var parseHex = function parseHex() { var len = parseLength(); return "0x" + hex.slice(i, i += len * 2); }; - + var parseList = function parseList() { var lim = parseLength() * 2 + i; var list = []; @@ -58040,20 +58040,20 @@ list.push(parseTree()); }return list; }; - + try { return parseTree(); } catch (e) { return []; } }; - + module.exports = { encode: encode, decode: decode }; },{}],356:[function(require,module,exports){ (function (global){ - + var rng; - + if (global.crypto && crypto.getRandomValues) { // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto // Moderately fast, high quality @@ -58063,7 +58063,7 @@ return _rnds8; }; } - + if (!rng) { // Math.random()-based (RNG) // @@ -58075,26 +58075,26 @@ if ((i & 0x03) === 0) r = Math.random() * 0x100000000; _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; } - + return _rnds; }; } - + module.exports = rng; - - + + }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],357:[function(require,module,exports){ // uuid.js // // Copyright (c) 2010-2012 Robert Kieffer // MIT License - http://opensource.org/licenses/mit-license.php - + // Unique ID creation requires a high quality random # generator. We feature // detect to determine the best RNG source, normalizing to a function that // returns 128-bits of randomness, since that's what's usually required var _rng = require('./rng'); - + // Maps for number <-> hex string conversion var _byteToHex = []; var _hexToByte = {}; @@ -58102,26 +58102,26 @@ _byteToHex[i] = (i + 0x100).toString(16).substr(1); _hexToByte[_byteToHex[i]] = i; } - + // **`parse()` - Parse a UUID into it's component bytes** function parse(s, buf, offset) { var i = (buf && offset) || 0, ii = 0; - + buf = buf || []; s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) { if (ii < 16) { // Don't overflow! buf[i + ii++] = _hexToByte[oct]; } }); - + // Zero out remaining bytes if string was short while (ii < 16) { buf[i + ii++] = 0; } - + return buf; } - + // **`unparse()` - Convert UUID byte array (ala parse()) into a string** function unparse(buf, offset) { var i = offset || 0, bth = _byteToHex; @@ -58134,156 +58134,156 @@ bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]]; } - + // **`v1()` - Generate time-based UUID** // // Inspired by https://github.com/LiosK/UUID.js // and http://docs.python.org/library/uuid.html - + // random #'s we need to init node and clockseq var _seedBytes = _rng(); - + // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) var _nodeId = [ _seedBytes[0] | 0x01, _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5] ]; - + // Per 4.2.2, randomize (14 bit) clockseq var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff; - + // Previous uuid creation time var _lastMSecs = 0, _lastNSecs = 0; - + // See https://github.com/broofa/node-uuid for API details function v1(options, buf, offset) { var i = buf && offset || 0; var b = buf || []; - + options = options || {}; - + var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; - + // UUID timestamps are 100 nano-second units since the Gregorian epoch, // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime(); - + // Per 4.2.1.2, use count of uuid's generated during the current clock // cycle to simulate higher resolution clock var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; - + // Time since last uuid creation (in msecs) var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000; - + // Per 4.2.1.2, Bump clockseq on clock regression if (dt < 0 && options.clockseq === undefined) { clockseq = clockseq + 1 & 0x3fff; } - + // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new // time interval if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { nsecs = 0; } - + // Per 4.2.1.2 Throw error if too many uuids are requested if (nsecs >= 10000) { throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec'); } - + _lastMSecs = msecs; _lastNSecs = nsecs; _clockseq = clockseq; - + // Per 4.1.4 - Convert from unix epoch to Gregorian epoch msecs += 12219292800000; - + // `time_low` var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; b[i++] = tl >>> 24 & 0xff; b[i++] = tl >>> 16 & 0xff; b[i++] = tl >>> 8 & 0xff; b[i++] = tl & 0xff; - + // `time_mid` var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff; b[i++] = tmh >>> 8 & 0xff; b[i++] = tmh & 0xff; - + // `time_high_and_version` b[i++] = tmh >>> 24 & 0xf | 0x10; // include version b[i++] = tmh >>> 16 & 0xff; - + // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) b[i++] = clockseq >>> 8 | 0x80; - + // `clock_seq_low` b[i++] = clockseq & 0xff; - + // `node` var node = options.node || _nodeId; for (var n = 0; n < 6; n++) { b[i + n] = node[n]; } - + return buf ? buf : unparse(b); } - + // **`v4()` - Generate random UUID** - + // See https://github.com/broofa/node-uuid for API details function v4(options, buf, offset) { // Deprecated - 'format' argument, as supported in v1.2 var i = buf && offset || 0; - + if (typeof(options) == 'string') { buf = options == 'binary' ? new Array(16) : null; options = null; } options = options || {}; - + var rnds = options.random || (options.rng || _rng)(); - + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` rnds[6] = (rnds[6] & 0x0f) | 0x40; rnds[8] = (rnds[8] & 0x3f) | 0x80; - + // Copy bytes to buffer, if provided if (buf) { for (var ii = 0; ii < 16; ii++) { buf[i + ii] = rnds[ii]; } } - + return buf || unparse(rnds); } - + // Export public API var uuid = v4; uuid.v1 = v1; uuid.v4 = v4; uuid.parse = parse; uuid.unparse = unparse; - + module.exports = uuid; - + },{"./rng":356}],358:[function(require,module,exports){ (function (global,Buffer){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -58292,9 +58292,9 @@ * @author Fabian Vogelsteller * @date 2017 */ - + "use strict"; - + var _ = require("underscore"); var core = require('web3-core'); var Method = require('web3-core-method'); @@ -58309,36 +58309,36 @@ var uuid = require('uuid'); var utils = require('web3-utils'); var helpers = require('web3-core-helpers'); - + var isNot = function(value) { return (_.isUndefined(value) || _.isNull(value)); }; - + var trimLeadingZero = function (hex) { while (hex && hex.startsWith('0x0')) { hex = '0x' + hex.slice(3); } return hex; }; - + var makeEven = function (hex) { if(hex.length % 2 === 1) { hex = hex.replace('0x', '0x0'); } return hex; }; - - + + var Accounts = function Accounts() { var _this = this; - + // sets _requestmanager core.packageInit(this, arguments); - + // remove unecessary core functions delete this.BatchRequest; delete this.extend; - + var _ethereumCall = [ new Method({ name: 'getId', @@ -58370,14 +58370,14 @@ method.attachToObject(_this._ethereumCall); method.setRequestManager(_this._requestManager); }); - - + + this.wallet = new Wallet(this); }; - + Accounts.prototype._addAccountFunctions = function (account) { var _this = this; - + // add sign functions account.signTransaction = function signTransaction(tx, callback) { return _this.signTransaction(tx, account.privateKey, callback); @@ -58385,64 +58385,64 @@ account.sign = function sign(data) { return _this.sign(data, account.privateKey); }; - + account.encrypt = function encrypt(password, options) { return _this.encrypt(account.privateKey, password, options); }; - - + + return account; }; - + Accounts.prototype.create = function create(entropy) { return this._addAccountFunctions(Account.create(entropy || utils.randomHex(32))); }; - + Accounts.prototype.privateKeyToAccount = function privateKeyToAccount(privateKey) { return this._addAccountFunctions(Account.fromPrivate(privateKey)); }; - + Accounts.prototype.signTransaction = function signTransaction(tx, privateKey, callback) { var _this = this, error = false, result; - + callback = callback || function () {}; - + if (!tx) { error = new Error('No transaction object given!'); - + callback(error); return Promise.reject(error); } - + function signed (tx) { - + if (!tx.gas && !tx.gasLimit) { error = new Error('"gas" is missing'); } - + if (tx.nonce < 0 || tx.gas < 0 || tx.gasPrice < 0 || tx.chainId < 0) { error = new Error('Gas, gasPrice, nonce or chainId is lower than 0'); } - + if (error) { callback(error); return Promise.reject(error); } - + try { tx = helpers.formatters.inputCallFormatter(tx); - + var transaction = tx; transaction.to = tx.to || '0x'; transaction.data = tx.data || '0x'; transaction.value = tx.value || '0x'; transaction.chainId = utils.numberToHex(tx.chainId); - + var rlpEncoded = RLP.encode([ Bytes.fromNat(transaction.nonce), Bytes.fromNat(transaction.gasPrice), @@ -58453,20 +58453,20 @@ Bytes.fromNat(transaction.chainId || "0x1"), "0x", "0x"]); - - + + var hash = Hash.keccak256(rlpEncoded); - + var signature = Account.makeSigner(Nat.toNumber(transaction.chainId || "0x1") * 2 + 35)(Hash.keccak256(rlpEncoded), privateKey); - + var rawTx = RLP.decode(rlpEncoded).slice(0, 6).concat(Account.decodeSignature(signature)); - + rawTx[6] = makeEven(trimLeadingZero(rawTx[6])); rawTx[7] = makeEven(trimLeadingZero(rawTx[7])); rawTx[8] = makeEven(trimLeadingZero(rawTx[8])); - + var rawTransaction = RLP.encode(rawTx); - + var values = RLP.decode(rawTransaction); result = { messageHash: hash, @@ -58475,22 +58475,22 @@ s: trimLeadingZero(values[8]), rawTransaction: rawTransaction }; - + } catch(e) { callback(e); return Promise.reject(e); } - + callback(null, result); return result; } - + // Resolve immediately if nonce, chainId and price are provided if (tx.nonce !== undefined && tx.chainId !== undefined && tx.gasPrice !== undefined) { return Promise.resolve(signed(tx)); } - - + + // Otherwise, get the missing info from the Ethereum Node return Promise.all([ isNot(tx.chainId) ? _this._ethereumCall.getId() : tx.chainId, @@ -58503,7 +58503,7 @@ return signed(_.extend(tx, {chainId: args[0], gasPrice: args[1], nonce: args[2]})); }); }; - + /* jshint ignore:start */ Accounts.prototype.recoverTransaction = function recoverTransaction(rawTx) { var values = RLP.decode(rawTx); @@ -58515,7 +58515,7 @@ return Account.recover(Hash.keccak256(signingDataHex), signature); }; /* jshint ignore:end */ - + Accounts.prototype.hashMessage = function hashMessage(data) { var message = utils.isHexStrict(data) ? utils.hexToBytes(data) : data; var messageBuffer = Buffer.from(message); @@ -58524,7 +58524,7 @@ var ethMessage = Buffer.concat([preambleBuffer, messageBuffer]); return Hash.keccak256s(ethMessage); }; - + Accounts.prototype.sign = function sign(data, privateKey) { var hash = this.hashMessage(data); var signature = Account.sign(hash, privateKey); @@ -58538,89 +58538,89 @@ signature: signature }; }; - + Accounts.prototype.recover = function recover(message, signature, preFixed) { var args = [].slice.apply(arguments); - - + + if (_.isObject(message)) { return this.recover(message.messageHash, Account.encodeSignature([message.v, message.r, message.s]), true); } - + if (!preFixed) { message = this.hashMessage(message); } - + if (args.length >= 4) { preFixed = args.slice(-1)[0]; preFixed = _.isBoolean(preFixed) ? !!preFixed : false; - + return this.recover(message, Account.encodeSignature(args.slice(1, 4)), preFixed); // v, r, s } return Account.recover(message, signature); }; - + // Taken from https://github.com/ethereumjs/ethereumjs-wallet Accounts.prototype.decrypt = function (v3Keystore, password, nonStrict) { /* jshint maxcomplexity: 10 */ - + if(!_.isString(password)) { throw new Error('No password given.'); } - + var json = (_.isObject(v3Keystore)) ? v3Keystore : JSON.parse(nonStrict ? v3Keystore.toLowerCase() : v3Keystore); - + if (json.version !== 3) { throw new Error('Not a valid V3 wallet'); } - + var derivedKey; var kdfparams; if (json.crypto.kdf === 'scrypt') { kdfparams = json.crypto.kdfparams; - + // FIXME: support progress reporting callback derivedKey = scryptsy(new Buffer(password), new Buffer(kdfparams.salt, 'hex'), kdfparams.n, kdfparams.r, kdfparams.p, kdfparams.dklen); } else if (json.crypto.kdf === 'pbkdf2') { kdfparams = json.crypto.kdfparams; - + if (kdfparams.prf !== 'hmac-sha256') { throw new Error('Unsupported parameters to PBKDF2'); } - + derivedKey = cryp.pbkdf2Sync(new Buffer(password), new Buffer(kdfparams.salt, 'hex'), kdfparams.c, kdfparams.dklen, 'sha256'); } else { throw new Error('Unsupported key derivation scheme'); } - + var ciphertext = new Buffer(json.crypto.ciphertext, 'hex'); - + var mac = utils.sha3(Buffer.concat([ derivedKey.slice(16, 32), ciphertext ])).replace('0x',''); if (mac !== json.crypto.mac) { throw new Error('Key derivation failed - possibly wrong password'); } - + var decipher = cryp.createDecipheriv(json.crypto.cipher, derivedKey.slice(0, 16), new Buffer(json.crypto.cipherparams.iv, 'hex')); var seed = '0x'+ Buffer.concat([ decipher.update(ciphertext), decipher.final() ]).toString('hex'); - + return this.privateKeyToAccount(seed); }; - + Accounts.prototype.encrypt = function (privateKey, password, options) { /* jshint maxcomplexity: 20 */ var account = this.privateKeyToAccount(privateKey); - + options = options || {}; var salt = options.salt || cryp.randomBytes(32); var iv = options.iv || cryp.randomBytes(16); - + var derivedKey; var kdf = options.kdf || 'scrypt'; var kdfparams = { dklen: options.dklen || 32, salt: salt.toString('hex') }; - + if (kdf === 'pbkdf2') { kdfparams.c = options.c || 262144; kdfparams.prf = 'hmac-sha256'; @@ -58634,16 +58634,16 @@ } else { throw new Error('Unsupported kdf'); } - + var cipher = cryp.createCipheriv(options.cipher || 'aes-128-ctr', derivedKey.slice(0, 16), iv); if (!cipher) { throw new Error('Unsupported cipher'); } - + var ciphertext = Buffer.concat([ cipher.update(new Buffer(account.privateKey.replace('0x',''), 'hex')), cipher.final() ]); - + var mac = utils.sha3(Buffer.concat([ derivedKey.slice(16, 32), new Buffer(ciphertext, 'hex') ])).replace('0x',''); - + return { version: 3, id: uuid.v4({ random: options.uuid || cryp.randomBytes(16) }), @@ -58660,17 +58660,17 @@ } }; }; - - + + // Note: this is trying to follow closely the specs on // http://web3js.readthedocs.io/en/1.0/web3-eth-accounts.html - + function Wallet(accounts) { this._accounts = accounts; this.length = 0; this.defaultKeyName = "web3js_wallet"; } - + Wallet.prototype._findSafeIndex = function (pointer) { pointer = pointer || 0; if (_.has(this, pointer)) { @@ -58679,47 +58679,47 @@ return pointer; } }; - + Wallet.prototype._currentIndexes = function () { var keys = Object.keys(this); var indexes = keys .map(function(key) { return parseInt(key); }) .filter(function(n) { return (n < 9e20); }); - + return indexes; }; - + Wallet.prototype.create = function (numberOfAccounts, entropy) { for (var i = 0; i < numberOfAccounts; ++i) { this.add(this._accounts.create(entropy).privateKey); } return this; }; - + Wallet.prototype.add = function (account) { - + if (_.isString(account)) { account = this._accounts.privateKeyToAccount(account); } if (!this[account.address]) { account = this._accounts.privateKeyToAccount(account.privateKey); account.index = this._findSafeIndex(); - + this[account.index] = account; this[account.address] = account; this[account.address.toLowerCase()] = account; - + this.length++; - + return account; } else { return this[account.address]; } }; - + Wallet.prototype.remove = function (addressOrIndex) { var account = this[addressOrIndex]; - + if (account && account.address) { // address this[account.address].privateKey = null; @@ -58730,97 +58730,97 @@ // index this[account.index].privateKey = null; delete this[account.index]; - + this.length--; - + return true; } else { return false; } }; - + Wallet.prototype.clear = function () { var _this = this; var indexes = this._currentIndexes(); - + indexes.forEach(function(index) { _this.remove(index); }); - + return this; }; - + Wallet.prototype.encrypt = function (password, options) { var _this = this; var indexes = this._currentIndexes(); - + var accounts = indexes.map(function(index) { return _this[index].encrypt(password, options); }); - + return accounts; }; - - + + Wallet.prototype.decrypt = function (encryptedWallet, password) { var _this = this; - + encryptedWallet.forEach(function (keystore) { var account = _this._accounts.decrypt(keystore, password); - + if (account) { _this.add(account); } else { throw new Error('Couldn\'t decrypt accounts. Password wrong?'); } }); - + return this; }; - + Wallet.prototype.save = function (password, keyName) { localStorage.setItem(keyName || this.defaultKeyName, JSON.stringify(this.encrypt(password))); - + return true; }; - + Wallet.prototype.load = function (password, keyName) { var keystore = localStorage.getItem(keyName || this.defaultKeyName); - + if (keystore) { try { keystore = JSON.parse(keystore); } catch(e) { - + } } - + return this.decrypt(keystore || [], password); }; - + if (typeof localStorage === 'undefined') { delete Wallet.prototype.save; delete Wallet.prototype.load; } - - + + module.exports = Accounts; - + }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) },{"any-promise":2,"buffer":84,"crypto":97,"crypto-browserify":97,"eth-lib/lib/account":350,"eth-lib/lib/bytes":352,"eth-lib/lib/hash":353,"eth-lib/lib/nat":354,"eth-lib/lib/rlp":355,"scrypt.js":293,"underscore":325,"uuid":357,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-utils":403}],359:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -58836,11 +58836,11 @@ * @author Fabian Vogelsteller * @date 2017 */ - - + + "use strict"; - - + + var _ = require('underscore'); var core = require('web3-core'); var Method = require('web3-core-method'); @@ -58850,8 +58850,8 @@ var errors = require('web3-core-helpers').errors; var promiEvent = require('web3-core-promievent'); var abi = require('web3-eth-abi'); - - + + /** * Should be called to create new contract instance * @@ -58864,37 +58864,37 @@ var Contract = function Contract(jsonInterface, address, options) { var _this = this, args = Array.prototype.slice.call(arguments); - + if(!(this instanceof Contract)) { throw new Error('Please use the "new" keyword to instantiate a web3.eth.contract() object!'); } - + // sets _requestmanager core.packageInit(this, [this.constructor.currentProvider]); - + this.clearSubscriptions = this._requestManager.clearSubscriptions; - - - + + + if(!jsonInterface || !(Array.isArray(jsonInterface))) { throw new Error('You must provide the json interface of the contract when instantiating a contract object.'); } - - - + + + // create the options object this.options = {}; - + var lastArg = args[args.length - 1]; if(_.isObject(lastArg) && !_.isArray(lastArg)) { options = lastArg; - + this.options = _.extend(this.options, this._getOrSetDefaultOptions(options)); if(_.isObject(address)) { address = null; } } - + // set address Object.defineProperty(this.options, 'address', { set: function(value){ @@ -58907,27 +58907,27 @@ }, enumerable: true }); - + // add method and event signatures, when the jsonInterface gets set Object.defineProperty(this.options, 'jsonInterface', { set: function(value){ _this.methods = {}; _this.events = {}; - + _this._jsonInterface = value.map(function(method) { var func, funcName; - + // make constant and payable backwards compatible method.constant = (method.stateMutability === "view" || method.stateMutability === "pure" || method.constant); method.payable = (method.stateMutability === "payable" || method.payable); - - + + if (method.name) { funcName = utils._jsonInterfaceMethodToString(method); } - - + + // function if (method.type === 'function') { method.signature = abi.encodeFunctionSignature(funcName); @@ -58935,8 +58935,8 @@ method: method, parent: _this }); - - + + // add method only if not one already exists if(!_this.methods[method.name]) { _this.methods[method.name] = func; @@ -58948,37 +58948,37 @@ }); _this.methods[method.name] = cascadeFunc; } - + // definitely add the method based on its signature _this.methods[method.signature] = func; - + // add method by name _this.methods[funcName] = func; - - + + // event } else if (method.type === 'event') { method.signature = abi.encodeEventSignature(funcName); var event = _this._on.bind(_this, method.signature); - + // add method only if not already exists if(!_this.events[method.name] || _this.events[method.name].name === 'bound ') _this.events[method.name] = event; - + // definitely add the method based on its signature _this.events[method.signature] = event; - + // add event by name _this.events[funcName] = event; } - - + + return method; }); - + // add allEvents _this.events.allEvents = _this._on.bind(_this, 'allevents'); - + return _this._jsonInterface; }, get: function(){ @@ -58986,11 +58986,11 @@ }, enumerable: true }); - + // get default account from the Class var defaultAccount = this.constructor.defaultAccount; var defaultBlock = this.constructor.defaultBlock || 'latest'; - + Object.defineProperty(this, 'defaultAccount', { get: function () { return defaultAccount; @@ -58999,7 +58999,7 @@ if(val) { defaultAccount = utils.toChecksumAddress(formatters.inputAddressFormatter(val)); } - + return val; }, enumerable: true @@ -59010,33 +59010,33 @@ }, set: function (val) { defaultBlock = val; - + return val; }, enumerable: true }); - + // properties this.methods = {}; this.events = {}; - + this._address = null; this._jsonInterface = []; - + // set getter/setter properties this.options.address = address; this.options.jsonInterface = jsonInterface; - + }; - + Contract.setProvider = function(provider, accounts) { // Contract.currentProvider = provider; core.packageInit(this, [provider]); - + this._ethAccounts = accounts; }; - - + + /** * Get the callback and modiufy the array if necessary * @@ -59049,7 +59049,7 @@ return args.pop(); // modify the args array! } }; - + /** * Checks that no listener with name "newListener" or "removeListener" is added. * @@ -59063,8 +59063,8 @@ throw new Error('The event "'+ type +'" is a reserved event name, you can\'t use it.'); } }; - - + + /** * Use default values, if options are not available * @@ -59075,20 +59075,20 @@ Contract.prototype._getOrSetDefaultOptions = function getOrSetDefaultOptions(options) { var gasPrice = options.gasPrice ? String(options.gasPrice): null; var from = options.from ? utils.toChecksumAddress(formatters.inputAddressFormatter(options.from)) : null; - + options.data = options.data || this.options.data; - + options.from = from || this.options.from; options.gasPrice = gasPrice || this.options.gasPrice; options.gas = options.gas || options.gasLimit || this.options.gas; - + // TODO replace with only gasLimit? delete options.gasLimit; - + return options; }; - - + + /** * Should be used to encode indexed params and options to one final object * @@ -59101,27 +59101,27 @@ options = options || {}; var filter = options.filter || {}, result = {}; - + ['fromBlock', 'toBlock'].filter(function (f) { return options[f] !== undefined; }).forEach(function (f) { result[f] = formatters.inputBlockNumberFormatter(options[f]); }); - + // use given topics if(_.isArray(options.topics)) { result.topics = options.topics; - + // create topics based on filter } else { - + result.topics = []; - + // add event signature if (event && !event.anonymous && event.name !== 'ALLEVENTS') { result.topics.push(event.signature); } - + // add event topics (indexed arguments) if (event.name !== 'ALLEVENTS') { var indexedTopics = event.inputs.filter(function (i) { @@ -59131,10 +59131,10 @@ if (!value) { return null; } - + // TODO: https://github.com/ethereum/web3.js/issues/344 // TODO: deal properly with components - + if (_.isArray(value)) { return value.map(function (v) { return abi.encodeParameter(i.type, v); @@ -59142,21 +59142,21 @@ } return abi.encodeParameter(i.type, value); }); - + result.topics = result.topics.concat(indexedTopics); } - + if(!result.topics.length) delete result.topics; } - + if(this.options.address) { result.address = this.options.address.toLowerCase(); } - + return result; }; - + /** * Should be used to decode indexed params and options * @@ -59166,33 +59166,33 @@ */ Contract.prototype._decodeEventABI = function (data) { var event = this; - + data.data = data.data || ''; data.topics = data.topics || []; var result = formatters.outputLogFormatter(data); - + // if allEvents get the right event if(event.name === 'ALLEVENTS') { event = event.jsonInterface.find(function (intf) { return (intf.signature === data.topics[0]); }) || {anonymous: true}; } - + // create empty inputs if none are present (e.g. anonymous events on allEvents) event.inputs = event.inputs || []; - - + + var argTopics = event.anonymous ? data.topics : data.topics.slice(1); - + result.returnValues = abi.decodeLog(event.inputs, data.data, argTopics); delete result.returnValues.__length__; - + // add name result.event = event.name; - + // add signature result.signature = (event.anonymous || !data.topics[0]) ? null : data.topics[0]; - + // move the data and topics to "raw" result.raw = { data: result.data, @@ -59200,11 +59200,11 @@ }; delete result.data; delete result.topics; - - + + return result; }; - + /** * Encodes an ABI for a method, including signature or the method. * Or when constructor encodes only the constructor parameters. @@ -59216,18 +59216,18 @@ Contract.prototype._encodeMethodABI = function _encodeMethodABI() { var methodSignature = this._method.signature, args = this.arguments || []; - + var signature = false, paramsABI = this._parent.options.jsonInterface.filter(function (json) { return ((methodSignature === 'constructor' && json.type === methodSignature) || ((json.signature === methodSignature || json.signature === methodSignature.replace('0x','') || json.name === methodSignature) && json.type === 'function')); }).map(function (json) { var inputLength = (_.isArray(json.inputs)) ? json.inputs.length : 0; - + if (inputLength !== args.length) { throw new Error('The number of arguments is not matching the methods required number. You need to pass '+ inputLength +' arguments.'); } - + if (json.type === 'function') { signature = json.signature; } @@ -59235,29 +59235,29 @@ }).map(function (inputs) { return abi.encodeParameters(inputs, args).replace('0x',''); })[0] || ''; - + // return constructor if(methodSignature === 'constructor') { if(!this._deployData) throw new Error('The contract has no contract data option set. This is necessary to append the constructor parameters.'); - + return this._deployData + paramsABI; - + // return method } else { - + var returnValue = (signature) ? signature + paramsABI : paramsABI; - + if(!returnValue) { throw new Error('Couldn\'t find a matching contract method named "'+ this._method.name +'".'); } else { return returnValue; } } - + }; - - + + /** * Decode method return values * @@ -59270,10 +59270,10 @@ if (!returnValues) { return null; } - + returnValues = returnValues.length >= 2 ? returnValues.slice(2) : returnValues; var result = abi.decodeParameters(outputs, returnValues); - + if (result.__length__ === 1) { return result[0]; } else { @@ -59281,8 +59281,8 @@ return result; } }; - - + + /** * Deploys a contract and fire events based on its state: transactionHash, receipt * @@ -59294,32 +59294,32 @@ * @return {Object} EventEmitter possible events are "error", "transactionHash" and "receipt" */ Contract.prototype.deploy = function(options, callback){ - + options = options || {}; - + options.arguments = options.arguments || []; options = this._getOrSetDefaultOptions(options); - - + + // return error, if no "data" is specified if(!options.data) { return utils._fireError(new Error('No "data" specified in neither the given options, nor the default options.'), null, null, callback); } - + var constructor = _.find(this.options.jsonInterface, function (method) { return (method.type === 'constructor'); }) || {}; constructor.signature = 'constructor'; - + return this._createTxObject.apply({ method: constructor, parent: this, deployData: options.data, _ethAccounts: this.constructor._ethAccounts }, options.arguments); - + }; - + /** * Gets the event signature and outputformatters * @@ -59331,13 +59331,13 @@ */ Contract.prototype._generateEventOptions = function() { var args = Array.prototype.slice.call(arguments); - + // get the callback var callback = this._getCallback(args); - + // get the options var options = (_.isObject(args[args.length - 1])) ? args.pop() : {}; - + var event = (_.isString(args[0])) ? args[0] : 'allevents'; event = (event.toLowerCase() === 'allevents') ? { name: 'ALLEVENTS', @@ -59345,22 +59345,22 @@ } : this.options.jsonInterface.find(function (json) { return (json.type === 'event' && (json.name === event || json.signature === '0x'+ event.replace('0x',''))); }); - + if (!event) { throw new Error('Event "' + event.name + '" doesn\'t exist in this contract.'); } - + if (!utils.isAddress(this.options.address)) { throw new Error('This contract object doesn\'t have address set yet, please set an address first.'); } - + return { params: this._encodeEventABI(event, options), event: event, callback: callback }; }; - + /** * Adds event listeners and creates a subscription, and remove it once its fired. * @@ -59370,8 +59370,8 @@ Contract.prototype.clone = function() { return new this.constructor(this.options.jsonInterface, this.options.address, this.options); }; - - + + /** * Adds event listeners and creates a subscription, and remove it once its fired. * @@ -59383,18 +59383,18 @@ */ Contract.prototype.once = function(event, options, callback) { var args = Array.prototype.slice.call(arguments); - + // get the callback callback = this._getCallback(args); - + if (!callback) { throw new Error('Once requires a callback as the second parameter.'); } - + // don't allow fromBlock if (options) delete options.fromBlock; - + // don't return as once shouldn't provide "on" this._on(event, options, function (err, res, sub) { sub.unsubscribe(); @@ -59402,10 +59402,10 @@ callback(err, res, sub); } }); - + return undefined; }; - + /** * Adds event listeners and creates a subscription. * @@ -59417,14 +59417,14 @@ */ Contract.prototype._on = function(){ var subOptions = this._generateEventOptions.apply(this, arguments); - - + + // prevent the event "newListener" and "removeListener" from being overwritten this._checkListener('newListener', subOptions.event.name, subOptions.callback); this._checkListener('removeListener', subOptions.event.name, subOptions.callback); - + // TODO check if listener already exists? and reuse subscription if options are the same. - + // create new subscription var subscription = new Subscription({ subscription: { @@ -59438,7 +59438,7 @@ } else { this.emit('data', output); } - + if (_.isFunction(this.callback)) { this.callback(null, output, this); } @@ -59448,10 +59448,10 @@ requestManager: this._requestManager }); subscription.subscribe('logs', subOptions.params, subOptions.callback || function () {}); - + return subscription; }; - + /** * Get past events from contracts * @@ -59463,7 +59463,7 @@ */ Contract.prototype.getPastEvents = function(){ var subOptions = this._generateEventOptions.apply(this, arguments); - + var getPastLogs = new Method({ name: 'getPastLogs', call: 'eth_getLogs', @@ -59473,13 +59473,13 @@ }); getPastLogs.setRequestManager(this._requestManager); var call = getPastLogs.buildCall(); - + getPastLogs = null; - + return call(subOptions.params, subOptions.callback); }; - - + + /** * returns the an object with call, send, estimate functions * @@ -59489,39 +59489,39 @@ Contract.prototype._createTxObject = function _createTxObject(){ var args = Array.prototype.slice.call(arguments); var txObject = {}; - + if(this.method.type === 'function') { - + txObject.call = this.parent._executeMethod.bind(txObject, 'call'); txObject.call.request = this.parent._executeMethod.bind(txObject, 'call', true); // to make batch requests - + } - + txObject.send = this.parent._executeMethod.bind(txObject, 'send'); txObject.send.request = this.parent._executeMethod.bind(txObject, 'send', true); // to make batch requests txObject.encodeABI = this.parent._encodeMethodABI.bind(txObject); txObject.estimateGas = this.parent._executeMethod.bind(txObject, 'estimate'); - + if (args && this.method.inputs && args.length !== this.method.inputs.length) { if (this.nextMethod) { return this.nextMethod.apply(null, args); } throw errors.InvalidNumberOfParams(args.length, this.method.inputs.length, this.method.name); } - + txObject.arguments = args || []; txObject._method = this.method; txObject._parent = this.parent; txObject._ethAccounts = this.parent.constructor._ethAccounts || this._ethAccounts; - + if(this.deployData) { txObject._deployData = this.deployData; } - + return txObject; }; - - + + /** * Generates the options for the execute call * @@ -59531,39 +59531,39 @@ */ Contract.prototype._processExecuteArguments = function _processExecuteArguments(args, defer) { var processedArgs = {}; - + processedArgs.type = args.shift(); - + // get the callback processedArgs.callback = this._parent._getCallback(args); - + // get block number to use for call if(processedArgs.type === 'call' && args[args.length - 1] !== true && (_.isString(args[args.length - 1]) || isFinite(args[args.length - 1]))) processedArgs.defaultBlock = args.pop(); - + // get the options processedArgs.options = (_.isObject(args[args.length - 1])) ? args.pop() : {}; - + // get the generateRequest argument for batch requests processedArgs.generateRequest = (args[args.length - 1] === true)? args.pop() : false; - + processedArgs.options = this._parent._getOrSetDefaultOptions(processedArgs.options); processedArgs.options.data = this.encodeABI(); - + // add contract address if(!this._deployData && !utils.isAddress(this._parent.options.address)) throw new Error('This contract object doesn\'t have address set yet, please set an address first.'); - + if(!this._deployData) processedArgs.options.to = this._parent.options.address; - + // return error, if no "data" is specified if(!processedArgs.options.data) return utils._fireError(new Error('Couldn\'t find a matching contract method, or the number of parameters is wrong.'), defer.eventEmitter, defer.reject, processedArgs.callback); - + return processedArgs; }; - + /** * Executes a call, transact or estimateGas on a contract function * @@ -59576,15 +59576,15 @@ args = this._parent._processExecuteArguments.call(this, Array.prototype.slice.call(arguments), defer), defer = promiEvent((args.type !== 'send')), ethAccounts = _this.constructor._ethAccounts || _this._ethAccounts; - + // simple return request for batch requests if(args.generateRequest) { - + var payload = { params: [formatters.inputCallFormatter.call(this._parent, args.options)], callback: args.callback }; - + if(args.type === 'call') { payload.params.push(formatters.inputDefaultBlockNumberFormatter.call(this._parent, args.defaultBlock)); payload.method = 'eth_call'; @@ -59592,14 +59592,14 @@ } else { payload.method = 'eth_sendTransaction'; } - + return payload; - + } else { - + switch (args.type) { case 'estimate': - + var estimateGas = (new Method({ name: 'estimateGas', call: 'eth_estimateGas', @@ -59611,13 +59611,13 @@ defaultAccount: _this._parent.defaultAccount, defaultBlock: _this._parent.defaultBlock })).createFunction(); - + return estimateGas(args.options, args.callback); - + case 'call': - + // TODO check errors: missing "from" should give error on deploy and send, call ? - + var call = (new Method({ name: 'call', call: 'eth_call', @@ -59632,26 +59632,26 @@ defaultAccount: _this._parent.defaultAccount, defaultBlock: _this._parent.defaultBlock })).createFunction(); - + return call(args.options, args.defaultBlock, args.callback); - + case 'send': - + // return error, if no "from" is specified if(!utils.isAddress(args.options.from)) { return utils._fireError(new Error('No "from" address specified in neither the given options, nor the default options.'), defer.eventEmitter, defer.reject, args.callback); } - + if (_.isBoolean(this._method.payable) && !this._method.payable && args.options.value && args.options.value > 0) { return utils._fireError(new Error('Can not send value to non-payable contract method or constructor'), defer.eventEmitter, defer.reject, args.callback); } - - + + // make sure receipt logs are decoded var extraFormatters = { receiptFormatter: function (receipt) { if (_.isArray(receipt.logs)) { - + // decode logs var events = _.map(receipt.logs, function(log) { return _this._parent._decodeEventABI.call({ @@ -59659,7 +59659,7 @@ jsonInterface: _this._parent.options.jsonInterface }, log); }); - + // make log names keys receipt.events = {}; var count = 0; @@ -59680,7 +59680,7 @@ count++; } }); - + delete receipt.logs; } return receipt; @@ -59691,7 +59691,7 @@ return newContract; } }; - + var sendTransaction = (new Method({ name: 'sendTransaction', call: 'eth_sendTransaction', @@ -59703,17 +59703,17 @@ defaultBlock: _this._parent.defaultBlock, extraFormatters: extraFormatters })).createFunction(); - + return sendTransaction(args.options, args.callback); - + } - + } - + }; - + module.exports = Contract; - + },{"underscore":325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-utils":403}],360:[function(require,module,exports){ /* This file is part of web3.js. @@ -59734,13 +59734,13 @@ * @author Samuel Furter * @date 2018 */ - + "use strict"; - + var config = require('./config'); var Registry = require('./contracts/Registry'); var ResolverMethodHandler = require('./lib/ResolverMethodHandler'); - + /** * Constructs a new instance of ENS * @@ -59751,21 +59751,21 @@ function ENS(eth) { this.eth = eth; } - + Object.defineProperty(ENS.prototype, 'registry', { get: function () { return new Registry(this); }, enumerable: true }); - + Object.defineProperty(ENS.prototype, 'resolverMethodHandler', { get: function () { return new ResolverMethodHandler(this.registry); }, enumerable: true }); - + /** * @param {string} name * @returns {Promise} @@ -59773,7 +59773,7 @@ ENS.prototype.resolver = function (name) { return this.registry.resolver(name); }; - + /** * Returns the address record associated with a name. * @@ -59785,7 +59785,7 @@ ENS.prototype.getAddress = function (name, callback) { return this.resolverMethodHandler.method(name, 'addr', []).call(callback); }; - + /** * Sets a new address * @@ -59799,7 +59799,7 @@ ENS.prototype.setAddress = function (name, address, sendOptions, callback) { return this.resolverMethodHandler.method(name, 'setAddr', [address]).send(sendOptions, callback); }; - + /** * Returns the public key * @@ -59811,7 +59811,7 @@ ENS.prototype.getPubkey = function (name, callback) { return this.resolverMethodHandler.method(name, 'pubkey', [], callback).call(callback); }; - + /** * Set the new public key * @@ -59826,7 +59826,7 @@ ENS.prototype.setPubkey = function (name, x, y, sendOptions, callback) { return this.resolverMethodHandler.method(name, 'setPubkey', [x, y]).send(sendOptions, callback); }; - + /** * Returns the content * @@ -59838,7 +59838,7 @@ ENS.prototype.getContent = function (name, callback) { return this.resolverMethodHandler.method(name, 'content', []).call(callback); }; - + /** * Set the content * @@ -59852,7 +59852,7 @@ ENS.prototype.setContent = function (name, hash, sendOptions, callback) { return this.resolverMethodHandler.method(name, 'setContent', [hash]).send(sendOptions, callback); }; - + /** * Get the multihash * @@ -59864,7 +59864,7 @@ ENS.prototype.getMultihash = function (name, callback) { return this.resolverMethodHandler.method(name, 'multihash', []).call(callback); }; - + /** * Set the multihash * @@ -59878,7 +59878,7 @@ ENS.prototype.setMultihash = function (name, hash, sendOptions, callback) { return this.resolverMethodHandler.method(name, 'multihash', [hash]).send(sendOptions, callback); }; - + /** * Checks if the current used network is synced and looks for ENS support there. * Throws an error if not. @@ -59898,16 +59898,16 @@ if (typeof addr === 'undefined') { throw new Error("ENS is not supported on network " + networkType); } - + return addr; }); }; - + module.exports = ENS; - + },{"./config":361,"./contracts/Registry":362,"./lib/ResolverMethodHandler":364}],361:[function(require,module,exports){ "use strict"; - + var config = { addresses: { main: "0x314159265dD8dbb310642f98f50C066173C1259b", @@ -59915,9 +59915,9 @@ rinkeby: "0xe7410170f87102df0055eb195163a03b7f2bff4a" }, }; - + module.exports = config; - + },{}],362:[function(require,module,exports){ /* This file is part of web3.js. @@ -59938,17 +59938,17 @@ * @author Samuel Furter * @date 2018 */ - + "use strict"; - + var _ = require('underscore'); var Contract = require('web3-eth-contract'); var namehash = require('eth-ens-namehash'); var PromiEvent = require('web3-core-promievent'); var REGISTRY_ABI = require('../ressources/ABI/Registry'); var RESOLVER_ABI = require('../ressources/ABI/Resolver'); - - + + /** * A wrapper around the ENS registry contract. * @@ -59962,11 +59962,11 @@ this.contract = ens.checkNetwork().then(function (address) { var contract = new Contract(REGISTRY_ABI, address); contract.setProvider(self.ens.eth.currentProvider); - + return contract; }); } - + /** * Returns the address of the owner of an ENS name. * @@ -59977,28 +59977,28 @@ */ Registry.prototype.owner = function (name, callback) { var promiEvent = new PromiEvent(true); - + this.contract.then(function (contract) { contract.methods.owner(namehash.hash(name)).call() .then(function (receipt) { promiEvent.resolve(receipt); - + if (_.isFunction(callback)) { callback(receipt); } }) .catch(function (error) { promiEvent.reject(error); - + if (_.isFunction(callback)) { callback(error); } }); }); - + return promiEvent.eventEmitter; }; - + /** * Returns the resolver contract associated with a name. * @@ -60008,7 +60008,7 @@ */ Registry.prototype.resolver = function (name) { var self = this; - + return this.contract.then(function (contract) { return contract.methods.resolver(namehash.hash(name)).call(); }).then(function (address) { @@ -60017,9 +60017,9 @@ return contract; }); }; - + module.exports = Registry; - + },{"../ressources/ABI/Registry":365,"../ressources/ABI/Resolver":366,"eth-ens-namehash":127,"underscore":325,"web3-core-promievent":340,"web3-eth-contract":359}],363:[function(require,module,exports){ /* This file is part of web3.js. @@ -60040,13 +60040,13 @@ * @author Samuel Furter * @date 2018 */ - + "use strict"; - + var ENS = require('./ENS'); - + module.exports = ENS; - + },{"./ENS":360}],364:[function(require,module,exports){ /* This file is part of web3.js. @@ -60067,13 +60067,13 @@ * @author Samuel Furter * @date 2018 */ - + "use strict"; - + var PromiEvent = require('web3-core-promievent'); var namehash = require('eth-ens-namehash'); var _ = require('underscore'); - + /** * @param {Registry} registry * @constructor @@ -60081,7 +60081,7 @@ function ResolverMethodHandler(registry) { this.registry = registry; } - + /** * Executes an resolver method and returns an eventifiedPromise * @@ -60109,7 +60109,7 @@ }) }; }; - + /** * Executes call * @@ -60119,17 +60119,17 @@ var self = this; var promiEvent = new PromiEvent(); var preparedArguments = this.parent.prepareArguments(this.ensName, this.methodArguments); - + this.parent.registry.resolver(this.ensName).then(function (resolver) { self.parent.handleCall(promiEvent, resolver.methods[self.methodName], preparedArguments, callback); }).catch(function (error) { promiEvent.reject(error); }); - + return promiEvent.eventEmitter; }; - - + + /** * Executes send * @@ -60141,16 +60141,16 @@ var self = this; var promiEvent = new PromiEvent(); var preparedArguments = this.parent.prepareArguments(this.ensName, this.methodArguments); - + this.parent.registry.resolver(this.ensName).then(function (resolver) { self.parent.handleSend(promiEvent, resolver.methods[self.methodName], preparedArguments, sendOptions, callback); }).catch(function (error) { promiEvent.reject(error); }); - + return promiEvent.eventEmitter; }; - + /** * Handles a call method * @@ -60164,21 +60164,21 @@ method.apply(this, preparedArguments).call() .then(function (receipt) { promiEvent.resolve(receipt); - + if (_.isFunction(callback)) { callback(receipt); } }).catch(function (error) { promiEvent.reject(error); - + if (_.isFunction(callback)) { callback(error); } }); - + return promiEvent; }; - + /** * Handles a send method * @@ -60200,7 +60200,7 @@ .on('receipt', function (receipt) { promiEvent.eventEmitter.emit('receipt', receipt); promiEvent.resolve(receipt); - + if (_.isFunction(callback)) { callback(receipt); } @@ -60208,15 +60208,15 @@ .on('error', function (error) { promiEvent.eventEmitter.emit('error', error); promiEvent.reject(error); - + if (_.isFunction(callback)) { callback(error); } }); - + return promiEvent; }; - + /** * Adds the ENS node to the arguments * @@ -60226,21 +60226,21 @@ */ ResolverMethodHandler.prototype.prepareArguments = function (name, methodArguments) { var node = namehash.hash(name); - + if (methodArguments.length > 0) { methodArguments.unshift(node); - + return methodArguments; } - + return [node]; }; - + module.exports = ResolverMethodHandler; - + },{"eth-ens-namehash":127,"underscore":325,"web3-core-promievent":340}],365:[function(require,module,exports){ "use strict"; - + var REGISTRY = [ { "constant": true, @@ -60442,12 +60442,12 @@ "type": "event" } ]; - + module.exports = REGISTRY; - + },{}],366:[function(require,module,exports){ "use strict"; - + var RESOLVER = [ { "constant": true, @@ -60800,25 +60800,25 @@ "type": "event" } ]; - + module.exports = RESOLVER; - + },{}],367:[function(require,module,exports){ arguments[4][154][0].apply(exports,arguments) },{"dup":154}],368:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -60830,13 +60830,13 @@ * @author Marek Kotewicz * @date 2015 */ - + "use strict"; - + var utils = require('web3-utils'); var BigNumber = require('bn.js'); - - + + var leftPad = function (string, bytes) { var result = string; while (result.length < bytes * 2) { @@ -60844,7 +60844,7 @@ } return result; }; - + /** * Prepare an IBAN for mod 97 computation by moving the first 4 chars to the end and transforming the letters to * numbers (A = 10, B = 11, ..., Z = 35), as specified in ISO13616. @@ -60856,10 +60856,10 @@ var iso13616Prepare = function (iban) { var A = 'A'.charCodeAt(0); var Z = 'Z'.charCodeAt(0); - + iban = iban.toUpperCase(); iban = iban.substr(4) + iban.substr(0,4); - + return iban.split('').map(function(n){ var code = n.charCodeAt(0); if (code >= A && code <= Z){ @@ -60870,7 +60870,7 @@ } }).join(''); }; - + /** * Calculates the MOD 97 10 of the passed IBAN as specified in ISO7064. * @@ -60881,15 +60881,15 @@ var mod9710 = function (iban) { var remainder = iban, block; - + while (remainder.length > 2){ block = remainder.slice(0, 9); remainder = parseInt(block, 10) % 97 + remainder.slice(block.length); } - + return parseInt(remainder, 10) % 97; }; - + /** * This prototype should be used to create iban object from iban correct string * @@ -60898,7 +60898,7 @@ var Iban = function Iban(iban) { this._iban = iban; }; - + /** * This method should be used to create an ethereum address from a direct iban address * @@ -60908,14 +60908,14 @@ */ Iban.toAddress = function (ib) { ib = new Iban(ib); - + if(!ib.isDirect()) { throw new Error('IBAN is indirect and can\'t be converted'); } - + return ib.toAddress(); }; - + /** * This method should be used to create iban address from an ethereum address * @@ -60926,7 +60926,7 @@ Iban.toIban = function (address) { return Iban.fromAddress(address).toString(); }; - + /** * This method should be used to create iban object from an ethereum address * @@ -60938,15 +60938,15 @@ if(!utils.isAddress(address)){ throw new Error('Provided address is not a valid address: '+ address); } - + address = address.replace('0x','').replace('0X',''); - + var asBn = new BigNumber(address, 16); var base36 = asBn.toString(36); var padded = leftPad(base36, 15); return Iban.fromBban(padded.toUpperCase()); }; - + /** * Convert the passed BBAN to an IBAN for this country specification. * Please note that "generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account". @@ -60958,13 +60958,13 @@ */ Iban.fromBban = function (bban) { var countryCode = 'XE'; - + var remainder = mod9710(iso13616Prepare(countryCode + '00' + bban)); var checkDigit = ('0' + (98 - remainder)).slice(-2); - + return new Iban(countryCode + checkDigit + bban); }; - + /** * Should be used to create IBAN object for given institution and identifier * @@ -60975,7 +60975,7 @@ Iban.createIndirect = function (options) { return Iban.fromBban('ETH' + options.institution + options.identifier); }; - + /** * This method should be used to check if given string is valid iban object * @@ -60987,7 +60987,7 @@ var i = new Iban(iban); return i.isValid(); }; - + /** * Should be called to check if iban is correct * @@ -60998,7 +60998,7 @@ return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) && mod9710(iso13616Prepare(this._iban)) === 1; }; - + /** * Should be called to check if iban number is direct * @@ -61008,7 +61008,7 @@ Iban.prototype.isDirect = function () { return this._iban.length === 34 || this._iban.length === 35; }; - + /** * Should be called to check if iban number if indirect * @@ -61018,7 +61018,7 @@ Iban.prototype.isIndirect = function () { return this._iban.length === 20; }; - + /** * Should be called to get iban checksum * Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003) @@ -61029,7 +61029,7 @@ Iban.prototype.checksum = function () { return this._iban.substr(2, 2); }; - + /** * Should be called to get institution identifier * eg. XREG @@ -61040,7 +61040,7 @@ Iban.prototype.institution = function () { return this.isIndirect() ? this._iban.substr(7, 4) : ''; }; - + /** * Should be called to get client identifier within institution * eg. GAVOFYORK @@ -61051,7 +61051,7 @@ Iban.prototype.client = function () { return this.isIndirect() ? this._iban.substr(11) : ''; }; - + /** * Should be called to get client direct address * @@ -61064,30 +61064,30 @@ var asBn = new BigNumber(base36, 36); return utils.toChecksumAddress(asBn.toString(16, 20)); } - + return ''; }; - + Iban.prototype.toString = function () { return this._iban; }; - + module.exports = Iban; - + },{"bn.js":367,"web3-utils":403}],369:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -61096,28 +61096,28 @@ * @author Fabian Vogelsteller * @date 2017 */ - + "use strict"; - + var core = require('web3-core'); var Method = require('web3-core-method'); var utils = require('web3-utils'); var Net = require('web3-net'); - + var formatters = require('web3-core-helpers').formatters; - - + + var Personal = function Personal() { var _this = this; - + // sets _requestmanager core.packageInit(this, arguments); - + this.net = new Net(this.currentProvider); - + var defaultAccount = null; var defaultBlock = 'latest'; - + Object.defineProperty(this, 'defaultAccount', { get: function () { return defaultAccount; @@ -61126,12 +61126,12 @@ if(val) { defaultAccount = utils.toChecksumAddress(formatters.inputAddressFormatter(val)); } - + // update defaultBlock methods.forEach(function(method) { method.defaultAccount = defaultAccount; }); - + return val; }, enumerable: true @@ -61142,18 +61142,18 @@ }, set: function (val) { defaultBlock = val; - + // update defaultBlock methods.forEach(function(method) { method.defaultBlock = defaultBlock; }); - + return val; }, enumerable: true }); - - + + var methods = [ new Method({ name: 'getAccounts', @@ -61217,29 +61217,29 @@ method.defaultAccount = _this.defaultAccount; }); }; - + core.addProviders(Personal); - - - + + + module.exports = Personal; - - - + + + },{"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-net":372,"web3-utils":403}],370:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -61248,26 +61248,26 @@ * @author Fabian Vogelsteller * @date 2017 */ - + "use strict"; - + var _ = require('underscore'); - + var getNetworkType = function (callback) { var _this = this, id; - - + + return this.net.getId() .then(function (givenId) { - + id = givenId; - + return _this.getBlock(0); }) .then(function (genesis) { var returnValue = 'private'; - + if (genesis.hash === '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3' && id === 1) { returnValue = 'main'; @@ -61288,11 +61288,11 @@ id === 42) { returnValue = 'kovan'; } - + if (_.isFunction(callback)) { callback(null, returnValue); } - + return returnValue; }) .catch(function (err) { @@ -61303,23 +61303,23 @@ } }); }; - + module.exports = getNetworkType; - + },{"underscore":325}],371:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -61328,9 +61328,9 @@ * @author Fabian Vogelsteller * @date 2017 */ - + "use strict"; - + var _ = require('underscore'); var core = require('web3-core'); var helpers = require('web3-core-helpers'); @@ -61338,45 +61338,45 @@ var Method = require('web3-core-method'); var utils = require('web3-utils'); var Net = require('web3-net'); - + var ENS = require('web3-eth-ens'); var Personal = require('web3-eth-personal'); var BaseContract = require('web3-eth-contract'); var Iban = require('web3-eth-iban'); var Accounts = require('web3-eth-accounts'); var abi = require('web3-eth-abi'); - + var getNetworkType = require('./getNetworkType.js'); var formatter = helpers.formatters; - - + + var blockCall = function (args) { return (_.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber"; }; - + var transactionFromBlockCall = function (args) { return (_.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex'; }; - + var uncleCall = function (args) { return (_.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex'; }; - + var getBlockTransactionCountCall = function (args) { return (_.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber'; }; - + var uncleCountCall = function (args) { return (_.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber'; }; - - + + var Eth = function Eth() { var _this = this; - + // sets _requestmanager core.packageInit(this, arguments); - + // overwrite setProvider var setProvider = this.setProvider; this.setProvider = function () { @@ -61386,11 +61386,11 @@ _this.accounts.setProvider.apply(_this, arguments); _this.Contract.setProvider(_this.currentProvider, _this.accounts); }; - - + + var defaultAccount = null; var defaultBlock = 'latest'; - + Object.defineProperty(this, 'defaultAccount', { get: function () { return defaultAccount; @@ -61399,16 +61399,16 @@ if(val) { defaultAccount = utils.toChecksumAddress(formatter.inputAddressFormatter(val)); } - + // also set on the Contract object _this.Contract.defaultAccount = defaultAccount; _this.personal.defaultAccount = defaultAccount; - + // update defaultBlock methods.forEach(function(method) { method.defaultAccount = defaultAccount; }); - + return val; }, enumerable: true @@ -61422,32 +61422,32 @@ // also set on the Contract object _this.Contract.defaultBlock = defaultBlock; _this.personal.defaultBlock = defaultBlock; - + // update defaultBlock methods.forEach(function(method) { method.defaultBlock = defaultBlock; }); - + return val; }, enumerable: true }); - - + + this.clearSubscriptions = _this._requestManager.clearSubscriptions; - + // add net this.net = new Net(this.currentProvider); // add chain detection this.net.getNetworkType = getNetworkType.bind(this); - + // add accounts this.accounts = new Accounts(this.currentProvider); - + // add personal this.personal = new Personal(this.currentProvider); this.personal.defaultAccount = this.defaultAccount; - + // create a proxy Contract type for this instance, as a Contract's provider // is stored as a class member rather than an instance variable. If we do // not create this proxy type, changing the provider in one instance of @@ -61456,7 +61456,7 @@ var self = this; var Contract = function Contract() { BaseContract.apply(this, arguments); - + // when Eth.setProvider is called, call packageInit // on all contract instances instantiated via this Eth // instances. This will update the currentProvider for @@ -61468,31 +61468,31 @@ core.packageInit(_this, [self.currentProvider]); }; }; - + Contract.setProvider = function() { BaseContract.setProvider.apply(this, arguments); }; - + // make our proxy Contract inherit from web3-eth-contract so that it has all // the right functionality and so that instanceof and friends work properly Contract.prototype = Object.create(BaseContract.prototype); Contract.prototype.constructor = Contract; - + // add contract this.Contract = Contract; this.Contract.defaultAccount = this.defaultAccount; this.Contract.defaultBlock = this.defaultBlock; this.Contract.setProvider(this.currentProvider, this.accounts); - + // add IBAN this.Iban = Iban; - + // add ABI this.abi = abi; - + // add ENS this.ens = new ENS(this); - + var methods = [ new Method({ name: 'getNodeInfo', @@ -61575,7 +61575,7 @@ params: 2, inputFormatter: [formatter.inputBlockNumberFormatter, utils.numberToHex], outputFormatter: formatter.outputBlockFormatter, - + }), new Method({ name: 'getBlockTransactionCount', @@ -61677,7 +61677,7 @@ inputFormatter: [formatter.inputLogFormatter], outputFormatter: formatter.outputLogFormatter }), - + // subscriptions new Subscriptions({ name: 'subscribe', @@ -61704,7 +61704,7 @@ } else { this.emit('data', output); } - + if (_.isFunction(this.callback)) { this.callback(null, output, this); } @@ -61715,38 +61715,38 @@ outputFormatter: formatter.outputSyncingFormatter, subscriptionHandler: function (output) { var _this = this; - + // fire TRUE at start if(this._isSyncing !== true) { this._isSyncing = true; this.emit('changed', _this._isSyncing); - + if (_.isFunction(this.callback)) { this.callback(null, _this._isSyncing, this); } - + setTimeout(function () { _this.emit('data', output); - + if (_.isFunction(_this.callback)) { _this.callback(null, output, _this); } }, 0); - + // fire sync status } else { this.emit('data', output); if (_.isFunction(_this.callback)) { this.callback(null, output, this); } - + // wait for some time before fireing the FALSE clearTimeout(this._isSyncingTimeout); this._isSyncingTimeout = setTimeout(function () { if(output.currentBlock > output.highestBlock - 200) { _this._isSyncing = false; _this.emit('changed', _this._isSyncing); - + if (_.isFunction(_this.callback)) { _this.callback(null, _this._isSyncing, _this); } @@ -61758,36 +61758,36 @@ } }) ]; - + methods.forEach(function(method) { method.attachToObject(_this); method.setRequestManager(_this._requestManager, _this.accounts); // second param means is eth.accounts (necessary for wallet signing) method.defaultBlock = _this.defaultBlock; method.defaultAccount = _this.defaultAccount; }); - + }; - + core.addProviders(Eth); - - + + module.exports = Eth; - - + + },{"./getNetworkType.js":370,"underscore":325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-eth-accounts":358,"web3-eth-contract":359,"web3-eth-ens":363,"web3-eth-iban":368,"web3-eth-personal":369,"web3-net":372,"web3-utils":403}],372:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -61796,21 +61796,21 @@ * @author Fabian Vogelsteller * @date 2017 */ - + "use strict"; - + var core = require('web3-core'); var Method = require('web3-core-method'); var utils = require('web3-utils'); - - + + var Net = function () { var _this = this; - + // sets _requestmanager core.packageInit(this, arguments); - - + + [ new Method({ name: 'getId', @@ -61833,16 +61833,16 @@ method.attachToObject(_this); method.setRequestManager(_this._requestManager); }); - + }; - + core.addProviders(Net); - - + + module.exports = Net; - - - + + + },{"web3-core":348,"web3-core-method":339,"web3-utils":403}],373:[function(require,module,exports){ const EventEmitter = require('events').EventEmitter const inherits = require('util').inherits @@ -61854,19 +61854,19 @@ const cacheUtils = require('./util/rpc-cache-utils.js') const createPayload = require('./util/create-payload.js') const noop = function(){} - + module.exports = Web3ProviderEngine - - + + inherits(Web3ProviderEngine, EventEmitter) - + function Web3ProviderEngine(opts) { const self = this EventEmitter.call(self) self.setMaxListeners(30) // parse options opts = opts || {} - + // block polling const directProvider = { sendAsync: self._handleAsync.bind(self) } const blockTrackerProvider = opts.blockTrackerProvider || directProvider @@ -61874,18 +61874,18 @@ provider: blockTrackerProvider, pollingInterval: opts.pollingInterval || 4000, }) - + // handle new block self._blockTracker.on('block', (jsonBlock) => { const bufferBlock = toBufferBlock(jsonBlock) self._setCurrentBlock(bufferBlock) }) - + // emit block events from the block tracker self._blockTracker.on('block', self.emit.bind(self, 'rawBlock')) self._blockTracker.on('sync', self.emit.bind(self, 'sync')) self._blockTracker.on('latest', self.emit.bind(self, 'latest')) - + // set initialization blocker self._ready = new Stoplight() // unblock initialization after first block @@ -61896,35 +61896,35 @@ self.currentBlock = null self._providers = [] } - + // public - + Web3ProviderEngine.prototype.start = function(cb = noop){ const self = this // start block polling self._blockTracker.start().then(cb).catch(cb) } - + Web3ProviderEngine.prototype.stop = function(){ const self = this // stop block polling self._blockTracker.stop() } - + Web3ProviderEngine.prototype.addProvider = function(source){ const self = this self._providers.push(source) source.setEngine(this) } - + Web3ProviderEngine.prototype.send = function(payload){ throw new Error('Web3ProviderEngine does not support synchronous requests.') } - + Web3ProviderEngine.prototype.sendAsync = function(payload, cb){ const self = this self._ready.await(function(){ - + if (Array.isArray(payload)) { // handle batch map(payload, self._handleAsync.bind(self), cb) @@ -61932,26 +61932,26 @@ // handle single self._handleAsync(payload, cb) } - + }) } - + // private - + Web3ProviderEngine.prototype._handleAsync = function(payload, finished) { var self = this var currentProvider = -1 var result = null var error = null - + var stack = [] - + next() - + function next(after) { currentProvider += 1 stack.unshift(after) - + // Bubbled down as far as we could go, and the request wasn't // handled. Return an error. if (currentProvider >= self._providers.length) { @@ -61965,13 +61965,13 @@ } } } - + function end(_error, _result) { error = _error result = _result - + eachSeries(stack, function(fn, callback) { - + if (fn) { fn(error, result, callback) } else { @@ -61980,13 +61980,13 @@ }, function() { // console.log('COMPLETED:', payload) // console.log('RESULT: ', result) - + var resultObj = { id: payload.id, jsonrpc: payload.jsonrpc, result: result } - + if (error != null) { resultObj.error = { message: error.stack || error.message || error, @@ -62000,19 +62000,19 @@ }) } } - + // // from remote-data // - + Web3ProviderEngine.prototype._setCurrentBlock = function(block){ const self = this self.currentBlock = block self.emit('block', block) } - + // util - + function toBufferBlock (jsonBlock) { return { number: ethUtil.toBuffer(jsonBlock.number), @@ -62036,10 +62036,10 @@ transactions: jsonBlock.transactions, } } - + },{"./util/create-payload.js":391,"./util/rpc-cache-utils.js":394,"./util/stoplight.js":396,"async/eachSeries":25,"async/map":41,"eth-block-tracker":126,"ethereumjs-util":141,"events":157,"util":333}],374:[function(require,module,exports){ var json = typeof JSON !== 'undefined' ? JSON : require('jsonify'); - + module.exports = function (obj, opts) { if (!opts) opts = {}; if (typeof opts === 'function') opts = { cmp: opts }; @@ -62047,7 +62047,7 @@ if (typeof space === 'number') space = Array(space+1).join(' '); var cycles = (typeof opts.cycles === 'boolean') ? opts.cycles : false; var replacer = opts.replacer || function(key, value) { return value; }; - + var cmp = opts.cmp && (function (f) { return function (node) { return function (a, b) { @@ -62057,18 +62057,18 @@ }; }; })(opts.cmp); - + var seen = []; return (function stringify (parent, key, node, level) { var indent = space ? ('\n' + new Array(level + 1).join(space)) : ''; var colonSeparator = space ? ': ' : ':'; - + if (node && node.toJSON && typeof node.toJSON === 'function') { node = node.toJSON(); } - + node = replacer.call(parent, key, node); - + if (node === undefined) { return; } @@ -62089,15 +62089,15 @@ throw new TypeError('Converting circular structure to JSON'); } else seen.push(node); - + var keys = objectKeys(node).sort(cmp && cmp(node)); var out = []; for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = stringify(node, key, node[key], level+1); - + if(!value) continue; - + var keyValue = json.stringify(key) + colonSeparator + value; @@ -62109,11 +62109,11 @@ } })({ '': obj }, '', obj, 0); }; - + var isArray = Array.isArray || function (x) { return {}.toString.call(x) === '[object Array]'; }; - + var objectKeys = Object.keys || function (obj) { var has = Object.prototype.hasOwnProperty || function () { return true }; var keys = []; @@ -62122,7 +62122,7 @@ } return keys; }; - + },{"jsonify":192}],375:[function(require,module,exports){ module.exports={ "_from": "web3-provider-engine@14.1.0", @@ -62210,7 +62210,7 @@ }, "version": "14.1.0" } - + },{}],376:[function(require,module,exports){ const inherits = require('util').inherits const ethUtil = require('ethereumjs-util') @@ -62219,11 +62219,11 @@ const cacheUtils = require('../util/rpc-cache-utils.js') const Stoplight = require('../util/stoplight.js') const Subprovider = require('./subprovider.js') - + module.exports = BlockCacheProvider - + inherits(BlockCacheProvider, Subprovider) - + function BlockCacheProvider(opts) { const self = this opts = opts || {} @@ -62238,7 +62238,7 @@ fork: new BlockCacheStrategy(self), } } - + // setup a block listener on 'setEngine' BlockCacheProvider.prototype.setEngine = function(engine) { const self = this @@ -62250,7 +62250,7 @@ // from now on, empty old cache every block engine.on('block', clearOldCache) }) - + function clearOldCache(newBlock) { var previousBlock = self.currentBlock self.currentBlock = newBlock @@ -62259,49 +62259,49 @@ self.strategies.fork.cacheRollOff(previousBlock) } } - + BlockCacheProvider.prototype.handleRequest = function(payload, next, end){ const self = this - + // skip cache if told to do so if (payload.skipCache) { // console.log('CACHE SKIP - skip cache if told to do so') return next() } - + // Ignore block polling requests. if (payload.method === 'eth_getBlockByNumber' && payload.params[0] === 'latest') { // console.log('CACHE SKIP - Ignore block polling requests.') return next() } - + // wait for first block self._ready.await(function(){ // actually handle the request self._handleRequest(payload, next, end) }) } - + BlockCacheProvider.prototype._handleRequest = function(payload, next, end){ const self = this - + var type = cacheUtils.cacheTypeForPayload(payload) var strategy = this.strategies[type] - + // If there's no strategy in place, pass it down the chain. if (!strategy) { return next() } - + // If the strategy can't cache this request, ignore it. if (!strategy.canCache(payload)) { return next() } - + var blockTag = cacheUtils.blockTagForPayload(payload) if (!blockTag) blockTag = 'latest' var requestedBlockNumber - + if (blockTag === 'earliest') { requestedBlockNumber = '0x00' } else if (blockTag === 'latest') { @@ -62310,9 +62310,9 @@ // We have a hex number requestedBlockNumber = blockTag } - + //console.log('REQUEST at block 0x' + requestedBlockNumber.toString('hex')) - + // end on a hit, continue on a miss strategy.hitCheck(payload, requestedBlockNumber, end, function() { // miss fallthrough to provider chain, caching the result on the way back up. @@ -62323,11 +62323,11 @@ }) }) } - + // // Cache Strategies // - + function PermaCacheStrategy() { var self = this self.cache = {} @@ -62338,13 +62338,13 @@ // do not require the Node.js event loop to remain active if (timeout.unref) timeout.unref() } - + PermaCacheStrategy.prototype.hitCheck = function(payload, requestedBlockNumber, hit, miss) { var identifier = cacheUtils.cacheIdentifierForPayload(payload) var cached = this.cache[identifier] - + if (!cached) return miss() - + // If the block number we're requesting at is greater than or // equal to the block where we cached a previous response, // the cache is valid. If it's from earlier than the cache, @@ -62357,10 +62357,10 @@ return miss() } } - + PermaCacheStrategy.prototype.cacheResult = function(payload, result, requestedBlockNumber, callback) { var identifier = cacheUtils.cacheIdentifierForPayload(payload) - + if (result) { var clonedValue = clone(result) this.cache[identifier] = { @@ -62368,30 +62368,30 @@ result: clonedValue, } } - + callback() } - + PermaCacheStrategy.prototype.canCache = function(payload) { return cacheUtils.canCache(payload) } - + // // ConditionalPermaCacheStrategy // - + function ConditionalPermaCacheStrategy(conditionals) { this.strategy = new PermaCacheStrategy() this.conditionals = conditionals } - + ConditionalPermaCacheStrategy.prototype.hitCheck = function(payload, requestedBlockNumber, hit, miss) { return this.strategy.hitCheck(payload, requestedBlockNumber, hit, miss) } - + ConditionalPermaCacheStrategy.prototype.cacheResult = function(payload, result, requestedBlockNumber, callback) { var conditional = this.conditionals[payload.method] - + if (conditional) { if (conditional(result)) { this.strategy.cacheResult(payload, result, requestedBlockNumber, callback) @@ -62403,19 +62403,19 @@ this.strategy.cacheResult(payload, result, requestedBlockNumber, callback) } } - + ConditionalPermaCacheStrategy.prototype.canCache = function(payload) { return this.strategy.canCache(payload) } - + // // BlockCacheStrategy // - + function BlockCacheStrategy() { this.cache = {} } - + BlockCacheStrategy.prototype.getBlockCacheForPayload = function(payload, blockNumberHex) { const blockNumber = Number.parseInt(blockNumberHex, 16) let blockCache = this.cache[blockNumber] @@ -62427,24 +62427,24 @@ } return blockCache } - + BlockCacheStrategy.prototype.hitCheck = function(payload, requestedBlockNumber, hit, miss) { var blockCache = this.getBlockCacheForPayload(payload, requestedBlockNumber) - + if (!blockCache) { return miss() } - + var identifier = cacheUtils.cacheIdentifierForPayload(payload) var cached = blockCache[identifier] - + if (cached) { return hit(null, cached) } else { return miss() } } - + BlockCacheStrategy.prototype.cacheResult = function(payload, result, requestedBlockNumber, callback) { if (result) { var blockCache = this.getBlockCacheForPayload(payload, requestedBlockNumber) @@ -62453,17 +62453,17 @@ } callback() } - + BlockCacheStrategy.prototype.canCache = function(payload) { if (!cacheUtils.canCache(payload)) { return false } - + var blockTag = cacheUtils.blockTagForPayload(payload) - + return (blockTag !== 'pending') } - + // naively removes older block caches BlockCacheStrategy.prototype.cacheRollOff = function(previousBlock){ const self = this @@ -62475,37 +62475,37 @@ .filter(num => num <= oldBlockNumber) .forEach(num => delete self.cache[num]) } - - + + // util - + function compareHex(hexA, hexB){ var numA = parseInt(hexA, 16) var numB = parseInt(hexB, 16) return numA === numB ? 0 : (numA > numB ? 1 : -1 ) } - + function hexToBN(hex){ return new BN(ethUtil.toBuffer(hex)) } - + function containsBlockhash(result) { if (!result) return false if (!result.blockHash) return false const hasNonZeroHash = hexToBN(result.blockHash).gt(new BN(0)) return hasNonZeroHash } - + },{"../util/rpc-cache-utils.js":394,"../util/stoplight.js":396,"./subprovider.js":387,"clone":87,"ethereumjs-util":141,"util":333}],377:[function(require,module,exports){ const inherits = require('util').inherits const extend = require('xtend') const FixtureProvider = require('./fixture.js') const version = require('../package.json').version - + module.exports = DefaultFixtures - + inherits(DefaultFixtures, FixtureProvider) - + function DefaultFixtures(opts) { const self = this opts = opts || {} @@ -62517,7 +62517,7 @@ }, opts) FixtureProvider.call(self, responses) } - + },{"../package.json":375,"./fixture.js":380,"util":333,"xtend":423}],378:[function(require,module,exports){ const fetch = require('cross-fetch') const inherits = require('util').inherits @@ -62528,7 +62528,7 @@ const promiseToCallback = require('promise-to-callback') const createPayload = require('../util/create-payload.js') const Subprovider = require('./subprovider.js') - + const RETRIABLE_ERRORS = [ // ignore server overload errors 'Gateway timeout', @@ -62537,26 +62537,26 @@ // or truncated json responses 'SyntaxError', ] - + module.exports = RpcSource - + inherits(RpcSource, Subprovider) - + function RpcSource (opts) { const self = this self.rpcUrl = opts.rpcUrl self.originHttpHeaderKey = opts.originHttpHeaderKey } - + RpcSource.prototype.handleRequest = function (payload, next, end) { const self = this const originDomain = payload.origin - + // overwrite id to not conflict with other concurrent users const newPayload = createPayload(payload) // remove extra parameter from request delete newPayload.origin - + const reqParams = { method: 'POST', headers: { @@ -62565,11 +62565,11 @@ }, body: JSON.stringify(newPayload) } - + if (self.originHttpHeaderKey && originDomain) { reqParams.headers[self.originHttpHeaderKey] = originDomain } - + retry({ times: 5, interval: 1000, @@ -62587,14 +62587,14 @@ return end(err, result) }) } - + RpcSource.prototype._submitRequest = function (reqParams, cb) { const self = this const targetUrl = self.rpcUrl - + promiseToCallback(fetch(targetUrl, reqParams))((err, res) => { if (err) return cb(err) - + // continue parsing result waterfall([ checkForHttpErrors, @@ -62604,25 +62604,25 @@ asyncify((rawBody) => JSON.parse(rawBody)), parseResponse ], cb) - + function checkForHttpErrors (cb) { // check for errors switch (res.status) { case 405: return cb(new JsonRpcError.MethodNotFound()) - + case 418: return cb(createRatelimitError()) - + case 503: case 504: return cb(createTimeoutError()) - + default: return cb() } } - + function parseResponse (body, cb) { // check for error code if (res.status !== 200) { @@ -62635,25 +62635,25 @@ } }) } - + function isErrorRetriable(err){ const errMsg = err.toString() return RETRIABLE_ERRORS.some(phrase => errMsg.includes(phrase)) } - + function createRatelimitError () { let msg = `Request is being rate limited.` const err = new Error(msg) return new JsonRpcError.InternalError(err) } - + function createTimeoutError () { let msg = `Gateway timeout. The request took too long to process. ` msg += `This can happen when querying logs over too wide a block range.` const err = new Error(msg) return new JsonRpcError.InternalError(err) } - + },{"../util/create-payload.js":391,"./subprovider.js":387,"async/asyncify":20,"async/retry":43,"async/waterfall":44,"cross-fetch":96,"json-rpc-error":189,"promise-to-callback":258,"util":333}],379:[function(require,module,exports){ const async = require('async') const inherits = require('util').inherits @@ -62661,9 +62661,9 @@ const Subprovider = require('./subprovider.js') const Stoplight = require('../util/stoplight.js') const EventEmitter = require('events').EventEmitter - + module.exports = FilterSubprovider - + // handles the following RPC methods: // eth_newBlockFilter // eth_newPendingTransactionFilter @@ -62671,9 +62671,9 @@ // eth_getFilterChanges // eth_uninstallFilter // eth_getFilterLogs - + inherits(FilterSubprovider, Subprovider) - + function FilterSubprovider(opts) { opts = opts || {} const self = this @@ -62687,7 +62687,7 @@ self._ready.go() self.pendingBlockTimeout = opts.pendingBlockTimeout || 4000 self.checkForPendingBlocksActive = false - + // we dont have engine immeditately setTimeout(function(){ // asyncBlockHandlers require locking provider until updates are completed @@ -62704,81 +62704,81 @@ }) }) }) - + } - + FilterSubprovider.prototype.handleRequest = function(payload, next, end){ const self = this switch(payload.method){ - + case 'eth_newBlockFilter': self.newBlockFilter(end) return - + case 'eth_newPendingTransactionFilter': self.newPendingTransactionFilter(end) self.checkForPendingBlocks() return - + case 'eth_newFilter': self.newLogFilter(payload.params[0], end) return - + case 'eth_getFilterChanges': self._ready.await(function(){ self.getFilterChanges(payload.params[0], end) }) return - + case 'eth_getFilterLogs': self._ready.await(function(){ self.getFilterLogs(payload.params[0], end) }) return - + case 'eth_uninstallFilter': self._ready.await(function(){ self.uninstallFilter(payload.params[0], end) }) return - + default: next() return } } - + FilterSubprovider.prototype.newBlockFilter = function(cb) { const self = this - + self._getBlockNumber(function(err, blockNumber){ if (err) return cb(err) - + var filter = new BlockFilter({ blockNumber: blockNumber, }) - + var newBlockHandler = filter.update.bind(filter) self.engine.on('block', newBlockHandler) var destroyHandler = function(){ self.engine.removeListener('block', newBlockHandler) } - + self.filterIndex++ self.filters[self.filterIndex] = filter self.filterDestroyHandlers[self.filterIndex] = destroyHandler - + var hexFilterIndex = intToHex(self.filterIndex) cb(null, hexFilterIndex) }) } - + FilterSubprovider.prototype.newLogFilter = function(opts, cb) { const self = this - + self._getBlockNumber(function(err, blockNumber){ if (err) return cb(err) - + var filter = new LogFilter(opts) var newLogHandler = filter.update.bind(filter) var blockHandler = function(block, cb){ @@ -62788,19 +62788,19 @@ cb() }) } - + self.filterIndex++ self.asyncBlockHandlers[self.filterIndex] = blockHandler self.filters[self.filterIndex] = filter - + var hexFilterIndex = intToHex(self.filterIndex) cb(null, hexFilterIndex) }) } - + FilterSubprovider.prototype.newPendingTransactionFilter = function(cb) { const self = this - + var filter = new PendingTransactionFilter() var newTxHandler = filter.update.bind(filter) var blockHandler = function(block, cb){ @@ -62810,18 +62810,18 @@ cb() }) } - + self.filterIndex++ self.asyncPendingBlockHandlers[self.filterIndex] = blockHandler self.filters[self.filterIndex] = filter - + var hexFilterIndex = intToHex(self.filterIndex) cb(null, hexFilterIndex) } - + FilterSubprovider.prototype.getFilterChanges = function(hexFilterId, cb) { const self = this - + var filterId = Number.parseInt(hexFilterId, 16) var filter = self.filters[filterId] if (!filter) console.warn('FilterSubprovider - no filter with that id:', hexFilterId) @@ -62830,10 +62830,10 @@ filter.clearChanges() cb(null, results) } - + FilterSubprovider.prototype.getFilterLogs = function(hexFilterId, cb) { const self = this - + var filterId = Number.parseInt(hexFilterId, 16) var filter = self.filters[filterId] if (!filter) console.warn('FilterSubprovider - no filter with that id:', hexFilterId) @@ -62856,31 +62856,31 @@ cb(null, results) } } - + FilterSubprovider.prototype.uninstallFilter = function(hexFilterId, cb) { const self = this - + var filterId = Number.parseInt(hexFilterId, 16) var filter = self.filters[filterId] if (!filter) { cb(null, false) return } - + self.filters[filterId].removeAllListeners() - + var destroyHandler = self.filterDestroyHandlers[filterId] delete self.filters[filterId] delete self.asyncBlockHandlers[filterId] delete self.asyncPendingBlockHandlers[filterId] delete self.filterDestroyHandlers[filterId] if (destroyHandler) destroyHandler() - + cb(null, true) } - + // private - + // check for pending blocks FilterSubprovider.prototype.checkForPendingBlocks = function(){ const self = this @@ -62905,7 +62905,7 @@ }) } } - + FilterSubprovider.prototype.onNewPendingBlock = function(block, cb){ const self = this // update filters @@ -62913,13 +62913,13 @@ .map(function(fn){ return fn.bind(null, block) }) async.parallel(updaters, cb) } - + FilterSubprovider.prototype._getBlockNumber = function(cb) { const self = this var blockNumber = bufferToNumberHex(self.engine.currentBlock.number) cb(null, blockNumber) } - + FilterSubprovider.prototype._logsForBlock = function(block, cb) { const self = this var blockNumber = bufferToNumberHex(block.number) @@ -62934,9 +62934,9 @@ if (response.error) return cb(response.error) cb(null, response.result) }) - + } - + FilterSubprovider.prototype._txHashesForBlock = function(block, cb) { const self = this var txs = block.transactions @@ -62951,13 +62951,13 @@ cb(null, results) } } - + // // BlockFilter // - + inherits(BlockFilter, EventEmitter) - + function BlockFilter(opts) { // console.log('BlockFilter - new') const self = this @@ -62967,7 +62967,7 @@ self.blockNumber = opts.blockNumber self.updates = [] } - + BlockFilter.prototype.update = function(block){ // console.log('BlockFilter - update') const self = this @@ -62975,26 +62975,26 @@ self.updates.push(blockHash) self.emit('data', block) } - + BlockFilter.prototype.getChanges = function(){ const self = this var results = self.updates // console.log('BlockFilter - getChanges:', results.length) return results } - + BlockFilter.prototype.clearChanges = function(){ // console.log('BlockFilter - clearChanges') const self = this self.updates = [] } - + // // LogFilter // - + inherits(LogFilter, EventEmitter) - + function LogFilter(opts) { // console.log('LogFilter - new') const self = this @@ -63008,21 +63008,21 @@ self.updates = [] self.allResults = [] } - + LogFilter.prototype.validateLog = function(log){ // console.log('LogFilter - validateLog:', log) const self = this - + // check if block number in bounds: // console.log('LogFilter - validateLog - blockNumber', self.fromBlock, self.toBlock) if (blockTagIsNumber(self.fromBlock) && hexToInt(self.fromBlock) >= hexToInt(log.blockNumber)) return false if (blockTagIsNumber(self.toBlock) && hexToInt(self.toBlock) <= hexToInt(log.blockNumber)) return false - + // address is correct: // console.log('LogFilter - validateLog - address', self.address) if (self.address && !(self.address.map((a) => a.toLowerCase()).includes( log.address.toLowerCase()))) return false - + // topics match: // topics are position-dependant // topics can be nested to represent `or` [[a || b], c] @@ -63044,11 +63044,11 @@ }).length > 0 return topicDoesMatch }, true) - + // console.log('LogFilter - validateLog - '+(topicsMatch ? 'approved!' : 'denied!')+' ==============') return topicsMatch } - + LogFilter.prototype.update = function(logs){ // console.log('LogFilter - update') const self = this @@ -63066,33 +63066,33 @@ self.emit('data', validLogs) } } - + LogFilter.prototype.getChanges = function(){ // console.log('LogFilter - getChanges') const self = this var results = self.updates return results } - + LogFilter.prototype.getAllResults = function(){ // console.log('LogFilter - getAllResults') const self = this var results = self.allResults return results } - + LogFilter.prototype.clearChanges = function(){ // console.log('LogFilter - clearChanges') const self = this self.updates = [] } - + // // PendingTxFilter // - + inherits(PendingTransactionFilter, EventEmitter) - + function PendingTransactionFilter(){ // console.log('PendingTransactionFilter - new') const self = this @@ -63101,12 +63101,12 @@ self.updates = [] self.allResults = [] } - + PendingTransactionFilter.prototype.validateUnique = function(tx){ const self = this return self.allResults.indexOf(tx) === -1 } - + PendingTransactionFilter.prototype.update = function(txs){ // console.log('PendingTransactionFilter - update') const self = this @@ -63124,49 +63124,49 @@ self.emit('data', validTxs) } } - + PendingTransactionFilter.prototype.getChanges = function(){ // console.log('PendingTransactionFilter - getChanges') const self = this var results = self.updates return results } - + PendingTransactionFilter.prototype.getAllResults = function(){ // console.log('PendingTransactionFilter - getAllResults') const self = this var results = self.allResults return results } - + PendingTransactionFilter.prototype.clearChanges = function(){ // console.log('PendingTransactionFilter - clearChanges') const self = this self.updates = [] } - + // util - + function normalizeHex(hexString) { return hexString.slice(0, 2) === '0x' ? hexString : '0x'+hexString } - + function intToHex(value) { return ethUtil.intToHex(value) } - + function hexToInt(hexString) { return Number(hexString) } - + function bufferToHex(buffer) { return '0x'+buffer.toString('hex') } - + function bufferToNumberHex(buffer) { return stripLeadingZero(buffer.toString('hex')) } - + function stripLeadingZero(hexNum) { let stripped = ethUtil.stripHexPrefix(hexNum) while (stripped[0] === '0') { @@ -63174,29 +63174,29 @@ } return `0x${stripped}` } - + function blockTagIsNumber(blockTag){ return blockTag && ['earliest', 'latest', 'pending'].indexOf(blockTag) === -1 } - + function valuesFor(obj){ return Object.keys(obj).map(function(key){ return obj[key] }) } - + },{"../util/stoplight.js":396,"./subprovider.js":387,"async":21,"ethereumjs-util":141,"events":157,"util":333}],380:[function(require,module,exports){ const inherits = require('util').inherits const Subprovider = require('./subprovider.js') - + module.exports = FixtureProvider - + inherits(FixtureProvider, Subprovider) - + function FixtureProvider(staticResponses){ const self = this staticResponses = staticResponses || {} self.staticResponses = staticResponses } - + FixtureProvider.prototype.handleRequest = function(payload, next, end){ const self = this var staticResponse = self.staticResponses[payload.method] @@ -63212,7 +63212,7 @@ next() } } - + },{"./subprovider.js":387,"util":333}],381:[function(require,module,exports){ /* * Emulate 'eth_accounts' / 'eth_sendTransaction' using 'eth_sendRawTransaction' @@ -63221,7 +63221,7 @@ * - getAccounts() -- array of addresses supported * - signTransaction(tx) -- sign a raw transaction object */ - + const waterfall = require('async/waterfall') const parallel = require('async/parallel') const inherits = require('util').inherits @@ -63232,9 +63232,9 @@ const Subprovider = require('./subprovider.js') const estimateGas = require('../util/estimate-gas.js') const hexRegex = /^[0-9A-Fa-f]+$/g - + module.exports = HookedWalletSubprovider - + // handles the following RPC methods: // eth_coinbase // eth_accounts @@ -63246,7 +63246,7 @@ // parity_postTransaction // parity_checkRequest // parity_defaultAccount - + // // Tx Signature Flow // @@ -63262,15 +63262,15 @@ // signTransaction (perform the signature) // publishTransaction (publish signed tx to network) // - - + + inherits(HookedWalletSubprovider, Subprovider) - + function HookedWalletSubprovider(opts){ const self = this // control flow self.nonceLock = Semaphore(1) - + // data lookup if (opts.getAccounts) self.getAccounts = opts.getAccounts // high level override @@ -63292,19 +63292,19 @@ // publish to network if (opts.publishTransaction) self.publishTransaction = opts.publishTransaction } - + HookedWalletSubprovider.prototype.handleRequest = function(payload, next, end){ const self = this self._parityRequests = {} self._parityRequestCount = 0 - + // switch statement is not block scoped // sp we cant repeat var declarations let txParams, msgParams, extraParams let message, address - + switch(payload.method) { - + case 'eth_coinbase': // process normally self.getAccounts(function(err, accounts){ @@ -63313,7 +63313,7 @@ end(null, result) }) return - + case 'eth_accounts': // process normally self.getAccounts(function(err, accounts){ @@ -63321,7 +63321,7 @@ end(null, accounts) }) return - + case 'eth_sendTransaction': txParams = payload.params[0] waterfall([ @@ -63329,7 +63329,7 @@ (cb) => self.processTransaction(txParams, cb), ], end) return - + case 'eth_signTransaction': txParams = payload.params[0] waterfall([ @@ -63337,7 +63337,7 @@ (cb) => self.processSignTransaction(txParams, cb), ], end) return - + case 'eth_sign': // process normally address = payload.params[0] @@ -63354,12 +63354,12 @@ (cb) => self.processMessage(msgParams, cb), ], end) return - + case 'personal_sign': // process normally const first = payload.params[0] const second = payload.params[1] - + // We initially incorrectly ordered these parameters. // To gracefully respect users who adopted this API early, // we are currently gracefully recovering from the wrong param order @@ -63373,14 +63373,14 @@ warning += `and has been corrected automatically. ` warning += `Please switch this param order for smooth behavior in the future.` console.warn(warning) - + address = payload.params[0] message = payload.params[1] } else { message = payload.params[0] address = payload.params[1] } - + // non-standard "extraParams" to be appended to our "msgParams" obj // good place for metadata extraParams = payload.params[2] || {} @@ -63393,7 +63393,7 @@ (cb) => self.processPersonalMessage(msgParams, cb), ], end) return - + case 'personal_ecRecover': message = payload.params[0] let signature = payload.params[1] @@ -63406,7 +63406,7 @@ }) self.recoverPersonalSignature(msgParams, end) return - + case 'eth_signTypedData': // process normally message = payload.params[0] @@ -63421,23 +63421,23 @@ (cb) => self.processTypedMessage(msgParams, cb), ], end) return - + case 'parity_postTransaction': txParams = payload.params[0] self.parityPostTransaction(txParams, end) return - + case 'parity_postSign': address = payload.params[0] message = payload.params[1] self.parityPostSign(address, message, end) return - + case 'parity_checkRequest': const requestId = payload.params[0] self.parityCheckRequest(requestId, end) return - + case 'parity_defaultAccount': self.getAccounts(function(err, accounts){ if (err) return end(err) @@ -63445,27 +63445,27 @@ end(null, account) }) return - + default: next() return - + } } - + // // data lookup // - + HookedWalletSubprovider.prototype.getAccounts = function(cb) { cb(null, []) } - - + + // // "process" high level flow // - + HookedWalletSubprovider.prototype.processTransaction = function(txParams, cb) { const self = this waterfall([ @@ -63474,8 +63474,8 @@ (cb) => self.finalizeAndSubmitTx(txParams, cb), ], cb) } - - + + HookedWalletSubprovider.prototype.processSignTransaction = function(txParams, cb) { const self = this waterfall([ @@ -63484,7 +63484,7 @@ (cb) => self.finalizeTx(txParams, cb), ], cb) } - + HookedWalletSubprovider.prototype.processMessage = function(msgParams, cb) { const self = this waterfall([ @@ -63493,7 +63493,7 @@ (cb) => self.signMessage(msgParams, cb), ], cb) } - + HookedWalletSubprovider.prototype.processPersonalMessage = function(msgParams, cb) { const self = this waterfall([ @@ -63502,7 +63502,7 @@ (cb) => self.signPersonalMessage(msgParams, cb), ], cb) } - + HookedWalletSubprovider.prototype.processTypedMessage = function(msgParams, cb) { const self = this waterfall([ @@ -63511,31 +63511,31 @@ (cb) => self.signTypedMessage(msgParams, cb), ], cb) } - + // // approval // - + HookedWalletSubprovider.prototype.autoApprove = function(txParams, cb) { cb(null, true) } - + HookedWalletSubprovider.prototype.checkApproval = function(type, didApprove, cb) { cb( didApprove ? null : new Error('User denied '+type+' signature.') ) } - + // // parity // - + HookedWalletSubprovider.prototype.parityPostTransaction = function(txParams, cb) { const self = this - + // get next id const count = self._parityRequestCount const reqId = `0x${count.toString(16)}` self._parityRequestCount++ - + self.emitPayload({ method: 'eth_sendTransaction', params: [txParams], @@ -63547,19 +63547,19 @@ const txHash = res.result self._parityRequests[reqId] = txHash }) - + cb(null, reqId) } - - + + HookedWalletSubprovider.prototype.parityPostSign = function(address, message, cb) { const self = this - + // get next id const count = self._parityRequestCount const reqId = `0x${count.toString(16)}` self._parityRequestCount++ - + self.emitPayload({ method: 'eth_sign', params: [address, message], @@ -63571,10 +63571,10 @@ const result = res.result self._parityRequests[reqId] = result }) - + cb(null, reqId) } - + HookedWalletSubprovider.prototype.parityCheckRequest = function(reqId, cb) { const self = this const result = self._parityRequests[reqId] || null @@ -63585,11 +63585,11 @@ // tx sent cb(null, result) } - + // // signature and recovery // - + HookedWalletSubprovider.prototype.recoverPersonalSignature = function(msgParams, cb) { let senderHex try { @@ -63599,11 +63599,11 @@ } cb(null, senderHex) } - + // // validation // - + HookedWalletSubprovider.prototype.validateTransaction = function(txParams, cb){ const self = this // shortcut: undefined sender is invalid @@ -63614,7 +63614,7 @@ cb() }) } - + HookedWalletSubprovider.prototype.validateMessage = function(msgParams, cb){ const self = this if (msgParams.from === undefined) return cb(new Error(`Undefined address - from address required to sign message.`)) @@ -63624,7 +63624,7 @@ cb() }) } - + HookedWalletSubprovider.prototype.validatePersonalMessage = function(msgParams, cb){ const self = this if (msgParams.from === undefined) return cb(new Error(`Undefined address - from address required to sign personal message.`)) @@ -63636,7 +63636,7 @@ cb() }) } - + HookedWalletSubprovider.prototype.validateTypedMessage = function(msgParams, cb){ if (msgParams.from === undefined) return cb(new Error(`Undefined address - from address required to sign typed data.`)) if (msgParams.data === undefined) return cb(new Error(`Undefined data - message required to sign typed data.`)) @@ -63646,7 +63646,7 @@ cb() }) } - + HookedWalletSubprovider.prototype.validateSender = function(senderAddress, cb){ const self = this // shortcut: undefined sender is invalid @@ -63657,11 +63657,11 @@ cb(null, senderIsValid) }) } - + // // tx helpers // - + HookedWalletSubprovider.prototype.finalizeAndSubmitTx = function(txParams, cb) { const self = this // can only allow one tx to pass through this flow at a time @@ -63678,7 +63678,7 @@ }) }) } - + HookedWalletSubprovider.prototype.finalizeTx = function(txParams, cb) { const self = this // can only allow one tx to pass through this flow at a time @@ -63694,7 +63694,7 @@ }) }) } - + HookedWalletSubprovider.prototype.publishTransaction = function(rawTx, cb) { const self = this self.emitPayload({ @@ -63705,44 +63705,44 @@ cb(null, res.result) }) } - + HookedWalletSubprovider.prototype.fillInTxExtras = function(txParams, cb){ const self = this const address = txParams.from // console.log('fillInTxExtras - address:', address) - + const reqs = {} - + if (txParams.gasPrice === undefined) { // console.log("need to get gasprice") reqs.gasPrice = self.emitPayload.bind(self, { method: 'eth_gasPrice', params: [] }) } - + if (txParams.nonce === undefined) { // console.log("need to get nonce") reqs.nonce = self.emitPayload.bind(self, { method: 'eth_getTransactionCount', params: [address, 'pending'] }) } - + if (txParams.gas === undefined) { // console.log("need to get gas") reqs.gas = estimateGas.bind(null, self.engine, cloneTxParams(txParams)) } - + parallel(reqs, function(err, result) { if (err) return cb(err) // console.log('fillInTxExtras - result:', result) - + const res = {} if (result.gasPrice) res.gasPrice = result.gasPrice.result if (result.nonce) res.nonce = result.nonce.result if (result.gas) res.gas = result.gas - + cb(null, extend(txParams, res)) }) } - + // util - + // we use this to clean any custom params from the txParams function cloneTxParams(txParams){ return { @@ -63755,17 +63755,17 @@ nonce: txParams.nonce, } } - + function toLowerCase(string){ return string.toLowerCase() } - + function resemblesAddress (string) { const fixed = ethUtil.addHexPrefix(string) const isValid = ethUtil.isValidAddress(fixed) return isValid } - + // Returns true if resembles hex data // but definitely not a valid address. function resemblesData (string) { @@ -63773,7 +63773,7 @@ const isValidAddress = ethUtil.isValidAddress(fixed) return !isValidAddress && isValidHex(string) } - + function isValidHex(data) { const isString = typeof data === 'string' if (!isString) return false @@ -63783,75 +63783,75 @@ const isValid = nonPrefixed.match(hexRegex) return isValid } - + function mustProvideInConstructor(methodName) { return function(params, cb) { cb(new Error('ProviderEngine - HookedWalletSubprovider - Must provide "' + methodName + '" fn in constructor options')) } } - + },{"../util/estimate-gas.js":392,"./subprovider.js":387,"async/parallel":42,"async/waterfall":44,"eth-sig-util":136,"ethereumjs-util":141,"semaphore":301,"util":333,"xtend":423}],382:[function(require,module,exports){ const cacheIdentifierForPayload = require('../util/rpc-cache-utils.js').cacheIdentifierForPayload const Subprovider = require('./subprovider.js') - - + + class InflightCacheSubprovider extends Subprovider { - + constructor (opts) { super() this.inflightRequests = {} } - + addEngine (engine) { this.engine = engine } - + handleRequest (req, next, end) { const cacheId = cacheIdentifierForPayload(req, { includeBlockRef: true }) - + // if not cacheable, skip if (!cacheId) return next() - + // check for matching requests let activeRequestHandlers = this.inflightRequests[cacheId] - + if (!activeRequestHandlers) { // create inflight cache for cacheId activeRequestHandlers = [] this.inflightRequests[cacheId] = activeRequestHandlers - + next((err, result, cb) => { // complete inflight for cacheId delete this.inflightRequests[cacheId] activeRequestHandlers.forEach((handler) => handler(err, result)) cb(err, result) }) - + } else { // hit inflight cache for cacheId // setup the response listener activeRequestHandlers.push(end) } - + } } - + module.exports = InflightCacheSubprovider - - + + },{"../util/rpc-cache-utils.js":394,"./subprovider.js":387}],383:[function(require,module,exports){ const createInfuraProvider = require('eth-json-rpc-infura/src/createProvider') const ProviderSubprovider = require('./provider.js') - + class InfuraSubprovider extends ProviderSubprovider { constructor(opts = {}) { const provider = createInfuraProvider(opts) super(provider) } } - + module.exports = InfuraSubprovider - + },{"./provider.js":385,"eth-json-rpc-infura/src/createProvider":129}],384:[function(require,module,exports){ (function (Buffer){ const inherits = require('util').inherits @@ -63859,28 +63859,28 @@ const ethUtil = require('ethereumjs-util') const Subprovider = require('./subprovider.js') const blockTagForPayload = require('../util/rpc-cache-utils').blockTagForPayload - + module.exports = NonceTrackerSubprovider - + // handles the following RPC methods: // eth_getTransactionCount (pending only) // observes the following RPC methods: // eth_sendRawTransaction - - + + inherits(NonceTrackerSubprovider, Subprovider) - + function NonceTrackerSubprovider(opts){ const self = this - + self.nonceCache = {} } - + NonceTrackerSubprovider.prototype.handleRequest = function(payload, next, end){ const self = this - + switch(payload.method) { - + case 'eth_getTransactionCount': var blockTag = blockTagForPayload(payload) var address = payload.params[0].toLowerCase() @@ -63904,7 +63904,7 @@ next() } return - + case 'eth_sendRawTransaction': // allow the request to continue normally next(function(err, result, cb){ @@ -63930,30 +63930,30 @@ cb() }) return - + default: next() return - + } } }).call(this,require("buffer").Buffer) },{"../util/rpc-cache-utils":394,"./subprovider.js":387,"buffer":84,"ethereumjs-tx":140,"ethereumjs-util":141,"util":333}],385:[function(require,module,exports){ const inherits = require('util').inherits const Subprovider = require('./subprovider.js') - + // wraps a provider in a subprovider interface - + module.exports = ProviderSubprovider - + inherits(ProviderSubprovider, Subprovider) - + function ProviderSubprovider(provider){ if (!provider) throw new Error('ProviderSubprovider - no provider specified') if (!provider.sendAsync) throw new Error('ProviderSubprovider - specified provider does not have a sendAsync method') this.provider = provider } - + ProviderSubprovider.prototype.handleRequest = function(payload, next, end){ this.provider.sendAsync(payload, function(err, response) { if (err) return end(err) @@ -63961,37 +63961,37 @@ end(null, response.result) }) } - + },{"./subprovider.js":387,"util":333}],386:[function(require,module,exports){ /* Sanitization Subprovider * For Parity compatibility * removes irregular keys */ - + const inherits = require('util').inherits const Subprovider = require('./subprovider.js') const extend = require('xtend') const ethUtil = require('ethereumjs-util') - + module.exports = SanitizerSubprovider - + inherits(SanitizerSubprovider, Subprovider) - + function SanitizerSubprovider(opts){ const self = this } - + SanitizerSubprovider.prototype.handleRequest = function(payload, next, end){ var txParams = payload.params[0] - + if (typeof txParams === 'object' && !Array.isArray(txParams)) { var sanitized = cloneTxParams(txParams) payload.params[0] = sanitized } - + next() } - + // we use this to clean any custom params from the txParams var permitted = [ 'from', @@ -64006,7 +64006,7 @@ 'address', 'topics', ] - + function cloneTxParams(txParams){ var sanitized = permitted.reduce(function(copy, permitted) { if (permitted in txParams) { @@ -64021,10 +64021,10 @@ } return copy }, {}) - + return sanitized } - + function sanitize(value) { switch (value) { case 'latest': @@ -64041,19 +64041,19 @@ } } } - + },{"./subprovider.js":387,"ethereumjs-util":141,"util":333,"xtend":423}],387:[function(require,module,exports){ const createPayload = require('../util/create-payload.js') - + module.exports = SubProvider - + // this is the base class for a subprovider -- mostly helpers - - + + function SubProvider() { - + } - + SubProvider.prototype.setEngine = function(engine) { const self = this self.engine = engine @@ -64061,11 +64061,11 @@ self.currentBlock = block }) } - + SubProvider.prototype.handleRequest = function(payload, next, end) { throw new Error('Subproviders should override `handleRequest`.') } - + SubProvider.prototype.emitPayload = function(payload, cb){ const self = this self.engine.sendAsync(createPayload(payload), cb) @@ -64076,36 +64076,36 @@ const from = require('../util/rpc-hex-encoding.js') const inherits = require('util').inherits const utils = require('ethereumjs-util') - + function SubscriptionSubprovider(opts) { const self = this - + opts = opts || {} - + EventEmitter.apply(this, Array.prototype.slice.call(arguments)) FilterSubprovider.apply(this, [opts]) - + this.subscriptions = {} } - + inherits(SubscriptionSubprovider, FilterSubprovider) - + // a cheap crack at multiple inheritance // I don't really care if `instanceof EventEmitter` passes... Object.assign(SubscriptionSubprovider.prototype, EventEmitter.prototype) - + // preserve our constructor, though SubscriptionSubprovider.prototype.constructor = SubscriptionSubprovider - + SubscriptionSubprovider.prototype.eth_subscribe = function(payload, cb) { const self = this let createSubscriptionFilter = () => {} let subscriptionType = payload.params[0] - + switch (subscriptionType) { case 'logs': let options = payload.params[1] - + createSubscriptionFilter = self.newLogFilter.bind(self, options) break case 'newPendingTransactions': @@ -64119,18 +64119,18 @@ cb(new Error('unsupported subscription type')) return } - + createSubscriptionFilter(function(err, hexId) { if (err) return cb(err) - + const id = Number.parseInt(hexId, 16) self.subscriptions[id] = subscriptionType - + self.filters[id].on('data', function(results) { if (!Array.isArray(results)) { results = [results] } - + var notificationHandler = self._notificationHandler.bind(self, hexId, subscriptionType) results.forEach(notificationHandler) self.filters[id].clearChanges() @@ -64141,7 +64141,7 @@ cb(null, hexId) }) } - + SubscriptionSubprovider.prototype.eth_unsubscribe = function(payload, cb) { const self = this let hexId = payload.params[0] @@ -64156,14 +64156,14 @@ }) } } - - + + SubscriptionSubprovider.prototype._notificationHandler = function (hexId, subscriptionType, result) { const self = this if (subscriptionType === 'newHeads') { result = self._notificationResultFromBlock(result) } - + // it seems that web3 doesn't expect there to be a separate error event // so we must emit null along with the result object self.emit('data', null, { @@ -64175,7 +64175,7 @@ }, }) } - + SubscriptionSubprovider.prototype._notificationResultFromBlock = function(block) { return { hash: utils.bufferToHex(block.hash), @@ -64196,7 +64196,7 @@ extraData: utils.bufferToHex(block.extraData) } } - + SubscriptionSubprovider.prototype.handleRequest = function(payload, next, end) { switch(payload.method){ case 'eth_subscribe': @@ -64209,9 +64209,9 @@ FilterSubprovider.prototype.handleRequest.apply(this, Array.prototype.slice.call(arguments)) } } - + module.exports = SubscriptionSubprovider - + },{"../util/rpc-hex-encoding.js":395,"./filters.js":379,"ethereumjs-util":141,"events":157,"util":333}],389:[function(require,module,exports){ (function (global){ const Backoff = require('backoff') @@ -64220,15 +64220,15 @@ const WebSocket = global.WebSocket || require('ws') const Subprovider = require('./subprovider') const createPayload = require('../util/create-payload') - + class WebsocketSubprovider extends Subprovider { constructor({ rpcUrl, debug, origin }) { super() - + // inherit from EventEmitter EventEmitter.call(this) - + Object.defineProperties(this, { _backoff: { value: Backoff.exponential({ @@ -64262,100 +64262,100 @@ value: rpcUrl } }) - + this._handleSocketClose = this._handleSocketClose.bind(this) this._handleSocketMessage = this._handleSocketMessage.bind(this) this._handleSocketOpen = this._handleSocketOpen.bind(this) - + // Called when a backoff timeout has finished. Time to try reconnecting. this._backoff.on('ready', () => { this._openSocket() }) - + this._openSocket() } - + handleRequest(payload, next, end) { if (!this._socket || this._socket.readyState !== WebSocket.OPEN) { this._unhandledRequests.push(Array.from(arguments)) this._log('Socket not open. Request queued.') return } - + this._pendingRequests.set(payload.id, [payload, end]) - + const newPayload = createPayload(payload) delete newPayload.origin - + this._socket.send(JSON.stringify(newPayload)) this._log(`Sent: ${newPayload.method} #${newPayload.id}`) } - + _handleSocketClose({ reason, code }) { this._log(`Socket closed, code ${code} (${reason || 'no reason'})`) // If the socket has been open for longer than 5 seconds, reset the backoff if (this._connectTime && Date.now() - this._connectTime > 5000) { this._backoff.reset() } - + this._socket.removeEventListener('close', this._handleSocketClose) this._socket.removeEventListener('message', this._handleSocketMessage) this._socket.removeEventListener('open', this._handleSocketOpen) - + this._socket = null this._backoff.backoff() } - + _handleSocketMessage(message) { let payload - + try { payload = JSON.parse(message.data) } catch (e) { this._log('Received a message that is not valid JSON:', payload) return } - + // check if server-sent notification if (payload.id === undefined) { return this.emit('data', null, payload) } - + // ignore if missing if (!this._pendingRequests.has(payload.id)) { return } - + // retrieve payload + arguments const [originalReq, end] = this._pendingRequests.get(payload.id) this._pendingRequests.delete(payload.id) - + this._log(`Received: ${originalReq.method} #${payload.id}`) - + // forward response if (payload.error) { return end(new Error(payload.error.message)) } end(null, payload.result) } - + _handleSocketOpen() { this._log('Socket open.') this._connectTime = Date.now() - + // Any pending requests need to be resent because our session was lost // and will not get responses for them in our new session. this._pendingRequests.forEach(([payload, end]) => { this._unhandledRequests.push([payload, null, end]) }) this._pendingRequests.clear() - + const unhandledRequests = this._unhandledRequests.splice(0, this._unhandledRequests.length) unhandledRequests.forEach(request => { this.handleRequest.apply(this, request) }) } - + _openSocket() { this._log('Opening socket...') this._socket = new WebSocket(this._url, null, {origin: this._origin}) @@ -64364,29 +64364,29 @@ this._socket.addEventListener('open', this._handleSocketOpen) } } - + // multiple inheritance Object.assign(WebsocketSubprovider.prototype, EventEmitter.prototype) - + module.exports = WebsocketSubprovider - + }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"../util/create-payload":391,"./subprovider":387,"backoff":45,"events":157,"util":333,"ws":55}],390:[function(require,module,exports){ module.exports = assert - + function assert(condition, message) { if (!condition) { throw message || "Assertion failed"; } } - + },{}],391:[function(require,module,exports){ const getRandomId = require('./random-id.js') const extend = require('xtend') - + module.exports = createPayload - - + + function createPayload(data){ return extend({ // defaults @@ -64396,19 +64396,19 @@ // user-specified }, data) } - + },{"./random-id.js":393,"xtend":423}],392:[function(require,module,exports){ const createPayload = require('./create-payload.js') - + module.exports = estimateGas - + /* - + This is a work around for https://github.com/ethereum/go-ethereum/issues/2577 - + */ - - + + function estimateGas(provider, txParams, cb) { provider.sendAsync(createPayload({ method: 'eth_estimateGas', @@ -64419,7 +64419,7 @@ if (err.message === 'no contract code at given address') { return cb(null, '0xcf08') } else { - return cb(err) + return cb(err) } } cb(null, res.result) @@ -64428,10 +64428,10 @@ },{"./create-payload.js":391}],393:[function(require,module,exports){ // gotta keep it within MAX_SAFE_INTEGER const extraDigits = 3 - + module.exports = createRandomId - - + + function createRandomId(){ // 13 time digits var datePart = new Date().getTime()*Math.pow(10, extraDigits) @@ -64442,7 +64442,7 @@ } },{}],394:[function(require,module,exports){ const stringify = require('json-stable-stringify') - + module.exports = { cacheIdentifierForPayload: cacheIdentifierForPayload, canCache: canCache, @@ -64451,45 +64451,45 @@ blockTagParamIndex: blockTagParamIndex, cacheTypeForPayload: cacheTypeForPayload, } - + function cacheIdentifierForPayload(payload, opts = {}){ if (!canCache(payload)) return null const { includeBlockRef } = opts const params = includeBlockRef ? payload.params : paramsWithoutBlockTag(payload) return payload.method + ':' + stringify(params) } - + function canCache(payload){ return cacheTypeForPayload(payload) !== 'never' } - + function blockTagForPayload(payload){ var index = blockTagParamIndex(payload); - + // Block tag param not passed. if (index >= payload.params.length) { return null; } - + return payload.params[index]; } - + function paramsWithoutBlockTag(payload){ var index = blockTagParamIndex(payload); - + // Block tag param not passed. if (index >= payload.params.length) { return payload.params; } - + // eth_getBlockByNumber has the block tag first, then the optional includeTx? param if (payload.method === 'eth_getBlockByNumber') { return payload.params.slice(1); } - + return payload.params.slice(0,index); } - + function blockTagParamIndex(payload){ switch(payload.method) { // blockTag is third param @@ -64510,7 +64510,7 @@ return undefined } } - + function cacheTypeForPayload(payload) { switch (payload.method) { // cache permanently @@ -64531,7 +64531,7 @@ case 'eth_compileSerpent': case 'shh_version': return 'perma' - + // cache until fork case 'eth_getBlockByNumber': case 'eth_getBlockTransactionCountByNumber': @@ -64539,7 +64539,7 @@ case 'eth_getTransactionByBlockNumberAndIndex': case 'eth_getUncleByBlockNumberAndIndex': return 'fork' - + // cache for block case 'eth_gasPrice': case 'eth_blockNumber': @@ -64552,7 +64552,7 @@ case 'eth_getLogs': case 'net_peerCount': return 'block' - + // never cache case 'net_version': case 'net_peerCount': @@ -64589,24 +64589,24 @@ return 'never' } } - + },{"json-stable-stringify":374}],395:[function(require,module,exports){ (function (Buffer){ const ethUtil = require('ethereumjs-util') const assert = require('./assert.js') - + module.exports = { intToQuantityHex: intToQuantityHex, quantityHexToInt: quantityHexToInt, } - + /* * As per https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding * Quanities should be represented by the most compact hex representation possible * This means that no leading zeroes are allowed. There helpers make it easy * to convert to and from integers and their compact hex representation */ - + function intToQuantityHex(n){ assert(typeof n === 'number' && n === Math.floor(n), 'intToQuantityHex arg must be an integer') var nHex = ethUtil.toBuffer(n).toString('hex') @@ -64615,7 +64615,7 @@ } return ethUtil.addHexPrefix(nHex) } - + function quantityHexToInt(prefixedQuantityHex) { assert(typeof prefixedQuantityHex === 'string', 'arg to quantityHexToInt must be a string') var quantityHex = ethUtil.stripHexPrefix(prefixedQuantityHex) @@ -64626,35 +64626,35 @@ var buf = new Buffer(quantityHex, 'hex') return ethUtil.bufferToInt(buf) } - + }).call(this,require("buffer").Buffer) },{"./assert.js":390,"buffer":84,"ethereumjs-util":141}],396:[function(require,module,exports){ const EventEmitter = require('events').EventEmitter const inherits = require('util').inherits - + module.exports = Stoplight - - + + inherits(Stoplight, EventEmitter) - + function Stoplight(){ const self = this EventEmitter.call(self) self.isLocked = true } - + Stoplight.prototype.go = function(){ const self = this self.isLocked = false self.emit('unlock') } - + Stoplight.prototype.stop = function(){ const self = this self.isLocked = true self.emit('lock') } - + Stoplight.prototype.await = function(fn){ const self = this if (self.isLocked) { @@ -64676,31 +64676,31 @@ const InfuraSubprovider = require('./subproviders/infura.js') const FetchSubprovider = require('./subproviders/fetch.js') const WebSocketSubprovider = require('./subproviders/websocket.js') - - + + module.exports = ZeroClientProvider - - + + function ZeroClientProvider(opts = {}){ const connectionType = getConnectionType(opts) - + const engine = new ProviderEngine(opts.engineParams) - + // static const staticSubprovider = new DefaultFixture(opts.static) engine.addProvider(staticSubprovider) - + // nonce tracker engine.addProvider(new NonceTrackerSubprovider()) - + // sanitization const sanitizer = new SanitizingSubprovider() engine.addProvider(sanitizer) - + // cache layer const cacheSubprovider = new CacheSubprovider() engine.addProvider(cacheSubprovider) - + // filters + subscriptions // for websockets, only polyfill filters if (connectionType === 'ws') { @@ -64715,11 +64715,11 @@ }) engine.addProvider(filterAndSubsSubprovider) } - + // inflight cache const inflightCache = new InflightCacheSubprovider() engine.addProvider(inflightCache) - + // id mgmt const idmgmtSubprovider = new HookedWalletSubprovider({ // accounts @@ -64744,7 +64744,7 @@ personalRecoverSigner: opts.personalRecoverSigner, }) engine.addProvider(idmgmtSubprovider) - + // data source const dataSubprovider = opts.dataSubprovider || createDataSubprovider(connectionType, opts) // for websockets, forward subscription events through provider @@ -64754,19 +64754,19 @@ }) } engine.addProvider(dataSubprovider) - + // start polling if (!opts.stopped) { engine.start() } - + return engine - + } - + function createDataSubprovider(connectionType, opts) { const { rpcUrl, debug } = opts - + // default to infura if (!connectionType) { return new InfuraSubprovider() @@ -64777,13 +64777,13 @@ if (connectionType === 'ws') { return new WebSocketSubprovider({ rpcUrl, debug }) } - + throw new Error(`ProviderEngine - unrecognized connectionType "${connectionType}"`) } - + function getConnectionType({ rpcUrl }) { if (!rpcUrl) return undefined - + const protocol = rpcUrl.split(':')[0].toLowerCase() switch (protocol) { case 'http': @@ -64796,21 +64796,21 @@ throw new Error(`ProviderEngine - unrecognized protocol in "${rpcUrl}"`) } } - + },{"./index.js":373,"./subproviders/cache.js":376,"./subproviders/default-fixture.js":377,"./subproviders/fetch.js":378,"./subproviders/filters.js":379,"./subproviders/hooked-wallet.js":381,"./subproviders/inflight-cache":382,"./subproviders/infura.js":383,"./subproviders/nonce-tracker.js":384,"./subproviders/sanitizer.js":386,"./subproviders/subscriptions":388,"./subproviders/websocket.js":389}],398:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -64821,13 +64821,13 @@ * Fabian Vogelsteller * @date 2015 */ - + var errors = require('web3-core-helpers').errors; var XHR2 = require('xhr2-cookies').XMLHttpRequest // jshint ignore: line var http = require('http'); var https = require('https'); - - + + /** * HttpProvider should be used to send rpc calls over http */ @@ -64843,28 +64843,28 @@ this.headers = options.headers; this.connected = false; }; - + HttpProvider.prototype._prepareRequest = function(){ var request = new XHR2(); request.nodejsSet({ httpsAgent:this.httpsAgent, httpAgent:this.httpAgent }); - + request.open('POST', this.host, true); request.setRequestHeader('Content-Type','application/json'); request.timeout = this.timeout && this.timeout !== 1 ? this.timeout : 0; request.withCredentials = true; - + if(this.headers) { this.headers.forEach(function(header) { request.setRequestHeader(header.name, header.value); }); } - + return request; }; - + /** * Should be used to make async request * @@ -64875,28 +64875,28 @@ HttpProvider.prototype.send = function (payload, callback) { var _this = this; var request = this._prepareRequest(); - + request.onreadystatechange = function() { if (request.readyState === 4 && request.timeout !== 1) { var result = request.responseText; var error = null; - + try { result = JSON.parse(result); } catch(e) { error = errors.InvalidResponse(request.responseText); } - + _this.connected = true; callback(error, result); } }; - + request.ontimeout = function() { _this.connected = false; callback(errors.ConnectionTimeout(this.timeout)); }; - + try { request.send(JSON.stringify(payload)); } catch(error) { @@ -64904,28 +64904,28 @@ callback(errors.InvalidConnection(this.host)); } }; - + HttpProvider.prototype.disconnect = function () { //NO OP }; - - + + module.exports = HttpProvider; - + },{"http":312,"https":175,"web3-core-helpers":338,"xhr2-cookies":418}],399:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -64934,31 +64934,31 @@ * Fabian Vogelsteller * @date 2017 */ - + "use strict"; - + var _ = require('underscore'); var errors = require('web3-core-helpers').errors; var oboe = require('oboe'); - - + + var IpcProvider = function IpcProvider(path, net) { var _this = this; this.responseCallbacks = {}; this.notificationCallbacks = []; this.path = path; this.connected = false; - + this.connection = net.connect({path: this.path}); - + this.addDefaultEvents(); - + // LISTEN FOR CONNECTION RESPONSES var callback = function(result) { /*jshint maxcomplexity: 6 */ - + var id = null; - + // get the id which matches the returned id if(_.isArray(result)) { result.forEach(function(load){ @@ -64968,21 +64968,21 @@ } else { id = result.id; } - + // notification if(!id && result.method.indexOf('_subscription') !== -1) { _this.notificationCallbacks.forEach(function(callback){ if(_.isFunction(callback)) callback(result); }); - + // fire the callback } else if(_this.responseCallbacks[id]) { _this.responseCallbacks[id](null, result); delete _this.responseCallbacks[id]; } }; - + // use oboe.js for Sockets if (net.constructor.name === 'Socket') { oboe(this.connection) @@ -64993,49 +64993,49 @@ }); } }; - + /** Will add the error and end event to timeout existing calls - + @method addDefaultEvents */ IpcProvider.prototype.addDefaultEvents = function(){ var _this = this; - + this.connection.on('connect', function(){ _this.connected = true; }); - + this.connection.on('close', function(){ _this.connected = false; }); - + this.connection.on('error', function(){ _this._timeout(); }); - + this.connection.on('end', function(){ _this._timeout(); }); - + this.connection.on('timeout', function(){ _this._timeout(); }); }; - - + + /** Will parse the response and make an array out of it. - + NOTE, this exists for backwards compatibility reasons. - + @method _parseResponse @param {String} data */ IpcProvider.prototype._parseResponse = function(data) { var _this = this, returnValues = []; - + // DE-CHUNKER var dechunkedData = data .replace(/\}[\n\r]?\{/g,'}|--|{') // }{ @@ -65043,61 +65043,61 @@ .replace(/\}[\n\r]?\[\{/g,'}|--|[{') // }[{ .replace(/\}\][\n\r]?\{/g,'}]|--|{') // }]{ .split('|--|'); - + dechunkedData.forEach(function(data){ - + // prepend the last chunk if(_this.lastChunk) data = _this.lastChunk + data; - + var result = null; - + try { result = JSON.parse(data); - + } catch(e) { - + _this.lastChunk = data; - + // start timeout to cancel all requests clearTimeout(_this.lastChunkTimeout); _this.lastChunkTimeout = setTimeout(function(){ _this._timeout(); throw errors.InvalidResponse(data); }, 1000 * 15); - + return; } - + // cancel timeout and set chunk to null clearTimeout(_this.lastChunkTimeout); _this.lastChunk = null; - + if(result) returnValues.push(result); }); - + return returnValues; }; - - + + /** Get the adds a callback to the responseCallbacks object, which will be called if a response matching the response Id will arrive. - + @method _addResponseCallback */ IpcProvider.prototype._addResponseCallback = function(payload, callback) { var id = payload.id || payload[0].id; var method = payload.method || payload[0].method; - + this.responseCallbacks[id] = callback; this.responseCallbacks[id].method = method; }; - + /** Timeout all requests when the end/error event is fired - + @method _timeout */ IpcProvider.prototype._timeout = function() { @@ -65108,76 +65108,76 @@ } } }; - + /** Try to reconnect - + @method reconnect */ IpcProvider.prototype.reconnect = function() { this.connection.connect({path: this.path}); }; - - + + IpcProvider.prototype.send = function (payload, callback) { // try reconnect, when connection is gone if(!this.connection.writable) this.connection.connect({path: this.path}); - - + + this.connection.write(JSON.stringify(payload)); this._addResponseCallback(payload, callback); }; - + /** Subscribes to provider events.provider - + @method on @param {String} type 'notification', 'connect', 'error', 'end' or 'data' @param {Function} callback the callback to call */ IpcProvider.prototype.on = function (type, callback) { - + if(typeof callback !== 'function') throw new Error('The second parameter callback must be a function.'); - + switch(type){ case 'data': this.notificationCallbacks.push(callback); break; - + // adds error, end, timeout, connect default: this.connection.on(type, callback); break; } }; - + /** Subscribes to provider events.provider - + @method on @param {String} type 'connect', 'error', 'end' or 'data' @param {Function} callback the callback to call */ IpcProvider.prototype.once = function (type, callback) { - + if(typeof callback !== 'function') throw new Error('The second parameter callback must be a function.'); - + this.connection.once(type, callback); }; - + /** Removes event listener - + @method removeListener @param {String} type 'data', 'connect', 'error', 'end' or 'data' @param {Function} callback the callback to call */ IpcProvider.prototype.removeListener = function (type, callback) { var _this = this; - + switch(type){ case 'data': this.notificationCallbacks.forEach(function(cb, index){ @@ -65185,16 +65185,16 @@ _this.notificationCallbacks.splice(index, 1); }); break; - + default: this.connection.removeListener(type, callback); break; } }; - + /** Removes all event listeners - + @method removeAllListeners @param {String} type 'data', 'connect', 'error', 'end' or 'data' */ @@ -65203,47 +65203,47 @@ case 'data': this.notificationCallbacks = []; break; - + default: this.connection.removeAllListeners(type); break; } }; - + /** Resets the providers, clears all callbacks - + @method reset */ IpcProvider.prototype.reset = function () { this._timeout(); this.notificationCallbacks = []; - + this.connection.removeAllListeners('error'); this.connection.removeAllListeners('end'); this.connection.removeAllListeners('timeout'); - + this.addDefaultEvents(); }; - + module.exports = IpcProvider; - - + + },{"oboe":239,"underscore":325,"web3-core-helpers":338}],400:[function(require,module,exports){ (function (Buffer){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -65252,12 +65252,12 @@ * Fabian Vogelsteller * @date 2017 */ - + "use strict"; - + var _ = require('underscore'); var errors = require('web3-core-helpers').errors; - + var Ws = null; var _btoa = null; var parseURL = null; @@ -65288,18 +65288,18 @@ } } // Default connection ws://localhost:8546 - - - - + + + + var WebsocketProvider = function WebsocketProvider(url, options) { var _this = this; this.responseCallbacks = {}; this.notificationCallbacks = []; - + options = options || {}; this._customTimeout = options.timeout; - + // The w3cwebsocket implementation does not support Basic Auth // username/password in the URL. So generate the basic auth header, and // pass through with any additional headers supplied in constructor @@ -65309,29 +65309,29 @@ if (parsedURL.username && parsedURL.password) { headers.authorization = 'Basic ' + _btoa(parsedURL.username + ':' + parsedURL.password); } - + // Allow a custom client configuration var clientConfig = options.clientConfig || undefined; - + // When all node core implementations that do not have the // WHATWG compatible URL parser go out of service this line can be removed. if (parsedURL.auth) { headers.authorization = 'Basic ' + _btoa(parsedURL.auth); } this.connection = new Ws(url, protocol, undefined, headers, undefined, clientConfig); - + this.addDefaultEvents(); - - + + // LISTEN FOR CONNECTION RESPONSES this.connection.onmessage = function(e) { /*jshint maxcomplexity: 6 */ var data = (typeof e.data === 'string') ? e.data : ''; - + _this._parseResponse(data).forEach(function(result){ - + var id = null; - + // get the id which matches the returned id if(_.isArray(result)) { result.forEach(function(load){ @@ -65341,14 +65341,14 @@ } else { id = result.id; } - + // notification if(!id && result && result.method && result.method.indexOf('_subscription') !== -1) { _this.notificationCallbacks.forEach(function(callback){ if(_.isFunction(callback)) callback(result); }); - + // fire the callback } else if(_this.responseCallbacks[id]) { _this.responseCallbacks[id](null, result); @@ -65356,7 +65356,7 @@ } }); }; - + // make property `connected` which will return the current connection status Object.defineProperty(this, 'connected', { get: function () { @@ -65365,41 +65365,41 @@ enumerable: true, }); }; - + /** Will add the error and end event to timeout existing calls - + @method addDefaultEvents */ WebsocketProvider.prototype.addDefaultEvents = function(){ var _this = this; - + this.connection.onerror = function(){ _this._timeout(); }; - + this.connection.onclose = function(){ _this._timeout(); - + // reset all requests and callbacks _this.reset(); }; - + // this.connection.on('timeout', function(){ // _this._timeout(); // }); }; - + /** Will parse the response and make an array out of it. - + @method _parseResponse @param {String} data */ WebsocketProvider.prototype._parseResponse = function(data) { var _this = this, returnValues = []; - + // DE-CHUNKER var dechunkedData = data .replace(/\}[\n\r]?\{/g,'}|--|{') // }{ @@ -65407,59 +65407,59 @@ .replace(/\}[\n\r]?\[\{/g,'}|--|[{') // }[{ .replace(/\}\][\n\r]?\{/g,'}]|--|{') // }]{ .split('|--|'); - + dechunkedData.forEach(function(data){ - + // prepend the last chunk if(_this.lastChunk) data = _this.lastChunk + data; - + var result = null; - + try { result = JSON.parse(data); - + } catch(e) { - + _this.lastChunk = data; - + // start timeout to cancel all requests clearTimeout(_this.lastChunkTimeout); _this.lastChunkTimeout = setTimeout(function(){ _this._timeout(); throw errors.InvalidResponse(data); }, 1000 * 15); - + return; } - + // cancel timeout and set chunk to null clearTimeout(_this.lastChunkTimeout); _this.lastChunk = null; - + if(result) returnValues.push(result); }); - + return returnValues; }; - - + + /** Adds a callback to the responseCallbacks object, which will be called if a response matching the response Id will arrive. - + @method _addResponseCallback */ WebsocketProvider.prototype._addResponseCallback = function(payload, callback) { var id = payload.id || payload[0].id; var method = payload.method || payload[0].method; - + this.responseCallbacks[id] = callback; this.responseCallbacks[id].method = method; - + var _this = this; - + // schedule triggering the error response if a custom timeout is set if (this._customTimeout) { setTimeout(function () { @@ -65470,10 +65470,10 @@ }, this._customTimeout); } }; - + /** Timeout all requests when the end/error event is fired - + @method _timeout */ WebsocketProvider.prototype._timeout = function() { @@ -65484,18 +65484,18 @@ } } }; - - + + WebsocketProvider.prototype.send = function (payload, callback) { var _this = this; - + if (this.connection.readyState === this.connection.CONNECTING) { setTimeout(function () { _this.send(payload, callback); }, 10); return; } - + // try reconnect, when connection is gone // if(!this.connection.writable) // this.connection.connect({url: this.url}); @@ -65509,58 +65509,58 @@ callback(new Error('connection not open')); return; } - + this.connection.send(JSON.stringify(payload)); this._addResponseCallback(payload, callback); }; - + /** Subscribes to provider events.provider - + @method on @param {String} type 'notifcation', 'connect', 'error', 'end' or 'data' @param {Function} callback the callback to call */ WebsocketProvider.prototype.on = function (type, callback) { - + if(typeof callback !== 'function') throw new Error('The second parameter callback must be a function.'); - + switch(type){ case 'data': this.notificationCallbacks.push(callback); break; - + case 'connect': this.connection.onopen = callback; break; - + case 'end': this.connection.onclose = callback; break; - + case 'error': this.connection.onerror = callback; break; - + // default: // this.connection.on(type, callback); // break; } }; - + // TODO add once - + /** Removes event listener - + @method removeListener @param {String} type 'notifcation', 'connect', 'error', 'end' or 'data' @param {Function} callback the callback to call */ WebsocketProvider.prototype.removeListener = function (type, callback) { var _this = this; - + switch(type){ case 'data': this.notificationCallbacks.forEach(function(cb, index){ @@ -65568,18 +65568,18 @@ _this.notificationCallbacks.splice(index, 1); }); break; - + // TODO remvoving connect missing - + // default: // this.connection.removeListener(type, callback); // break; } }; - + /** Removes all event listeners - + @method removeAllListeners @param {String} type 'notifcation', 'connect', 'error', 'end' or 'data' */ @@ -65588,66 +65588,66 @@ case 'data': this.notificationCallbacks = []; break; - + // TODO remvoving connect properly missing - + case 'connect': this.connection.onopen = null; break; - + case 'end': this.connection.onclose = null; break; - + case 'error': this.connection.onerror = null; break; - + default: // this.connection.removeAllListeners(type); break; } }; - + /** Resets the providers, clears all callbacks - + @method reset */ WebsocketProvider.prototype.reset = function () { this._timeout(); this.notificationCallbacks = []; - + // this.connection.removeAllListeners('error'); // this.connection.removeAllListeners('end'); // this.connection.removeAllListeners('timeout'); - + this.addDefaultEvents(); }; - + WebsocketProvider.prototype.disconnect = function () { if (this.connection) { this.connection.close(); } }; - + module.exports = WebsocketProvider; - + }).call(this,require("buffer").Buffer) },{"buffer":84,"underscore":325,"url":327,"web3-core-helpers":338,"websocket":408}],401:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -65656,34 +65656,34 @@ * @author Fabian Vogelsteller * @date 2017 */ - + "use strict"; - + var core = require('web3-core'); var Subscriptions = require('web3-core-subscriptions').subscriptions; var Method = require('web3-core-method'); // var formatters = require('web3-core-helpers').formatters; var Net = require('web3-net'); - - + + var Shh = function Shh() { var _this = this; - + // sets _requestmanager core.packageInit(this, arguments); - + // overwrite setProvider var setProvider = this.setProvider; this.setProvider = function () { setProvider.apply(_this, arguments); _this.net.setProvider.apply(_this, arguments); }; - + this.clearSubscriptions = _this._requestManager.clearSubscriptions; - + this.net = new Net(this.currentProvider); - - + + [ new Subscriptions({ name: 'subscribe', @@ -65696,7 +65696,7 @@ } } }), - + new Method({ name: 'getVersion', call: 'shh_version', @@ -65782,7 +65782,7 @@ call: 'shh_deleteSymKey', params: 1 }), - + new Method({ name: 'newMessageFilter', call: 'shh_newMessageFilter', @@ -65798,14 +65798,14 @@ call: 'shh_deleteMessageFilter', params: 1 }), - + new Method({ name: 'post', call: 'shh_post', params: 1, inputFormatter: [null] }), - + new Method({ name: 'unsubscribe', call: 'shh_unsubscribe', @@ -65816,31 +65816,31 @@ method.setRequestManager(_this._requestManager); }); }; - + core.addProviders(Shh); - - - + + + module.exports = Shh; - - - + + + },{"web3-core":348,"web3-core-method":339,"web3-core-subscriptions":345,"web3-net":372}],402:[function(require,module,exports){ arguments[4][154][0].apply(exports,arguments) },{"dup":154}],403:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -65850,16 +65850,16 @@ * @author Fabian Vogelsteller * @date 2017 */ - - + + var _ = require('underscore'); var ethjsUnit = require('ethjs-unit'); var utils = require('./utils.js'); var soliditySha3 = require('./soliditySha3.js'); var randomHex = require('randomhex'); - - - + + + /** * Fires an error in an event emitter and callback and returns the eventemitter * @@ -65872,20 +65872,20 @@ */ var _fireError = function (error, emitter, reject, callback) { /*jshint maxcomplexity: 10 */ - + // add data if given if(_.isObject(error) && !(error instanceof Error) && error.data) { if(_.isObject(error.data) || _.isArray(error.data)) { error.data = JSON.stringify(error.data, null, 2); } - + error = error.message +"\n"+ error.data; } - + if(_.isString(error)) { error = new Error(error); } - + if (_.isFunction(callback)) { callback(error); } @@ -65902,7 +65902,7 @@ reject(error); }, 1); } - + if(emitter && _.isFunction(emitter.emit)) { // emit later, to be able to return emitter setTimeout(function () { @@ -65910,10 +65910,10 @@ emitter.removeAllListeners(); }, 1); } - + return emitter; }; - + /** * Should be used to create full function/event name from json abi * @@ -65925,11 +65925,11 @@ if (_.isObject(json) && json.name && json.name.indexOf('(') !== -1) { return json.name; } - + return json.name + '(' + _flattenTypes(false, json.inputs).join(',') + ')'; }; - - + + /** * Should be used to flatten json abi inputs/outputs into an array of type-representing-strings * @@ -65942,7 +65942,7 @@ { // console.log("entered _flattenTypes. inputs/outputs: " + puts) var types = []; - + puts.forEach(function(param) { if (typeof param.components === 'object') { if (param.type.substring(0, 5) !== 'tuple') { @@ -65970,11 +65970,11 @@ types.push(param.type); } }); - + return types; }; - - + + /** * Should be called to get ascii from it's hex representation * @@ -65985,7 +65985,7 @@ var hexToAscii = function(hex) { if (!utils.isHexStrict(hex)) throw new Error('The parameter must be a valid HEX string.'); - + var str = ""; var i = 0, l = hex.length; if (hex.substring(0, 2) === '0x') { @@ -65995,10 +65995,10 @@ var code = parseInt(hex.substr(i, 2), 16); str += String.fromCharCode(code); } - + return str; }; - + /** * Should be called to get hex representation (prefixed by 0x) of ascii string * @@ -66015,12 +66015,12 @@ var n = code.toString(16); hex += n.length < 2 ? '0' + n : n; } - + return "0x" + hex; }; - - - + + + /** * Returns value of unit in Wei * @@ -66036,7 +66036,7 @@ } return unit; }; - + /** * Takes a number of wei and converts it to any other ether unit. * @@ -66060,14 +66060,14 @@ */ var fromWei = function(number, unit) { unit = getUnitValue(unit); - + if(!utils.isBN(number) && !_.isString(number)) { throw new Error('Please pass numbers as strings or BigNumber objects to avoid precision errors.'); } - + return utils.isBN(number) ? ethjsUnit.fromWei(number, unit) : ethjsUnit.fromWei(number, unit).toString(10); }; - + /** * Takes a number of a unit and converts it to wei. * @@ -66092,17 +66092,17 @@ */ var toWei = function(number, unit) { unit = getUnitValue(unit); - + if(!utils.isBN(number) && !_.isString(number)) { throw new Error('Please pass numbers as strings or BigNumber objects to avoid precision errors.'); } - + return utils.isBN(number) ? ethjsUnit.toWei(number, unit) : ethjsUnit.toWei(number, unit).toString(10); }; - - - - + + + + /** * Converts to a checksum address * @@ -66112,16 +66112,16 @@ */ var toChecksumAddress = function (address) { if (typeof address === 'undefined') return ''; - + if(!/^(0x)?[0-9a-f]{40}$/i.test(address)) throw new Error('Given address "'+ address +'" is not a valid Ethereum address.'); - - - + + + address = address.toLowerCase().replace(/^0x/i,''); var addressHash = utils.sha3(address).replace(/^0x/i,''); var checksumAddress = '0x'; - + for (var i = 0; i < address.length; i++ ) { // If ith character is 9 to f then make it uppercase if (parseInt(addressHash[i], 16) > 7) { @@ -66132,9 +66132,9 @@ } return checksumAddress; }; - - - + + + module.exports = { _fireError: _fireError, _jsonInterfaceMethodToString: _jsonInterfaceMethodToString, @@ -66156,57 +66156,57 @@ toChecksumAddress: toChecksumAddress, toHex: utils.toHex, toBN: utils.toBN, - + bytesToHex: utils.bytesToHex, hexToBytes: utils.hexToBytes, - + hexToNumberString: utils.hexToNumberString, - + hexToNumber: utils.hexToNumber, toDecimal: utils.hexToNumber, // alias - + numberToHex: utils.numberToHex, fromDecimal: utils.numberToHex, // alias - + hexToUtf8: utils.hexToUtf8, hexToString: utils.hexToUtf8, toUtf8: utils.hexToUtf8, - + utf8ToHex: utils.utf8ToHex, stringToHex: utils.utf8ToHex, fromUtf8: utils.utf8ToHex, - + hexToAscii: hexToAscii, toAscii: hexToAscii, asciiToHex: asciiToHex, fromAscii: asciiToHex, - + unitMap: ethjsUnit.unitMap, toWei: toWei, fromWei: fromWei, - + padLeft: utils.leftPad, leftPad: utils.leftPad, padRight: utils.rightPad, rightPad: utils.rightPad, toTwosComplement: utils.toTwosComplement }; - - + + },{"./soliditySha3.js":404,"./utils.js":405,"ethjs-unit":153,"randomhex":274,"underscore":325}],404:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -66215,15 +66215,15 @@ * @author Fabian Vogelsteller * @date 2017 */ - + var _ = require('underscore'); var BN = require('bn.js'); var utils = require('./utils.js'); - - + + var _elementaryName = function (name) { /*jshint maxcomplexity:false */ - + if (name.startsWith('int[')) { return 'int256' + name.slice(3); } else if (name === 'int') { @@ -66243,19 +66243,19 @@ } return name; }; - + // Parse N from type var _parseTypeN = function (type) { var typesize = /^\D+(\d+).*$/.exec(type); return typesize ? parseInt(typesize[1], 10) : null; }; - + // Parse N from type[] var _parseTypeNArray = function (type) { var arraySize = /^\D+\d*\[(\d+)\]$/.exec(type); return arraySize ? parseInt(arraySize[1], 10) : null; }; - + var _parseNumber = function (arg) { var type = typeof arg; if (type === 'string') { @@ -66274,20 +66274,20 @@ throw new Error(arg +' is not a number'); } }; - + var _solidityPack = function (type, value, arraySize) { /*jshint maxcomplexity:false */ - + var size, num; type = _elementaryName(type); - - + + if (type === 'bytes') { - + if (value.replace(/^0x/i,'').length % 2 !== 0) { throw new Error('Invalid bytes characters '+ value.length); } - + return value; } else if (type === 'string') { return utils.utf8ToHex(value); @@ -66299,102 +66299,102 @@ } else { size = 40; } - + if(!utils.isAddress(value)) { throw new Error(value +' is not a valid address, or the checksum is invalid.'); } - + return utils.leftPad(value.toLowerCase(), size); } - + size = _parseTypeN(type); - + if (type.startsWith('bytes')) { - + if(!size) { throw new Error('bytes[] not yet supported in solidity'); } - + // must be 32 byte slices when in an array if(arraySize) { size = 32; } - + if (size < 1 || size > 32 || size < value.replace(/^0x/i,'').length / 2 ) { throw new Error('Invalid bytes' + size +' for '+ value); } - + return utils.rightPad(value, size * 2); } else if (type.startsWith('uint')) { - + if ((size % 8) || (size < 8) || (size > 256)) { throw new Error('Invalid uint'+size+' size'); } - + num = _parseNumber(value); if (num.bitLength() > size) { throw new Error('Supplied uint exceeds width: ' + size + ' vs ' + num.bitLength()); } - + if(num.lt(new BN(0))) { throw new Error('Supplied uint '+ num.toString() +' is negative'); } - + return size ? utils.leftPad(num.toString('hex'), size/8 * 2) : num; } else if (type.startsWith('int')) { - + if ((size % 8) || (size < 8) || (size > 256)) { throw new Error('Invalid int'+size+' size'); } - + num = _parseNumber(value); if (num.bitLength() > size) { throw new Error('Supplied int exceeds width: ' + size + ' vs ' + num.bitLength()); } - + if(num.lt(new BN(0))) { return num.toTwos(size).toString('hex'); } else { return size ? utils.leftPad(num.toString('hex'), size/8 * 2) : num; } - + } else { // FIXME: support all other types throw new Error('Unsupported or invalid type: ' + type); } }; - - + + var _processSoliditySha3Args = function (arg) { /*jshint maxcomplexity:false */ - + if(_.isArray(arg)) { throw new Error('Autodetection of array types is not supported.'); } - + var type, value = ''; var hexArg, arraySize; - + // if type is given if (_.isObject(arg) && (arg.hasOwnProperty('v') || arg.hasOwnProperty('t') || arg.hasOwnProperty('value') || arg.hasOwnProperty('type'))) { type = arg.hasOwnProperty('t') ? arg.t : arg.type; value = arg.hasOwnProperty('v') ? arg.v : arg.value; - + // otherwise try to guess the type } else { - + type = utils.toHex(arg, true); value = utils.toHex(arg); - + if (!type.startsWith('int') && !type.startsWith('uint')) { type = 'bytes'; } } - + if ((type.startsWith('int') || type.startsWith('uint')) && typeof value === 'string' && !/^(-)?0x/i.test(value)) { value = new BN(value); } - + // get the array size if(_.isArray(value)) { arraySize = _parseTypeNArray(type); @@ -66404,8 +66404,8 @@ arraySize = value.length; } } - - + + if (_.isArray(value)) { hexArg = value.map(function (val) { return _solidityPack(type, val, arraySize).toString('hex').replace('0x',''); @@ -66415,9 +66415,9 @@ hexArg = _solidityPack(type, value, arraySize); return hexArg.toString('hex').replace('0x',''); } - + }; - + /** * Hashes solidity values to a sha3 hash using keccak 256 * @@ -66426,34 +66426,34 @@ */ var soliditySha3 = function () { /*jshint maxcomplexity:false */ - + var args = Array.prototype.slice.call(arguments); - + var hexArgs = _.map(args, _processSoliditySha3Args); - + // console.log(args, hexArgs); // console.log('0x'+ hexArgs.join('')); - + return utils.sha3('0x'+ hexArgs.join('')); }; - - + + module.exports = soliditySha3; - + },{"./utils.js":405,"bn.js":402,"underscore":325}],405:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -66462,14 +66462,14 @@ * @author Fabian Vogelsteller * @date 2017 */ - + var _ = require('underscore'); var BN = require('bn.js'); var numberToBN = require('number-to-bn'); var utf8 = require('utf8'); var Hash = require("eth-lib/lib/hash"); - - + + /** * Returns true if object is BN, otherwise false * @@ -66481,7 +66481,7 @@ return object instanceof BN || (object && object.constructor && object.constructor.name === 'BN'); }; - + /** * Returns true if object is BigNumber, otherwise false * @@ -66492,7 +66492,7 @@ var isBigNumber = function (object) { return object && object.constructor && object.constructor.name === 'BigNumber'; }; - + /** * Takes an input and transforms it into an BN * @@ -66507,8 +66507,8 @@ throw new Error(e + ' Given value: "'+ number +'"'); } }; - - + + /** * Takes and input transforms it into BN and if it is negative value, into two's complement * @@ -66519,7 +66519,7 @@ var toTwosComplement = function (number) { return '0x'+ toBN(number).toTwos(256).toString(16, 64); }; - + /** * Checks if the given string is an address * @@ -66539,9 +66539,9 @@ return checkAddressChecksum(address); } }; - - - + + + /** * Checks if the given string is a checksummed address * @@ -66553,7 +66553,7 @@ // Check each case address = address.replace(/^0x/i,''); var addressHash = sha3(address.toLowerCase()).replace(/^0x/i,''); - + for (var i = 0; i < 40; i++ ) { // the nth letter should be uppercase if the nth digit of casemap is 1 if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) { @@ -66562,7 +66562,7 @@ } return true; }; - + /** * Should be called to pad string to expected length * @@ -66575,12 +66575,12 @@ var leftPad = function (string, chars, sign) { var hasPrefix = /^0x/i.test(string) || typeof string === 'number'; string = string.toString(16).replace(/^0x/i,''); - + var padding = (chars - string.length + 1 >= 0) ? chars - string.length + 1 : 0; - + return (hasPrefix ? '0x' : '') + new Array(padding).join(sign ? sign : "0") + string; }; - + /** * Should be called to pad string to expected length * @@ -66593,13 +66593,13 @@ var rightPad = function (string, chars, sign) { var hasPrefix = /^0x/i.test(string) || typeof string === 'number'; string = string.toString(16).replace(/^0x/i,''); - + var padding = (chars - string.length + 1 >= 0) ? chars - string.length + 1 : 0; - + return (hasPrefix ? '0x' : '') + string + (new Array(padding).join(sign ? sign : "0")); }; - - + + /** * Should be called to get hex representation (prefixed by 0x) of utf8 string * @@ -66610,13 +66610,13 @@ var utf8ToHex = function(str) { str = utf8.encode(str); var hex = ""; - + // remove \u0000 padding from either side str = str.replace(/^(?:\u0000)*/,''); str = str.split("").reverse().join(""); str = str.replace(/^(?:\u0000)*/,''); str = str.split("").reverse().join(""); - + for(var i = 0; i < str.length; i++) { var code = str.charCodeAt(i); // if (code !== 0) { @@ -66624,10 +66624,10 @@ hex += n.length < 2 ? '0' + n : n; // } } - + return "0x" + hex; }; - + /** * Should be called to get utf8 from it's hex representation * @@ -66638,30 +66638,30 @@ var hexToUtf8 = function(hex) { if (!isHexStrict(hex)) throw new Error('The parameter "'+ hex +'" must be a valid HEX string.'); - + var str = ""; var code = 0; hex = hex.replace(/^0x/i,''); - + // remove 00 padding from either side hex = hex.replace(/^(?:00)*/,''); hex = hex.split("").reverse().join(""); hex = hex.replace(/^(?:00)*/,''); hex = hex.split("").reverse().join(""); - + var l = hex.length; - + for (var i=0; i < l; i+=2) { code = parseInt(hex.substr(i, 2), 16); // if (code !== 0) { str += String.fromCharCode(code); // } } - + return utf8.decode(str); }; - - + + /** * Converts value to it's number representation * @@ -66673,10 +66673,10 @@ if (!value) { return value; } - + return toBN(value).toNumber(); }; - + /** * Converts value to it's decimal representation in string * @@ -66686,11 +66686,11 @@ */ var hexToNumberString = function (value) { if (!value) return value; - + return toBN(value).toString(10); }; - - + + /** * Converts value to it's hex representation * @@ -66702,18 +66702,18 @@ if (_.isNull(value) || _.isUndefined(value)) { return value; } - + if (!isFinite(value) && !isHexStrict(value)) { throw new Error('Given input "'+value+'" is not a number.'); } - + var number = toBN(value); var result = number.toString(16); - + return number.lt(new BN(0)) ? '-0x' + result.substr(1) : '0x' + result; }; - - + + /** * Convert a byte array to a hex string * @@ -66732,7 +66732,7 @@ } return '0x'+ hex.join(""); }; - + /** * Convert a hex string to a byte array * @@ -66744,18 +66744,18 @@ */ var hexToBytes = function(hex) { hex = hex.toString(16); - + if (!isHexStrict(hex)) { throw new Error('Given value "'+ hex +'" is not a valid hex string.'); } - + hex = hex.replace(/^0x/i,''); - + for (var bytes = [], c = 0; c < hex.length; c += 2) bytes.push(parseInt(hex.substr(c, 2), 16)); return bytes; }; - + /** * Auto converts any given value into it's hex representation. * @@ -66768,20 +66768,20 @@ */ var toHex = function (value, returnType) { /*jshint maxcomplexity: false */ - + if (isAddress(value)) { return returnType ? 'address' : '0x'+ value.toLowerCase().replace(/^0x/i,''); } - + if (_.isBoolean(value)) { return returnType ? 'bool' : value ? '0x01' : '0x00'; } - - + + if (_.isObject(value) && !isBigNumber(value) && !isBN(value)) { return returnType ? 'string' : utf8ToHex(JSON.stringify(value)); } - + // if its a negative number, pass it through numberToHex if (_.isString(value)) { if (value.indexOf('-0x') === 0 || value.indexOf('-0X') === 0) { @@ -66792,11 +66792,11 @@ return returnType ? 'string' : utf8ToHex(value); } } - + return returnType ? (value < 0 ? 'int256' : 'uint256') : numberToHex(value); }; - - + + /** * Check if string is HEX, requires a 0x in front * @@ -66807,7 +66807,7 @@ var isHexStrict = function (hex) { return ((_.isString(hex) || _.isNumber(hex)) && /^(-)?0x[0-9a-f]*$/i.test(hex)); }; - + /** * Check if string is HEX * @@ -66818,8 +66818,8 @@ var isHex = function (hex) { return ((_.isString(hex) || _.isNumber(hex)) && /^(-0x|0x)?[0-9a-f]*$/i.test(hex)); }; - - + + /** * Returns true if given string is a valid Ethereum block header bloom. * @@ -66837,7 +66837,7 @@ } return false; }; - + /** * Returns true if given string is a valid log topic. * @@ -66855,8 +66855,8 @@ } return false; }; - - + + /** * Hashes values to a sha3 hash using keccak 256 * @@ -66866,14 +66866,14 @@ * @return {String} the sha3 string */ var SHA3_NULL_S = '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'; - + var sha3 = function (value) { if (isHexStrict(value) && /^0x/i.test((value).toString())) { value = hexToBytes(value); } - + var returnValue = Hash.keccak256(value); // jshint ignore:line - + if(returnValue === SHA3_NULL_S) { return null; } else { @@ -66882,8 +66882,8 @@ }; // expose the under the hood keccak256 sha3._Hash = Hash; - - + + module.exports = { BN: BN, isBN: isBN, @@ -66908,7 +66908,7 @@ toTwosComplement: toTwosComplement, sha3: sha3 }; - + },{"bn.js":402,"eth-lib/lib/hash":134,"number-to-bn":237,"underscore":325,"utf8":329}],406:[function(require,module,exports){ module.exports={ "_from": "web3@1.0.0-beta.36", @@ -66994,21 +66994,21 @@ }, "version": "1.0.0-beta.36" } - + },{}],407:[function(require,module,exports){ /* This file is part of web3.js. - + web3.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + web3.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ @@ -67022,10 +67022,10 @@ * Marian Oancea * @date 2017 */ - + "use strict"; - - + + var version = require('../package.json').version; var core = require('web3-core'); var Eth = require('web3-eth'); @@ -67034,33 +67034,33 @@ var Shh = require('web3-shh'); var Bzz = require('web3-bzz'); var utils = require('web3-utils'); - + var Web3 = function Web3() { var _this = this; - + // sets _requestmanager etc core.packageInit(this, arguments); - + this.version = version; this.utils = utils; - + this.eth = new Eth(this); this.shh = new Shh(this); this.bzz = new Bzz(this); - + // overwrite package setProvider var setProvider = this.setProvider; this.setProvider = function (provider, net) { setProvider.apply(_this, arguments); - + this.eth.setProvider(provider, net); this.shh.setProvider(provider, net); this.bzz.setProvider(provider); - + return true; }; }; - + Web3.version = version; Web3.utils = utils; Web3.modules = { @@ -67070,31 +67070,31 @@ Shh: Shh, Bzz: Bzz }; - + core.addProviders(Web3); - + module.exports = Web3; - - + + },{"../package.json":406,"web3-bzz":335,"web3-core":348,"web3-eth":371,"web3-eth-personal":369,"web3-net":372,"web3-shh":401,"web3-utils":403}],408:[function(require,module,exports){ var _global = (function() { return this || {}; })(); var NativeWebSocket = _global.WebSocket || _global.MozWebSocket; var websocket_version = require('./version'); - - + + /** * Expose a W3C WebSocket class with just one or two arguments. */ function W3CWebSocket(uri, protocols) { var native_instance; - + if (protocols) { native_instance = new NativeWebSocket(uri, protocols); } else { native_instance = new NativeWebSocket(uri); } - + /** * 'native_instance' is an instance of nativeWebSocket (the browser's WebSocket * class). Since it is an Object it will be returned as it is when creating an @@ -67111,7 +67111,7 @@ }); }); } - + /** * Module exports. */ @@ -67119,10 +67119,10 @@ 'w3cwebsocket' : NativeWebSocket ? W3CWebSocket : null, 'version' : websocket_version }; - + },{"./version":409}],409:[function(require,module,exports){ module.exports = require('../package.json').version; - + },{"../package.json":410}],410:[function(require,module,exports){ module.exports={ "_from": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible", @@ -67217,10 +67217,10 @@ }, "version": "1.0.26" } - + },{}],411:[function(require,module,exports){ var request = require('xhr-request') - + module.exports = function (url, options) { return new Promise(function (resolve, reject) { request(url, options, function (err, data) { @@ -67229,19 +67229,19 @@ }); }); }; - + },{"xhr-request":412}],412:[function(require,module,exports){ var queryString = require('query-string') var setQuery = require('url-set-query') var assign = require('object-assign') var ensureHeader = require('./lib/ensure-header.js') - + // this is replaced in the browser var request = require('./lib/request.js') - + var mimeTypeJson = 'application/json' var noop = function () {} - + module.exports = xhrRequest function xhrRequest (url, opt, cb) { if (!url || typeof url !== 'string') { @@ -67254,13 +67254,13 @@ if (cb && typeof cb !== 'function') { throw new TypeError('expected cb to be undefined or a function') } - + cb = cb || noop opt = opt || {} - + var defaultResponse = opt.json ? 'json' : 'text' opt = assign({ responseType: defaultResponse }, opt) - + var headers = opt.headers || {} var method = (opt.method || 'GET').toUpperCase() var query = opt.query @@ -67270,27 +67270,27 @@ } url = setQuery(url, query) } - + // allow json response if (opt.responseType === 'json') { ensureHeader(headers, 'Accept', mimeTypeJson) } - + // if body content is json if (opt.json && method !== 'GET' && method !== 'HEAD') { ensureHeader(headers, 'Content-Type', mimeTypeJson) opt.body = JSON.stringify(opt.body) } - + opt.method = method opt.url = url opt.headers = headers delete opt.query delete opt.json - + return request(opt, cb) } - + },{"./lib/ensure-header.js":413,"./lib/request.js":415,"object-assign":238,"query-string":266,"url-set-query":326}],413:[function(require,module,exports){ module.exports = ensureHeader function ensureHeader (headers, key, value) { @@ -67299,7 +67299,7 @@ headers[key] = value } } - + },{}],414:[function(require,module,exports){ module.exports = getResponse function getResponse (opt, resp) { @@ -67313,23 +67313,23 @@ rawRequest: resp.rawRequest ? resp.rawRequest : resp } } - + },{}],415:[function(require,module,exports){ var xhr = require('xhr') var normalize = require('./normalize-response') var noop = function () {} - + module.exports = xhrRequest function xhrRequest (opt, cb) { delete opt.uri - + // for better JSON.parse error handling than xhr module var useJson = false if (opt.responseType === 'json') { opt.responseType = 'text' useJson = true } - + var req = xhr(opt, function xhrRequestResult (err, resp, body) { if (useJson && !err) { try { @@ -67339,13 +67339,13 @@ err = e } } - + resp = normalize(opt, resp) if (err) cb(err, null, resp) else cb(err, body, resp) cb = noop }) - + // Patch abort() so that it also calls the callback, but with an error var onabort = req.onabort req.onabort = function () { @@ -67354,23 +67354,23 @@ cb = noop return ret } - + return req } - + },{"./normalize-response":414,"xhr":416}],416:[function(require,module,exports){ "use strict"; var window = require("global/window") var isFunction = require("is-function") var parseHeaders = require("parse-headers") var xtend = require("xtend") - + module.exports = createXHR // Allow use of default import syntax in TypeScript module.exports.default = createXHR; createXHR.XMLHttpRequest = window.XMLHttpRequest || noop createXHR.XDomainRequest = "withCredentials" in (new createXHR.XMLHttpRequest()) ? createXHR.XMLHttpRequest : window.XDomainRequest - + forEachArray(["get", "put", "post", "patch", "head", "delete"], function(method) { createXHR[method === "delete" ? "del" : method] = function(uri, options, callback) { options = initParams(uri, options, callback) @@ -67378,23 +67378,23 @@ return _createXHR(options) } }) - + function forEachArray(array, iterator) { for (var i = 0; i < array.length; i++) { iterator(array[i]) } } - + function isEmpty(obj){ for(var i in obj){ if(obj.hasOwnProperty(i)) return false } return true } - + function initParams(uri, options, callback) { var params = uri - + if (isFunction(options)) { callback = options if (typeof uri === "string") { @@ -67403,21 +67403,21 @@ } else { params = xtend(options, {uri: uri}) } - + params.callback = callback return params } - + function createXHR(uri, options, callback) { options = initParams(uri, options, callback) return _createXHR(options) } - + function _createXHR(options) { if(typeof options.callback === "undefined"){ throw new Error("callback argument missing") } - + var called = false var callback = function cbOnce(err, response, body){ if(!called){ @@ -67425,32 +67425,32 @@ options.callback(err, response, body) } } - + function readystatechange() { if (xhr.readyState === 4) { setTimeout(loadFunc, 0) } } - + function getBody() { // Chrome with requestType=blob throws errors arround when even testing access to responseText var body = undefined - + if (xhr.response) { body = xhr.response } else { body = xhr.responseText || getXml(xhr) } - + if (isJson) { try { body = JSON.parse(body) } catch (e) {} } - + return body } - + function errorFunc(evt) { clearTimeout(timeoutTimer) if(!(evt instanceof Error)){ @@ -67459,7 +67459,7 @@ evt.statusCode = 0 return callback(evt, failureResponse) } - + // will load the data & process the response in a special response object function loadFunc() { if (aborted) return @@ -67473,7 +67473,7 @@ } var response = failureResponse var err = null - + if (status !== 0){ response = { body: getBody(), @@ -67491,9 +67491,9 @@ } return callback(err, response, response.body) } - + var xhr = options.xhr || null - + if (!xhr) { if (options.cors || options.useXDR) { xhr = new createXHR.XDomainRequest() @@ -67501,7 +67501,7 @@ xhr = new createXHR.XMLHttpRequest() } } - + var key var aborted var uri = xhr.url = options.uri || options.url @@ -67519,7 +67519,7 @@ url: uri, rawRequest: xhr } - + if ("json" in options && options.json !== false) { isJson = true headers["accept"] || headers["Accept"] || (headers["Accept"] = "application/json") //Don't override existing accept header declared by user @@ -67528,7 +67528,7 @@ body = JSON.stringify(options.json === true ? body : options.json) } } - + xhr.onreadystatechange = readystatechange xhr.onload = loadFunc xhr.onerror = errorFunc @@ -67558,7 +67558,7 @@ errorFunc(e) }, options.timeout ) } - + if (xhr.setRequestHeader) { for(key in headers){ if(headers.hasOwnProperty(key)){ @@ -67568,27 +67568,27 @@ } else if (options.headers && !isEmpty(options.headers)) { throw new Error("Headers cannot be set on an XDomainRequest object") } - + if ("responseType" in options) { xhr.responseType = options.responseType } - + if ("beforeSend" in options && typeof options.beforeSend === "function" ) { options.beforeSend(xhr) } - + // Microsoft Edge browser sends "undefined" when send is called with undefined value. // XMLHttpRequest spec says to pass null as body to indicate no body // See https://github.com/naugtur/xhr/issues/100. xhr.send(body || null) - + return xhr - - + + } - + function getXml(xhr) { // xhr.responseXML will throw Exception "InvalidStateError" or "DOMException" // See https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseXML. @@ -67601,12 +67601,12 @@ return xhr.responseXML } } catch (e) {} - + return null } - + function noop() {} - + },{"global/window":160,"is-function":184,"parse-headers":246,"xtend":423}],417:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { @@ -67652,7 +67652,7 @@ return SyntaxError; }(Error)); exports.SyntaxError = SyntaxError; - + },{}],418:[function(require,module,exports){ "use strict"; function __export(m) { @@ -67662,7 +67662,7 @@ __export(require("./xml-http-request")); var xml_http_request_event_target_1 = require("./xml-http-request-event-target"); exports.XMLHttpRequestEventTarget = xml_http_request_event_target_1.XMLHttpRequestEventTarget; - + },{"./xml-http-request":422,"./xml-http-request-event-target":420}],419:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -67678,7 +67678,7 @@ return ProgressEvent; }()); exports.ProgressEvent = ProgressEvent; - + },{}],420:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -67720,7 +67720,7 @@ return XMLHttpRequestEventTarget; }()); exports.XMLHttpRequestEventTarget = XMLHttpRequestEventTarget; - + },{}],421:[function(require,module,exports){ (function (Buffer){ "use strict"; @@ -67800,7 +67800,7 @@ return XMLHttpRequestUpload; }(xml_http_request_event_target_1.XMLHttpRequestEventTarget)); exports.XMLHttpRequestUpload = XMLHttpRequestUpload; - + }).call(this,require("buffer").Buffer) },{"./xml-http-request-event-target":420,"buffer":84}],422:[function(require,module,exports){ (function (process,Buffer){ @@ -68250,29 +68250,29 @@ XMLHttpRequest.prototype.nodejsHttpAgent = http.globalAgent; XMLHttpRequest.prototype.nodejsHttpsAgent = https.globalAgent; XMLHttpRequest.prototype.nodejsBaseUrl = null; - + }).call(this,require('_process'),require("buffer").Buffer) },{"./errors":417,"./progress-event":419,"./xml-http-request-event-target":420,"./xml-http-request-upload":421,"_process":257,"buffer":84,"cookiejar":88,"http":312,"https":175,"os":240,"url":327}],423:[function(require,module,exports){ module.exports = extend - + var hasOwnProperty = Object.prototype.hasOwnProperty; - + function extend() { var target = {} - + for (var i = 0; i < arguments.length; i++) { var source = arguments[i] - + for (var key in source) { if (hasOwnProperty.call(source, key)) { target[key] = source[key] } } } - + return target } - + },{}],424:[function(require,module,exports){ "use strict"; (function() { @@ -68345,6 +68345,6 @@ }; }(); }()); - + //# sourceURL=/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy/wk.bridge.js },{}]},{},[1]); diff --git a/Sources/web3swift/Operations/WriteOperation.swift b/Sources/web3swift/Operations/WriteOperation.swift index f1fa366aa..10fd972cb 100755 --- a/Sources/web3swift/Operations/WriteOperation.swift +++ b/Sources/web3swift/Operations/WriteOperation.swift @@ -13,9 +13,9 @@ public class WriteOperation: ReadOperation { // FIXME: Rewrite this to CodableTransaction /// Sends signed or unsigned transaction for write operation. /// - Parameters: - /// - password: Password for the private key in the keystore manager attached to the provider + /// - password: Password for the private key in the keystore manager attached to the provider /// you set to `web3` passed in the initializer. - /// - policies: Determining the behaviour of how transaction attributes like gas limit and + /// - policies: Determining the behaviour of how transaction attributes like gas limit and /// nonce are resolved. Default value is ``Policies/auto``. /// - sendRaw: If set to `true` transaction will be signed and sent using `eth_sendRawTransaction`. /// Otherwise, no signing attempts will take place and the `eth_sendTransaction` RPC will be used instead. diff --git a/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift b/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift index 806a038ee..0d7323ed9 100644 --- a/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift +++ b/Sources/web3swift/Tokens/ERC20/ERC20BaseProperties.swift @@ -1,6 +1,6 @@ // // ERC20BaseProperties.swift -// +// // // Created by Jann Driessen on 21.11.22. // diff --git a/Sources/web3swift/Tokens/ERC20/ERC20BasePropertiesProvider.swift b/Sources/web3swift/Tokens/ERC20/ERC20BasePropertiesProvider.swift index 7f5c1a75d..e786e1517 100644 --- a/Sources/web3swift/Tokens/ERC20/ERC20BasePropertiesProvider.swift +++ b/Sources/web3swift/Tokens/ERC20/ERC20BasePropertiesProvider.swift @@ -1,6 +1,6 @@ // // ERC20BasePropertiesProvider.swift -// +// // // Created by Jann Driessen on 21.11.22. // @@ -8,7 +8,7 @@ import BigInt import Foundation -/// The default implementation of access of common [ERC-20](https://eips.ethereum.org/EIPS/eip-20#methods) properties `name`, `symbol` and `decimals`. +/// The default implementation of access of common [ERC-20](https://eips.ethereum.org/EIPS/eip-20#methods) properties `name`, `symbol` and `decimals`. public final class ERC20BasePropertiesProvider { var name: String? var symbol: String? diff --git a/Sources/web3swift/Web3/Web3+Resolver.swift b/Sources/web3swift/Web3/Web3+Resolver.swift index c2eb0b481..1fa3d6299 100644 --- a/Sources/web3swift/Web3/Web3+Resolver.swift +++ b/Sources/web3swift/Web3/Web3+Resolver.swift @@ -1,6 +1,6 @@ // // Web3+Resolver.swift -// +// // // Created by Jann Driessen on 01.11.22. // diff --git a/TestToken/Helpers/TokenBasics/ERC20.sol b/TestToken/Helpers/TokenBasics/ERC20.sol index 7ecea0073..87593bfdf 100755 --- a/TestToken/Helpers/TokenBasics/ERC20.sol +++ b/TestToken/Helpers/TokenBasics/ERC20.sol @@ -202,4 +202,4 @@ contract ERC20 is IERC20 { amount); _burn(account, amount); } -} \ No newline at end of file +} diff --git a/TestToken/Helpers/TokenBasics/IERC20.sol b/TestToken/Helpers/TokenBasics/IERC20.sol index 6e322fe03..37e5a447c 100755 --- a/TestToken/Helpers/TokenBasics/IERC20.sol +++ b/TestToken/Helpers/TokenBasics/IERC20.sol @@ -31,4 +31,4 @@ interface IERC20 { address indexed spender, uint256 value ); -} \ No newline at end of file +} diff --git a/TestToken/Token/Web3SwiftToken.sol b/TestToken/Token/Web3SwiftToken.sol index 6f3fab8fd..3d4e91ded 100755 --- a/TestToken/Token/Web3SwiftToken.sol +++ b/TestToken/Token/Web3SwiftToken.sol @@ -16,4 +16,3 @@ contract web3swift is ERC20 { constructor() public { _mint(msg.sender, INITIAL_SUPPLY); } - diff --git a/Tests/web3swiftTests/localTests/EthereumAddressTest.swift b/Tests/web3swiftTests/localTests/EthereumAddressTest.swift index 7747d2155..51f862d6d 100644 --- a/Tests/web3swiftTests/localTests/EthereumAddressTest.swift +++ b/Tests/web3swiftTests/localTests/EthereumAddressTest.swift @@ -1,6 +1,6 @@ // // EthereumAddressTest.swift -// +// // // Created by JeneaVranceanu on 03.02.2023. // diff --git a/Tests/web3swiftTests/localTests/PromisesTests.swift b/Tests/web3swiftTests/localTests/PromisesTests.swift index 434c6389c..eb9bd3509 100755 --- a/Tests/web3swiftTests/localTests/PromisesTests.swift +++ b/Tests/web3swiftTests/localTests/PromisesTests.swift @@ -15,7 +15,7 @@ // func testGetBalancePromise() async throws { // let web3 = try await Web3.new(LocalTestCase.url) // let balance = try await web3.eth.getBalance(for: EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")!) -// +// // } // // func testEstimateGasPromise() async throws { @@ -29,7 +29,7 @@ // writeTX.transaction.from = tempKeystore!.addresses?.first // writeTX.transaction.value = BigUInt("1.0", Utilities.Units.eth)! // let estimate = try await writeTX.estimateGas(with: nil) -// +// // XCTAssertEqual(estimate, 21000) // } // @@ -47,12 +47,12 @@ // deployTx.transaction.gasLimitPolicy = .manual(3000000) // let result = try await deployTx.send(password: "web3swift") // let txHash = result.hash -// +// // // Thread.sleep(forTimeInterval: 1.0) // // let receipt = try await web3.eth.transactionReceipt(txHash) -// +// // // switch receipt.status { // case .notYetProcessed: @@ -87,7 +87,7 @@ // } // // MARK: Writing Data flow // let estimate1 = try await tx1.estimateGas(with: nil) -// +// // // let amount2 = Utilities.parseToBigUInt("0.00000005", units: .eth) // 50 gwei // @@ -100,7 +100,7 @@ // } // // MARK: Writing Data flow // let estimate2 = try await tx2.estimateGas(with: nil) -// +// // XCTAssertLessThanOrEqual(estimate2 - estimate1, 22000) // } // // FIXME: Temporary deleted method `sendETH` should be restored. @@ -113,7 +113,7 @@ // // writeTX.transaction.from = allAddresses[0] // // writeTX.transaction.gasPricePolicy = .manual(gasPricePolicy) // // let result = try await writeTX.send() -// // +// // // // } // // // func testERC20tokenBalancePromise() async throws { diff --git a/Tests/web3swiftTests/remoteTests/EIP1559Tests.swift b/Tests/web3swiftTests/remoteTests/EIP1559Tests.swift index e493edace..3b325e0a3 100644 --- a/Tests/web3swiftTests/remoteTests/EIP1559Tests.swift +++ b/Tests/web3swiftTests/remoteTests/EIP1559Tests.swift @@ -1,6 +1,6 @@ // // EIP1559Tests.swift -// +// // // Created by Jann Driessen on 01.11.22. // diff --git a/Tests/web3swiftTests/remoteTests/GasOracleTests.swift b/Tests/web3swiftTests/remoteTests/GasOracleTests.swift index 9b7769b82..fe32ff1ea 100644 --- a/Tests/web3swiftTests/remoteTests/GasOracleTests.swift +++ b/Tests/web3swiftTests/remoteTests/GasOracleTests.swift @@ -87,7 +87,7 @@ class GasOracleTests: XCTestCase { // 111000000000, // 60 percentile // 127210686305 // 90 percentile // ] -// +// // let gasPriceLegacyPercentiles = await oracle.gasPriceLegacyPercentiles() // XCTAssertEqual(gasPriceLegacyPercentiles, etalonPercentiles, "Arrays should be equal") // } @@ -109,12 +109,12 @@ class GasOracleTests: XCTestCase { // func testBlockNumber() async throws { // let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) // let latestBlockNumber = try await web3.eth.getBlockNumber() -// +// // } // // func testgetAccounts() async throws { // let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) // let accounts = try await web3.eth.getAccounts() -// +// // } } diff --git a/Tests/web3swiftTests/remoteTests/InfuraTests.swift b/Tests/web3swiftTests/remoteTests/InfuraTests.swift index 8de339cdd..6cf8b8e80 100755 --- a/Tests/web3swiftTests/remoteTests/InfuraTests.swift +++ b/Tests/web3swiftTests/remoteTests/InfuraTests.swift @@ -97,7 +97,7 @@ class InfuraTests: XCTestCase { // filter.topics = [EventFilterParameters.Topic.strings([EventFilterParameters.Topic.string("0xefdcf2c36f3756ce7247628afdb632fa4ee12ec5"), EventFilterParameters.Topic.string(nil)])] // // need // let eventParserResult = try await contract!.getIndexedEvents(eventName: "Transfer", filter: filter, joinWithReceipts: true) -// +// // XCTAssert(eventParserResult.count == 2) // XCTAssert(eventParserResult.first?.transactionReceipt != nil) // XCTAssert(eventParserResult.first?.eventLog != nil) @@ -112,10 +112,10 @@ class InfuraTests: XCTestCase { // filter.parameterFilters = [([EthereumAddress("0xefdcf2c36f3756ce7247628afdb632fa4ee12ec5")!] as [EventFilterable]), ([EthereumAddress("0xd5395c132c791a7f46fa8fc27f0ab6bacd824484")!] as [EventFilterable])] // guard let eventParser = contract?.createEventParser("Transfer", filter: filter) else {return XCTFail()} // let present = try eventParser.parseBlockByNumberPromise(UInt64(5200120)).wait() -// +// // XCTAssert(present.count == 1) // } -// +// // func testUserCaseEventParsing() throws { // let contractAddress = EthereumAddress("0x7ff546aaccd379d2d1f241e1d29cdd61d4d50778") // let jsonString = "[{\"constant\":false,\"inputs\":[{\"name\":\"_id\",\"type\":\"string\"}],\"name\":\"deposit\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_id\",\"type\":\"string\"},{\"indexed\":true,\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Deposit\",\"type\":\"event\"}]" diff --git a/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift b/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift index 84db3b8df..6256ef11f 100644 --- a/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift +++ b/Tests/web3swiftTests/remoteTests/PolicyResolverTests.swift @@ -1,6 +1,6 @@ // // PolicyResolverTests.swift -// +// // // Created by Jann Driessen on 01.11.22. // diff --git a/Tests/web3swiftTests/remoteTests/RemoteParsingTests.swift b/Tests/web3swiftTests/remoteTests/RemoteParsingTests.swift index b4b272b20..62ae4c463 100755 --- a/Tests/web3swiftTests/remoteTests/RemoteParsingTests.swift +++ b/Tests/web3swiftTests/remoteTests/RemoteParsingTests.swift @@ -14,23 +14,23 @@ import Web3Core class RemoteParsingTests: XCTestCase { // func testEventParsing1usingABIv2() throws { -// +// // let jsonString = "[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"version\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"balance\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"},{\"name\":\"_extraData\",\"type\":\"bytes\"}],\"name\":\"approveAndCall\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"remaining\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"_initialAmount\",\"type\":\"uint256\"},{\"name\":\"_tokenName\",\"type\":\"string\"},{\"name\":\"_decimalUnits\",\"type\":\"uint8\"},{\"name\":\"_tokenSymbol\",\"type\":\"string\"}],\"type\":\"constructor\"},{\"payable\":false,\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_spender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},]" -// +// // let contractAddress = EthereumAddress("0x45245bc59219eeaaf6cd3f382e078a461ff9de7b") -// +// // let web3 = Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) -// +// // let contract = web3.contract(jsonString, at: contractAddress, abiVersion: 2) -// +// // guard let eventParser = contract?.createEventParser("Transfer", filter: nil) else {return XCTFail()} -// +// // let present = try eventParser.parseBlockByNumber(UInt64(5200088)) -// +// // XCTAssert(present.count == 1) -// +// // let decoded = present[0].decodedResult -// +// // XCTAssert(decoded["name"] as! String == "Transfer") // XCTAssert(decoded["_to"] as! EthereumAddress == EthereumAddress("0xa5dcf6e0fee38f635c4a8d50d90e24400ed547d2")!) // XCTAssert(decoded["_from"] as! EthereumAddress == EthereumAddress("0xdbf493e8d7db835192c02b992bd1ab72e96fd2e3")!) @@ -65,7 +65,7 @@ class RemoteParsingTests: XCTestCase { // let present = try eventParser.parseBlockByNumber(i) // for p in present { // + "\n") -// +// // .addHexPrefix() + "\n") // .address + "\n") // .address + "\n") From 6a29977dfff91a8fe4064810b43639bf08e0f9ef Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 15 Feb 2023 18:28:27 +0100 Subject: [PATCH 113/210] Update pre-commit.yml --- .github/workflows/pre-commit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 65fec63f9..19c7b391b 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -1,6 +1,6 @@ # https://pre-commit.com # This GitHub Action assumes that the repo contains a valid .pre-commit-config.yaml file. -# Using pre-commit.ci is even better that using GitHub Actions for pre-commit. +# Using pre-commit.ci is even better than using GitHub Actions for pre-commit. name: pre-commit on: pull_request: From 561eb1ca9dc39d9aea7d4118821a22b7bb0e7694 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 18 Feb 2023 23:32:46 +0100 Subject: [PATCH 114/210] =?UTF-8?q?Don=E2=80=99t=20analyze?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/macOS-tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index 7ea285b9d..8b475e4d4 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -38,11 +38,10 @@ jobs: run: | pip3 install --upgrade pip pip3 install codespell - codespell --count --ignore-words-list=ans,deriver,inout,packag --skip="*.js,*WordLists.swift" + codespell # See .codespellrc for args - name: SwiftLint run: | swiftlint --fix - # swiftlint analyze - name: Resolve dependencies run: swift package resolve - name: Build From 58c12c33334fecfa7288de94ff6cd5a99f17e012 Mon Sep 17 00:00:00 2001 From: albertopeam Date: Mon, 20 Feb 2023 22:53:33 +0100 Subject: [PATCH 115/210] added EthereumAddress conformance to CustomStringConvertible. added sender to CustomStringConvertible for CodableTransaction --- .../Web3Core/EthereumAddress/EthereumAddress.swift | 13 +++++++++++++ .../Web3Core/Transaction/CodableTransaction.swift | 2 +- .../localTests/EthereumAddressTest.swift | 13 ++++++++++++- .../localTests/TransactionsTests.swift | 12 ++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/Sources/Web3Core/EthereumAddress/EthereumAddress.swift b/Sources/Web3Core/EthereumAddress/EthereumAddress.swift index cec972433..ddc54b963 100755 --- a/Sources/Web3Core/EthereumAddress/EthereumAddress.swift +++ b/Sources/Web3Core/EthereumAddress/EthereumAddress.swift @@ -155,3 +155,16 @@ extension EthereumAddress: Codable { extension EthereumAddress: Hashable { } extension EthereumAddress: APIResultType { } + +// MARK: - CustomStringConvertible + +extension EthereumAddress: CustomStringConvertible { + /// Used when converting an instance to a string + public var description: String { + var toReturn = "" + toReturn += "EthereumAddress" + "\n" + toReturn += "type: " + String(describing: type) + "\n" + toReturn += "address: " + String(describing: address) + "\n" + return toReturn + } +} diff --git a/Sources/Web3Core/Transaction/CodableTransaction.swift b/Sources/Web3Core/Transaction/CodableTransaction.swift index af407e00f..806e2a36f 100644 --- a/Sources/Web3Core/Transaction/CodableTransaction.swift +++ b/Sources/Web3Core/Transaction/CodableTransaction.swift @@ -271,7 +271,7 @@ extension CodableTransaction: CustomStringConvertible { var toReturn = "" toReturn += "Transaction" + "\n" toReturn += String(describing: self.envelope) - toReturn += "from: " + String(describing: self.sender?.address) + "\n" + toReturn += "from: " + String(describing: self.sender) + "\n" toReturn += "hash: " + String(describing: self.hash?.toHexString().addHexPrefix()) + "\n" return toReturn } diff --git a/Tests/web3swiftTests/localTests/EthereumAddressTest.swift b/Tests/web3swiftTests/localTests/EthereumAddressTest.swift index 7747d2155..4862047c7 100644 --- a/Tests/web3swiftTests/localTests/EthereumAddressTest.swift +++ b/Tests/web3swiftTests/localTests/EthereumAddressTest.swift @@ -1,6 +1,6 @@ // // EthereumAddressTest.swift -// +// // // Created by JeneaVranceanu on 03.02.2023. // @@ -35,4 +35,15 @@ class EthereumAddressTest: XCTestCase { XCTAssertNil(ethereumAddress) } + func testDescription() async throws { + let rawAddress = "0x200eb5ccda1c35b0f5bf82552fdd65a8aee98e79" + let ethereumAddress = EthereumAddress(rawAddress) + + let sut = String(describing: ethereumAddress) + print(sut) + + XCTAssertTrue(sut.contains("EthereumAddress\n")) + XCTAssertTrue(sut.contains("type: normal\n")) + XCTAssertTrue(sut.contains("address: 0x")) + } } diff --git a/Tests/web3swiftTests/localTests/TransactionsTests.swift b/Tests/web3swiftTests/localTests/TransactionsTests.swift index 4af0c4fa9..27a7d3d6a 100644 --- a/Tests/web3swiftTests/localTests/TransactionsTests.swift +++ b/Tests/web3swiftTests/localTests/TransactionsTests.swift @@ -592,6 +592,18 @@ class TransactionsTests: XCTestCase { } } + func testDescription() async throws { + let vector = testVector[TestCase.eip1559.rawValue] + let jsonData = try XCTUnwrap(vector.JSON.data(using: .utf8)) + let txn = try JSONDecoder().decode(CodableTransaction.self, from: jsonData) + + let sut = String(describing: txn) + + XCTAssertTrue(sut.contains("Transaction")) + XCTAssertTrue(sut.contains("from: ")) + XCTAssertTrue(sut.contains("hash: ")) + } + // ***** Legacy Tests ***** // TODO: Replace `XCTAssert` with more explicit `XCTAssertEqual`, where Applicable From 57e282eb3a3a5079b2c7d29cdcc4f394e1264707 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Tue, 21 Feb 2023 16:58:40 +0200 Subject: [PATCH 116/210] chore: added comment about --fix flag in CI --- .github/workflows/macOS-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index 8b475e4d4..db570bbf0 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -41,6 +41,7 @@ jobs: codespell # See .codespellrc for args - name: SwiftLint run: | + # Adding --fix flag makes CI print only errors that cannot be fixed automatically swiftlint --fix - name: Resolve dependencies run: swift package resolve From 86b01a3665fe6ffc14925d44c249306fa18fd94b Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 22 Feb 2023 08:13:40 +0100 Subject: [PATCH 117/210] SwiftLint recommends a double run when fixing https://github.com/realm/SwiftLint#xcode recommends > If you wish to fix violations as well, your script could run `swiftlint --fix && swiftlint` instead of just `swiftlint`. This will mean that all correctable violations are fixed while ensuring warnings show up in your project for remaining violations. https://github.com/realm/SwiftLint#auto-correct > Standard linting is disabled while correcting because of the high likelihood of violations (or their offsets) being incorrect after modifying a file while applying corrections. --- .github/workflows/macOS-tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index db570bbf0..2d2eb41cd 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -42,7 +42,10 @@ jobs: - name: SwiftLint run: | # Adding --fix flag makes CI print only errors that cannot be fixed automatically - swiftlint --fix + # 1. Make automated fixes that are possible + # 2. git diff to see what automated fixes were made + # 3. See https://github.com/realm/SwiftLint#xcode explains why the double run + swiftlint --fix && git diff && swiftlint - name: Resolve dependencies run: swift package resolve - name: Build From 3ffeb4965a97f712dd6a3b52f2e7f1ab902f0713 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 22 Feb 2023 08:18:38 +0100 Subject: [PATCH 118/210] Enable `git diff` in GitHub Actions https://stackoverflow.com/questions/65944700/how-to-run-git-diff-in-github-actions --- .github/workflows/macOS-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index 2d2eb41cd..5fb14bae9 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -34,6 +34,8 @@ jobs: cancel-in-progress: false steps: - uses: actions/checkout@v3 + with: + fetch-depth: 2 # Enable `git diff` in GitHub Actions - name: Discover typos run: | pip3 install --upgrade pip From cf253863b6d3a00ccfb22fb05015f7929ac75b45 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Wed, 22 Feb 2023 10:12:41 +0200 Subject: [PATCH 119/210] chore: removed obsolete comment --- .github/workflows/macOS-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index 5fb14bae9..5ae62c35c 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -43,7 +43,6 @@ jobs: codespell # See .codespellrc for args - name: SwiftLint run: | - # Adding --fix flag makes CI print only errors that cannot be fixed automatically # 1. Make automated fixes that are possible # 2. git diff to see what automated fixes were made # 3. See https://github.com/realm/SwiftLint#xcode explains why the double run From 374bd1d1eb2af95140186a834b21836927cddb69 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 22 Feb 2023 09:58:09 +0100 Subject: [PATCH 120/210] git diff origin/${GITHUB_REF##*/} origin/${GITHUB_HEAD_REF} --- .github/workflows/macOS-tests.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index 5ae62c35c..27f72c2c1 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -34,8 +34,6 @@ jobs: cancel-in-progress: false steps: - uses: actions/checkout@v3 - with: - fetch-depth: 2 # Enable `git diff` in GitHub Actions - name: Discover typos run: | pip3 install --upgrade pip @@ -46,7 +44,7 @@ jobs: # 1. Make automated fixes that are possible # 2. git diff to see what automated fixes were made # 3. See https://github.com/realm/SwiftLint#xcode explains why the double run - swiftlint --fix && git diff && swiftlint + swiftlint --fix && git diff origin/${GITHUB_REF##*/} origin/${GITHUB_HEAD_REF} && swiftlint - name: Resolve dependencies run: swift package resolve - name: Build From 6effeb453eaf89404ccf7c2e006b313479d6ce01 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 22 Feb 2023 10:02:42 +0100 Subject: [PATCH 121/210] git diff origin/develop origin/${GITHUB_HEAD_REF} --- .github/workflows/macOS-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index 27f72c2c1..dd88fbbfb 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -44,7 +44,7 @@ jobs: # 1. Make automated fixes that are possible # 2. git diff to see what automated fixes were made # 3. See https://github.com/realm/SwiftLint#xcode explains why the double run - swiftlint --fix && git diff origin/${GITHUB_REF##*/} origin/${GITHUB_HEAD_REF} && swiftlint + swiftlint --fix && git diff origin/develop origin/${GITHUB_HEAD_REF} && swiftlint - name: Resolve dependencies run: swift package resolve - name: Build From 17e7890c8774f554f81763372ff2e7a316ef6a88 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 22 Feb 2023 10:35:54 +0100 Subject: [PATCH 122/210] Update macOS-tests.yml --- .github/workflows/macOS-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index dd88fbbfb..bad209335 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -44,7 +44,7 @@ jobs: # 1. Make automated fixes that are possible # 2. git diff to see what automated fixes were made # 3. See https://github.com/realm/SwiftLint#xcode explains why the double run - swiftlint --fix && git diff origin/develop origin/${GITHUB_HEAD_REF} && swiftlint + swiftlint --fix && git branch && git status && git diff origin/${GITHUB_REF} origin/${GITHUB_HEAD_REF} && swiftlint - name: Resolve dependencies run: swift package resolve - name: Build From dbc1e4baf392519d630b16b791a5b9aa7ec0c967 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 22 Feb 2023 10:47:54 +0100 Subject: [PATCH 123/210] Update macOS-tests.yml --- .github/workflows/macOS-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index bad209335..fafd8f8fe 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -44,7 +44,7 @@ jobs: # 1. Make automated fixes that are possible # 2. git diff to see what automated fixes were made # 3. See https://github.com/realm/SwiftLint#xcode explains why the double run - swiftlint --fix && git branch && git status && git diff origin/${GITHUB_REF} origin/${GITHUB_HEAD_REF} && swiftlint + echo "test" > target.txt && swiftlint --fix && git branch && git status && git diff && swiftlint - name: Resolve dependencies run: swift package resolve - name: Build From b0ded207c3c0df5bd1cb24ef17989bbd443d5632 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 22 Feb 2023 13:43:25 +0100 Subject: [PATCH 124/210] Update macOS-tests.yml --- .github/workflows/macOS-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index fafd8f8fe..729fd6d80 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -44,7 +44,7 @@ jobs: # 1. Make automated fixes that are possible # 2. git diff to see what automated fixes were made # 3. See https://github.com/realm/SwiftLint#xcode explains why the double run - echo "test" > target.txt && swiftlint --fix && git branch && git status && git diff && swiftlint + swiftlint --fix && git diff && swiftlint - name: Resolve dependencies run: swift package resolve - name: Build From e00f053de7fcf252947d37dcbcf02c537c7e5441 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 22 Feb 2023 13:46:52 +0100 Subject: [PATCH 125/210] Update macOS-tests.yml --- .github/workflows/macOS-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml index 729fd6d80..3e3bafb6f 100644 --- a/.github/workflows/macOS-tests.yml +++ b/.github/workflows/macOS-tests.yml @@ -41,10 +41,10 @@ jobs: codespell # See .codespellrc for args - name: SwiftLint run: | - # 1. Make automated fixes that are possible - # 2. git diff to see what automated fixes were made + # 1. Make all automated fixes that are possible + # 2. git diff to see what (if any) automated fixes were made # 3. See https://github.com/realm/SwiftLint#xcode explains why the double run - swiftlint --fix && git diff && swiftlint + swiftlint --fix --quiet && git diff && swiftlint --quiet - name: Resolve dependencies run: swift package resolve - name: Build From 767bb493a0eb323db0de64ea8c1fcb3151b80171 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 22 Feb 2023 15:57:15 +0100 Subject: [PATCH 126/210] Update .swiftlint.yml --- .swiftlint.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index a794f4992..fafe7f358 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -60,9 +60,9 @@ opt_in_rules: - unneeded_parentheses_in_closure_argument - weak_delegate -# force warnings -force_cast: error -force_try: error +# force warnings (disabled above) +# force_cast: error +# force_try: error custom_rules: commented_out_code: From 2df196a259482d9c1aee0504786bdf7c86b57e90 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 22 Feb 2023 18:24:31 +0100 Subject: [PATCH 127/210] Update .swiftlint.yml --- .swiftlint.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index fafe7f358..f7519e42f 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -60,10 +60,6 @@ opt_in_rules: - unneeded_parentheses_in_closure_argument - weak_delegate -# force warnings (disabled above) -# force_cast: error -# force_try: error - custom_rules: commented_out_code: included: .*\.swift # regex that defines paths to include during linting. optional. From c52e1c40a213ac24ed3827c4821c4da47b915b2a Mon Sep 17 00:00:00 2001 From: albertopeam Date: Wed, 22 Feb 2023 22:11:57 +0100 Subject: [PATCH 128/210] removed dead print --- Tests/web3swiftTests/localTests/EthereumAddressTest.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Tests/web3swiftTests/localTests/EthereumAddressTest.swift b/Tests/web3swiftTests/localTests/EthereumAddressTest.swift index 4862047c7..8182a4be4 100644 --- a/Tests/web3swiftTests/localTests/EthereumAddressTest.swift +++ b/Tests/web3swiftTests/localTests/EthereumAddressTest.swift @@ -40,7 +40,6 @@ class EthereumAddressTest: XCTestCase { let ethereumAddress = EthereumAddress(rawAddress) let sut = String(describing: ethereumAddress) - print(sut) XCTAssertTrue(sut.contains("EthereumAddress\n")) XCTAssertTrue(sut.contains("type: normal\n")) From f5c38f37b0e9ec2fdb66f00c9a6b58f77ab49f80 Mon Sep 17 00:00:00 2001 From: albertopeam Date: Wed, 22 Feb 2023 22:25:50 +0100 Subject: [PATCH 129/210] added address to test --- Tests/web3swiftTests/localTests/EthereumAddressTest.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/web3swiftTests/localTests/EthereumAddressTest.swift b/Tests/web3swiftTests/localTests/EthereumAddressTest.swift index 8182a4be4..9cf812ba0 100644 --- a/Tests/web3swiftTests/localTests/EthereumAddressTest.swift +++ b/Tests/web3swiftTests/localTests/EthereumAddressTest.swift @@ -43,6 +43,6 @@ class EthereumAddressTest: XCTestCase { XCTAssertTrue(sut.contains("EthereumAddress\n")) XCTAssertTrue(sut.contains("type: normal\n")) - XCTAssertTrue(sut.contains("address: 0x")) + XCTAssertTrue(sut.contains("address: 0x200EB5cCdA1c35B0F5Bf82552FDD65a8AEe98E79")) } } From 316ad9b2e23ed409469923659c7d8f0076929a29 Mon Sep 17 00:00:00 2001 From: albertopeam Date: Wed, 22 Feb 2023 22:26:17 +0100 Subject: [PATCH 130/210] added hash to test --- Tests/web3swiftTests/localTests/TransactionsTests.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/web3swiftTests/localTests/TransactionsTests.swift b/Tests/web3swiftTests/localTests/TransactionsTests.swift index 27a7d3d6a..9192bdb80 100644 --- a/Tests/web3swiftTests/localTests/TransactionsTests.swift +++ b/Tests/web3swiftTests/localTests/TransactionsTests.swift @@ -601,7 +601,8 @@ class TransactionsTests: XCTestCase { XCTAssertTrue(sut.contains("Transaction")) XCTAssertTrue(sut.contains("from: ")) - XCTAssertTrue(sut.contains("hash: ")) + XCTAssertTrue(sut.contains(#"hash: Optional("0x41dc0cd9b133e0d4e47e269988b0109c966db5220d57e2a7f3cdc6c2f8de6a72")"#)) + } // ***** Legacy Tests ***** From 43f1e9a6aff98cceb47729be1eede70f437da756 Mon Sep 17 00:00:00 2001 From: albertopeam Date: Thu, 23 Feb 2023 22:01:40 +0100 Subject: [PATCH 131/210] complete from assertion --- Tests/web3swiftTests/localTests/TransactionsTests.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Tests/web3swiftTests/localTests/TransactionsTests.swift b/Tests/web3swiftTests/localTests/TransactionsTests.swift index 9192bdb80..255c5a731 100644 --- a/Tests/web3swiftTests/localTests/TransactionsTests.swift +++ b/Tests/web3swiftTests/localTests/TransactionsTests.swift @@ -600,9 +600,8 @@ class TransactionsTests: XCTestCase { let sut = String(describing: txn) XCTAssertTrue(sut.contains("Transaction")) - XCTAssertTrue(sut.contains("from: ")) + XCTAssertTrue(sut.contains("from: Optional(EthereumAddress\ntype: normal\naddress: 0x9d8A62f656a8d1615C1294fd71e9CFb3E4855A4F\n)\n")) XCTAssertTrue(sut.contains(#"hash: Optional("0x41dc0cd9b133e0d4e47e269988b0109c966db5220d57e2a7f3cdc6c2f8de6a72")"#)) - } // ***** Legacy Tests ***** From a9b4a46971b2a8a860f3d5d6b3fa1ea7544434e9 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Sun, 5 Mar 2023 20:28:33 -0800 Subject: [PATCH 132/210] Update EthereumKeystoreV3.swift --- .../KeystoreManager/EthereumKeystoreV3.swift | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/EthereumKeystoreV3.swift b/Sources/Web3Core/KeystoreManager/EthereumKeystoreV3.swift index d7b6993a4..d2602637c 100755 --- a/Sources/Web3Core/KeystoreManager/EthereumKeystoreV3.swift +++ b/Sources/Web3Core/KeystoreManager/EthereumKeystoreV3.swift @@ -1,4 +1,3 @@ -// web3swift // // Created by Alex Vlasov. // Copyright © 2018 Alex Vlasov. All rights reserved. @@ -71,7 +70,7 @@ public class EthereumKeystoreV3: AbstractKeystore { } } - public init?(password: String = "web3swift", aesMode: String = "aes-128-cbc") throws { + public init?(password: String, aesMode: String = "aes-128-cbc") throws { guard var newPrivateKey = SECP256K1.generatePrivateKey() else { return nil } @@ -81,7 +80,7 @@ public class EthereumKeystoreV3: AbstractKeystore { try encryptDataToStorage(password, keyData: newPrivateKey, aesMode: aesMode) } - public init?(privateKey: Data, password: String = "web3swift", aesMode: String = "aes-128-cbc") throws { + public init?(privateKey: Data, password: String, aesMode: String = "aes-128-cbc") throws { guard privateKey.count == 32 else { return nil } @@ -95,14 +94,18 @@ public class EthereumKeystoreV3: AbstractKeystore { if keyData == nil { throw AbstractKeystoreError.encryptionError("Encryption without key data") } - let saltLen = 32; - let saltData = Data.randomBytes(length: saltLen)! + let saltLen = 32 + guard let saltData = Data.randomBytes(length: saltLen) else { + throw AbstractKeystoreError.noEntropyError + } guard let derivedKey = scrypt(password: password, salt: saltData, length: dkLen, N: N, R: R, P: P) else { throw AbstractKeystoreError.keyDerivationError } let last16bytes = Data(derivedKey[(derivedKey.count - 16)...(derivedKey.count - 1)]) let encryptionKey = Data(derivedKey[0...15]) - let IV = Data.randomBytes(length: 16)! + guard let IV = Data.randomBytes(length: 16) else { + throw AbstractKeystoreError.noEntropyError + } var aesCipher: AES? switch aesMode { case "aes-128-cbc": From 224490275ab2940e854b9c97210b860824749300 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Sun, 5 Mar 2023 20:31:50 -0800 Subject: [PATCH 133/210] Update Data+Extension.swift --- Sources/Web3Core/Utility/Data+Extension.swift | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/Sources/Web3Core/Utility/Data+Extension.swift b/Sources/Web3Core/Utility/Data+Extension.swift index bed56dc0c..448728f1a 100755 --- a/Sources/Web3Core/Utility/Data+Extension.swift +++ b/Sources/Web3Core/Utility/Data+Extension.swift @@ -4,7 +4,6 @@ // import Foundation -import Metal extension Data { init(fromArray values: [T]) { @@ -42,23 +41,21 @@ extension Data { } public static func randomBytes(length: Int) -> Data? { - let entropy_bit_size = length//128 - //# valid_entropy_bit_sizes = [128, 160, 192, 224, 256], count: [12, 15, 18, 21, 24] - var entropy_bytes = [UInt8](repeating: 0, count: entropy_bit_size)// / 8) - let status = SecRandomCopyBytes(kSecRandomDefault, entropy_bytes.count, &entropy_bytes) - - if status != errSecSuccess { // Always test the status. - } else { - entropy_bytes = [UInt8](repeating: 0, count: entropy_bit_size)// / 8) - arc4random_buf(&entropy_bytes, entropy_bytes.count) - } - - let source1 = MTLCreateSystemDefaultDevice()?.makeBuffer(length: length)?.hash.description.data(using: .utf8) - - let entropyData = entropy_bytes.shuffled().map{ bit in - return bit ^ (source1?.randomElement() ?? 0) + for _ in 0...1024 { + var data = Data(repeating: 0, count: length) + let result = data.withUnsafeMutableBytes { (body: UnsafeMutableRawBufferPointer) -> Int32? in + if let bodyAddress = body.baseAddress, body.count > 0 { + let pointer = bodyAddress.assumingMemoryBound(to: UInt8.self) + return SecRandomCopyBytes(kSecRandomDefault, length, pointer) + } else { + return nil + } + } + if let notNilResult = result, notNilResult == errSecSuccess { + return data + } } - return Data(entropyData) + return nil } public func bitsInRange(_ startingBit: Int, _ length: Int) -> UInt64? { // return max of 8 bytes for simplicity, non-public From 4108eddb558b931eafbefc1e6f15d5e50955356d Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Sun, 5 Mar 2023 20:36:18 -0800 Subject: [PATCH 134/210] Update Encodable+Extensions.swift --- Sources/Web3Core/Utility/Encodable+Extensions.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sources/Web3Core/Utility/Encodable+Extensions.swift b/Sources/Web3Core/Utility/Encodable+Extensions.swift index e43a39b7f..1981636e6 100644 --- a/Sources/Web3Core/Utility/Encodable+Extensions.swift +++ b/Sources/Web3Core/Utility/Encodable+Extensions.swift @@ -63,5 +63,3 @@ public extension EncodableToHex where Self: BinaryInteger { extension BigUInt: EncodableToHex { } extension UInt: EncodableToHex { } - -extension Int: EncodableToHex { } From 0847410c2ade515f7771660c42252a837ce316a7 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Sun, 5 Mar 2023 20:36:22 -0800 Subject: [PATCH 135/210] Update String+Extension.swift --- .../Web3Core/Utility/String+Extension.swift | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/Sources/Web3Core/Utility/String+Extension.swift b/Sources/Web3Core/Utility/String+Extension.swift index 0ea3aaaed..dbe0a10ca 100755 --- a/Sources/Web3Core/Utility/String+Extension.swift +++ b/Sources/Web3Core/Utility/String+Extension.swift @@ -32,26 +32,6 @@ extension String { return output } - /// Splits a string into groups of `every` n characters, grouping from left-to-right by default. If `backwards` is true, right-to-left. - public func split(every: Int, backwards: Bool = false) -> [String] { - var result = [String]() - - for i in stride(from: 0, to: self.count, by: every) { - switch backwards { - case true: - let endIndex = self.index(self.endIndex, offsetBy: -i) - let startIndex = self.index(endIndex, offsetBy: -every, limitedBy: self.startIndex) ?? self.startIndex - result.insert(String(self[startIndex..) -> String { let start = index(self.startIndex, offsetBy: bounds.lowerBound) let end = index(self.startIndex, offsetBy: bounds.upperBound) From dd93a0c040bf3b21f7363030e6d37e691aa1b1f0 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Sun, 5 Mar 2023 20:36:25 -0800 Subject: [PATCH 136/210] Update WriteOperation.swift --- .../web3swift/Operations/WriteOperation.swift | 43 ------------------- 1 file changed, 43 deletions(-) diff --git a/Sources/web3swift/Operations/WriteOperation.swift b/Sources/web3swift/Operations/WriteOperation.swift index 5c54b6cff..10fd972cb 100755 --- a/Sources/web3swift/Operations/WriteOperation.swift +++ b/Sources/web3swift/Operations/WriteOperation.swift @@ -42,47 +42,4 @@ public class WriteOperation: ReadOperation { guard let transactionData = transaction.encode(for: .transaction) else { throw Web3Error.dataError } return try await web3.eth.send(raw: transactionData) } - - public func depploy(password: String, policies: Policies = .auto) async throws -> TransactionSendingResult { - //TODO: optimize/cleanup -// try await transaction.resolve(provider: web3.provider) - try await policyResolver.resolveAll(for: &transaction, with: policies) - - guard let attachedKeystoreManager = self.web3.provider.attachedKeystoreManager else { - throw Web3Error.inputError(desc: "Failed to locally sign a transaction") - } - - do { - //TODO: optimize/cleanup -// transaction.unsign() - let account = transaction.from ?? transaction.sender ?? EthereumAddress.contractDeploymentAddress() - var privateKey = try attachedKeystoreManager.UNSAFE_getPrivateKeyData(password: password, account: account) - defer { Data.zero(&privateKey) } - try transaction.sign(privateKey: privateKey, useExtraEntropy: false) - } catch { - throw Web3Error.inputError(desc: "Failed to locally sign a transaction") - } - - //TODO: optimize/cleanup - guard let transactionData = transaction.encode(for: .transaction) else { throw Web3Error.dataError } -// let vectorHash = transaction.hash!.toHexString().addHexPrefix() -// print(vectorHash) - - //TODO: optimize/cleanup - return try await web3.eth.send(raw: transactionData) - } - - // FIXME: Rewrite this to CodableTransaction -// func nonce(for policy: CodableTransaction.NoncePolicy, from: EthereumAddress) async throws -> BigUInt { -// switch policy { -// case .latest: -// return try await self.web3.eth.getTransactionCount(for: from, onBlock: .latest) -// case .pending: -// return try await self.web3.eth.getTransactionCount(for: from, onBlock: .pending) -// case .earliest: -// return try await self.web3.eth.getTransactionCount(for: from, onBlock: .earliest) -// case .exact(let nonce): -// return nonce -// } -// } } From c0506de6df181e315a8d2185dcb0903fc748e777 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Sun, 5 Mar 2023 21:46:02 -0800 Subject: [PATCH 137/210] add the tests --- .../localTests/BIP39ArrayTests.swift | 90 ++++++++++ .../localTests/BIP39StringTests.swift | 91 +++++++++++ .../localTests/BIP39Tests.swift | 154 ++++++++++++++++++ 3 files changed, 335 insertions(+) create mode 100644 Tests/web3swiftTests/localTests/BIP39ArrayTests.swift create mode 100644 Tests/web3swiftTests/localTests/BIP39StringTests.swift create mode 100644 Tests/web3swiftTests/localTests/BIP39Tests.swift diff --git a/Tests/web3swiftTests/localTests/BIP39ArrayTests.swift b/Tests/web3swiftTests/localTests/BIP39ArrayTests.swift new file mode 100644 index 000000000..9c7307b5c --- /dev/null +++ b/Tests/web3swiftTests/localTests/BIP39ArrayTests.swift @@ -0,0 +1,90 @@ +// +// BIP39ArrayTests.swift +// +// +// Created by Daniel Bell on 11/26/22. +// + +import XCTest +@testable import Core +@testable import web3swift + +final class BIP39ArrayTests: XCTestCase { + + let mnemonic = ["fruit", "wave", "dwarf", "banana", "earth", "journey", "tattoo", "true", "farm", "silk", "olive", "fence"] + + func testBIP32keystoreExportPrivateKey() throws { + let keystore = try BIP32Keystore(mnemonicsPhrase: mnemonic, password: "", mnemonicsPassword: "") + XCTAssertNotNil(keystore) + let account = keystore!.addresses![0] + let key = try keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + XCTAssertNotNil(key) + } + + func testBIP32keystoreMatching() throws { + let keystore = try BIP32Keystore(mnemonicsPhrase: mnemonic, password: "", mnemonicsPassword: "banana") + XCTAssertNotNil(keystore) + let account = keystore!.addresses![0] + let key = try keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + let pubKey = Utilities.privateToPublic(key, compressed: true) + XCTAssert(pubKey?.toHexString() == "027160bd3a4d938cac609ff3a11fe9233de7b76c22a80d2b575e202cbf26631659") + } + + func testBIP32keystoreMatchingRootNode() throws { + let keystore = try BIP32Keystore(mnemonicsPhrase: mnemonic, password: "", mnemonicsPassword: "banana") + XCTAssertNotNil(keystore) + let rootNode = try keystore!.serializeRootNodeToString(password: "") + XCTAssert(rootNode == "xprvA2KM71v838kPwE8Lfr12m9DL939TZmPStMnhoFcZkr1nBwDXSG7c3pjYbMM9SaqcofK154zNSCp7W7b4boEVstZu1J3pniLQJJq7uvodfCV") + } + + func testBIP32keystoreCustomPathMatching() throws { + let keystore = try BIP32Keystore(mnemonicsPhrase: mnemonic, password: "", mnemonicsPassword: "banana", prefixPath: "m/44'/60'/0'/0") + XCTAssertNotNil(keystore) + let account = keystore!.addresses![0] + let key = try keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + let pubKey = Utilities.privateToPublic(key, compressed: true) + XCTAssert(pubKey?.toHexString() == "027160bd3a4d938cac609ff3a11fe9233de7b76c22a80d2b575e202cbf26631659") + } + + func testByBIP32keystoreCreateChildAccount() throws { + let keystore = try BIP32Keystore(mnemonicsPhrase: mnemonic, password: "", mnemonicsPassword: "") + XCTAssertNotNil(keystore) + XCTAssertEqual(keystore!.addresses?.count, 1) + try keystore?.createNewChildAccount(password: "") + XCTAssertEqual(keystore?.addresses?.count, 2) + let account = keystore!.addresses![0] + let key = try keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + XCTAssertNotNil(key) + } + + func testByBIP32keystoreCreateCustomChildAccount() throws { + let keystore = try BIP32Keystore(mnemonicsPhrase: mnemonic, password: "", mnemonicsPassword: "") + XCTAssertNotNil(keystore) + XCTAssertEqual(keystore!.addresses?.count, 1) + try keystore?.createNewCustomChildAccount(password: "", path: "/42/1") + XCTAssertEqual(keystore?.addresses?.count, 2) + let account = keystore!.addresses![1] + let key = try keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + XCTAssertNotNil(key) + print(keystore!.addressStorage.paths) + } + + func testByBIP32keystoreSaveAndDeriva() throws { + let keystore = try BIP32Keystore(mnemonicsPhrase: mnemonic, password: "", mnemonicsPassword: "", prefixPath: "m/44'/60'/0'") + XCTAssertNotNil(keystore) + XCTAssertEqual(keystore!.addresses?.count, 1) + try keystore?.createNewCustomChildAccount(password: "", path: "/0/1") + XCTAssertEqual(keystore?.addresses?.count, 2) + let data = try keystore?.serialize() + let recreatedStore = BIP32Keystore(data!) + XCTAssert(keystore?.addresses?.count == recreatedStore?.addresses?.count) + XCTAssert(keystore?.rootPrefix == recreatedStore?.rootPrefix) + print(keystore!.addresses![0].address) + print(keystore!.addresses![1].address) + print(recreatedStore!.addresses![0].address) + print(recreatedStore!.addresses![1].address) + XCTAssert(keystore?.addresses![0] == recreatedStore?.addresses![0]) + XCTAssert(keystore?.addresses![1] == recreatedStore?.addresses![1]) + } + +} diff --git a/Tests/web3swiftTests/localTests/BIP39StringTests.swift b/Tests/web3swiftTests/localTests/BIP39StringTests.swift new file mode 100644 index 000000000..99480f376 --- /dev/null +++ b/Tests/web3swiftTests/localTests/BIP39StringTests.swift @@ -0,0 +1,91 @@ +// +// BIP39StringTests.swift +// +// +// Created by Daniel Bell on 11/26/22. +// + +import XCTest +@testable import Core +@testable import web3swift + + +final class BIP39StringTests: XCTestCase { + + let mnemonic = "fruit wave dwarf banana earth journey tattoo true farm silk olive fence" + + func testBIP32keystoreExportPrivateKey() throws { + let keystore = try BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") + XCTAssertNotNil(keystore) + let account = keystore!.addresses![0] + let key = try keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + XCTAssertNotNil(key) + } + + func testBIP32keystoreMatching() throws { + let keystore = try BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "banana") + XCTAssertNotNil(keystore) + let account = keystore!.addresses![0] + let key = try keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + let pubKey = Utilities.privateToPublic(key, compressed: true) + XCTAssert(pubKey?.toHexString() == "027160bd3a4d938cac609ff3a11fe9233de7b76c22a80d2b575e202cbf26631659") + } + + func testBIP32keystoreMatchingRootNode() throws { + let keystore = try BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "banana") + XCTAssertNotNil(keystore) + let rootNode = try keystore!.serializeRootNodeToString(password: "") + XCTAssert(rootNode == "xprvA2KM71v838kPwE8Lfr12m9DL939TZmPStMnhoFcZkr1nBwDXSG7c3pjYbMM9SaqcofK154zNSCp7W7b4boEVstZu1J3pniLQJJq7uvodfCV") + } + + func testBIP32keystoreCustomPathMatching() throws { + let keystore = try BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "banana", prefixPath: "m/44'/60'/0'/0") + XCTAssertNotNil(keystore) + let account = keystore!.addresses![0] + let key = try keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + let pubKey = Utilities.privateToPublic(key, compressed: true) + XCTAssert(pubKey?.toHexString() == "027160bd3a4d938cac609ff3a11fe9233de7b76c22a80d2b575e202cbf26631659") + } + + func testByBIP32keystoreCreateChildAccount() throws { + let keystore = try BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") + XCTAssertNotNil(keystore) + XCTAssertEqual(keystore!.addresses?.count, 1) + try keystore?.createNewChildAccount(password: "") + XCTAssertEqual(keystore?.addresses?.count, 2) + let account = keystore!.addresses![0] + let key = try keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + XCTAssertNotNil(key) + } + + func testByBIP32keystoreCreateCustomChildAccount() throws { + let keystore = try BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") + XCTAssertNotNil(keystore) + XCTAssertEqual(keystore!.addresses?.count, 1) + try keystore?.createNewCustomChildAccount(password: "", path: "/42/1") + XCTAssertEqual(keystore?.addresses?.count, 2) + let account = keystore!.addresses![1] + let key = try keystore!.UNSAFE_getPrivateKeyData(password: "", account: account) + XCTAssertNotNil(key) + print(keystore!.addressStorage.paths) + } + + func testByBIP32keystoreSaveAndDeriva() throws { + let keystore = try BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "", prefixPath: "m/44'/60'/0'") + XCTAssertNotNil(keystore) + XCTAssertEqual(keystore!.addresses?.count, 1) + try keystore?.createNewCustomChildAccount(password: "", path: "/0/1") + XCTAssertEqual(keystore?.addresses?.count, 2) + let data = try keystore?.serialize() + let recreatedStore = BIP32Keystore(data!) + XCTAssert(keystore?.addresses?.count == recreatedStore?.addresses?.count) + XCTAssert(keystore?.rootPrefix == recreatedStore?.rootPrefix) + print(keystore!.addresses![0].address) + print(keystore!.addresses![1].address) + print(recreatedStore!.addresses![0].address) + print(recreatedStore!.addresses![1].address) + XCTAssert(keystore?.addresses![0] == recreatedStore?.addresses![0]) + XCTAssert(keystore?.addresses![1] == recreatedStore?.addresses![1]) + } + +} diff --git a/Tests/web3swiftTests/localTests/BIP39Tests.swift b/Tests/web3swiftTests/localTests/BIP39Tests.swift new file mode 100644 index 000000000..0431bf075 --- /dev/null +++ b/Tests/web3swiftTests/localTests/BIP39Tests.swift @@ -0,0 +1,154 @@ +// +// BIP39Tests.swift +// +// +// Created by Daniel Bell on 11/26/22. +// + +import XCTest +@testable import Core +@testable import web3swift + +final class BIP39Tests: XCTestCase { + + func testBIP39 () throws { + var entropy = Data.fromHex("00000000000000000000000000000000")! + var phrase = BIP39.generateMnemonicsFromEntropy(entropy: entropy) + XCTAssert( phrase == "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about") + var seed = BIP39.seedFromMmemonics(phrase!, password: "TREZOR") + XCTAssert(seed?.toHexString() == "c55257c360c07c72029aebc1b53c05ed0362ada38ead3e3e9efa3708e53495531f09a6987599d18264c1e1c92f2cf141630c7a3c4ab7c81b2f001698e7463b04") + entropy = Data.fromHex("68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c")! + phrase = BIP39.generateMnemonicsFromEntropy(entropy: entropy) + XCTAssert( phrase == "hamster diagram private dutch cause delay private meat slide toddler razor book happy fancy gospel tennis maple dilemma loan word shrug inflict delay length") + seed = BIP39.seedFromMmemonics(phrase!, password: "TREZOR") + XCTAssert(seed?.toHexString() == "64c87cde7e12ecf6704ab95bb1408bef047c22db4cc7491c4271d170a1b213d20b385bc1588d9c7b38f1b39d415665b8a9030c9ec653d75e65f847d8fc1fc440") + } + + func testBIP39SeedAndMnemConversions() throws { + let seed = Data.randomBytes(length: 32)! + let mnemonics = BIP39.generateMnemonicsFromEntropy(entropy: seed) + let recoveredSeed = BIP39.mnemonicsToEntropy(mnemonics!, language: .english) + XCTAssert(seed == recoveredSeed) + } + +// https://github.com/trezor/python-mnemonic/blob/master/vectors.json + func testBIP39MnemonicIsMultipleOfThree() { + // https://github.com/trezor/python-mnemonic/blob/master/vectors.json#L95 + let mnemonic_12 = "scheme spot photo card baby mountain device kick cradle pact join borrow" + let entropy_12 = BIP39.mnemonicsToEntropy(mnemonic_12, language: .english) + XCTAssertEqual(entropy_12!.toHexString(), "c0ba5a8e914111210f2bd131f3d5e08d") + + let mnemonic_15 = "foster muscle start pluck when army tool surprise essay monitor impulse hello segment garage twenty" + let entropy_15 = BIP39.mnemonicsToEntropy(mnemonic_15, language: .english) + XCTAssertEqual(entropy_15!.toHexString(), "5c123352d35fa218392ed34d31e1c8b56c32befa") + + // https://github.com/trezor/python-mnemonic/blob/master/vectors.json#L101 + let mnemonic_18 = "horn tenant knee talent sponsor spell gate clip pulse soap slush warm silver nephew swap uncle crack brave" + let entropy_18 = BIP39.mnemonicsToEntropy(mnemonic_18, language: .english) + XCTAssertEqual(entropy_18!.toHexString(), "6d9be1ee6ebd27a258115aad99b7317b9c8d28b6d76431c3") + + let mnemonic_21 = "weird change toe upper damp panel unaware long noise resource grant prevent file live travel price cry danger fix manage base" + let entropy_21 = BIP39.mnemonicsToEntropy(mnemonic_21, language: .english) + XCTAssertEqual(entropy_21!.toHexString(), "f924c78e7783733f3b1c1e95d6f196d525630579e5533526ed604371") + + // https://github.com/trezor/python-mnemonic/blob/master/vectors.json#L107 + let mnemonic_24 = "panda eyebrow bullet gorilla call smoke muffin taste mesh discover soft ostrich alcohol speed nation flash devote level hobby quick inner drive ghost inside" + let entropy_24 = BIP39.mnemonicsToEntropy(mnemonic_24, language: .english) + XCTAssertEqual(entropy_24!.toHexString(), "9f6a2878b2520799a44ef18bc7df394e7061a224d2c33cd015b157d746869863") + + // Invalid mnemonics + + let mnemonic_9 = "initial repeat scout eye october lucky rabbit enact unfair" + XCTAssertNil(BIP39.mnemonicsToEntropy(mnemonic_9, language: .english)) + + let mnemonic_16 = "success drip spoon lunar effort unfold clinic seminar custom protect orchard correct pledge cousin slab visa" + XCTAssertNil(BIP39.mnemonicsToEntropy(mnemonic_16, language: .english)) + + let mnemonic_27 = "clock venue style demise net float differ click object poet afraid october hurry organ faint inject cart trade test immense gentle speak almost rude success drip spoon" + XCTAssertNil(BIP39.mnemonicsToEntropy(mnemonic_27, language: .english)) + } + + func testNewBIP32keystore() throws { + let mnemonic = try BIP39.generateMnemonics(bitsOfEntropy: 256)! + let keystore = try BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") + XCTAssert(keystore != nil) + } + + func testSameAddressesFromTheSameMnemonics() throws { + let mnemonic = try BIP39.generateMnemonics(bitsOfEntropy: 256)! + let keystore1 = try BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") + let keystore2 = try BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") + XCTAssert(keystore1?.addresses?.first == keystore2?.addresses?.first) + } + //==================================================================== + func testBIP39Array () throws { + var entropy = Data.fromHex("00000000000000000000000000000000")! + var phrase = BIP39.generateMnemonicsFrom(entropy: entropy) + XCTAssert( phrase == ["abandon", "abandon", "abandon", "abandon", "abandon", "abandon", "abandon", "abandon", "abandon", "abandon", "abandon", "about"]) + var seed = BIP39.seedFromMmemonics(phrase, password: "TREZOR") + XCTAssert(seed?.toHexString() == "c55257c360c07c72029aebc1b53c05ed0362ada38ead3e3e9efa3708e53495531f09a6987599d18264c1e1c92f2cf141630c7a3c4ab7c81b2f001698e7463b04") + entropy = Data.fromHex("68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c")! + phrase = BIP39.generateMnemonicsFrom(entropy: entropy) + XCTAssert( phrase == ["hamster", "diagram", "private", "dutch", "cause", "delay", "private", "meat", "slide", "toddler", "razor", "book", "happy", "fancy", "gospel", "tennis", "maple", "dilemma", "loan", "word", "shrug", "inflict", "delay", "length"]) + seed = BIP39.seedFromMmemonics(phrase, password: "TREZOR") + XCTAssert(seed?.toHexString() == "64c87cde7e12ecf6704ab95bb1408bef047c22db4cc7491c4271d170a1b213d20b385bc1588d9c7b38f1b39d415665b8a9030c9ec653d75e65f847d8fc1fc440") + } + + func testBIP39SeedAndMnemConversionsArray() throws { + let seed = Data.randomBytes(length: 32)! + let mnemonics = BIP39.generateMnemonicsFrom(entropy: seed) + let recoveredSeed = BIP39.mnemonicsToEntropy(mnemonics, language: .english) + XCTAssert(seed == recoveredSeed) + } + +// https://github.com/trezor/python-mnemonic/blob/master/vectors.json + func testBIP39MnemonicIsMultipleOfThreeArray() { + // https://github.com/trezor/python-mnemonic/blob/master/vectors.json#L95 + let mnemonic_12 = ["scheme", "spot", "photo", "card", "baby", "mountain", "device", "kick", "cradle", "pact", "join", "borrow"] + let entropy_12 = BIP39.mnemonicsToEntropy(mnemonic_12, language: .english) + XCTAssertEqual(entropy_12!.toHexString(), "c0ba5a8e914111210f2bd131f3d5e08d") + + let mnemonic_15 = ["foster", "muscle", "start", "pluck", "when", "army", "tool", "surprise", "essay", "monitor", "impulse", "hello", "segment", "garage", "twenty"] + let entropy_15 = BIP39.mnemonicsToEntropy(mnemonic_15, language: .english) + XCTAssertEqual(entropy_15!.toHexString(), "5c123352d35fa218392ed34d31e1c8b56c32befa") + + // https://github.com/trezor/python-mnemonic/blob/master/vectors.json#L101 + let mnemonic_18 = ["horn", "tenant", "knee", "talent", "sponsor", "spell", "gate", "clip", "pulse", "soap", "slush", "warm", "silver", "nephew", "swap", "uncle", "crack", "brave"] + let entropy_18 = BIP39.mnemonicsToEntropy(mnemonic_18, language: .english) + XCTAssertEqual(entropy_18!.toHexString(), "6d9be1ee6ebd27a258115aad99b7317b9c8d28b6d76431c3") + + let mnemonic_21 = ["weird", "change", "toe", "upper", "damp", "panel", "unaware", "long", "noise", "resource", "grant", "prevent", "file", "live", "travel", "price", "cry", "danger", "fix", "manage", "base"] + let entropy_21 = BIP39.mnemonicsToEntropy(mnemonic_21, language: .english) + XCTAssertEqual(entropy_21!.toHexString(), "f924c78e7783733f3b1c1e95d6f196d525630579e5533526ed604371") + + // https://github.com/trezor/python-mnemonic/blob/master/vectors.json#L107 + let mnemonic_24 = ["panda", "eyebrow", "bullet", "gorilla", "call", "smoke", "muffin", "taste", "mesh", "discover", "soft", "ostrich", "alcohol", "speed", "nation", "flash", "devote", "level", "hobby", "quick", "inner", "drive", "ghost", "inside"] + let entropy_24 = BIP39.mnemonicsToEntropy(mnemonic_24, language: .english) + XCTAssertEqual(entropy_24!.toHexString(), "9f6a2878b2520799a44ef18bc7df394e7061a224d2c33cd015b157d746869863") + + // Invalid mnemonics + + let mnemonic_9 = ["initial", "repeat", "scout", "eye", "october", "lucky", "rabbit", "enact", "unfair"] + XCTAssertNil(BIP39.mnemonicsToEntropy(mnemonic_9, language: .english)) + + let mnemonic_16 = ["success", "drip", "spoon", "lunar", "effort", "unfold", "clinic", "seminar", "custom", "protect", "orchard", "correct", "pledge", "cousin", "slab", "visa"] + XCTAssertNil(BIP39.mnemonicsToEntropy(mnemonic_16, language: .english)) + + let mnemonic_27 = ["clock", "venue", "style", "demise", "net", "float", "differ", "click", "object", "poet", "afraid", "october", "hurry", "organ", "faint", "inject", "cart", "trade", "test", "immense", "gentle", "speak", "almost", "rude", "success", "drip", "spoon"] + XCTAssertNil(BIP39.mnemonicsToEntropy(mnemonic_27, language: .english)) + } + + func testNewBIP32keystoreArray() throws { + let mnemonic = BIP39.generateMnemonics(entropy: 256)! + let keystore = try BIP32Keystore(mnemonicsPhrase: mnemonic, password: "", mnemonicsPassword: "") + XCTAssert(keystore != nil) + } + + func testSameAddressesFromTheSameMnemonicsArray() throws { + let mnemonic = BIP39.generateMnemonics(entropy: 256)! + let keystore1 = try BIP32Keystore(mnemonicsPhrase: mnemonic, password: "", mnemonicsPassword: "") + let keystore2 = try BIP32Keystore(mnemonicsPhrase: mnemonic, password: "", mnemonicsPassword: "") + XCTAssert(keystore1?.addresses?.first == keystore2?.addresses?.first) + } + +} From 951ba0cbd68725f8dfa8bdb923fa489dab69b645 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Sun, 5 Mar 2023 22:26:30 -0800 Subject: [PATCH 138/210] add support for array as phrase --- .../KeystoreManager/BIP32HDNode.swift | 290 +++++++++--------- .../KeystoreManager/BIP32Keystore.swift | 48 ++- Sources/Web3Core/KeystoreManager/BIP39.swift | 131 +++++--- .../localTests/BIP39ArrayTests.swift | 2 +- .../localTests/BIP39StringTests.swift | 2 +- .../localTests/BIP39Tests.swift | 2 +- 6 files changed, 267 insertions(+), 208 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift index 6a57a8e43..ad8c0702f 100644 --- a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift @@ -22,12 +22,11 @@ extension UInt32 { } public class HDNode { - public struct HDversion { - // swiftlint:disable force_unwrapping - public var privatePrefix: Data = Data.fromHex("0x0488ADE4")! - public var publicPrefix: Data = Data.fromHex("0x0488B21E")! - // swiftlint:enable force_unwrapping - public init() {} + + private struct HDversion{ + public static var privatePrefix: Data? = Data.fromHex("0x0488ADE4") + public static var publicPrefix: Data? = Data.fromHex("0x0488B21E") + } public var path: String? = "m" public var privateKey: Data? @@ -40,11 +39,11 @@ public class HDNode { childNumber >= (UInt32(1) << 31) } public var index: UInt32 { - if self.isHardened { - return childNumber - (UInt32(1) << 31) - } else { - return childNumber - } + if self.isHardened { + return childNumber - (UInt32(1) << 31) + } else { + return childNumber + } } public var hasPrivate: Bool { privateKey != nil @@ -65,7 +64,7 @@ public class HDNode { guard data.count == 82 else { return nil } let header = data[0..<4] var serializePrivate = false - if header == HDNode.HDversion().privatePrefix { + if header == HDversion.privatePrefix { serializePrivate = true } depth = data[4..<5].bytes[0] @@ -90,9 +89,10 @@ public class HDNode { public init?(seed: Data) { guard seed.count >= 16 else { return nil } - // swiftlint:disable force_unwrapping - let hmacKey = "Bitcoin seed".data(using: .ascii)! - let hmac = HMAC(key: hmacKey.bytes, variant: HMAC.Variant.sha2(.sha512)) + + guard let hmacKey = "Bitcoin seed".data(using: .ascii) else { return nil } + let hmac:Authenticator = HMAC(key: hmacKey.bytes, variant: HMAC.Variant.sha2(.sha512)) + guard let entropy = try? hmac.authenticate(seed.bytes), entropy.count == 64 else { return nil } let I_L = entropy[0..<32] let I_R = entropy[32..<64] @@ -100,7 +100,7 @@ public class HDNode { let privKeyCandidate = Data(I_L) guard SECP256K1.verifyPrivateKey(privateKey: privKeyCandidate) else { return nil } guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: privKeyCandidate, compressed: true) else { return nil } - guard pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03 else { return nil } + guard pubKeyCandidate.bytes.first == 0x02 || pubKeyCandidate.bytes.first == 0x03 else { return nil } publicKey = pubKeyCandidate privateKey = privKeyCandidate depth = 0x00 @@ -108,7 +108,6 @@ public class HDNode { } private static var curveOrder = BigUInt("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", radix: 16)! - // swiftlint:enable force_unwrapping public static var defaultPath: String = "m/44'/60'/0'/0" public static var defaultPathPrefix: String = "m/44'/60'/0'" public static var defaultPathMetamask: String = "m/44'/60'/0'/0/0" @@ -119,183 +118,184 @@ public class HDNode { extension HDNode { public func derive(index: UInt32, derivePrivateKey: Bool, hardened: Bool = false) -> HDNode? { if derivePrivateKey { - return self.derivePrivateKey(index: index, hardened: hardened) - } else { - return derivePublicKey(index: index, hardened: hardened) + return deriveWithPrivateKey(index: index, hardened: hardened) + } else { // deriving only the public key + return deriveWithoutPrivateKey(index: index, hardened: hardened) } } - public func derive(path: String, derivePrivateKey: Bool = true) -> HDNode? { - let components = path.components(separatedBy: "/") - var currentNode: HDNode = self - var firstComponent = 0 - if path.hasPrefix("m") { - firstComponent = 1 + public func deriveWithoutPrivateKey(index: UInt32, hardened: Bool = false) -> HDNode? { + var entropy: [UInt8] // derive public key when is itself public key + if index >= (UInt32(1) << 31) || hardened { + return nil // no derivation of hardened public key from extended public key + } else { + let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) + var inputForHMAC = Data() + inputForHMAC.append(self.publicKey) + inputForHMAC.append(index.serialize32()) + guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else {return nil } + guard ent.count == 64 else { return nil } + entropy = ent } - for component in components[firstComponent ..< components.count] { - var hardened = false - if component.hasSuffix("'") { - hardened = true + let I_L = entropy[0..<32] + let I_R = entropy[32..<64] + let cc = Data(I_R) + let bn = BigUInt(Data(I_L)) + if bn > HDNode.curveOrder { + if index < UInt32.max { + return self.derive(index: index+1, derivePrivateKey: false, hardened: hardened) } - guard let index = UInt32(component.trimmingCharacters(in: CharacterSet(charactersIn: "'"))) else { return nil } - guard let newNode = currentNode.derive(index: index, derivePrivateKey: derivePrivateKey, hardened: hardened) else { return nil } - currentNode = newNode + return nil } - return currentNode + guard let tempKey = bn.serialize().setLengthLeft(32) else { return nil } + guard SECP256K1.verifyPrivateKey(privateKey: tempKey) else {return nil } + guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: tempKey, compressed: true) else { return nil } + guard pubKeyCandidate.bytes.first == 0x02 || pubKeyCandidate.bytes.first == 0x03 else { return nil } + guard let newPublicKey = SECP256K1.combineSerializedPublicKeys(keys: [self.publicKey, pubKeyCandidate], outputCompressed: true) else { return nil } + guard newPublicKey.bytes.first == 0x02 || newPublicKey.bytes.first == 0x03 else { return nil } + guard self.depth < UInt8.max else { return nil } + let newNode = HDNode() + newNode.chaincode = cc + newNode.depth = self.depth + 1 + newNode.publicKey = newPublicKey + newNode.childNumber = index + guard let fprint = try? RIPEMD160.hash(message: self.publicKey.sha256())[0..<4] else { + return nil + } + newNode.parentFingerprint = fprint + var newPath = String() + if newNode.isHardened { + newPath = (self.path ?? "") + "/" + newPath += String(newNode.index % HDNode.hardenedIndexPrefix) + "'" + } else { + newPath = (self.path ?? "") + "/" + String(newNode.index) + } + newNode.path = newPath + return newNode } + public func deriveWithPrivateKey(index: UInt32, hardened: Bool = false) -> HDNode? { - /// Derive public key when is itself private key. - /// Derivation of private key when is itself extended public key is impossible and will return `nil`. - private func derivePrivateKey(index: UInt32, hardened: Bool) -> HDNode? { - guard let privateKey = privateKey else { - // derive private key when is itself extended public key (impossible) + guard let privateKey = self.privateKey else { return nil } - - var trueIndex = index - if trueIndex < (UInt32(1) << 31) && hardened { - trueIndex += (UInt32(1) << 31) + var entropy: [UInt8] + var trueIndex: UInt32 + if index >= (UInt32(1) << 31) || hardened { + trueIndex = index + if trueIndex < (UInt32(1) << 31) { + trueIndex = trueIndex + (UInt32(1) << 31) + } + let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) + var inputForHMAC = Data() + inputForHMAC.append(Data([UInt8(0x00)])) + inputForHMAC.append(privateKey) + inputForHMAC.append(trueIndex.serialize32()) + guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else {return nil } + guard ent.count == 64 else { return nil } + entropy = ent + } else { + trueIndex = index + let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) + var inputForHMAC = Data() + inputForHMAC.append(self.publicKey) + inputForHMAC.append(trueIndex.serialize32()) + guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else {return nil } + guard ent.count == 64 else { return nil } + entropy = ent } - - guard let entropy = calculateEntropy(index: trueIndex, privateKey: privateKey, hardened: hardened) else { return nil } - let I_L = entropy[0..<32] let I_R = entropy[32..<64] - let chainCode = Data(I_R) + let cc = Data(I_R) let bn = BigUInt(Data(I_L)) if bn > HDNode.curveOrder { if trueIndex < UInt32.max { - return self.derive(index: index + 1, derivePrivateKey: true, hardened: hardened) + return self.derive(index: index+1, derivePrivateKey: true, hardened: hardened) } return nil } - let newPK = (bn + BigUInt(privateKey)) % HDNode.curveOrder + let newPK = (bn + BigUInt(self.privateKey!)) % HDNode.curveOrder if newPK == BigUInt(0) { if trueIndex < UInt32.max { - return self.derive(index: index + 1, derivePrivateKey: true, hardened: hardened) + return self.derive(index: index+1, derivePrivateKey: true, hardened: hardened) } return nil } - - guard - let newPrivateKey = newPK.serialize().setLengthLeft(32), - SECP256K1.verifyPrivateKey(privateKey: newPrivateKey), - let newPublicKey = SECP256K1.privateToPublic(privateKey: newPrivateKey, compressed: true), - (newPublicKey.bytes[0] == 0x02 || newPublicKey.bytes[0] == 0x03), - self.depth < UInt8.max - else { return nil } - return createNode(chainCode: chainCode, depth: depth + 1, publicKey: newPublicKey, privateKey: newPrivateKey, childNumber: trueIndex) - } - - /// Derive public key when is itself public key. - /// No derivation of hardened public key from extended public key is allowed. - private func derivePublicKey(index: UInt32, hardened: Bool) -> HDNode? { - if index >= (UInt32(1) << 31) || hardened { - // no derivation of hardened public key from extended public key - return nil - } - - guard let entropy = calculateEntropy(index: index, hardened: hardened) else { return nil } - - let I_L = entropy[0..<32] - let I_R = entropy[32..<64] - let chainCode = Data(I_R) - let bn = BigUInt(Data(I_L)) - if bn > HDNode.curveOrder { - if index < UInt32.max { - return self.derive(index: index+1, derivePrivateKey: false, hardened: hardened) - } + guard let privKeyCandidate = newPK.serialize().setLengthLeft(32) else { return nil } + guard SECP256K1.verifyPrivateKey(privateKey: privKeyCandidate) else {return nil } + guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: privKeyCandidate, compressed: true) else { return nil } + guard pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03 else { return nil } + guard self.depth < UInt8.max else { return nil } + let newNode = HDNode() + newNode.chaincode = cc + newNode.depth = self.depth + 1 + newNode.publicKey = pubKeyCandidate + newNode.privateKey = privKeyCandidate + newNode.childNumber = trueIndex + guard let fprint = try? RIPEMD160.hash(message: self.publicKey.sha256())[0..<4] else { return nil } - - guard - let tempKey = bn.serialize().setLengthLeft(32), - SECP256K1.verifyPrivateKey(privateKey: tempKey), - let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: tempKey, compressed: true), - (pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03), - let newPublicKey = SECP256K1.combineSerializedPublicKeys(keys: [self.publicKey, pubKeyCandidate], outputCompressed: true), - (newPublicKey.bytes[0] == 0x02 || newPublicKey.bytes[0] == 0x03), - self.depth < UInt8.max - else { return nil } - - return createNode(chainCode: chainCode, depth: depth + 1, publicKey: newPublicKey, childNumber: index) - } - - private func createNode(chainCode: Data, depth: UInt8, publicKey: Data, privateKey: Data? = nil, childNumber: UInt32) -> HDNode? { - let newNode = HDNode() - newNode.chaincode = chainCode - newNode.depth = depth - newNode.publicKey = publicKey - newNode.privateKey = privateKey - newNode.childNumber = childNumber - guard - let fprint = try? RIPEMD160.hash(message: self.publicKey.sha256())[0..<4], - let path = path - else { return nil } newNode.parentFingerprint = fprint var newPath = String() if newNode.isHardened { - newPath = path + "/" + newPath = self.path! + "/" newPath += String(newNode.index % HDNode.hardenedIndexPrefix) + "'" } else { - newPath = path + "/" + String(newNode.index) + newPath = self.path! + "/" + String(newNode.index) } newNode.path = newPath return newNode + } - private func calculateHMACInput(_ index: UInt32, privateKey: Data? = nil, hardened: Bool) -> Data { - var inputForHMAC = Data() + public func derive(path: String, derivePrivateKey: Bool = true) -> HDNode? { - if let privateKey = privateKey, (index >= (UInt32(1) << 31) || hardened) { - inputForHMAC.append(Data([UInt8(0x00)])) - inputForHMAC.append(privateKey) - } else { - inputForHMAC.append(self.publicKey) + let components = path.components(separatedBy: "/") + var currentNode: HDNode = self + var firstComponent = 0 + if path.hasPrefix("m") { + firstComponent = 1 } - - inputForHMAC.append(index.serialize32()) - return inputForHMAC + for component in components[firstComponent ..< components.count] { + var hardened = false + if component.hasSuffix("'") { + hardened = true + } + guard let index = UInt32(component.trimmingCharacters(in: CharacterSet(charactersIn: "'"))) else { return nil } + guard let newNode = currentNode.derive(index: index, derivePrivateKey: derivePrivateKey, hardened: hardened) else { return nil } + currentNode = newNode + } + return currentNode } - /// Calculates entropy used for private or public key derivation. - /// - Parameters: - /// - index: index - /// - privateKey: private key data or `nil` if entropy is calculated for a public key; - /// - hardened: is hardened key - /// - Returns: 64 bytes entropy or `nil`. - private func calculateEntropy(index: UInt32, privateKey: Data? = nil, hardened: Bool) -> [UInt8]? { - let inputForHMAC = calculateHMACInput(index, privateKey: privateKey, hardened: hardened) - let hmac = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) - guard let entropy = try? hmac.authenticate(inputForHMAC.bytes), entropy.count == 64 else { return nil } - return entropy + public func serializeToString(serializePublic: Bool = true) -> String? { + guard let data = self.serialize(serializePublic: serializePublic) else { return nil } + let encoded = Base58.base58FromBytes(data.bytes) + return encoded } - public func serializeToString(serializePublic: Bool = true, version: HDversion = HDversion()) -> String? { - guard let data = self.serialize(serializePublic: serializePublic, version: version) else { return nil } - return Base58.base58FromBytes(data.bytes) - } + public func serialize(serializePublic: Bool = true) -> Data? { - public func serialize(serializePublic: Bool = true, version: HDversion = HDversion()) -> Data? { var data = Data() - /// Public or private key - let keyData: Data + + guard serializePublic || privateKey != nil else { + return nil + } + if serializePublic { - keyData = publicKey - data.append(version.publicPrefix) + data.append(HDversion.publicPrefix!) } else { - guard let privateKey = privateKey else { return nil } - keyData = privateKey - data.append(version.privatePrefix) + data.append(HDversion.privatePrefix!) } - data.append(contentsOf: [depth]) - data.append(parentFingerprint) - data.append(childNumber.serialize32()) - data.append(chaincode) - if !serializePublic { + data.append(contentsOf: [self.depth]) + data.append(self.parentFingerprint) + data.append(self.childNumber.serialize32()) + data.append(self.chaincode) + if serializePublic { + data.append(self.publicKey) + } else { data.append(contentsOf: [0x00]) + data.append(self.privateKey!) } - data.append(keyData) let hashedData = data.sha256().sha256() let checksum = hashedData[0..<4] data.append(checksum) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index 89205dde0..7e9fe5a1e 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -44,7 +44,6 @@ public class BIP32Keystore: AbstractKeystore { guard let decryptedRootNode = try? self.getPrefixNodeData(password) else {throw AbstractKeystoreError.encryptionError("Failed to decrypt a keystore")} guard let rootNode = HDNode(decryptedRootNode) else {throw AbstractKeystoreError.encryptionError("Failed to deserialize a root node")} guard rootNode.depth == (self.rootPrefix.components(separatedBy: "/").count - 1) else {throw AbstractKeystoreError.encryptionError("Derivation depth mismatch")} -// guard rootNode.depth == HDNode.defaultPathPrefix.components(separatedBy: "/").count - 1 else {throw AbstractKeystoreError.encryptionError("Derivation depth mismatch")} guard let index = UInt32(key.components(separatedBy: "/").last!) else { throw AbstractKeystoreError.encryptionError("Derivation depth mismatch") } @@ -98,6 +97,18 @@ public class BIP32Keystore: AbstractKeystore { try self.init(seed: seed, password: password, prefixPath: prefixPath, aesMode: aesMode) } + //TODO: Unit Test + //TODO: merge and cleanup with above code + public convenience init?(mnemonicsPhrase: [String], password: String, mnemonicsPassword: String = "", language: BIP39Language = .english, prefixPath: String = HDNode.defaultPathMetamaskPrefix, aesMode: String = "aes-128-cbc") throws { + guard var seed = BIP39.seedFromMmemonics(mnemonicsPhrase, password: mnemonicsPassword, language: language) else { + throw AbstractKeystoreError.noEntropyError + } + defer { + Data.zero(&seed) + } + try self.init(seed: seed, password: password, prefixPath: prefixPath, aesMode: aesMode) + } + public init? (seed: Data, password: String, prefixPath: String = HDNode.defaultPathMetamaskPrefix, aesMode: String = "aes-128-cbc") throws { addressStorage = PathAddressStorage() guard let rootNode = HDNode(seed: seed)?.derive(path: prefixPath, derivePrivateKey: true) else { return nil } @@ -127,13 +138,19 @@ public class BIP32Keystore: AbstractKeystore { try encryptDataToStorage(password, data: serializedRootNode, aesMode: self.keystoreParams!.crypto.cipher) } - func createNewAccount(parentNode: HDNode, password: String ) throws { - var newIndex = UInt32(0) - for p in addressStorage.paths { - guard let idx = UInt32(p.components(separatedBy: "/").last!) else {continue} - if idx >= newIndex { - newIndex = idx + 1 - } + func createNewAccount(parentNode: HDNode, password: String = "web3swift") throws { + + let maxIndex = addressStorage.paths + .compactMap { $0.components(separatedBy: "/").last } + .compactMap { UInt32($0) } + .max() + + let newIndex: UInt32 + + if let idx = maxIndex { + newIndex = idx + 1 + } else { + newIndex = UInt32.zero } guard let newNode = parentNode.derive(index: newIndex, derivePrivateKey: true, hardened: false) else { throw AbstractKeystoreError.keyDerivationError @@ -151,7 +168,8 @@ public class BIP32Keystore: AbstractKeystore { addressStorage.add(address: newAddress, for: newPath) } - public func createNewCustomChildAccount(password: String, path: String) throws {guard let decryptedRootNode = try? self.getPrefixNodeData(password) else { + public func createNewCustomChildAccount(password: String, path: String) throws { + guard let decryptedRootNode = try? getPrefixNodeData(password) else { throw AbstractKeystoreError.encryptionError("Failed to decrypt a keystore") } guard let rootNode = HDNode(decryptedRootNode) else { @@ -201,15 +219,11 @@ public class BIP32Keystore: AbstractKeystore { try encryptDataToStorage(password, data: serializedRootNode, aesMode: self.keystoreParams!.crypto.cipher) } - fileprivate func encryptDataToStorage(_ password: String, data: Data?, dkLen: Int = 32, N: Int = 4096, R: Int = 6, P: Int = 1, aesMode: String = "aes-128-cbc") throws { - if data == nil { - throw AbstractKeystoreError.encryptionError("Encryption without key data") - } - if data!.count != 82 { + fileprivate func encryptDataToStorage(_ password: String, data: Data, dkLen: Int = 32, N: Int = 4096, R: Int = 6, P: Int = 1, aesMode: String = "aes-128-cbc") throws { + guard data.count == 82 else { throw AbstractKeystoreError.encryptionError("Invalid expected data length") } - let saltLen = 32 - guard let saltData = Data.randomBytes(length: saltLen) else { + guard let saltData = Data.randomBytes(length: 32) else { throw AbstractKeystoreError.noEntropyError } guard let derivedKey = scrypt(password: password, salt: saltData, length: dkLen, N: N, R: R, P: P) else { @@ -232,7 +246,7 @@ public class BIP32Keystore: AbstractKeystore { if aesCipher == nil { throw AbstractKeystoreError.aesError } - guard let encryptedKey = try aesCipher?.encrypt(data!.bytes) else { + guard let encryptedKey = try aesCipher?.encrypt(data.bytes) else { throw AbstractKeystoreError.aesError } let encryptedKeyData = Data(encryptedKey) diff --git a/Sources/Web3Core/KeystoreManager/BIP39.swift b/Sources/Web3Core/KeystoreManager/BIP39.swift index 32ba25294..3a5c138c0 100755 --- a/Sources/Web3Core/KeystoreManager/BIP39.swift +++ b/Sources/Web3Core/KeystoreManager/BIP39.swift @@ -69,50 +69,88 @@ public enum BIP39Language { } public class BIP39 { + /** + Initializes a new mnemonics set with the provided bitsOfEntropy. + **/ + /// Initializes a new mnemonics set with the provided bitsOfEntropy. + /// - Parameters: + /// - bitsOfEntropy: 128 - 12 words, 192 - 18 words , 256 - 24 words in output. + /// - language: words language, default english + /// - Returns: random 12-24 words, that represent new Mnemonic phrase. + static public func generateMnemonics(bitsOfEntropy: Int, language: BIP39Language = .english) throws -> String? { + guard let entropy = entropyOf(size: bitsOfEntropy) else { throw AbstractKeystoreError.noEntropyError } + return generateMnemonicsFromEntropy(entropy: entropy, language: language) + } + + static public func generateMnemonics(entropy: Int, language: BIP39Language = .english) -> [String]? { + guard let entropy = entropyOf(size: entropy) else { return nil } + return generateMnemonicsFrom(entropy: entropy, language: language) + } - static public func generateMnemonicsFromEntropy(entropy: Data, language: BIP39Language = BIP39Language.english) -> String? { - guard entropy.count >= 16, entropy.count & 4 == 0 else { return nil } - let checksum = entropy.sha256() - let checksumBits = entropy.count*8/32 - var fullEntropy = Data() - fullEntropy.append(entropy) - fullEntropy.append(checksum[0 ..< (checksumBits+7)/8 ]) - var wordList = [String]() - for i in 0 ..< fullEntropy.count*8/11 { - guard let bits = fullEntropy.bitsInRange(i*11, 11) else { return nil } - let index = Int(bits) - guard language.words.count > index else { return nil } - let word = language.words[index] - wordList.append(word) + static private func entropyOf(size: Int) -> Data? { + guard size >= 128 && size <= 256 && size.isMultiple(of: 32) else { + return nil } + + return Data.randomBytes(length: size/8) + } + + static func bitarray(from data: Data) -> String { + data.map { + let binary = String($0, radix: 2) + let padding = String(repeating: "0", count: 8 - binary.count) + return padding + binary + }.joined() + } + + static func generateChecksum(entropyBytes inputData: Data, checksumLength: Int) -> String? { + guard let checksumData = inputData.sha256().bitsInRange(0, checksumLength) else { + return nil + } + let checksum = String(checksumData, radix: 2).leftPadding(toLength: checksumLength, withPad: "0") + return checksum + } + + static public func generateMnemonicsFromEntropy(entropy: Data, language: BIP39Language = .english) -> String? { + guard entropy.count >= 16, entropy.count & 4 == 0 else {return nil} let separator = language.separator + let wordList = generateMnemonicsFrom(entropy: entropy) return wordList.joined(separator: separator) } - /// Initializes a new mnemonics set with the provided bitsOfEntropy. - /// - Parameters: - /// - bitsOfEntropy: 128 - 12 words, 192 - 18 words , 256 - 24 words in output. - /// - language: words language, default english - /// - Returns: random 12-24 words, that represent new Mnemonic phrase. - static public func generateMnemonics(bitsOfEntropy: Int, language: BIP39Language = BIP39Language.english) throws -> String? { - guard bitsOfEntropy >= 128 && bitsOfEntropy <= 256 && bitsOfEntropy.isMultiple(of: 32) else { return nil } - guard let entropy = Data.randomBytes(length: bitsOfEntropy/8) else {throw AbstractKeystoreError.noEntropyError} - return BIP39.generateMnemonicsFromEntropy(entropy: entropy, language: - language) + static public func generateMnemonicsFrom(entropy: Data, language: BIP39Language = .english) -> [String] { + let entropyBitSize = entropy.count * 8 + let checksum_length = entropyBitSize / 32 + + var entropy_bits = bitarray(from: entropy) + + guard let checksumTest = generateChecksum(entropyBytes: entropy, checksumLength: checksum_length) else { + return [] + } + entropy_bits += checksumTest + return entropy_bits + .split(intoChunksOf: 11) + .compactMap { binary in + Int(binary, radix: 2) + } + .map { index in + language.words[index] + } + } + static public func mnemonicsToEntropy(_ mnemonics: String, language: BIP39Language = .english) -> Data? { + let wordList = mnemonics.components(separatedBy: language.separator) + return mnemonicsToEntropy(wordList, language: language) } - static public func mnemonicsToEntropy(_ mnemonics: String, language: BIP39Language = BIP39Language.english) -> Data? { - let wordList = mnemonics.components(separatedBy: " ") - guard wordList.count >= 12 && wordList.count.isMultiple(of: 3) && wordList.count <= 24 else { return nil } + static public func mnemonicsToEntropy(_ mnemonics: [String], language: BIP39Language = .english) -> Data? { + guard mnemonics.count >= 12 && mnemonics.count.isMultiple(of: 3) && mnemonics.count <= 24 else {return nil} var bitString = "" - for word in wordList { - let idx = language.words.firstIndex(of: word) - if idx == nil { + for word in mnemonics { + guard let idx = language.words.firstIndex(of: word) else { return nil } - let idxAsInt = language.words.startIndex.distance(to: idx!) - let stringForm = String(UInt16(idxAsInt), radix: 2).leftPadding(toLength: 11, withPad: "0") + let stringForm = String(UInt16(idx), radix: 2).leftPadding(toLength: 11, withPad: "0") bitString.append(stringForm) } let stringCount = bitString.count @@ -131,23 +169,30 @@ public class BIP39 { return entropy } - static public func seedFromMmemonics(_ mnemonics: String, password: String = "", language: BIP39Language = BIP39Language.english) -> Data? { - let valid = BIP39.mnemonicsToEntropy(mnemonics, language: language) != nil - if !valid { + static public func seedFromMmemonics(_ mnemonics: [String], password: String = "", language: BIP39Language = .english) -> Data? { + let wordList = mnemonics.joined(separator: language.separator) + return seedFromMmemonics(wordList, password: password, language: language) + } + + static public func seedFromMmemonics(_ mnemonics: String, password: String = "", language: BIP39Language = .english) -> Data? { + if mnemonicsToEntropy(mnemonics, language: language) == nil { return nil } - guard let mnemData = mnemonics.decomposedStringWithCompatibilityMapping.data(using: .utf8) else { return nil } + return dataFrom(mnemonics: mnemonics, password: password) + } + + static private func dataFrom(mnemonics: String, password: String) -> Data? { + guard let mnemData = mnemonics.decomposedStringWithCompatibilityMapping.data(using: .utf8) else {return nil} let salt = "mnemonic" + password - guard let saltData = salt.decomposedStringWithCompatibilityMapping.data(using: .utf8) else { return nil } - guard let seedArray = try? PKCS5.PBKDF2(password: mnemData.bytes, salt: saltData.bytes, iterations: 2048, keyLength: 64, variant: HMAC.Variant.sha2(.sha512)).calculate() else { return nil } - let seed = Data(seedArray) - return seed + guard let saltData = salt.decomposedStringWithCompatibilityMapping.data(using: .utf8) else {return nil} + guard let seedArray = try? PKCS5.PBKDF2(password: mnemData.bytes, salt: saltData.bytes, iterations: 2048, keyLength: 64, variant: HMAC.Variant.sha2(.sha512)).calculate() else {return nil} + return Data(seedArray) } - static public func seedFromEntropy(_ entropy: Data, password: String = "", language: BIP39Language = BIP39Language.english) -> Data? { - guard let mnemonics = BIP39.generateMnemonicsFromEntropy(entropy: entropy, language: language) else { + static public func seedFromEntropy(_ entropy: Data, password: String = "", language: BIP39Language = .english) -> Data? { + guard let mnemonics = generateMnemonicsFromEntropy(entropy: entropy, language: language) else { return nil } - return BIP39.seedFromMmemonics(mnemonics, password: password, language: language) + return seedFromMmemonics(mnemonics, password: password, language: language) } } diff --git a/Tests/web3swiftTests/localTests/BIP39ArrayTests.swift b/Tests/web3swiftTests/localTests/BIP39ArrayTests.swift index 9c7307b5c..c8b4b66be 100644 --- a/Tests/web3swiftTests/localTests/BIP39ArrayTests.swift +++ b/Tests/web3swiftTests/localTests/BIP39ArrayTests.swift @@ -6,7 +6,7 @@ // import XCTest -@testable import Core +@testable import Web3Core @testable import web3swift final class BIP39ArrayTests: XCTestCase { diff --git a/Tests/web3swiftTests/localTests/BIP39StringTests.swift b/Tests/web3swiftTests/localTests/BIP39StringTests.swift index 99480f376..d67fca812 100644 --- a/Tests/web3swiftTests/localTests/BIP39StringTests.swift +++ b/Tests/web3swiftTests/localTests/BIP39StringTests.swift @@ -6,7 +6,7 @@ // import XCTest -@testable import Core +@testable import Web3Core @testable import web3swift diff --git a/Tests/web3swiftTests/localTests/BIP39Tests.swift b/Tests/web3swiftTests/localTests/BIP39Tests.swift index 0431bf075..0c19353d4 100644 --- a/Tests/web3swiftTests/localTests/BIP39Tests.swift +++ b/Tests/web3swiftTests/localTests/BIP39Tests.swift @@ -6,7 +6,7 @@ // import XCTest -@testable import Core +@testable import Web3Core @testable import web3swift final class BIP39Tests: XCTestCase { From 184607026fd47df6f31e06bd3f77d97f1b76068b Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Sun, 5 Mar 2023 22:42:26 -0800 Subject: [PATCH 139/210] some cleanup --- .../KeystoreManager/BIP32HDNode.swift | 27 ++++++----- .../KeystoreManager/BIP32Keystore.swift | 2 - Sources/Web3Core/KeystoreManager/BIP39.swift | 47 +++++++++---------- 3 files changed, 36 insertions(+), 40 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift index ad8c0702f..15c15e327 100644 --- a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift @@ -19,6 +19,7 @@ extension UInt32 { let byteArray = Array(bytePtr) return Data(byteArray) } + static var maxIterationIndex = UInt32(1) << 31 } public class HDNode { @@ -36,11 +37,11 @@ public class HDNode { public var parentFingerprint: Data = Data(repeating: 0, count: 4) public var childNumber: UInt32 = UInt32(0) public var isHardened: Bool { - childNumber >= (UInt32(1) << 31) + childNumber >= UInt32.maxIterationIndex } public var index: UInt32 { if self.isHardened { - return childNumber - (UInt32(1) << 31) + return childNumber - UInt32.maxIterationIndex } else { return childNumber } @@ -91,7 +92,7 @@ public class HDNode { guard seed.count >= 16 else { return nil } guard let hmacKey = "Bitcoin seed".data(using: .ascii) else { return nil } - let hmac:Authenticator = HMAC(key: hmacKey.bytes, variant: HMAC.Variant.sha2(.sha512)) + let hmac: Authenticator = HMAC(key: hmacKey.bytes, variant: HMAC.Variant.sha2(.sha512)) guard let entropy = try? hmac.authenticate(seed.bytes), entropy.count == 64 else { return nil } let I_L = entropy[0..<32] @@ -112,7 +113,7 @@ public class HDNode { public static var defaultPathPrefix: String = "m/44'/60'/0'" public static var defaultPathMetamask: String = "m/44'/60'/0'/0/0" public static var defaultPathMetamaskPrefix: String = "m/44'/60'/0'/0" - public static var hardenedIndexPrefix: UInt32 = (UInt32(1) << 31) + public static var hardenedIndexPrefix: UInt32 = UInt32.maxIterationIndex } extension HDNode { @@ -126,14 +127,14 @@ extension HDNode { public func deriveWithoutPrivateKey(index: UInt32, hardened: Bool = false) -> HDNode? { var entropy: [UInt8] // derive public key when is itself public key - if index >= (UInt32(1) << 31) || hardened { + if index >= UInt32.maxIterationIndex || hardened { return nil // no derivation of hardened public key from extended public key } else { let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) var inputForHMAC = Data() inputForHMAC.append(self.publicKey) inputForHMAC.append(index.serialize32()) - guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else {return nil } + guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else { return nil } guard ent.count == 64 else { return nil } entropy = ent } @@ -148,7 +149,7 @@ extension HDNode { return nil } guard let tempKey = bn.serialize().setLengthLeft(32) else { return nil } - guard SECP256K1.verifyPrivateKey(privateKey: tempKey) else {return nil } + guard SECP256K1.verifyPrivateKey(privateKey: tempKey) else { return nil } guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: tempKey, compressed: true) else { return nil } guard pubKeyCandidate.bytes.first == 0x02 || pubKeyCandidate.bytes.first == 0x03 else { return nil } guard let newPublicKey = SECP256K1.combineSerializedPublicKeys(keys: [self.publicKey, pubKeyCandidate], outputCompressed: true) else { return nil } @@ -180,17 +181,17 @@ extension HDNode { } var entropy: [UInt8] var trueIndex: UInt32 - if index >= (UInt32(1) << 31) || hardened { + if index >= UInt32.maxIterationIndex || hardened { trueIndex = index - if trueIndex < (UInt32(1) << 31) { - trueIndex = trueIndex + (UInt32(1) << 31) + if trueIndex < UInt32.maxIterationIndex { + trueIndex = trueIndex + UInt32.maxIterationIndex } let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) var inputForHMAC = Data() inputForHMAC.append(Data([UInt8(0x00)])) inputForHMAC.append(privateKey) inputForHMAC.append(trueIndex.serialize32()) - guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else {return nil } + guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else { return nil } guard ent.count == 64 else { return nil } entropy = ent } else { @@ -199,7 +200,7 @@ extension HDNode { var inputForHMAC = Data() inputForHMAC.append(self.publicKey) inputForHMAC.append(trueIndex.serialize32()) - guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else {return nil } + guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else { return nil } guard ent.count == 64 else { return nil } entropy = ent } @@ -221,7 +222,7 @@ extension HDNode { return nil } guard let privKeyCandidate = newPK.serialize().setLengthLeft(32) else { return nil } - guard SECP256K1.verifyPrivateKey(privateKey: privKeyCandidate) else {return nil } + guard SECP256K1.verifyPrivateKey(privateKey: privKeyCandidate) else { return nil } guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: privKeyCandidate, compressed: true) else { return nil } guard pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03 else { return nil } guard self.depth < UInt8.max else { return nil } diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index 7e9fe5a1e..238f89c29 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -97,8 +97,6 @@ public class BIP32Keystore: AbstractKeystore { try self.init(seed: seed, password: password, prefixPath: prefixPath, aesMode: aesMode) } - //TODO: Unit Test - //TODO: merge and cleanup with above code public convenience init?(mnemonicsPhrase: [String], password: String, mnemonicsPassword: String = "", language: BIP39Language = .english, prefixPath: String = HDNode.defaultPathMetamaskPrefix, aesMode: String = "aes-128-cbc") throws { guard var seed = BIP39.seedFromMmemonics(mnemonicsPhrase, password: mnemonicsPassword, language: language) else { throw AbstractKeystoreError.noEntropyError diff --git a/Sources/Web3Core/KeystoreManager/BIP39.swift b/Sources/Web3Core/KeystoreManager/BIP39.swift index 3a5c138c0..39361b3b8 100755 --- a/Sources/Web3Core/KeystoreManager/BIP39.swift +++ b/Sources/Web3Core/KeystoreManager/BIP39.swift @@ -43,7 +43,7 @@ public enum BIP39Language { return " " } } - + init?(language: String) { switch language { case "english": @@ -69,32 +69,29 @@ public enum BIP39Language { } public class BIP39 { - /** - Initializes a new mnemonics set with the provided bitsOfEntropy. - **/ /// Initializes a new mnemonics set with the provided bitsOfEntropy. /// - Parameters: - /// - bitsOfEntropy: 128 - 12 words, 192 - 18 words , 256 - 24 words in output. + /// - bitsOfEntropy: 128 - 12 words, 192 - 18 words, 256 - 24 words in output. /// - language: words language, default english /// - Returns: random 12-24 words, that represent new Mnemonic phrase. static public func generateMnemonics(bitsOfEntropy: Int, language: BIP39Language = .english) throws -> String? { guard let entropy = entropyOf(size: bitsOfEntropy) else { throw AbstractKeystoreError.noEntropyError } return generateMnemonicsFromEntropy(entropy: entropy, language: language) } - + static public func generateMnemonics(entropy: Int, language: BIP39Language = .english) -> [String]? { guard let entropy = entropyOf(size: entropy) else { return nil } return generateMnemonicsFrom(entropy: entropy, language: language) } - + static private func entropyOf(size: Int) -> Data? { guard size >= 128 && size <= 256 && size.isMultiple(of: 32) else { return nil } - + return Data.randomBytes(length: size/8) } - + static func bitarray(from data: Data) -> String { data.map { let binary = String($0, radix: 2) @@ -102,7 +99,7 @@ public class BIP39 { return padding + binary }.joined() } - + static func generateChecksum(entropyBytes inputData: Data, checksumLength: Int) -> String? { guard let checksumData = inputData.sha256().bitsInRange(0, checksumLength) else { return nil @@ -110,20 +107,20 @@ public class BIP39 { let checksum = String(checksumData, radix: 2).leftPadding(toLength: checksumLength, withPad: "0") return checksum } - + static public func generateMnemonicsFromEntropy(entropy: Data, language: BIP39Language = .english) -> String? { guard entropy.count >= 16, entropy.count & 4 == 0 else {return nil} let separator = language.separator let wordList = generateMnemonicsFrom(entropy: entropy) return wordList.joined(separator: separator) } - + static public func generateMnemonicsFrom(entropy: Data, language: BIP39Language = .english) -> [String] { let entropyBitSize = entropy.count * 8 let checksum_length = entropyBitSize / 32 - + var entropy_bits = bitarray(from: entropy) - + guard let checksumTest = generateChecksum(entropyBytes: entropy, checksumLength: checksum_length) else { return [] } @@ -131,18 +128,18 @@ public class BIP39 { return entropy_bits .split(intoChunksOf: 11) .compactMap { binary in - Int(binary, radix: 2) - } - .map { index in - language.words[index] - } + Int(binary, radix: 2) + } + .map { index in + language.words[index] + } } - + static public func mnemonicsToEntropy(_ mnemonics: String, language: BIP39Language = .english) -> Data? { let wordList = mnemonics.components(separatedBy: language.separator) return mnemonicsToEntropy(wordList, language: language) } - + static public func mnemonicsToEntropy(_ mnemonics: [String], language: BIP39Language = .english) -> Data? { guard mnemonics.count >= 12 && mnemonics.count.isMultiple(of: 3) && mnemonics.count <= 24 else {return nil} var bitString = "" @@ -168,19 +165,19 @@ public class BIP39 { } return entropy } - + static public func seedFromMmemonics(_ mnemonics: [String], password: String = "", language: BIP39Language = .english) -> Data? { let wordList = mnemonics.joined(separator: language.separator) return seedFromMmemonics(wordList, password: password, language: language) } - + static public func seedFromMmemonics(_ mnemonics: String, password: String = "", language: BIP39Language = .english) -> Data? { if mnemonicsToEntropy(mnemonics, language: language) == nil { return nil } return dataFrom(mnemonics: mnemonics, password: password) } - + static private func dataFrom(mnemonics: String, password: String) -> Data? { guard let mnemData = mnemonics.decomposedStringWithCompatibilityMapping.data(using: .utf8) else {return nil} let salt = "mnemonic" + password @@ -188,7 +185,7 @@ public class BIP39 { guard let seedArray = try? PKCS5.PBKDF2(password: mnemData.bytes, salt: saltData.bytes, iterations: 2048, keyLength: 64, variant: HMAC.Variant.sha2(.sha512)).calculate() else {return nil} return Data(seedArray) } - + static public func seedFromEntropy(_ entropy: Data, password: String = "", language: BIP39Language = .english) -> Data? { guard let mnemonics = generateMnemonicsFromEntropy(entropy: entropy, language: language) else { return nil From 4cdd87caff22d6d03be605736ff724d1ffe904bc Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Sun, 5 Mar 2023 23:32:20 -0800 Subject: [PATCH 140/210] cleanup --- .../KeystoreManager/BIP32HDNode.swift | 2 +- Sources/Web3Core/KeystoreManager/BIP39.swift | 34 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift index 15c15e327..02bbf2e40 100644 --- a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift @@ -24,7 +24,7 @@ extension UInt32 { public class HDNode { - private struct HDversion{ + private struct HDversion { public static var privatePrefix: Data? = Data.fromHex("0x0488ADE4") public static var publicPrefix: Data? = Data.fromHex("0x0488B21E") diff --git a/Sources/Web3Core/KeystoreManager/BIP39.swift b/Sources/Web3Core/KeystoreManager/BIP39.swift index 39361b3b8..0036ed390 100755 --- a/Sources/Web3Core/KeystoreManager/BIP39.swift +++ b/Sources/Web3Core/KeystoreManager/BIP39.swift @@ -43,7 +43,7 @@ public enum BIP39Language { return " " } } - + init?(language: String) { switch language { case "english": @@ -78,20 +78,20 @@ public class BIP39 { guard let entropy = entropyOf(size: bitsOfEntropy) else { throw AbstractKeystoreError.noEntropyError } return generateMnemonicsFromEntropy(entropy: entropy, language: language) } - + static public func generateMnemonics(entropy: Int, language: BIP39Language = .english) -> [String]? { guard let entropy = entropyOf(size: entropy) else { return nil } return generateMnemonicsFrom(entropy: entropy, language: language) } - + static private func entropyOf(size: Int) -> Data? { guard size >= 128 && size <= 256 && size.isMultiple(of: 32) else { return nil } - + return Data.randomBytes(length: size/8) } - + static func bitarray(from data: Data) -> String { data.map { let binary = String($0, radix: 2) @@ -99,7 +99,7 @@ public class BIP39 { return padding + binary }.joined() } - + static func generateChecksum(entropyBytes inputData: Data, checksumLength: Int) -> String? { guard let checksumData = inputData.sha256().bitsInRange(0, checksumLength) else { return nil @@ -107,20 +107,20 @@ public class BIP39 { let checksum = String(checksumData, radix: 2).leftPadding(toLength: checksumLength, withPad: "0") return checksum } - + static public func generateMnemonicsFromEntropy(entropy: Data, language: BIP39Language = .english) -> String? { guard entropy.count >= 16, entropy.count & 4 == 0 else {return nil} let separator = language.separator let wordList = generateMnemonicsFrom(entropy: entropy) return wordList.joined(separator: separator) } - - static public func generateMnemonicsFrom(entropy: Data, language: BIP39Language = .english) -> [String] { + + static public func generateMnemonicsFrom(entropy: Data, language: BIP39Language = .english) -> [String] { let entropyBitSize = entropy.count * 8 let checksum_length = entropyBitSize / 32 - + var entropy_bits = bitarray(from: entropy) - + guard let checksumTest = generateChecksum(entropyBytes: entropy, checksumLength: checksum_length) else { return [] } @@ -134,12 +134,12 @@ public class BIP39 { language.words[index] } } - + static public func mnemonicsToEntropy(_ mnemonics: String, language: BIP39Language = .english) -> Data? { let wordList = mnemonics.components(separatedBy: language.separator) return mnemonicsToEntropy(wordList, language: language) } - + static public func mnemonicsToEntropy(_ mnemonics: [String], language: BIP39Language = .english) -> Data? { guard mnemonics.count >= 12 && mnemonics.count.isMultiple(of: 3) && mnemonics.count <= 24 else {return nil} var bitString = "" @@ -165,19 +165,19 @@ public class BIP39 { } return entropy } - + static public func seedFromMmemonics(_ mnemonics: [String], password: String = "", language: BIP39Language = .english) -> Data? { let wordList = mnemonics.joined(separator: language.separator) return seedFromMmemonics(wordList, password: password, language: language) } - + static public func seedFromMmemonics(_ mnemonics: String, password: String = "", language: BIP39Language = .english) -> Data? { if mnemonicsToEntropy(mnemonics, language: language) == nil { return nil } return dataFrom(mnemonics: mnemonics, password: password) } - + static private func dataFrom(mnemonics: String, password: String) -> Data? { guard let mnemData = mnemonics.decomposedStringWithCompatibilityMapping.data(using: .utf8) else {return nil} let salt = "mnemonic" + password @@ -185,7 +185,7 @@ public class BIP39 { guard let seedArray = try? PKCS5.PBKDF2(password: mnemData.bytes, salt: saltData.bytes, iterations: 2048, keyLength: 64, variant: HMAC.Variant.sha2(.sha512)).calculate() else {return nil} return Data(seedArray) } - + static public func seedFromEntropy(_ entropy: Data, password: String = "", language: BIP39Language = .english) -> Data? { guard let mnemonics = generateMnemonicsFromEntropy(entropy: entropy, language: language) else { return nil From 2a12ec493934395b58e9feebf31e59d4e28af389 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Wed, 8 Mar 2023 11:09:12 +0200 Subject: [PATCH 141/210] fix: updated EIP4361 (aka SIWE) regular expressions to more precisely match the requirements (RFC 3986) --- Sources/web3swift/Utils/EIP/EIP4361.swift | 89 +++++++++++++++++------ 1 file changed, 65 insertions(+), 24 deletions(-) diff --git a/Sources/web3swift/Utils/EIP/EIP4361.swift b/Sources/web3swift/Utils/EIP/EIP4361.swift index 0fa9c0161..9b82b7a71 100644 --- a/Sources/web3swift/Utils/EIP/EIP4361.swift +++ b/Sources/web3swift/Utils/EIP/EIP4361.swift @@ -15,6 +15,9 @@ private let uriPattern = "(([^:?#\\s]+):)?(([^?#\\s]*))?([^?#\\s]*)(\\?([^#\\s]* /// Sign-In with Ethereum protocol and parser implementation. /// +/// _Regular expressions were generated using ABNF grammar from https://github.com/spruceid/siwe/blob/main/packages/siwe-parser/lib/abnf.ts#L5 +/// and tool https://pypi.org/project/abnf-to-regexp/ that outputs Python supported regular expressions._ +/// /// EIP-4361: /// - https://eips.ethereum.org/EIPS/eip-4361 /// - https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4361.md @@ -60,22 +63,64 @@ public final class EIP4361 { case resources } - private static let domain = "(?<\(EIP4361Field.domain.rawValue)>([^?#]*)) wants you to sign in with your Ethereum account:" - private static let address = "\\n(?<\(EIP4361Field.address.rawValue)>0x[a-zA-Z0-9]{40})\\n\\n" - private static let statementParagraph = "((?<\(EIP4361Field.statement.rawValue)>[^\\n]+)\\n)?" - private static let uri = "\\nURI: (?<\(EIP4361Field.uri.rawValue)>(\(uriPattern))?)" - private static let version = "\\nVersion: (?<\(EIP4361Field.version.rawValue)>[0-9]+)" - private static let chainId = "\\nChain ID: (?<\(EIP4361Field.chainId.rawValue)>[0-9a-fA-F]+)" - private static let nonce = "\\nNonce: (?<\(EIP4361Field.nonce.rawValue)>[a-zA-Z0-9]{8,})" - private static let issuedAt = "\\nIssued At: (?<\(EIP4361Field.issuedAt.rawValue)>(\(datetimePattern)))" - private static let expirationTime = "(\\nExpiration Time: (?<\(EIP4361Field.expirationTime.rawValue)>(\(datetimePattern))))?" - private static let notBefore = "(\\nNot Before: (?<\(EIP4361Field.notBefore.rawValue)>(\(datetimePattern))))?" - private static let requestId = "(\\nRequest ID: (?<\(EIP4361Field.requestId.rawValue)>[-._~!$&'()*+,;=:@%a-zA-Z0-9]*))?" - private static let resourcesParagraph = "(\\nResources:(?<\(EIP4361Field.resources.rawValue)>(\\n- (\(uriPattern))?)+))?" - - private static var eip4361Pattern: String { - "^\(domain)\(address)\(statementParagraph)\(uri)\(version)\(chainId)\(nonce)\(issuedAt)\(expirationTime)\(notBefore)\(requestId)\(resourcesParagraph)$" - } + private static let unreserved = "[a-zA-Z0-9\\-._~]" + private static let pctEncoded = "%[0-9A-Fa-f][0-9A-Fa-f]" + private static let subDelims = "[!$&'()*+,;=]" + private static let userinfo = "(\(unreserved)|\(pctEncoded)|\(subDelims)|:)*" + private static let h16 = "[0-9A-Fa-f]{1,4}" + private static let decOctet = "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])" + private static let ipv4address = "\(decOctet)\\.\(decOctet)\\.\(decOctet)\\.\(decOctet)" + private static let ls32 = "(\(h16):\(h16)|\(ipv4address))" + private static let ipv6address = "((\(h16):){6}\(ls32)|::(\(h16):){5}\(ls32)|(\(h16))?::(\(h16):){4}\(ls32)|((\(h16):)?\(h16))?::(\(h16):){3}\(ls32)|((\(h16):){2}\(h16))?::(\(h16):){2}\(ls32)|((\(h16):){3}\(h16))?::\(h16):\(ls32)|((\(h16):){4}\(h16))?::\(ls32)|((\(h16):){5}\(h16))?::\(h16)|((\(h16):){6}\(h16))?::)" + private static let ipvfuture = "[vV][0-9A-Fa-f]+\\.(\(unreserved)|\(subDelims)|:)+" + private static let ipLiteral = "\\[(\(ipv6address)|\(ipvfuture))\\]" + private static let regName = "(\(unreserved)|\(pctEncoded)|\(subDelims))*" + private static let host = "(\(ipLiteral)|\(ipv4address)|\(regName))" + private static let port = "[0-9]*" + private static let authority = "(\(userinfo)@)?\(host)(:\(port))?" + private static let dateFullyear = "[0-9]{4}" + private static let dateMday = "[0-9]{2}" + private static let dateMonth = "[0-9]{2}" + private static let fullDate = "\(dateFullyear)-\(dateMonth)-\(dateMday)" + private static let timeHour = "[0-9]{2}" + private static let timeMinute = "[0-9]{2}" + private static let timeSecond = "[0-9]{2}" + private static let timeSecfrac = "\\.[0-9]+" + private static let partialTime = "\(timeHour):\(timeMinute):\(timeSecond)(\(timeSecfrac))?" + private static let timeNumoffset = "[+\\-]\(timeHour):\(timeMinute)" + private static let timeOffset = "([zZ]|\(timeNumoffset))" + private static let fullTime = "\(partialTime)\(timeOffset)" + private static let dateTime = "\(fullDate)[tT]\(fullTime)" + private static let pchar = "(\(unreserved)|\(pctEncoded)|\(subDelims)|[:@])" + private static let fragment = "(\(pchar)|[/?])*" + private static let genDelims = "[:/?#\\[\\]@]" + private static let segment = "(\(pchar))*" + private static let pathAbempty = "(/\(segment))*" + private static let segmentNz = "(\(pchar))+" + private static let pathAbsolute = "/(\(segmentNz)(/\(segment))*)?" + private static let pathRootless = "\(segmentNz)(/\(segment))*" + private static let pathEmpty = "(\(pchar)){0}" + private static let hierPart = "(//\(authority)\(pathAbempty)|\(pathAbsolute)|\(pathRootless)|\(pathEmpty))" + private static let query = "(\(pchar)|[/?])*" + private static let reserved = "(\(genDelims)|\(subDelims))" + private static let scheme = "[a-zA-Z][a-zA-Z0-9+\\-.]*" + private static let resource = "- \(uri)" + + // MARK: The final regular expression parts + private static let domain = authority + private static let address = "0x[0-9A-Fa-f]{40}" + private static let statement = "(\(reserved)|\(unreserved)| )+" + private static let uri = "\(scheme):\(hierPart)(\\?\(query))?(\\#\(fragment))?" + private static let version = "[0-9]+" + private static let chainId = "[0-9]+" + private static let nonce = "[a-zA-Z0-9]{8,}" + private static let issuedAt = dateTime + private static let expirationTime = dateTime + private static let notBefore = dateTime + private static let requestId = "(\(pchar))*" + private static let resources = "(\\n\(resource))*" + + private static let eip4361Pattern = "(?<\(EIP4361Field.domain.rawValue)>\(domain)) wants you to sign in with your Ethereum account:\\n(?<\(EIP4361Field.address.rawValue)>\(address))\\n\\n((?<\(EIP4361Field.statement.rawValue)>\(statement))\\n)?\\nURI: (?<\(EIP4361Field.uri.rawValue)>\(uri))\\nVersion: (?<\(EIP4361Field.version.rawValue)>\(version))\\nChain ID: (?<\(EIP4361Field.chainId.rawValue)>\(chainId))\\nNonce: (?<\(EIP4361Field.nonce.rawValue)>\(nonce))\\nIssued At: (?<\(EIP4361Field.issuedAt.rawValue)>\(issuedAt))(\\nExpiration Time: (?<\(EIP4361Field.expirationTime.rawValue)>\(expirationTime)))?(\\nNot Before: (?<\(EIP4361Field.notBefore.rawValue)>\(notBefore)))?(\\nRequest ID: (?<\(EIP4361Field.requestId.rawValue)>\(requestId)))?(\\nResources:(?<\(EIP4361Field.resources.rawValue)>\(resources)))?" private static var _eip4361OptionalPattern: String? private static var eip4361OptionalPattern: String { @@ -95,7 +140,7 @@ public final class EIP4361 { let patternParts: [String] = ["^\(domain)", "(\(address))?", - "\(statementParagraph)", + "((?<\(EIP4361Field.statement.rawValue)>\(statement))\\n)?", "(\(uri))?", "(\(version))?", "(\(chainId))?", @@ -113,12 +158,7 @@ public final class EIP4361 { public static func validate(_ message: String) -> EIP4361ValidationResponse { // swiftlint:disable force_try - let siweConstantMessageRegex = try! NSRegularExpression(pattern: "^\(domain)\\n") - guard siweConstantMessageRegex.firstMatch(in: message, range: message.fullNSRange) != nil else { - return EIP4361ValidationResponse(isEIP4361: false, eip4361: nil, capturedFields: [:]) - } - - let eip4361Regex = try! NSRegularExpression(pattern: eip4361OptionalPattern) + let eip4361Regex = try! NSRegularExpression(pattern: EIP4361.eip4361OptionalPattern) // swiftlint:enable force_try var capturedFields: [EIP4361Field: String] = [:] for (key, value) in eip4361Regex.captureGroups(string: message) { @@ -129,7 +169,7 @@ public final class EIP4361 { // swiftlint:enable force_unwrapping } return EIP4361ValidationResponse(isEIP4361: true, - eip4361: EIP4361(message), + eip4361: EIP4361(message), capturedFields: capturedFields) } @@ -167,6 +207,7 @@ public final class EIP4361 { let dateFormatter = ISO8601DateFormatter() dateFormatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds] guard let domain = groups["domain"], + !domain.isEmpty, let rawAddress = groups["address"], let address = EthereumAddress(rawAddress), let rawUri = groups["uri"], From e616a03446b7f1f765c359afca01e60b9440641a Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Wed, 8 Mar 2023 11:09:36 +0200 Subject: [PATCH 142/210] fix: fixed EIP4361 tests and added a new one for domain --- .../localTests/EIP4361Test.swift | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/Tests/web3swiftTests/localTests/EIP4361Test.swift b/Tests/web3swiftTests/localTests/EIP4361Test.swift index 8e750e222..69075edcc 100644 --- a/Tests/web3swiftTests/localTests/EIP4361Test.swift +++ b/Tests/web3swiftTests/localTests/EIP4361Test.swift @@ -14,7 +14,7 @@ class EIP4361Test: XCTestCase { /// Parsing Sign in with Ethereum message func test_EIP4361Parsing() { - let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-request-id_STRING!@$%%&\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" + let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" guard let siweMessage = EIP4361(rawSiweMessage) else { XCTFail("Failed to parse SIWE message.") return @@ -32,14 +32,14 @@ class EIP4361Test: XCTestCase { XCTAssertEqual(siweMessage.issuedAt, dateFormatter.date(from: "2021-09-30T16:25:24.345Z")!) XCTAssertEqual(siweMessage.expirationTime, dateFormatter.date(from: "2021-09-29T15:25:24.234Z")!) XCTAssertEqual(siweMessage.notBefore, dateFormatter.date(from: "2021-10-28T14:25:24.123Z")!) - XCTAssertEqual(siweMessage.requestId, "random-request-id_STRING!@$%%&") + XCTAssertEqual(siweMessage.requestId, "random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=") XCTAssertEqual(siweMessage.resources, [URL(string: "ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/")!, URL(string: "https://example.com/my-web2-claim.json")!]) XCTAssertEqual(siweMessage.description, rawSiweMessage) } func test_EIP4361StaticValidationFunc() { - let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-request-id_STRING!@$%%&\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" + let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) @@ -62,7 +62,7 @@ class EIP4361Test: XCTestCase { XCTAssertEqual(siweMessage.issuedAt, dateFormatter.date(from: "2021-09-30T16:25:24.345Z")!) XCTAssertEqual(siweMessage.expirationTime, dateFormatter.date(from: "2021-09-29T15:25:24.234Z")!) XCTAssertEqual(siweMessage.notBefore, dateFormatter.date(from: "2021-10-28T14:25:24.123Z")!) - XCTAssertEqual(siweMessage.requestId, "random-request-id_STRING!@$%%&") + XCTAssertEqual(siweMessage.requestId, "random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=") XCTAssertEqual(siweMessage.resources, [URL(string: "ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/")!, URL(string: "https://example.com/my-web2-claim.json")!]) XCTAssertEqual(siweMessage.description, rawSiweMessage) @@ -85,7 +85,7 @@ class EIP4361Test: XCTestCase { } func test_invalidEIP4361_missingAddress() { - let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-request-id_STRING!@$%%&\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" + let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) guard validationResponse.isEIP4361 && !validationResponse.isValid else { @@ -97,7 +97,7 @@ class EIP4361Test: XCTestCase { } func test_invalidEIP4361_missingUri() { - let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-request-id_STRING!@$%%&\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" + let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) guard validationResponse.isEIP4361 && !validationResponse.isValid else { @@ -109,7 +109,7 @@ class EIP4361Test: XCTestCase { } func test_invalidEIP4361_missingVersion() { - let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-request-id_STRING!@$%%&\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" + let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) guard validationResponse.isEIP4361 && !validationResponse.isValid else { @@ -121,7 +121,7 @@ class EIP4361Test: XCTestCase { } func test_invalidEIP4361_missingChainId() { - let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-request-id_STRING!@$%%&\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" + let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) guard validationResponse.isEIP4361 && !validationResponse.isValid else { @@ -133,7 +133,7 @@ class EIP4361Test: XCTestCase { } func test_invalidEIP4361_missingNonce() { - let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-request-id_STRING!@$%%&\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" + let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) guard validationResponse.isEIP4361 && !validationResponse.isValid else { @@ -145,7 +145,7 @@ class EIP4361Test: XCTestCase { } func test_invalidEIP4361_missingIssuedAt() { - let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-request-id_STRING!@$%%&\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" + let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) guard validationResponse.isEIP4361 && !validationResponse.isValid else { @@ -157,7 +157,7 @@ class EIP4361Test: XCTestCase { } func test_invalidEIP4361_wrongVersionNumber() { - let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 123\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-request-id_STRING!@$%%&\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" + let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 123\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) guard validationResponse.isEIP4361 && !validationResponse.isValid else { @@ -168,8 +168,21 @@ class EIP4361Test: XCTestCase { XCTAssertEqual(validationResponse.capturedFields[.version], "123") } + func test_invalidEIP4361_wrongCharInDomain() { + let rawSiweMessage = "service.invalid/ wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z" + + let validationResponse = EIP4361.validate(rawSiweMessage) + guard !validationResponse.isValid else { + XCTFail("Failed to parse valid SIWE message.") + return + } + + XCTAssertNil(validationResponse.eip4361) + XCTAssertEqual(validationResponse.capturedFields[.domain], "service.invalid/") + } + func test_validEIP4361_allRequiredFieldsContainWrongData() { - let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\nnot-a-hex-1234567890qwertyuiop1234567890qwertyuiop\n\nTHESTATEMENT123102938102938: aURIisSupposedToBeHEre\n\nURI: ANOTHER_URIisSupposedToBeHEre\nVersion: dsfjlsdafhjalsdfjh\nChain ID: not-a-chain-id\nNonce: not a nonce\nIssued At: this-is-not-a-date\nExpiration Time: expiration-time-not-a-date\nNot Before: not-before-not-a-date\nRequest ID: random-request-id_STRING!@$%%&\nResources:noURLSreallyHERE" + let rawSiweMessage = "service.invalid/path wants you to sign in with your Ethereum account:\nnot-a-hex-1234567890qwertyuiop1234567890qwertyuiop\n\nTHESTATEMENT123102938102938: aURIisSupposedToBeHEre\n\nURI: ANOTHER_URIisSupposedToBeHEre\nVersion: dsfjlsdafhjalsdfjh\nChain ID: not-a-chain-id\nNonce: not a nonce\nIssued At: this-is-not-a-date\nExpiration Time: expiration-time-not-a-date\nNot Before: not-before-not-a-date\nRequest ID: %%%%random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:noURLSreallyHERE" let validationResponse = EIP4361.validate(rawSiweMessage) guard validationResponse.isEIP4361 && !validationResponse.isValid else { @@ -177,7 +190,7 @@ class EIP4361Test: XCTestCase { return } - XCTAssertEqual(validationResponse.capturedFields[.domain], "service.invalid") + XCTAssertEqual(validationResponse.capturedFields[.domain], "service.invalid/path") XCTAssertEqual(validationResponse.capturedFields[.address], "not-a-hex-1234567890qwertyuiop1234567890qwertyuiop") XCTAssertEqual(validationResponse.capturedFields[.statement], "THESTATEMENT123102938102938: aURIisSupposedToBeHEre") XCTAssertEqual(validationResponse.capturedFields[.uri], "ANOTHER_URIisSupposedToBeHEre") @@ -187,7 +200,7 @@ class EIP4361Test: XCTestCase { XCTAssertEqual(validationResponse.capturedFields[.issuedAt], "this-is-not-a-date") XCTAssertEqual(validationResponse.capturedFields[.expirationTime], "expiration-time-not-a-date") XCTAssertEqual(validationResponse.capturedFields[.notBefore], "not-before-not-a-date") - XCTAssertEqual(validationResponse.capturedFields[.requestId], "random-request-id_STRING!@$%%&") + XCTAssertEqual(validationResponse.capturedFields[.requestId], "%%%%random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=") XCTAssertEqual(validationResponse.capturedFields[.resources], "noURLSreallyHERE") } } From 261ab36819aaf7fa46ec89cd9836dd0e48a8b861 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Wed, 8 Mar 2023 11:15:39 +0200 Subject: [PATCH 143/210] chore: EIP4361 tests renamed to match the code style requirements --- .../localTests/EIP4361Test.swift | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Tests/web3swiftTests/localTests/EIP4361Test.swift b/Tests/web3swiftTests/localTests/EIP4361Test.swift index 69075edcc..0fc25bd81 100644 --- a/Tests/web3swiftTests/localTests/EIP4361Test.swift +++ b/Tests/web3swiftTests/localTests/EIP4361Test.swift @@ -13,7 +13,7 @@ import Web3Core class EIP4361Test: XCTestCase { /// Parsing Sign in with Ethereum message - func test_EIP4361Parsing() { + func testEIP4361Parsing() { let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" guard let siweMessage = EIP4361(rawSiweMessage) else { XCTFail("Failed to parse SIWE message.") @@ -38,7 +38,7 @@ class EIP4361Test: XCTestCase { XCTAssertEqual(siweMessage.description, rawSiweMessage) } - func test_EIP4361StaticValidationFunc() { + func testEIP4361StaticValidationFunc() { let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) @@ -68,7 +68,7 @@ class EIP4361Test: XCTestCase { XCTAssertEqual(siweMessage.description, rawSiweMessage) } - func test_validEIP4361_noOptionalFields() { + func testValidEIP4361NoOptionalFields() { let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z" let validationResponse = EIP4361.validate(rawSiweMessage) @@ -84,7 +84,7 @@ class EIP4361Test: XCTestCase { XCTAssertNil(validationResponse.capturedFields[.resources]) } - func test_invalidEIP4361_missingAddress() { + func testInvalidEIP4361MissingAddress() { let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) @@ -96,7 +96,7 @@ class EIP4361Test: XCTestCase { XCTAssertNil(validationResponse.capturedFields[.address]) } - func test_invalidEIP4361_missingUri() { + func testInvalidEIP4361MissingUri() { let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) @@ -108,7 +108,7 @@ class EIP4361Test: XCTestCase { XCTAssertNil(validationResponse.capturedFields[.uri]) } - func test_invalidEIP4361_missingVersion() { + func testInvalidEIP4361MissingVersion() { let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) @@ -120,7 +120,7 @@ class EIP4361Test: XCTestCase { XCTAssertNil(validationResponse.capturedFields[.version]) } - func test_invalidEIP4361_missingChainId() { + func testInvalidEIP4361MissingChainId() { let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) @@ -132,7 +132,7 @@ class EIP4361Test: XCTestCase { XCTAssertNil(validationResponse.capturedFields[.chainId]) } - func test_invalidEIP4361_missingNonce() { + func testInvalidEIP4361MissingNonce() { let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) @@ -144,7 +144,7 @@ class EIP4361Test: XCTestCase { XCTAssertNil(validationResponse.capturedFields[.nonce]) } - func test_invalidEIP4361_missingIssuedAt() { + func testInvalidEIP4361MissingIssuedAt() { let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) @@ -156,7 +156,7 @@ class EIP4361Test: XCTestCase { XCTAssertNil(validationResponse.capturedFields[.issuedAt]) } - func test_invalidEIP4361_wrongVersionNumber() { + func testInvalidEIP4361WrongVersionNumber() { let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 123\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" let validationResponse = EIP4361.validate(rawSiweMessage) @@ -168,7 +168,7 @@ class EIP4361Test: XCTestCase { XCTAssertEqual(validationResponse.capturedFields[.version], "123") } - func test_invalidEIP4361_wrongCharInDomain() { + func testInvalidEIP4361WrongCharInDomain() { let rawSiweMessage = "service.invalid/ wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z" let validationResponse = EIP4361.validate(rawSiweMessage) @@ -181,7 +181,7 @@ class EIP4361Test: XCTestCase { XCTAssertEqual(validationResponse.capturedFields[.domain], "service.invalid/") } - func test_validEIP4361_allRequiredFieldsContainWrongData() { + func testInvalidEIP4361AllRequiredFieldsContainWrongData() { let rawSiweMessage = "service.invalid/path wants you to sign in with your Ethereum account:\nnot-a-hex-1234567890qwertyuiop1234567890qwertyuiop\n\nTHESTATEMENT123102938102938: aURIisSupposedToBeHEre\n\nURI: ANOTHER_URIisSupposedToBeHEre\nVersion: dsfjlsdafhjalsdfjh\nChain ID: not-a-chain-id\nNonce: not a nonce\nIssued At: this-is-not-a-date\nExpiration Time: expiration-time-not-a-date\nNot Before: not-before-not-a-date\nRequest ID: %%%%random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:noURLSreallyHERE" let validationResponse = EIP4361.validate(rawSiweMessage) From 3e742dba89f526634bf463b0cac10ec339f198c0 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Wed, 8 Mar 2023 11:16:02 +0200 Subject: [PATCH 144/210] chore: added EIP4361 test for missing domain --- Tests/web3swiftTests/localTests/EIP4361Test.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Tests/web3swiftTests/localTests/EIP4361Test.swift b/Tests/web3swiftTests/localTests/EIP4361Test.swift index 0fc25bd81..0bccee178 100644 --- a/Tests/web3swiftTests/localTests/EIP4361Test.swift +++ b/Tests/web3swiftTests/localTests/EIP4361Test.swift @@ -84,6 +84,19 @@ class EIP4361Test: XCTestCase { XCTAssertNil(validationResponse.capturedFields[.resources]) } + func testInvalidEIP4361MissingDomain() { + let rawSiweMessage = "wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z" + + let validationResponse = EIP4361.validate(rawSiweMessage) + guard !validationResponse.isValid else { + XCTFail("Failed to parse valid SIWE message.") + return + } + + XCTAssertNil(validationResponse.eip4361) + XCTAssertNil(validationResponse.capturedFields[.domain]) + } + func testInvalidEIP4361MissingAddress() { let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json" From 0308f9bd4f3f93b2d98b7a39c8482ff04d6edcd9 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Wed, 8 Mar 2023 07:39:56 -0800 Subject: [PATCH 145/210] PR request --- .../Web3Core/KeystoreManager/BIP32HDNode.swift | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift index 02bbf2e40..efaf77c81 100644 --- a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift @@ -19,11 +19,10 @@ extension UInt32 { let byteArray = Array(bytePtr) return Data(byteArray) } - static var maxIterationIndex = UInt32(1) << 31 } public class HDNode { - + static var maxIterationIndex = UInt32(1) << 31 private struct HDversion { public static var privatePrefix: Data? = Data.fromHex("0x0488ADE4") public static var publicPrefix: Data? = Data.fromHex("0x0488B21E") @@ -37,11 +36,11 @@ public class HDNode { public var parentFingerprint: Data = Data(repeating: 0, count: 4) public var childNumber: UInt32 = UInt32(0) public var isHardened: Bool { - childNumber >= UInt32.maxIterationIndex + childNumber >= Self.maxIterationIndex } public var index: UInt32 { if self.isHardened { - return childNumber - UInt32.maxIterationIndex + return childNumber - Self.maxIterationIndex } else { return childNumber } @@ -113,7 +112,7 @@ public class HDNode { public static var defaultPathPrefix: String = "m/44'/60'/0'" public static var defaultPathMetamask: String = "m/44'/60'/0'/0/0" public static var defaultPathMetamaskPrefix: String = "m/44'/60'/0'/0" - public static var hardenedIndexPrefix: UInt32 = UInt32.maxIterationIndex + public static var hardenedIndexPrefix: UInt32 { Self.maxIterationIndex } } extension HDNode { @@ -127,7 +126,7 @@ extension HDNode { public func deriveWithoutPrivateKey(index: UInt32, hardened: Bool = false) -> HDNode? { var entropy: [UInt8] // derive public key when is itself public key - if index >= UInt32.maxIterationIndex || hardened { + if index >= Self.maxIterationIndex || hardened { return nil // no derivation of hardened public key from extended public key } else { let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) @@ -181,10 +180,10 @@ extension HDNode { } var entropy: [UInt8] var trueIndex: UInt32 - if index >= UInt32.maxIterationIndex || hardened { + if index >= Self.maxIterationIndex || hardened { trueIndex = index - if trueIndex < UInt32.maxIterationIndex { - trueIndex = trueIndex + UInt32.maxIterationIndex + if trueIndex < Self.maxIterationIndex { + trueIndex = trueIndex + Self.maxIterationIndex } let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) var inputForHMAC = Data() From 40d34775dd6f0f5a8588ddb8121f8e8af9fbda62 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:16:50 -0800 Subject: [PATCH 146/210] revert per PR comments --- .../KeystoreManager/BIP32HDNode.swift | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift index efaf77c81..ae0a683ed 100644 --- a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift @@ -23,9 +23,19 @@ extension UInt32 { public class HDNode { static var maxIterationIndex = UInt32(1) << 31 - private struct HDversion { - public static var privatePrefix: Data? = Data.fromHex("0x0488ADE4") - public static var publicPrefix: Data? = Data.fromHex("0x0488B21E") + + public struct HDversion { + // swiftlint:disable force_unwrapping + public var privatePrefix: Data = Data.fromHex("0x0488ADE4") ?? Data() + public var publicPrefix: Data = Data.fromHex("0x0488B21E") ?? Data() + // swiftlint:enable force_unwrapping + public init() {} + public static var privatePrefix: Data { + HDversion().privatePrefix + } + public static var publicPrefix: Data { + HDversion().publicPrefix + } } public var path: String? = "m" @@ -231,16 +241,16 @@ extension HDNode { newNode.publicKey = pubKeyCandidate newNode.privateKey = privKeyCandidate newNode.childNumber = trueIndex - guard let fprint = try? RIPEMD160.hash(message: self.publicKey.sha256())[0..<4] else { - return nil - } + guard let fprint = try? RIPEMD160.hash(message: self.publicKey.sha256())[0..<4], + let path = path + else { return nil } newNode.parentFingerprint = fprint var newPath = String() if newNode.isHardened { - newPath = self.path! + "/" + newPath = path + "/" newPath += String(newNode.index % HDNode.hardenedIndexPrefix) + "'" } else { - newPath = self.path! + "/" + String(newNode.index) + newPath = path + "/" + String(newNode.index) } newNode.path = newPath return newNode @@ -282,9 +292,9 @@ extension HDNode { } if serializePublic { - data.append(HDversion.publicPrefix!) + data.append(HDversion.publicPrefix) } else { - data.append(HDversion.privatePrefix!) + data.append(HDversion.privatePrefix) } data.append(contentsOf: [self.depth]) data.append(self.parentFingerprint) From 5a91bb5eb52d3d82c08adc75bb356ab6461056d9 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:22:00 -0800 Subject: [PATCH 147/210] revert changes --- .../KeystoreManager/BIP32HDNode.swift | 253 +++++++++--------- 1 file changed, 126 insertions(+), 127 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift index ae0a683ed..12e2afcb9 100644 --- a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift @@ -128,121 +128,118 @@ public class HDNode { extension HDNode { public func derive(index: UInt32, derivePrivateKey: Bool, hardened: Bool = false) -> HDNode? { if derivePrivateKey { - return deriveWithPrivateKey(index: index, hardened: hardened) - } else { // deriving only the public key - return deriveWithoutPrivateKey(index: index, hardened: hardened) + return self.derivePrivateKey(index: index, hardened: hardened) + } else { + return derivePublicKey(index: index, hardened: hardened) } } - public func deriveWithoutPrivateKey(index: UInt32, hardened: Bool = false) -> HDNode? { - var entropy: [UInt8] // derive public key when is itself public key - if index >= Self.maxIterationIndex || hardened { - return nil // no derivation of hardened public key from extended public key - } else { - let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) - var inputForHMAC = Data() - inputForHMAC.append(self.publicKey) - inputForHMAC.append(index.serialize32()) - guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else { return nil } - guard ent.count == 64 else { return nil } - entropy = ent + public func derive(path: String, derivePrivateKey: Bool = true) -> HDNode? { + let components = path.components(separatedBy: "/") + var currentNode: HDNode = self + var firstComponent = 0 + if path.hasPrefix("m") { + firstComponent = 1 } - let I_L = entropy[0..<32] - let I_R = entropy[32..<64] - let cc = Data(I_R) - let bn = BigUInt(Data(I_L)) - if bn > HDNode.curveOrder { - if index < UInt32.max { - return self.derive(index: index+1, derivePrivateKey: false, hardened: hardened) + for component in components[firstComponent ..< components.count] { + var hardened = false + if component.hasSuffix("'") { + hardened = true } - return nil - } - guard let tempKey = bn.serialize().setLengthLeft(32) else { return nil } - guard SECP256K1.verifyPrivateKey(privateKey: tempKey) else { return nil } - guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: tempKey, compressed: true) else { return nil } - guard pubKeyCandidate.bytes.first == 0x02 || pubKeyCandidate.bytes.first == 0x03 else { return nil } - guard let newPublicKey = SECP256K1.combineSerializedPublicKeys(keys: [self.publicKey, pubKeyCandidate], outputCompressed: true) else { return nil } - guard newPublicKey.bytes.first == 0x02 || newPublicKey.bytes.first == 0x03 else { return nil } - guard self.depth < UInt8.max else { return nil } - let newNode = HDNode() - newNode.chaincode = cc - newNode.depth = self.depth + 1 - newNode.publicKey = newPublicKey - newNode.childNumber = index - guard let fprint = try? RIPEMD160.hash(message: self.publicKey.sha256())[0..<4] else { - return nil - } - newNode.parentFingerprint = fprint - var newPath = String() - if newNode.isHardened { - newPath = (self.path ?? "") + "/" - newPath += String(newNode.index % HDNode.hardenedIndexPrefix) + "'" - } else { - newPath = (self.path ?? "") + "/" + String(newNode.index) + guard let index = UInt32(component.trimmingCharacters(in: CharacterSet(charactersIn: "'"))) else { return nil } + guard let newNode = currentNode.derive(index: index, derivePrivateKey: derivePrivateKey, hardened: hardened) else { return nil } + currentNode = newNode } - newNode.path = newPath - return newNode + return currentNode } - public func deriveWithPrivateKey(index: UInt32, hardened: Bool = false) -> HDNode? { - guard let privateKey = self.privateKey else { + /// Derive public key when is itself private key. + /// Derivation of private key when is itself extended public key is impossible and will return `nil`. + private func derivePrivateKey(index: UInt32, hardened: Bool) -> HDNode? { + guard let privateKey = privateKey else { + // derive private key when is itself extended public key (impossible) return nil } - var entropy: [UInt8] - var trueIndex: UInt32 - if index >= Self.maxIterationIndex || hardened { - trueIndex = index - if trueIndex < Self.maxIterationIndex { - trueIndex = trueIndex + Self.maxIterationIndex - } - let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) - var inputForHMAC = Data() - inputForHMAC.append(Data([UInt8(0x00)])) - inputForHMAC.append(privateKey) - inputForHMAC.append(trueIndex.serialize32()) - guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else { return nil } - guard ent.count == 64 else { return nil } - entropy = ent - } else { - trueIndex = index - let hmac: Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) - var inputForHMAC = Data() - inputForHMAC.append(self.publicKey) - inputForHMAC.append(trueIndex.serialize32()) - guard let ent = try? hmac.authenticate(inputForHMAC.bytes) else { return nil } - guard ent.count == 64 else { return nil } - entropy = ent + + var trueIndex = index + if trueIndex < (UInt32(1) << 31) && hardened { + trueIndex += (UInt32(1) << 31) } + + guard let entropy = calculateEntropy(index: trueIndex, privateKey: privateKey, hardened: hardened) else { return nil } + let I_L = entropy[0..<32] let I_R = entropy[32..<64] - let cc = Data(I_R) + let chainCode = Data(I_R) let bn = BigUInt(Data(I_L)) if bn > HDNode.curveOrder { if trueIndex < UInt32.max { - return self.derive(index: index+1, derivePrivateKey: true, hardened: hardened) + return self.derive(index: index + 1, derivePrivateKey: true, hardened: hardened) } return nil } - let newPK = (bn + BigUInt(self.privateKey!)) % HDNode.curveOrder + let newPK = (bn + BigUInt(privateKey)) % HDNode.curveOrder if newPK == BigUInt(0) { if trueIndex < UInt32.max { - return self.derive(index: index+1, derivePrivateKey: true, hardened: hardened) + return self.derive(index: index + 1, derivePrivateKey: true, hardened: hardened) } return nil } - guard let privKeyCandidate = newPK.serialize().setLengthLeft(32) else { return nil } - guard SECP256K1.verifyPrivateKey(privateKey: privKeyCandidate) else { return nil } - guard let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: privKeyCandidate, compressed: true) else { return nil } - guard pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03 else { return nil } - guard self.depth < UInt8.max else { return nil } + + guard + let newPrivateKey = newPK.serialize().setLengthLeft(32), + SECP256K1.verifyPrivateKey(privateKey: newPrivateKey), + let newPublicKey = SECP256K1.privateToPublic(privateKey: newPrivateKey, compressed: true), + (newPublicKey.bytes[0] == 0x02 || newPublicKey.bytes[0] == 0x03), + self.depth < UInt8.max + else { return nil } + return createNode(chainCode: chainCode, depth: depth + 1, publicKey: newPublicKey, privateKey: newPrivateKey, childNumber: trueIndex) + } + + /// Derive public key when is itself public key. + /// No derivation of hardened public key from extended public key is allowed. + private func derivePublicKey(index: UInt32, hardened: Bool) -> HDNode? { + if index >= (UInt32(1) << 31) || hardened { + // no derivation of hardened public key from extended public key + return nil + } + + guard let entropy = calculateEntropy(index: index, hardened: hardened) else { return nil } + + let I_L = entropy[0..<32] + let I_R = entropy[32..<64] + let chainCode = Data(I_R) + let bn = BigUInt(Data(I_L)) + if bn > HDNode.curveOrder { + if index < UInt32.max { + return self.derive(index: index+1, derivePrivateKey: false, hardened: hardened) + } + return nil + } + + guard + let tempKey = bn.serialize().setLengthLeft(32), + SECP256K1.verifyPrivateKey(privateKey: tempKey), + let pubKeyCandidate = SECP256K1.privateToPublic(privateKey: tempKey, compressed: true), + (pubKeyCandidate.bytes[0] == 0x02 || pubKeyCandidate.bytes[0] == 0x03), + let newPublicKey = SECP256K1.combineSerializedPublicKeys(keys: [self.publicKey, pubKeyCandidate], outputCompressed: true), + (newPublicKey.bytes[0] == 0x02 || newPublicKey.bytes[0] == 0x03), + self.depth < UInt8.max + else { return nil } + + return createNode(chainCode: chainCode, depth: depth + 1, publicKey: newPublicKey, childNumber: index) + } + + private func createNode(chainCode: Data, depth: UInt8, publicKey: Data, privateKey: Data? = nil, childNumber: UInt32) -> HDNode? { let newNode = HDNode() - newNode.chaincode = cc - newNode.depth = self.depth + 1 - newNode.publicKey = pubKeyCandidate - newNode.privateKey = privKeyCandidate - newNode.childNumber = trueIndex - guard let fprint = try? RIPEMD160.hash(message: self.publicKey.sha256())[0..<4], - let path = path + newNode.chaincode = chainCode + newNode.depth = depth + newNode.publicKey = publicKey + newNode.privateKey = privateKey + newNode.childNumber = childNumber + guard + let fprint = try? RIPEMD160.hash(message: self.publicKey.sha256())[0..<4], + let path = path else { return nil } newNode.parentFingerprint = fprint var newPath = String() @@ -254,58 +251,60 @@ extension HDNode { } newNode.path = newPath return newNode - } - public func derive(path: String, derivePrivateKey: Bool = true) -> HDNode? { + private func calculateHMACInput(_ index: UInt32, privateKey: Data? = nil, hardened: Bool) -> Data { + var inputForHMAC = Data() - let components = path.components(separatedBy: "/") - var currentNode: HDNode = self - var firstComponent = 0 - if path.hasPrefix("m") { - firstComponent = 1 - } - for component in components[firstComponent ..< components.count] { - var hardened = false - if component.hasSuffix("'") { - hardened = true - } - guard let index = UInt32(component.trimmingCharacters(in: CharacterSet(charactersIn: "'"))) else { return nil } - guard let newNode = currentNode.derive(index: index, derivePrivateKey: derivePrivateKey, hardened: hardened) else { return nil } - currentNode = newNode + if let privateKey = privateKey, (index >= (UInt32(1) << 31) || hardened) { + inputForHMAC.append(Data([UInt8(0x00)])) + inputForHMAC.append(privateKey) + } else { + inputForHMAC.append(self.publicKey) } - return currentNode + + inputForHMAC.append(index.serialize32()) + return inputForHMAC } - public func serializeToString(serializePublic: Bool = true) -> String? { - guard let data = self.serialize(serializePublic: serializePublic) else { return nil } - let encoded = Base58.base58FromBytes(data.bytes) - return encoded + /// Calculates entropy used for private or public key derivation. + /// - Parameters: + /// - index: index + /// - privateKey: private key data or `nil` if entropy is calculated for a public key; + /// - hardened: is hardened key + /// - Returns: 64 bytes entropy or `nil`. + private func calculateEntropy(index: UInt32, privateKey: Data? = nil, hardened: Bool) -> [UInt8]? { + let inputForHMAC = calculateHMACInput(index, privateKey: privateKey, hardened: hardened) + let hmac = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) + guard let entropy = try? hmac.authenticate(inputForHMAC.bytes), entropy.count == 64 else { return nil } + return entropy } - public func serialize(serializePublic: Bool = true) -> Data? { + public func serializeToString(serializePublic: Bool = true, version: HDversion = HDversion()) -> String? { + guard let data = self.serialize(serializePublic: serializePublic, version: version) else { return nil } + return Base58.base58FromBytes(data.bytes) + } + public func serialize(serializePublic: Bool = true, version: HDversion = HDversion()) -> Data? { var data = Data() - - guard serializePublic || privateKey != nil else { - return nil - } - + /// Public or private key + let keyData: Data if serializePublic { - data.append(HDversion.publicPrefix) + keyData = publicKey + data.append(version.publicPrefix) } else { - data.append(HDversion.privatePrefix) + guard let privateKey = privateKey else { return nil } + keyData = privateKey + data.append(version.privatePrefix) } - data.append(contentsOf: [self.depth]) - data.append(self.parentFingerprint) - data.append(self.childNumber.serialize32()) - data.append(self.chaincode) - if serializePublic { - data.append(self.publicKey) - } else { + data.append(contentsOf: [depth]) + data.append(parentFingerprint) + data.append(childNumber.serialize32()) + data.append(chaincode) + if !serializePublic { data.append(contentsOf: [0x00]) - data.append(self.privateKey!) } + data.append(keyData) let hashedData = data.sha256().sha256() let checksum = hashedData[0..<4] data.append(checksum) From 709e42295805984e97b1f44ae53f5b2205e37ac9 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:24:32 -0800 Subject: [PATCH 148/210] fix error? --- Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift b/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift index a7082d731..5b7c2d5f4 100644 --- a/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift +++ b/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift @@ -64,7 +64,7 @@ public extension ENS { return expirity } - @available(*, message: "This function should not be used to check if a name can be registered by a user. To check if a name can be registered by a user, check name availablility via the controller") + @available(*, message: "This function should not be used to check if a name can be registered by a user. To check if a name can be registered by a user, check name availability via the controller") public func isNameAvailable(name: BigUInt) async throws -> Bool { guard let transaction = self.contract.createReadOperation("available", parameters: [name]) else { throw Web3Error.transactionSerializationError } From 6b6f791359d72239477da6406fbfea946a274440 Mon Sep 17 00:00:00 2001 From: Sara Tavares Date: Wed, 8 Mar 2023 23:55:14 +0000 Subject: [PATCH 149/210] chore(typos): fix typos --- CHANGELOG.md | 4 +- .../WalletViewController.swift | 2 +- .../RequestParameter+RawRepresentable.swift | 2 +- Sources/Web3Core/Structure/SECP256k1.swift | 22 +- Sources/web3swift/Browser/browser.js | 200 +++++++++--------- Sources/web3swift/Browser/browser.min.js | 4 +- .../Tokens/ST20/Web3+SecurityToken.swift | 2 +- Sources/web3swift/Utils/EIP/EIP681.swift | 10 +- .../Utils/ENS/ENSBaseRegistrar.swift | 2 +- Sources/web3swift/Web3/Web3+EIP1559.swift | 18 +- 10 files changed, 133 insertions(+), 133 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1fef400b..b477f29d7 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -162,7 +162,7 @@ - Update libs versions, Cartfile and Pods dependencies [\#334](https://github.com/skywinder/web3swift/pull/334) ([AnnaYatsun1](https://github.com/AnnaYatsun1)) - fix crash when 'payable' nil [\#332](https://github.com/skywinder/web3swift/pull/332) ([xdozorx](https://github.com/xdozorx)) - Update README.md [\#331](https://github.com/skywinder/web3swift/pull/331) ([Iysbaera](https://github.com/Iysbaera)) -- CrytoSwift update version 1.4.0 [\#327](https://github.com/skywinder/web3swift/pull/327) ([lzttxs](https://github.com/lzttxs)) +- CryptoSwift update version 1.4.0 [\#327](https://github.com/skywinder/web3swift/pull/327) ([lzttxs](https://github.com/lzttxs)) - Update carthage libraries [\#325](https://github.com/skywinder/web3swift/pull/325) ([alex78pro](https://github.com/alex78pro)) - Gas estimate fix [\#324](https://github.com/skywinder/web3swift/pull/324) ([frostiq](https://github.com/frostiq)) - Update README.md [\#306](https://github.com/skywinder/web3swift/pull/306) ([manuG420](https://github.com/manuG420)) @@ -252,7 +252,7 @@ - received transaction id from geth node server but not able to see that transaction id at etherscan.io [\#200](https://github.com/skywinder/web3swift/issues/200) - How do I fetch information such as balance, decimal,symbol and name of ERC20token ? [\#199](https://github.com/skywinder/web3swift/issues/199) - Starscream 3.1.0 not compatible with Swift 5.0 [\#195](https://github.com/skywinder/web3swift/issues/195) -- How to Connect infuraWebsocket and subsribe particular event in swift? [\#193](https://github.com/skywinder/web3swift/issues/193) +- How to Connect infuraWebsocket and subscribe particular event in swift? [\#193](https://github.com/skywinder/web3swift/issues/193) - Use of unresolved identifier 'Wallet' [\#192](https://github.com/skywinder/web3swift/issues/192) - V in Signed Message Hash not being calculated properly [\#191](https://github.com/skywinder/web3swift/issues/191) - Not possible to calculate fast, normal and cheap transaction fee ? [\#190](https://github.com/skywinder/web3swift/issues/190) diff --git a/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift b/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift index 922cd5757..12e560853 100644 --- a/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift +++ b/Example/myWeb3Wallet/myWeb3Wallet/ViewControllers/WalletController/WalletViewController.swift @@ -102,7 +102,7 @@ class WalletViewController: UIViewController { } } catch { #if DEBUG - print("error creating keyStrore") + print("error creating keyStore") print("Private key error.") #endif let alert = UIAlertController(title: "Error", message: "Please enter correct Private key", preferredStyle: .alert) diff --git a/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+RawRepresentable.swift b/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+RawRepresentable.swift index ef04032ba..af5a4b6b5 100644 --- a/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+RawRepresentable.swift +++ b/Sources/Web3Core/EthereumNetwork/RequestParameter/RequestParameter+RawRepresentable.swift @@ -13,7 +13,7 @@ extension RequestParameter: RawRepresentable { /// to encode mixed type values array in JSON. /// /// This protocol is used to implement custom `encode` method for that enum, - /// which encodes an array of self-assosiated values. + /// which encodes an array of self-associated values. /// /// You're totally free to use explicit and more convenience member init as `RequestParameter.int(12)` in your code. /// - Parameter rawValue: one of the supported types like `Int`, `UInt` etc. diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index f67e69d77..9ebcaa9cb 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -83,7 +83,7 @@ extension SECP256K1 { return serializedKey } - internal static func recoverPublicKey(hash: Data, recoverableSignature: inout secp256k1_ecdsa_recoverable_signature) -> secp256k1_pubkey? { + internal static func recoverPublicKey(hash: Data, recoverableSignature: input secp256k1_ecdsa_recoverable_signature) -> secp256k1_pubkey? { guard let context = context, hash.count == 32 else { return nil } var publicKey: secp256k1_pubkey = secp256k1_pubkey() let result = hash.withUnsafeBytes { (hashRawBufferPointer: UnsafeRawBufferPointer) -> Int32? in @@ -124,7 +124,7 @@ extension SECP256K1 { return publicKey } - public static func serializePublicKey(publicKey: inout secp256k1_pubkey, compressed: Bool = false) -> Data? { + public static func serializePublicKey(publicKey: input secp256k1_pubkey, compressed: Bool = false) -> Data? { guard let context = context else { return nil } var keyLength = compressed ? 33 : 65 var serializedPubkey = Data(repeating: 0x00, count: keyLength) @@ -189,11 +189,11 @@ extension SECP256K1 { } else if v >= 35 && v <= 38 { v -= 35 } - let result = serializedSignature.withUnsafeBytes { (serRawBufferPtr: UnsafeRawBufferPointer) -> Int32? in - if let serRawPtr = serRawBufferPtr.baseAddress, serRawBufferPtr.count > 0 { - let serPtr = serRawPtr.assumingMemoryBound(to: UInt8.self) + let result = serializedSignature.withUnsafeBytes { (setRawBufferPtr: UnsafeRawBufferPointer) -> Int32? in + if let setRawPtr = setRawBufferPtr.baseAddress, setRawBufferPtr.count > 0 { + let setPtr = setRawPtr.assumingMemoryBound(to: UInt8.self) return withUnsafeMutablePointer(to: &recoverableSignature) { (signaturePointer: UnsafeMutablePointer) -> Int32 in - let res = secp256k1_ecdsa_recoverable_signature_parse_compact(context, signaturePointer, serPtr, v) + let res = secp256k1_ecdsa_recoverable_signature_parse_compact(context, signaturePointer, setPtr, v) return res } } else { @@ -206,16 +206,16 @@ extension SECP256K1 { return recoverableSignature } - internal static func serializeSignature(recoverableSignature: inout secp256k1_ecdsa_recoverable_signature) -> Data? { + internal static func serializeSignature(recoverableSignature: input secp256k1_ecdsa_recoverable_signature) -> Data? { guard let context = context else { return nil } var serializedSignature = Data(repeating: 0x00, count: 64) var v: Int32 = 0 - let result = serializedSignature.withUnsafeMutableBytes { (serSignatureRawBufferPointer: UnsafeMutableRawBufferPointer) -> Int32? in - if let serSignatureRawPointer = serSignatureRawBufferPointer.baseAddress, serSignatureRawBufferPointer.count > 0 { - let serSignaturePointer = serSignatureRawPointer.assumingMemoryBound(to: UInt8.self) + let result = serializedSignature.withUnsafeMutableBytes { (setSignatureRawBufferPointer: UnsafeMutableRawBufferPointer) -> Int32? in + if let setSignatureRawPointer = setSignatureRawBufferPointer.baseAddress, setSignatureRawBufferPointer.count > 0 { + let setSignaturePointer = setSignatureRawPointer.assumingMemoryBound(to: UInt8.self) return withUnsafePointer(to: &recoverableSignature) { (signaturePointer: UnsafePointer) -> Int32 in withUnsafeMutablePointer(to: &v) { (vPtr: UnsafeMutablePointer) -> Int32 in - let res = secp256k1_ecdsa_recoverable_signature_serialize_compact(context, serSignaturePointer, vPtr, signaturePointer) + let res = secp256k1_ecdsa_recoverable_signature_serialize_compact(context, setSignaturePointer, vPtr, signaturePointer) return res } } diff --git a/Sources/web3swift/Browser/browser.js b/Sources/web3swift/Browser/browser.js index d85214d3d..f1ba2fff4 100644 --- a/Sources/web3swift/Browser/browser.js +++ b/Sources/web3swift/Browser/browser.js @@ -137,7 +137,7 @@ * * 1. Previous registration * 2. global.Promise if node.js version >= 0.12 - * 3. Auto detected promise based on first sucessful require of + * 3. Auto detected promise based on first successful require of * known promise libraries. Note this is a last resort, as the * loaded library is non-deterministic. node.js >= 0.12 will * always use global.Promise over this priority list. @@ -1554,7 +1554,7 @@ // Long form var num = len & 0x7f; if (num > 4) - return buf.error('length octect is too long'); + return buf.error('length octet is too long'); len = 0; for (var i = 0; i < num; i++) { @@ -1706,7 +1706,7 @@ if (!this._isPrintstr(str)) { return this.reporter.error('Encoding of string type: printstr supports ' + 'only latin upper and lower case letters, ' + - 'digits, space, apostrophe, left and rigth ' + + 'digits, space, apostrophe, left and right ' + 'parenthesis, plus sign, comma, hyphen, ' + 'dot, slash, colon, equal sign, ' + 'question mark'); @@ -9326,7 +9326,7 @@ this.backoffNumber_++; }; - // Stops any backoff operation and resets the backoff delay to its inital value. + // Stops any backoff operation and resets the backoff delay to its initial value. Backoff.prototype.reset = function() { this.backoffNumber_ = 0; this.backoffStrategy_.reset(); @@ -13413,7 +13413,7 @@ },{"crypto":55}],55:[function(require,module,exports){ },{}],56:[function(require,module,exports){ - // based on the aes implimentation in triple sec + // based on the aes implementation in triple sec // https://github.com/keybase/triplesec // which is in turn based on the one from crypto-js // https://code.google.com/p/crypto-js/ @@ -13762,7 +13762,7 @@ module.exports = StreamCipher },{"./aes":56,"./ghash":61,"./incr32":62,"buffer-xor":83,"cipher-base":86,"inherits":180,"safe-buffer":290}],58:[function(require,module,exports){ - var ciphers = require('./encrypter') + var ciphers = require('./encryptor') var deciphers = require('./decrypter') var modes = require('./modes/list.json') @@ -13776,7 +13776,7 @@ exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv exports.listCiphers = exports.getCiphers = getCiphers - },{"./decrypter":59,"./encrypter":60,"./modes/list.json":70}],59:[function(require,module,exports){ + },{"./decrypter":59,"./encryptor":60,"./modes/list.json":70}],59:[function(require,module,exports){ var AuthCipher = require('./authCipher') var Buffer = require('safe-buffer').Buffer var MODES = require('./modes') @@ -14633,15 +14633,15 @@ var inherits = require('inherits') var modes = { - 'des-ede3-cbc': des.CBC.instantiate(des.EDE), - 'des-ede3': des.EDE, - 'des-ede-cbc': des.CBC.instantiate(des.EDE), - 'des-ede': des.EDE, + 'des-edge3-cbc': des.CBC.instantiate(des.EDGE), + 'des-edge3': des.EDGE, + 'des-edge-cbc': des.CBC.instantiate(des.EDGE), + 'des-edge': des.EDGE, 'des-cbc': des.CBC.instantiate(des.DES), 'des-ecb': des.DES } modes.des = modes['des-cbc'] - modes.des3 = modes['des-ede3-cbc'] + modes.des3 = modes['des-edge3-cbc'] module.exports = DES inherits(DES, CipherBase) function DES (opts) { @@ -14655,7 +14655,7 @@ type = 'encrypt' } var key = opts.key - if (modeName === 'des-ede' || modeName === 'des-ede-cbc') { + if (modeName === 'des-edge' || modeName === 'des-edge-cbc') { key = Buffer.concat([key, key.slice(0, 8)]) } var iv = opts.iv @@ -14682,19 +14682,19 @@ key: 8, iv: 8 } - exports['des-ede3-cbc'] = exports.des3 = { + exports['des-edge3-cbc'] = exports.des3 = { key: 24, iv: 8 } - exports['des-ede3'] = { + exports['des-edge3'] = { key: 24, iv: 0 } - exports['des-ede-cbc'] = { + exports['des-edge-cbc'] = { key: 16, iv: 8 } - exports['des-ede'] = { + exports['des-edge'] = { key: 16, iv: 0 } @@ -15406,7 +15406,7 @@ if (fill !== undefined) { // Only pay attention to encoding if it's a string. This // prevents accidentally sending in a number that would - // be interpretted as a start offset. + // be interpreted as a start offset. return typeof encoding === 'string' ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill) @@ -15689,7 +15689,7 @@ return '' } - // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + // Force coercion to uint32. This will also coerce falsey/NaN values to 0. end >>>= 0 start >>>= 0 @@ -18955,7 +18955,7 @@ exports.Cipher = require('./des/cipher'); exports.DES = require('./des/des'); exports.CBC = require('./des/cbc'); - exports.EDE = require('./des/ede'); + exports.EDGE = require('./des/ede'); },{"./des/cbc":100,"./des/cipher":101,"./des/des":102,"./des/ede":103,"./des/utils":104}],100:[function(require,module,exports){ 'use strict'; @@ -19322,7 +19322,7 @@ var Cipher = des.Cipher; var DES = des.DES; - function EDEState(type, key) { + function EDGEState(type, key) { assert.equal(key.length, 24, 'Invalid key length'); var k1 = key.slice(0, 8); @@ -19344,30 +19344,30 @@ } } - function EDE(options) { + function EDGE(options) { Cipher.call(this, options); - var state = new EDEState(this.type, this.options.key); - this._edeState = state; + var state = new EDGEState(this.type, this.options.key); + this._edgeState = state; } - inherits(EDE, Cipher); + inherits(EDGE, Cipher); - module.exports = EDE; + module.exports = EDGE; - EDE.create = function create(options) { - return new EDE(options); + EDGE.create = function create(options) { + return new EDGE(options); }; - EDE.prototype._update = function _update(inp, inOff, out, outOff) { - var state = this._edeState; + EDGE.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._edgeState; state.ciphers[0]._update(inp, inOff, out, outOff); state.ciphers[1]._update(out, outOff, out, outOff); state.ciphers[2]._update(out, outOff, out, outOff); }; - EDE.prototype._pad = DES.prototype._pad; - EDE.prototype._unpad = DES.prototype._unpad; + EDGE.prototype._pad = DES.prototype._pad; + EDGE.prototype._unpad = DES.prototype._unpad; },{"../des":99,"inherits":180,"minimalistic-assert":234}],104:[function(require,module,exports){ 'use strict'; @@ -22355,7 +22355,7 @@ var isYOdd = j & 1; var isSecondKey = j >> 1; if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) - throw new Error('Unable to find sencond key candinate'); + throw new Error('Unable to find second key candidate'); // 1.1. Let x = r + jn. if (isSecondKey) @@ -24751,7 +24751,7 @@ try { // attempt request await performFetch(network, req, res) - // request was succesful + // request was successful break } catch (err) { // an error was caught while performing the request @@ -25749,7 +25749,7 @@ }, "expGas": { "v": 10, - "d": "Once per EXP instuction." + "d": "Once per EXP instruction." }, "expByteGas": { "v": 10, @@ -25894,11 +25894,11 @@ }, "ommerReward": { "v": "625000000000000000", - "d": "The amount of wei a miner of an uncle block gets for being inculded in the blockchain" + "d": "The amount of wei a miner of an uncle block gets for being included in the blockchain" }, "niblingReward": { "v": "156250000000000000", - "d": "the amount a miner gets for inculding a uncle" + "d": "the amount a miner gets for including a uncle" }, "homeSteadForkNumber": { "v": 1150000, @@ -26526,7 +26526,7 @@ * var tx = new Transaction(rawTx); * * @class - * @param {Buffer | Array | Object} data a transaction can be initiailized with either a buffer containing the RLP serialized transaction or an array of buffers relating to each of the tx Properties, listed in order below in the exmple. + * @param {Buffer | Array | Object} data a transaction can be initiailized with either a buffer containing the RLP serialized transaction or an array of buffers relating to each of the tx Properties, listed in order below in the example. * * Or lastly an Object containing the Properties of the transaction like in the Usage example. * @@ -26643,7 +26643,7 @@ /** * Computes a sha3-256 hash of the serialized tx - * @param {Boolean} [includeSignature=true] whether or not to inculde the signature + * @param {Boolean} [includeSignature=true] whether or not to include the signature * @return {Buffer} */ @@ -27509,7 +27509,7 @@ } }); - // if the constuctor is passed data + // if the constructor is passed data if (data) { if (typeof data === 'string') { data = Buffer.from(exports.stripHexPrefix(data), 'hex'); @@ -28338,7 +28338,7 @@ else if (c === ')') { depth--; if (depth === -1) { - throw new Error('unbalanced parenthsis'); + throw new Error('unbalanced parenthesis'); } } } @@ -28613,7 +28613,7 @@ * BigNumber * * A wrapper around the BN.js object. We use the BN.js library - * because it is used by elliptic, so it is required regardles. + * because it is used by elliptic, so it is required regardless. * */ var bn_js_1 = __importDefault(require("bn.js")); @@ -28826,7 +28826,7 @@ if (typeof (value) === 'string') { var match = value.match(/^(0x)?[0-9a-fA-F]*$/); if (!match) { - errors.throwError('invalid hexidecimal string', errors.INVALID_ARGUMENT, { arg: 'value', value: value }); + errors.throwError('invalid hexadecimal string', errors.INVALID_ARGUMENT, { arg: 'value', value: value }); } if (match[1] !== '0x') { errors.throwError('hex string must have 0x prefix', errors.INVALID_ARGUMENT, { arg: 'value', value: value }); @@ -28929,7 +28929,7 @@ if (typeof (value) === 'string') { var match = value.match(/^(0x)?[0-9a-fA-F]*$/); if (!match) { - errors.throwError('invalid hexidecimal string', errors.INVALID_ARGUMENT, { arg: 'value', value: value }); + errors.throwError('invalid hexadecimal string', errors.INVALID_ARGUMENT, { arg: 'value', value: value }); } if (match[1] !== '0x') { errors.throwError('hex string must have 0x prefix', errors.INVALID_ARGUMENT, { arg: 'value', value: value }); @@ -29311,7 +29311,7 @@ else if (data[offset] >= 0x80) { var length = data[offset] - 0x80; if (offset + 1 + length > data.length) { - throw new Error('invlaid rlp data'); + throw new Error('invalid rlp data'); } var result = bytes_1.hexlify(data.slice(offset + 1, offset + 1 + length)); return { consumed: (1 + length), result: result }; @@ -33460,7 +33460,7 @@ * Register a new EventListener for the given event. * * @param {String} event Name of the event. - * @param {Functon} fn Callback function. + * @param {Function} fn Callback function. * @param {Mixed} context The context of the function. * @api public */ @@ -36311,7 +36311,7 @@ throw new Error("Failed to validate " + label); // 4. The label must not contain a U+002E ( . ) FULL STOP. - // this should nerver happen as label is chunked internally by this character + // this should never happen as label is chunked internally by this character /* istanbul ignore if */ if (label.includes('.')) throw new Error("Failed to validate " + label); @@ -37409,7 +37409,7 @@ case 'shake128': return new Shake(1344, 256, 0x1f, options) case 'shake256': return new Shake(1088, 512, 0x1f, options) - default: throw new Error('Invald algorithm: ' + algorithm) + default: throw new Error('Invalid algorithm: ' + algorithm) } } } @@ -42912,7 +42912,7 @@ var cachedSetTimeout; var cachedClearTimeout; - function defaultSetTimout() { + function defaultSetTimeout() { throw new Error('setTimeout has not been defined'); } function defaultClearTimeout () { @@ -42923,10 +42923,10 @@ if (typeof setTimeout === 'function') { cachedSetTimeout = setTimeout; } else { - cachedSetTimeout = defaultSetTimout; + cachedSetTimeout = defaultSetTimeout; } } catch (e) { - cachedSetTimeout = defaultSetTimout; + cachedSetTimeout = defaultSetTimeout; } try { if (typeof clearTimeout === 'function') { @@ -42940,23 +42940,23 @@ } ()) function runTimeout(fun) { if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations + //normal environments in sane situations return setTimeout(fun, 0); } // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + if ((cachedSetTimeout === defaultSetTimeout || !cachedSetTimeout) && setTimeout) { cachedSetTimeout = setTimeout; return setTimeout(fun, 0); } try { - // when when somebody has screwed with setTimeout but no I.E. maddness + // when when somebody has screwed with setTimeout but no I.E. madness return cachedSetTimeout(fun, 0); } catch(e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedSetTimeout.call(null, fun, 0); } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + // same as above but when it's a version of I.E. that must have the global object for 'this', hopefully our context correct otherwise it will throw a global error return cachedSetTimeout.call(this, fun, 0); } } @@ -42965,7 +42965,7 @@ } function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations + //normal environments in sane situations return clearTimeout(marker); } // if clearTimeout wasn't available but was latter defined @@ -42974,14 +42974,14 @@ return clearTimeout(marker); } try { - // when when somebody has screwed with setTimeout but no I.E. maddness + // when when somebody has screwed with setTimeout but no I.E. madness return cachedClearTimeout(marker); } catch (e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedClearTimeout.call(null, marker); } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // same as above but when it's a version of I.E. that must have the global object for 'this', hopefully our context correct otherwise it will throw a global error. // Some versions of I.E. have different rules for clearTimeout vs setTimeout return cachedClearTimeout.call(this, marker); } @@ -43047,7 +43047,7 @@ } }; - // v8 likes predictible objects + // v8 likes predictable objects function Item(fun, array) { this.fun = fun; this.array = array; @@ -47142,7 +47142,7 @@ /** * RLP Decoding based on: {@link https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-RLP|RLP} * @param {Buffer,String,Integer,Array} data - will be converted to buffer - * @returns {Array} - returns decode Array of Buffers containg the original message + * @returns {Array} - returns decode Array of Buffers containing the original message **/ exports.decode = function (input, stream) { if (!input || input.length === 0) { @@ -47460,7 +47460,7 @@ try { ReflectApply(handler, context, args) } catch (err) { - // throw error after timeout so as not to interupt the stack + // throw error after timeout so as not to interrupt the stack setTimeout(() => { throw err }) @@ -48037,7 +48037,7 @@ B32[i] |= (B[i * 4 + 1] & 0xff) << 8 B32[i] |= (B[i * 4 + 2] & 0xff) << 16 B32[i] |= (B[i * 4 + 3] & 0xff) << 24 - // B32[i] = B.readUInt32LE(i*4) <--- this is signficantly slower even in Node.js + // B32[i] = B.readUInt32LE(i*4) <--- this is significantly slower even in Node.js } arraycopy(B32, 0, x, 0, 16) @@ -48085,7 +48085,7 @@ B[bi + 1] = (B32[i] >> 8 & 0xff) B[bi + 2] = (B32[i] >> 16 & 0xff) B[bi + 3] = (B32[i] >> 24 & 0xff) - // B.writeInt32LE(B32[i], i*4) //<--- this is signficantly slower even in Node.js + // B.writeInt32LE(B32[i], i*4) //<--- this is significantly slower even in Node.js } } @@ -49728,18 +49728,18 @@ var Wi16l = W[i - 16 * 2 + 1] var Wil = (gamma0l + Wi7l) | 0 - var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0 + var With = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0 Wil = (Wil + gamma1l) | 0 - Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0 + With = (With + gamma1 + getCarry(Wil, gamma1l)) | 0 Wil = (Wil + Wi16l) | 0 - Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0 + With = (With + Wi16h + getCarry(Wil, Wi16l)) | 0 - W[i] = Wih + W[i] = With W[i + 1] = Wil } for (var j = 0; j < 160; j += 2) { - Wih = W[j] + With = W[j] Wil = W[j + 1] var majh = maj(ah, bh, ch) @@ -49764,7 +49764,7 @@ t1l = (t1l + Kil) | 0 t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0 t1l = (t1l + Wil) | 0 - t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0 + t1h = (t1h + With + getCarry(t1l, Wil)) | 0 // t2 = sigma0 + maj var t2l = (sigma0l + majl) | 0 @@ -50438,7 +50438,7 @@ 'host', 'keep-alive', 'origin', - 'referer', + 'referrer', 'te', 'trailer', 'transfer-encoding', @@ -51250,20 +51250,20 @@ return function (hash) { return downloadEntries(swarmUrl)(hash).then(function (entries) { var paths = Object.keys(entries); - var hashs = paths.map(function (path) { + var hashes = paths.map(function (path) { return entries[path].hash; }); var types = paths.map(function (path) { return entries[path].type; }); - var datas = hashs.map(downloadData(swarmUrl)); - var files = function files(datas) { - return datas.map(function (data, i) { + var data = hashes.map(downloadData(swarmUrl)); + var files = function files(data) { + return data.map(function (data, i) { return { type: types[i], data: data }; }); }; - return Promise.all(datas).then(function (datas) { - return toMap(paths)(files(datas)); + return Promise.all(data).then(function (data) { + return toMap(paths)(files(data)); }); }); }; @@ -51394,14 +51394,14 @@ return files.directoryTree(dirPath).then(function (fullPaths) { return Promise.all(fullPaths.map(function (path) { return fsp.readFile(path); - })).then(function (datas) { + })).then(function (data) { var paths = fullPaths.map(function (path) { return path.slice(dirPath.length); }); var types = fullPaths.map(function (path) { return mimetype.lookup(path) || "text/plain"; }); - return toMap(paths)(datas.map(function (data, i) { + return toMap(paths)(data.map(function (data, i) { return { type: types[i], data: data }; })); }); @@ -51605,7 +51605,7 @@ // String ~> Promise Bool // Returns true if Swarm is available on `url`. - // Perfoms a test upload to determine that. + // Performs a test upload to determine that. // TODO: improve this? var _isAvailable = function _isAvailable(swarmUrl) { var testFile = "test"; @@ -53211,7 +53211,7 @@ source += "';\n" + evaluate + "\n__p+='"; } - // Adobe VMs need the match returned to produce the correct offest. + // Adobe VMs need the match returned to produce the correct offset. return match; }); source += "';\n"; @@ -54544,7 +54544,7 @@ /** - * Echos the value of a value. Trys to print the value out + * Echos the value of a value. Tries to print the value out * in the best way possible given the different types. * * @param {Object} obj The object to print out. @@ -55703,7 +55703,7 @@ } else if (utils.isAddress(address)) { return '0x' + address.toLowerCase().replace('0x',''); } - throw new Error('Provided address "'+ address +'" is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can\'t be converted.'); + throw new Error('Provided address "'+ address +'" is invalid, the capitalization checksum test failed, or its an indirect IBAN address which can\'t be converted.'); }; @@ -56100,7 +56100,7 @@ defer.resolve(receipt); } - // need to remove listeners, as they aren't removed automatically when succesfull + // need to remove listeners, as they aren't removed automatically when successful if (canUnsubscribe) { defer.eventEmitter.removeAllListeners(); } @@ -56129,7 +56129,7 @@ defer.eventEmitter.emit('receipt', receipt); defer.resolve(receipt); - // need to remove listeners, as they aren't removed automatically when succesfull + // need to remove listeners, as they aren't removed automatically when successful if (canUnsubscribe) { defer.eventEmitter.removeAllListeners(); } @@ -56496,7 +56496,7 @@ * Should be called to add create new request to batch request * * @method add - * @param {Object} jsonrpc requet object + * @param {Object} jsonrpc request object */ Batch.prototype.add = function (request) { this.requests.push(request); @@ -58335,7 +58335,7 @@ // sets _requestmanager core.packageInit(this, arguments); - // remove unecessary core functions + // remove unnecessary core functions delete this.BatchRequest; delete this.extend; @@ -59431,7 +59431,7 @@ params: 1, inputFormatter: [formatters.inputLogFormatter], outputFormatter: this._decodeEventABI.bind(subOptions.event), - // DUBLICATE, also in web3-eth + // DUPLICATE, also in web3-eth subscriptionHandler: function (output) { if(output.removed) { this.emit('changed', output); @@ -59731,7 +59731,7 @@ /** * @file ENS.js * - * @author Samuel Furter + * @author Samuel Further * @date 2018 */ @@ -59935,7 +59935,7 @@ /** * @file Registry.js * - * @author Samuel Furter + * @author Samuel Further * @date 2018 */ @@ -60037,7 +60037,7 @@ /** * @file index.js * - * @author Samuel Furter + * @author Samuel Further * @date 2018 */ @@ -60064,7 +60064,7 @@ /** * @file ResolverMethodHandler.js * - * @author Samuel Furter + * @author Samuel Further * @date 2018 */ @@ -61697,7 +61697,7 @@ params: 1, inputFormatter: [formatter.inputLogFormatter], outputFormatter: formatter.outputLogFormatter, - // DUBLICATE, also in web3-eth-contract + // DUPLICATE, also in web3-eth-contract subscriptionHandler: function (output) { if(output.removed) { this.emit('changed', output); @@ -62419,7 +62419,7 @@ BlockCacheStrategy.prototype.getBlockCacheForPayload = function(payload, blockNumberHex) { const blockNumber = Number.parseInt(blockNumberHex, 16) let blockCache = this.cache[blockNumber] - // create new cache if necesary + // create new cache if necessary if (!blockCache) { const newCache = {} this.cache[blockNumber] = newCache @@ -62688,7 +62688,7 @@ self.pendingBlockTimeout = opts.pendingBlockTimeout || 4000 self.checkForPendingBlocksActive = false - // we dont have engine immeditately + // we dont have engine immediately setTimeout(function(){ // asyncBlockHandlers require locking provider until updates are completed self.engine.on('block', function(block){ @@ -65518,7 +65518,7 @@ Subscribes to provider events.provider @method on - @param {String} type 'notifcation', 'connect', 'error', 'end' or 'data' + @param {String} type 'notification', 'connect', 'error', 'end' or 'data' @param {Function} callback the callback to call */ WebsocketProvider.prototype.on = function (type, callback) { @@ -65555,7 +65555,7 @@ Removes event listener @method removeListener - @param {String} type 'notifcation', 'connect', 'error', 'end' or 'data' + @param {String} type 'notification', 'connect', 'error', 'end' or 'data' @param {Function} callback the callback to call */ WebsocketProvider.prototype.removeListener = function (type, callback) { @@ -65581,7 +65581,7 @@ Removes all event listeners @method removeAllListeners - @param {String} type 'notifcation', 'connect', 'error', 'end' or 'data' + @param {String} type 'notification', 'connect', 'error', 'end' or 'data' */ WebsocketProvider.prototype.removeAllListeners = function (type) { switch(type){ @@ -67433,7 +67433,7 @@ } function getBody() { - // Chrome with requestType=blob throws errors arround when even testing access to responseText + // Chrome with requestType=blob throws errors around when even testing access to responseText var body = undefined if (xhr.response) { @@ -67885,7 +67885,7 @@ host: true, 'keep-alive': true, origin: true, - referer: true, + referrer: true, te: true, trailer: true, 'transfer-encoding': true, @@ -68062,7 +68062,7 @@ } }; XMLHttpRequest.prototype._finalizeHeaders = function () { - this._headers = __assign({}, this._headers, { Connection: 'keep-alive', Host: this._url.host, 'User-Agent': this._userAgent }, this._anonymous ? { Referer: 'about:blank' } : {}); + this._headers = __assign({}, this._headers, { Connection: 'keep-alive', Host: this._url.host, 'User-Agent': this._userAgent }, this._anonymous ? { Referrer: 'about:blank' } : {}); this.upload._finalizeHeaders(this._headers, this._loweredHeaders); }; XMLHttpRequest.prototype._onHttpResponse = function (request, response) { diff --git a/Sources/web3swift/Browser/browser.min.js b/Sources/web3swift/Browser/browser.min.js index f838d4a4b..6d75533da 100644 --- a/Sources/web3swift/Browser/browser.min.js +++ b/Sources/web3swift/Browser/browser.min.js @@ -1,2 +1,2 @@ -!function(){return function e(t,r,n){function i(a,s){if(!r[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var f=r[a]={exports:{}};t[a][0].call(f.exports,function(e){var r=t[a][1][e];return i(r||e)},f,f.exports,e,t,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a0&&(window.web3.eth.defaultAccount=t[0])})}window.ethereum=s}}},console.log("JS bridging rpc url access"),"undefined"!=typeof window&&window.bridge?window.bridge.post("getRPCurl",{},function(e,r){r&&t(r.description,null),t(null,e.rpcURL)}):(console.log("No bridge to native code is found"),t(!0,null))}()},{"./wk.bridge":424,web3:407,"web3-provider-engine/zero.js":397}],2:[function(e,t,r){t.exports=e("./register")().Promise},{"./register":4}],3:[function(e,t,r){"use strict";var n=null;t.exports=function(e,t){return function(r,i){r=r||null;var o=!1!==(i=i||{}).global;if(null===n&&o&&(n=e["@@any-promise/REGISTRATION"]||null),null!==n&&null!==r&&n.implementation!==r)throw new Error('any-promise already defined as "'+n.implementation+'". You can only register an implementation before the first call to require("any-promise") and an implementation cannot be changed');return null===n&&(n=null!==r&&void 0!==i.Promise?{Promise:i.Promise,implementation:r}:t(r),o&&(e["@@any-promise/REGISTRATION"]=n)),n}}},{}],4:[function(e,t,r){"use strict";t.exports=e("./loader")(window,function(){if(void 0===window.Promise)throw new Error("any-promise browser requires a polyfill or explicit registration e.g: require('any-promise/register/bluebird')");return{Promise:window.Promise,implementation:"window.Promise"}})},{"./loader":3}],5:[function(e,t,r){var n=r;n.bignum=e("bn.js"),n.define=e("./asn1/api").define,n.base=e("./asn1/base"),n.constants=e("./asn1/constants"),n.decoders=e("./asn1/decoders"),n.encoders=e("./asn1/encoders")},{"./asn1/api":6,"./asn1/base":8,"./asn1/constants":12,"./asn1/decoders":14,"./asn1/encoders":17,"bn.js":53}],6:[function(e,t,r){var n=e("../asn1"),i=e("inherits");function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}r.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(t){var r;try{r=e("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){r=function(e){this._initNamed(e)}}return i(r,t),r.prototype._initNamed=function(e){t.call(this,e)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(n.decoders[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(n.encoders[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},{"../asn1":5,inherits:180,vm:334}],7:[function(e,t,r){var n=e("inherits"),i=e("../base").Reporter,o=e("buffer").Buffer;function a(e,t){i.call(this,t),o.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function s(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return e instanceof s||(e=new s(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=o.byteLength(e);else{if(!o.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}n(a,i),r.DecoderBuffer=a,a.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},a.prototype.restore=function(e){var t=new a(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,i.prototype.restore.call(this,e.reporter),t},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},a.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new a(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},a.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},r.EncoderBuffer=s,s.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length?e:(Array.isArray(this.value)?this.value.forEach(function(r){r.join(e,t),t+=r.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):o.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},{"../base":8,buffer:84,inherits:180}],8:[function(e,t,r){var n=r;n.Reporter=e("./reporter").Reporter,n.DecoderBuffer=e("./buffer").DecoderBuffer,n.EncoderBuffer=e("./buffer").EncoderBuffer,n.Node=e("./node")},{"./buffer":7,"./node":9,"./reporter":10}],9:[function(e,t,r){var n=e("../base").Reporter,i=e("../base").EncoderBuffer,o=e("../base").DecoderBuffer,a=e("minimalistic-assert"),s=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],u=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function c(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}t.exports=c;var f=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){var e=this._baseState,t={};f.forEach(function(r){t[r]=e[r]});var r=new this.constructor(t.parent);return r._baseState=t,r},c.prototype._wrap=function(){var e=this._baseState;u.forEach(function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}},this)},c.prototype._init=function(e){var t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter(function(e){return e._baseState.parent===this},this),a.equal(t.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(e){var t=this._baseState,r=e.filter(function(e){return e instanceof this.constructor},this);e=e.filter(function(e){return!(e instanceof this.constructor)},this),0!==r.length&&(a(null===t.children),t.children=r,r.forEach(function(e){e._baseState.parent=this},this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map(function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach(function(r){r==(0|r)&&(r|=0);var n=e[r];t[n]=r}),t}))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(e){c.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}}),s.forEach(function(e){c.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(r),this}}),c.prototype.use=function(e){a(e);var t=this._baseState;return a(null===t.use),t.use=e,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(e){var t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},c.prototype.explicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},c.prototype.implicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},c.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},c.prototype.key=function(e){var t=this._baseState;return a(null===t.key),t.key=e,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(e){var t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map(function(t){return e[t]})),this},c.prototype.contains=function(e){var t=this._baseState;return a(null===t.use),t.contains=e,this},c.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var n,i=r.default,a=!0,s=null;if(null!==r.key&&(s=e.enterKey(r.key)),r.optional){var u=null;if(null!==r.explicit?u=r.explicit:null!==r.implicit?u=r.implicit:null!==r.tag&&(u=r.tag),null!==u||r.any){if(a=this._peekTag(e,u,r.any),e.isError(a))return a}else{var c=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(c)}}if(r.obj&&a&&(n=e.enterObject()),a){if(null!==r.explicit){var f=this._decodeTag(e,r.explicit);if(e.isError(f))return f;e=f}var h=e.offset;if(null===r.use&&null===r.choice){if(r.any)c=e.save();var l=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(l))return l;r.any?i=e.raw(c):e=l}if(t&&t.track&&null!==r.tag&&t.track(e.path(),h,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),i=r.any?i:null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),e.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach(function(r){r._decode(e,t)}),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var d=new o(i);i=this._getUse(r.contains,e._reporterState.obj)._decode(d,t)}}return r.obj&&a&&(i=e.leaveObject(n)),null===r.key||null===i&&!0!==a?null!==s&&e.exitKey(s):e.leaveKey(s,r.key,i),i},c.prototype._decodeGeneric=function(e,t,r){var n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},c.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},c.prototype._decodeChoice=function(e,t){var r=this._baseState,n=null,i=!1;return Object.keys(r.choice).some(function(o){var a=e.save(),s=r.choice[o];try{var u=s._decode(e,t);if(e.isError(u))return!1;n={type:o,value:u},i=!0}catch(t){return e.restore(a),!1}return!0},this),i?n:e.error("Choice not matched")},c.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},c.prototype._encode=function(e,t,r){var n=this._baseState;if(null===n.default||n.default!==e){var i=this._encodeValue(e,t,r);if(void 0!==i&&!this._skipDefault(i,t,r))return i}},c.prototype._encodeValue=function(e,t,r){var i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);var o=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}var a=null,s=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)a=this._getUse(i.contains,r)._encode(e,t),s=!0;else if(i.children)a=i.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i},this).filter(function(e){return e}),a=this._createEncoderBuffer(a);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var u=this.clone();u._baseState.implicit=null,a=this._createEncoderBuffer(e.map(function(r){var n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)},u))}else null!==i.use?o=this._getUse(i.use,r)._encode(e,t):(a=this._encodePrimitive(i.tag,e),s=!0);if(!i.any&&null===i.choice){var c=null!==i.implicit?i.implicit:i.tag,f=null===i.implicit?"universal":"context";null===c?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(c,s,f,a))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},c.prototype._encodeChoice=function(e,t){var r=this._baseState,n=r.choice[e.type];return n||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},c.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},c.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},c.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},{"../base":8,"minimalistic-assert":234}],10:[function(e,t,r){var n=e("inherits");function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}r.Reporter=i,i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,r){var n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){var t,r=this._reporterState,n=e instanceof o;if(t=n?e:new o(r.path.map(function(e){return"["+JSON.stringify(e)+"]"}).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},i.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},n(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{inherits:180}],11:[function(e,t,r){var n=e("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=n._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=n._reverse(r.tag)},{"../constants":12}],12:[function(e,t,r){var n=r;n._reverse=function(e){var t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r|=0);var n=e[r];t[n]=r}),t},n.der=e("./der")},{"./der":11}],13:[function(e,t,r){var n=e("inherits"),i=e("../../asn1"),o=i.base,a=i.bignum,s=i.constants.der;function u(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){o.Node.call(this,"der",e)}function f(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var n=s.tagClass[r>>6],i=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:s.tag[r]}}function h(e,t,r){var n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;var i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(var o=0;o=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=s.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(n.length<128)return(o=new i(2))[0]=a,o[1]=n.length,this._createEncoderBuffer([o,n]);for(var u=1,c=n.length;c>=256;c>>=8)u++;(o=new i(2+u))[0]=a,o[1]=128|u;c=1+u;for(var f=n.length;f>0;c--,f>>=8)o[c]=255&f;return this._createEncoderBuffer([o,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new i(2*e.length),n=0;n=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var o=0;for(n=0;n=128;a>>=7)o++}var s=new i(o),u=s.length-1;for(n=e.length-1;n>=0;n--){a=e[n];for(s[u--]=127&a;(a>>=7)>0;)s[u--]=128|127&a}return this._createEncoderBuffer(s)},c.prototype._encodeTime=function(e,t){var r,n=new Date(e);return"gentime"===t?r=[f(n.getFullYear()),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[f(n.getFullYear()%100),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!i.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new i(r)}if(i.isBuffer(e)){var n=e.length;0===e.length&&n++;var o=new i(n);return e.copy(o),0===e.length&&(o[0]=0),this._createEncoderBuffer(o)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);n=1;for(var a=e;a>=256;a>>=8)n++;for(a=(o=new Array(n)).length-1;a>=0;a--)o[a]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new i(o))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){var n,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,r).join()),o.length!==i.defaultBuffer.length)return!1;for(n=0;n=0;c--)if(f[c]!==h[c])return!1;for(c=f.length-1;c>=0;c--)if(u=f[c],!v(e[u],t[u],r,n))return!1;return!0}(e,t,r,a))}return r?e===t:e==t}function g(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function w(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function _(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&y(i,r,"Missing expected exception"+n);var a="string"==typeof n,s=!e&&i&&!r;if((!e&&o.isError(i)&&a&&w(i,r)||s)&&y(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(i,r)||!e&&i)throw i}h.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=p(b((t=this).actual),128)+" "+t.operator+" "+p(b(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=d(r),a=i.indexOf("\n"+o);if(a>=0){var s=i.indexOf("\n",a+1);i=i.substring(s+1)}this.stack=i}}},o.inherits(h.AssertionError,Error),h.fail=y,h.ok=m,h.equal=function(e,t,r){e!=t&&y(e,t,r,"==",h.equal)},h.notEqual=function(e,t,r){e==t&&y(e,t,r,"!=",h.notEqual)},h.deepEqual=function(e,t,r){v(e,t,!1)||y(e,t,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(e,t,r){v(e,t,!0)||y(e,t,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(e,t,r){v(e,t,!1)&&y(e,t,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function e(t,r,n){v(t,r,!0)&&y(t,r,n,"notDeepStrictEqual",e)},h.strictEqual=function(e,t,r){e!==t&&y(e,t,r,"===",h.strictEqual)},h.notStrictEqual=function(e,t,r){e===t&&y(e,t,r,"!==",h.notStrictEqual)},h.throws=function(e,t,r){_(!0,e,t,r)},h.doesNotThrow=function(e,t,r){_(!1,e,t,r)},h.ifError=function(e){if(e)throw e};var A=Object.keys||function(e){var t=[];for(var r in e)a.call(e,r)&&t.push(r);return t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":333}],20:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){return(0,i.default)(function(t,r){var i;try{i=e.apply(this,t)}catch(e){return r(e)}(0,n.default)(i)&&"function"==typeof i.then?i.then(function(e){s(r,null,e)},function(e){s(r,e.message?e:new Error(e))}):r(null,i)})};var n=a(e("lodash/isObject")),i=a(e("./internal/initialParams")),o=a(e("./internal/setImmediate"));function a(e){return e&&e.__esModule?e:{default:e}}function s(e,t,r){try{e(t,r)}catch(e){(0,o.default)(u,e)}}function u(e){throw e}t.exports=r.default},{"./internal/initialParams":31,"./internal/setImmediate":37,"lodash/isObject":225}],21:[function(e,t,r){(function(e,n){!function(e,n){"object"==typeof r&&void 0!==t?n(r):"function"==typeof define&&define.amd?define(["exports"],n):n(e.async=e.async||{})}(this,function(r){"use strict";function i(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i-1&&e%1==0&&e<=L}function D(e){return null!=e&&O(e.length)&&!function(e){if(!s(e))return!1;var t=B(e);return t==C||t==N||t==P||t==R}(e)}var F={};function q(){}function H(e){return function(){if(null!==e){var t=e;e=null,t.apply(this,arguments)}}}var z="function"==typeof Symbol&&Symbol.iterator,K=function(e){return z&&e[z]&&e[z]()};function V(e){return null!=e&&"object"==typeof e}var G="[object Arguments]";function W(e){return V(e)&&B(e)==G}var Y=Object.prototype,X=Y.hasOwnProperty,Z=Y.propertyIsEnumerable,J=W(function(){return arguments}())?W:function(e){return V(e)&&X.call(e,"callee")&&!Z.call(e,"callee")},$=Array.isArray;var Q="object"==typeof r&&r&&!r.nodeType&&r,ee=Q&&"object"==typeof t&&t&&!t.nodeType&&t,te=ee&&ee.exports===Q?A.Buffer:void 0,re=(te?te.isBuffer:void 0)||function(){return!1},ne=9007199254740991,ie=/^(?:0|[1-9]\d*)$/;function oe(e,t){return!!(t=null==t?ne:t)&&("number"==typeof e||ie.test(e))&&e>-1&&e%1==0&&e2&&(n=i(arguments,1)),t){var c={};Fe(o,function(e,t){c[t]=e}),c[e]=n,s=!0,u=Object.create(null),r(t,c)}else o[e]=n,Le(u[e]||[],function(e){e()}),d()});a++;var c=v(t[t.length-1]);t.length>1?c(o,n):c(n)}(e,t)})}function d(){if(0===c.length&&0===a)return r(null,o);for(;c.length&&a=0&&r.push(n)}),r}Fe(e,function(t,r){if(!$(t))return l(r,[t]),void f.push(r);var n=t.slice(0,t.length-1),i=n.length;if(0===i)return l(r,t),void f.push(r);h[r]=i,Le(n,function(o){if(!e[o])throw new Error("async.auto task `"+r+"` has a non-existent dependency `"+o+"` in "+n.join(", "));!function(e,t){var r=u[e];r||(r=u[e]=[]);r.push(t)}(o,function(){0===--i&&l(r,t)})})}),function(){var e,t=0;for(;f.length;)e=f.pop(),t++,Le(p(e),function(e){0==--h[e]&&f.push(e)});if(t!==n)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),d()};function Ke(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r=n?e:function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n-1;);return r}(i,o),function(e,t){for(var r=e.length;r--&&He(t,e[r],0)>-1;);return r}(i,o)+1).join("")}var ht=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,lt=/,/,dt=/(=.+)?(\s*)$/,pt=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;function bt(e,t){var r={};Fe(e,function(e,t){var n,i,o=m(e),a=!o&&1===e.length||o&&0===e.length;if($(e))n=e.slice(0,-1),e=e[e.length-1],r[t]=n.concat(n.length>0?s:e);else if(a)r[t]=e;else{if(n=i=(i=(i=(i=(i=e).toString().replace(pt,"")).match(ht)[2].replace(" ",""))?i.split(lt):[]).map(function(e){return ft(e.replace(dt,""))}),0===e.length&&!o&&0===n.length)throw new Error("autoInject task functions require explicit parameters.");o||n.pop(),r[t]=n.concat(s)}function s(t,r){var i=Ke(n,function(e){return t[e]});i.push(r),v(e).apply(null,i)}}),ze(r,t)}function yt(){this.head=this.tail=null,this.length=0}function mt(e,t){e.length=1,e.head=e.tail=t}function vt(e,t,r){if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var n=v(e),i=0,o=[],a=!1;function s(e,t,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(f.started=!0,$(e)||(e=[e]),0===e.length&&f.idle())return l(function(){f.drain()});for(var n=0,i=e.length;n0&&o.splice(s,1),a.callback.apply(a,arguments),null!=t&&f.error(t,a.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()}}var c=!1,f={_tasks:new yt,concurrency:t,payload:r,saturated:q,unsaturated:q,buffer:t/4,empty:q,drain:q,error:q,started:!1,paused:!1,push:function(e,t){s(e,!1,t)},kill:function(){f.drain=q,f._tasks.empty()},unshift:function(e,t){s(e,!0,t)},remove:function(e){f._tasks.remove(e)},process:function(){if(!c){for(c=!0;!f.paused&&i2&&(o=i(arguments,1)),n[t]=o,r(e)})},function(e){r(e,n)})}function br(e,t){pr(Ie,e,t)}function yr(e,t,r){pr(Ee(t),e,r)}var mr=function(e,t){var r=v(e);return vt(function(e,t){r(e[0],t)},t,1)},vr=function(e,t){var r=mr(e,t);return r.push=function(e,t,n){if(null==n&&(n=q),"function"!=typeof n)throw new Error("task callback must be a function");if(r.started=!0,$(e)||(e=[e]),0===e.length)return l(function(){r.drain()});t=t||0;for(var i=r._tasks.head;i&&t>=i.priority;)i=i.next;for(var o=0,a=e.length;on?1:0}je(e,function(e,t){n(e,function(r,n){if(r)return t(r);t(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);r(null,Ke(t.sort(i),Zt("value")))})}function Nr(e,t,r){var n=v(e);return a(function(i,o){var a,s=!1;i.push(function(){s||(o.apply(null,arguments),clearTimeout(a))}),a=setTimeout(function(){var t=e.name||"anonymous",n=new Error('Callback function "'+t+'" timed out.');n.code="ETIMEDOUT",r&&(n.info=r),s=!0,o(n)},t),n.apply(null,i)})}var Rr=Math.ceil,Lr=Math.max;function Or(e,t,r,n){var i=v(r);Ce(function(e,t,r,n){for(var i=-1,o=Lr(Rr((t-e)/(r||1)),0),a=Array(o);o--;)a[n?o:++i]=e,e+=r;return a}(0,e,1),t,i,n)}var Dr=ke(Or,1/0),Fr=ke(Or,1);function qr(e,t,r,n){arguments.length<=3&&(n=r,r=t,t=$(e)?[]:{}),n=H(n||q);var i=v(r);Ie(e,function(e,r,n){i(t,e,r,n)},function(e){n(e,t)})}function Hr(e,t){var r,n=null;t=t||q,Kt(e,function(e,t){v(e)(function(e,o){r=arguments.length>2?i(arguments,1):o,n=e,t(!e)})},function(){t(n,r)})}function zr(e){return function(){return(e.unmemoized||e).apply(null,arguments)}}function Kr(e,t,r){r=Ae(r||q);var n=v(t);if(!e())return r(null);var o=function(t){if(t)return r(t);if(e())return n(o);var a=i(arguments,1);r.apply(null,[null].concat(a))};n(o)}function Vr(e,t,r){Kr(function(){return!e.apply(this,arguments)},t,r)}var Gr=function(e,t){if(t=H(t||q),!$(e))return t(new Error("First argument to waterfall must be an array of functions"));if(!e.length)return t();var r=0;function n(t){var n=v(e[r++]);t.push(Ae(o)),n.apply(null,t)}function o(o){if(o||r===e.length)return t.apply(null,arguments);n(i(arguments,1))}n([])},Wr={apply:o,applyEach:Be,applyEachSeries:Re,asyncify:d,auto:ze,autoInject:bt,cargo:gt,compose:Et,concat:St,concatLimit:kt,concatSeries:Mt,constant:It,detect:Bt,detectLimit:Pt,detectSeries:Ct,dir:Rt,doDuring:Lt,doUntil:Dt,doWhilst:Ot,during:Ft,each:Ht,eachLimit:zt,eachOf:Ie,eachOfLimit:xe,eachOfSeries:wt,eachSeries:Kt,ensureAsync:Vt,every:Wt,everyLimit:Yt,everySeries:Xt,filter:er,filterLimit:tr,filterSeries:rr,forever:nr,groupBy:or,groupByLimit:ir,groupBySeries:ar,log:sr,map:je,mapLimit:Ce,mapSeries:Ne,mapValues:cr,mapValuesLimit:ur,mapValuesSeries:fr,memoize:lr,nextTick:dr,parallel:br,parallelLimit:yr,priorityQueue:vr,queue:mr,race:gr,reduce:_t,reduceRight:wr,reflect:_r,reflectAll:Ar,reject:xr,rejectLimit:kr,rejectSeries:Sr,retry:Ir,retryable:Tr,seq:At,series:Ur,setImmediate:l,some:jr,someLimit:Br,someSeries:Pr,sortBy:Cr,timeout:Nr,times:Dr,timesLimit:Or,timesSeries:Fr,transform:qr,tryEach:Hr,unmemoize:zr,until:Vr,waterfall:Gr,whilst:Kr,all:Wt,allLimit:Yt,allSeries:Xt,any:jr,anyLimit:Br,anySeries:Pr,find:Bt,findLimit:Pt,findSeries:Ct,forEach:Ht,forEachSeries:Kt,forEachLimit:zt,forEachOf:Ie,forEachOfSeries:wt,forEachOfLimit:xe,inject:_t,foldl:_t,foldr:wr,select:er,selectLimit:tr,selectSeries:rr,wrapSync:d};r.default=Wr,r.apply=o,r.applyEach=Be,r.applyEachSeries=Re,r.asyncify=d,r.auto=ze,r.autoInject=bt,r.cargo=gt,r.compose=Et,r.concat=St,r.concatLimit=kt,r.concatSeries=Mt,r.constant=It,r.detect=Bt,r.detectLimit=Pt,r.detectSeries=Ct,r.dir=Rt,r.doDuring=Lt,r.doUntil=Dt,r.doWhilst=Ot,r.during=Ft,r.each=Ht,r.eachLimit=zt,r.eachOf=Ie,r.eachOfLimit=xe,r.eachOfSeries=wt,r.eachSeries=Kt,r.ensureAsync=Vt,r.every=Wt,r.everyLimit=Yt,r.everySeries=Xt,r.filter=er,r.filterLimit=tr,r.filterSeries=rr,r.forever=nr,r.groupBy=or,r.groupByLimit=ir,r.groupBySeries=ar,r.log=sr,r.map=je,r.mapLimit=Ce,r.mapSeries=Ne,r.mapValues=cr,r.mapValuesLimit=ur,r.mapValuesSeries=fr,r.memoize=lr,r.nextTick=dr,r.parallel=br,r.parallelLimit=yr,r.priorityQueue=vr,r.queue=mr,r.race=gr,r.reduce=_t,r.reduceRight=wr,r.reflect=_r,r.reflectAll=Ar,r.reject=xr,r.rejectLimit=kr,r.rejectSeries=Sr,r.retry=Ir,r.retryable=Tr,r.seq=At,r.series=Ur,r.setImmediate=l,r.some=jr,r.someLimit=Br,r.someSeries=Pr,r.sortBy=Cr,r.timeout=Nr,r.times=Dr,r.timesLimit=Or,r.timesSeries=Fr,r.transform=qr,r.tryEach=Hr,r.unmemoize=zr,r.until=Vr,r.waterfall=Gr,r.whilst=Kr,r.all=Wt,r.allLimit=Yt,r.allSeries=Xt,r.any=jr,r.anyLimit=Br,r.anySeries=Pr,r.find=Bt,r.findLimit=Pt,r.findSeries=Ct,r.forEach=Ht,r.forEachSeries=Kt,r.forEachLimit=zt,r.forEachOf=Ie,r.forEachOfSeries=wt,r.forEachOfLimit=xe,r.inject=_t,r.foldl=_t,r.foldr=wr,r.select=er,r.selectLimit=tr,r.selectSeries=rr,r.wrapSync=d,Object.defineProperty(r,"__esModule",{value:!0})})}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257}],22:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r,a){(0,n.default)(t)(e,(0,i.default)((0,o.default)(r)),a)};var n=a(e("./internal/eachOfLimit")),i=a(e("./internal/withoutIndex")),o=a(e("./internal/wrapAsync"));function a(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./internal/eachOfLimit":29,"./internal/withoutIndex":39,"./internal/wrapAsync":40}],23:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r){((0,n.default)(e)?l:d)(e,(0,f.default)(t),r)};var n=h(e("lodash/isArrayLike")),i=h(e("./internal/breakLoop")),o=h(e("./eachOfLimit")),a=h(e("./internal/doLimit")),s=h(e("lodash/noop")),u=h(e("./internal/once")),c=h(e("./internal/onlyOnce")),f=h(e("./internal/wrapAsync"));function h(e){return e&&e.__esModule?e:{default:e}}function l(e,t,r){r=(0,u.default)(r||s.default);var n=0,o=0,a=e.length;function f(e,t){e?r(e):++o!==a&&t!==i.default||r(null)}for(0===a&&r(null);n2&&(n=(0,o.default)(arguments,1)),s[t]=n,r(e)})},function(e){r(e,s)})};var n=s(e("lodash/noop")),i=s(e("lodash/isArrayLike")),o=s(e("./slice")),a=s(e("./wrapAsync"));function s(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./slice":38,"./wrapAsync":40,"lodash/isArrayLike":221,"lodash/noop":229}],37:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.hasNextTick=r.hasSetImmediate=void 0,r.fallback=c,r.wrap=f;var n,i=e("./slice"),o=(n=i)&&n.__esModule?n:{default:n};var a,s=r.hasSetImmediate="function"==typeof setImmediate&&setImmediate,u=r.hasNextTick="object"==typeof t&&"function"==typeof t.nextTick;function c(e){setTimeout(e,0)}function f(e){return function(t){var r=(0,o.default)(arguments,1);e(function(){t.apply(null,r)})}}a=s?setImmediate:u?t.nextTick:c,r.default=f(a)}).call(this,e("_process"))},{"./slice":38,_process:257}],38:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i0,"Expected a maximum number of retry greater than 0 but got %s.",e),this.maxNumberOfRetry_=e},o.prototype.backoff=function(e){i.checkState(-1===this.timeoutID_,"Backoff in progress."),this.backoffNumber_===this.maxNumberOfRetry_?(this.emit("fail",e),this.reset()):(this.backoffDelay_=this.backoffStrategy_.next(),this.timeoutID_=setTimeout(this.handlers.backoff,this.backoffDelay_),this.emit("backoff",this.backoffNumber_,this.backoffDelay_,e))},o.prototype.onBackoff_=function(){this.timeoutID_=-1,this.emit("ready",this.backoffNumber_,this.backoffDelay_),this.backoffNumber_++},o.prototype.reset=function(){this.backoffNumber_=0,this.backoffStrategy_.reset(),clearTimeout(this.timeoutID_),this.timeoutID_=-1},t.exports=o},{events:157,precond:253,util:333}],47:[function(e,t,r){var n=e("events"),i=e("precond"),o=e("util"),a=e("./backoff"),s=e("./strategy/fibonacci");function u(e,t,r){n.EventEmitter.call(this),i.checkIsFunction(e,"Expected fn to be a function."),i.checkIsArray(t,"Expected args to be an array."),i.checkIsFunction(r,"Expected callback to be a function."),this.function_=e,this.arguments_=t,this.callback_=r,this.lastResult_=[],this.numRetries_=0,this.backoff_=null,this.strategy_=null,this.failAfter_=-1,this.retryPredicate_=u.DEFAULT_RETRY_PREDICATE_,this.state_=u.State_.PENDING}o.inherits(u,n.EventEmitter),u.State_={PENDING:0,RUNNING:1,COMPLETED:2,ABORTED:3},u.DEFAULT_RETRY_PREDICATE_=function(e){return!0},u.prototype.isPending=function(){return this.state_==u.State_.PENDING},u.prototype.isRunning=function(){return this.state_==u.State_.RUNNING},u.prototype.isCompleted=function(){return this.state_==u.State_.COMPLETED},u.prototype.isAborted=function(){return this.state_==u.State_.ABORTED},u.prototype.setStrategy=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.strategy_=e,this},u.prototype.retryIf=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.retryPredicate_=e,this},u.prototype.getLastResult=function(){return this.lastResult_.concat()},u.prototype.getNumRetries=function(){return this.numRetries_},u.prototype.failAfter=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.failAfter_=e,this},u.prototype.abort=function(){this.isCompleted()||this.isAborted()||(this.isRunning()&&this.backoff_.reset(),this.state_=u.State_.ABORTED,this.lastResult_=[new Error("Backoff aborted.")],this.emit("abort"),this.doCallback_())},u.prototype.start=function(e){i.checkState(!this.isAborted(),"FunctionCall is aborted."),i.checkState(this.isPending(),"FunctionCall already started.");var t=this.strategy_||new s;this.backoff_=e?e(t):new a(t),this.backoff_.on("ready",this.doCall_.bind(this,!0)),this.backoff_.on("fail",this.doCallback_.bind(this)),this.backoff_.on("backoff",this.handleBackoff_.bind(this)),this.failAfter_>0&&this.backoff_.failAfter(this.failAfter_),this.state_=u.State_.RUNNING,this.doCall_(!1)},u.prototype.doCall_=function(e){e&&this.numRetries_++;var t=["call"].concat(this.arguments_);n.EventEmitter.prototype.emit.apply(this,t);var r=this.handleFunctionCallback_.bind(this);this.function_.apply(null,this.arguments_.concat(r))},u.prototype.doCallback_=function(){this.callback_.apply(null,this.lastResult_)},u.prototype.handleFunctionCallback_=function(){if(!this.isAborted()){var e=Array.prototype.slice.call(arguments);this.lastResult_=e,n.EventEmitter.prototype.emit.apply(this,["callback"].concat(e));var t=e[0];t&&this.retryPredicate_(t)?this.backoff_.backoff(t):(this.state_=u.State_.COMPLETED,this.doCallback_())}},u.prototype.handleBackoff_=function(e,t,r){this.emit("backoff",e,t,r)},t.exports=u},{"./backoff":46,"./strategy/fibonacci":49,events:157,precond:253,util:333}],48:[function(e,t,r){var n=e("util"),i=e("precond"),o=e("./strategy");function a(e){o.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay(),this.factor_=a.DEFAULT_FACTOR,e&&void 0!==e.factor&&(i.checkArgument(e.factor>1,"Exponential factor should be greater than 1 but got %s.",e.factor),this.factor_=e.factor)}n.inherits(a,o),a.DEFAULT_FACTOR=2,a.prototype.next_=function(){return this.backoffDelay_=Math.min(this.nextBackoffDelay_,this.getMaxDelay()),this.nextBackoffDelay_=this.backoffDelay_*this.factor_,this.backoffDelay_},a.prototype.reset_=function(){this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()},t.exports=a},{"./strategy":50,precond:253,util:333}],49:[function(e,t,r){var n=e("util"),i=e("./strategy");function o(e){i.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}n.inherits(o,i),o.prototype.next_=function(){var e=Math.min(this.nextBackoffDelay_,this.getMaxDelay());return this.nextBackoffDelay_+=this.backoffDelay_,this.backoffDelay_=e,e},o.prototype.reset_=function(){this.nextBackoffDelay_=this.getInitialDelay(),this.backoffDelay_=0},t.exports=o},{"./strategy":50,util:333}],50:[function(e,t,r){e("events"),e("util");function n(e){return null!=e}function i(e){if(n((e=e||{}).initialDelay)&&e.initialDelay<1)throw new Error("The initial timeout must be greater than 0.");if(n(e.maxDelay)&&e.maxDelay<1)throw new Error("The maximal timeout must be greater than 0.");if(this.initialDelay_=e.initialDelay||100,this.maxDelay_=e.maxDelay||1e4,this.maxDelay_<=this.initialDelay_)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");if(n(e.randomisationFactor)&&(e.randomisationFactor<0||e.randomisationFactor>1))throw new Error("The randomisation factor must be between 0 and 1.");this.randomisationFactor_=e.randomisationFactor||0}i.prototype.getMaxDelay=function(){return this.maxDelay_},i.prototype.getInitialDelay=function(){return this.initialDelay_},i.prototype.next=function(){var e=this.next_(),t=1+Math.random()*this.randomisationFactor_;return Math.round(e*t)},i.prototype.next_=function(){throw new Error("BackoffStrategy.next_() unimplemented.")},i.prototype.reset=function(){this.reset_()},i.prototype.reset_=function(){throw new Error("BackoffStrategy.reset_() unimplemented.")},t.exports=i},{events:157,util:333}],51:[function(e,t,r){"use strict";r.byteLength=function(e){return 3*e.length/4-c(e)},r.toByteArray=function(e){var t,r,n,a,s,u=e.length;a=c(e),s=new o(3*u/4-a),r=a>0?u-4:u;var f=0;for(t=0;t>16&255,s[f++]=n>>8&255,s[f++]=255&n;2===a?(n=i[e.charCodeAt(t)]<<2|i[e.charCodeAt(t+1)]>>4,s[f++]=255&n):1===a&&(n=i[e.charCodeAt(t)]<<10|i[e.charCodeAt(t+1)]<<4|i[e.charCodeAt(t+2)]>>2,s[f++]=n>>8&255,s[f++]=255&n);return s},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o="",a=[],s=0,u=r-i;su?u:s+16383));1===i?(t=e[r-1],o+=n[t>>2],o+=n[t<<4&63],o+="=="):2===i&&(t=(e[r-2]<<8)+e[r-1],o+=n[t>>10],o+=n[t>>4&63],o+=n[t<<2&63],o+="=");return a.push(o),a.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function f(e,t,r){for(var i,o,a=[],s=t;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],52:[function(e,t,r){var n=e("safe-buffer").Buffer;t.exports={check:function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))},decode:function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");var r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},encode:function(e,t){var r=e.length,i=t.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(i>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+r]=2,o[5+r]=t.length,t.copy(o,6+r),o}}},{"safe-buffer":290}],53:[function(e,t,r){!function(t,r){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var a;"object"==typeof t?t.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{a=e("buffer").Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:55}],54:[function(e,t,r){var n;function i(e){this.rand=e}if(t.exports=function(e){return n||(n=new i(null)),n.generate(e)},t.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^t[m++],a=c[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^t[m++],s=c[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^t[m++],u=c[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^t[m++],d=o,p=a,b=s,y=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^t[m++],a=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^t[m++],s=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[m++],u=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^t[m++],[o>>>=0,a>>>=0,s>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],u=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,u=0;u<256;++u){var c=s^s<<1^s<<2^s<<3^s<<4;c=c>>>8^255&c^99,r[a]=c,n[c]=a;var f=e[a],h=e[f],l=e[h],d=257*e[c]^16843008*c;i[0][a]=d<<24|d>>>8,i[1][a]=d<<16|d>>>16,i[2][a]=d<<8|d>>>24,i[3][a]=d,d=16843009*l^65537*h^257*f^16843008*a,o[0][c]=d<<24|d>>>8,o[1][c]=d<<16|d>>>16,o[2][c]=d<<8|d>>>24,o[3][c]=d,0===a?a=s=1:(a=f^e[e[e[l^f]]],s^=e[e[s]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(e){this._key=i(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a],a^=s[o/t|0]<<24):t>6&&o%t==4&&(a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a]),i[o]=i[o-t]^a}for(var c=[],f=0;f>>24]]^u.INV_SUB_MIX[1][u.SBOX[l>>>16&255]]^u.INV_SUB_MIX[2][u.SBOX[l>>>8&255]]^u.INV_SUB_MIX[3][u.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},c.prototype.encryptBlockRaw=function(e){return a(e=i(e),this._keySchedule,u.SUB_MIX,u.SBOX,this._nRounds)},c.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=n.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},c.prototype.decryptBlock=function(e){var t=(e=i(e))[1];e[1]=e[3],e[3]=t;var r=a(e,this._invKeySchedule,u.INV_SUB_MIX,u.INV_SBOX,this._nRounds),o=n.allocUnsafe(16);return o.writeUInt32BE(r[0],0),o.writeUInt32BE(r[3],4),o.writeUInt32BE(r[2],8),o.writeUInt32BE(r[1],12),o},c.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},t.exports.AES=c},{"safe-buffer":290}],57:[function(e,t,r){var n=e("./aes"),i=e("safe-buffer").Buffer,o=e("cipher-base"),a=e("inherits"),s=e("./ghash"),u=e("buffer-xor"),c=e("./incr32");function f(e,t,r,a){o.call(this);var u=i.alloc(4,0);this._cipher=new n.AES(t);var f=this._cipher.encryptBlock(u);this._ghash=new s(f),r=function(e,t,r){if(12===t.length)return e._finID=i.concat([t,i.from([0,0,0,1])]),i.concat([t,i.from([0,0,0,2])]);var n=new s(r),o=t.length,a=o%16;n.update(t),a&&(a=16-a,n.update(i.alloc(a,0))),n.update(i.alloc(8,0));var u=8*o,f=i.alloc(8);f.writeUIntBE(u,0,8),n.update(f),e._finID=n.state;var h=i.from(e._finID);return c(h),h}(this,r,f),this._prev=i.from(r),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=a,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}a(f,o),f.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=i.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},f.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=u(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var n=Math.min(e.length,t.length),i=0;i16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},h.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(e,t){var r=o[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(t,!1,r.key,r.iv);return l(e,n.key,n.iv)},r.createDecipheriv=l},{"./aes":56,"./authCipher":57,"./modes":69,"./streamCipher":72,"cipher-base":86,evp_bytestokey:158,inherits:180,"safe-buffer":290}],60:[function(e,t,r){var n=e("./modes"),i=e("./authCipher"),o=e("safe-buffer").Buffer,a=e("./streamCipher"),s=e("cipher-base"),u=e("./aes"),c=e("evp_bytestokey");function f(e,t,r){s.call(this),this._cache=new l,this._cipher=new u.AES(t),this._prev=o.from(r),this._mode=e,this._autopadding=!0}e("inherits")(f,s),f.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get();)r=this._mode.encrypt(this,t),n.push(r);return o.concat(n)};var h=o.alloc(16,16);function l(){this.cache=o.allocUnsafe(0)}function d(e,t,r){var s=n[e.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=o.from(t)),t.length!==s.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=o.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new a(s.module,t,r):"auth"===s.type?new i(s.module,t,r):new f(s.module,t,r)}f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(h))throw this._cipher.scrub(),new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},l.prototype.add=function(e){this.cache=o.concat([this.cache,e])},l.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},l.prototype.flush=function(){for(var e=16-this.cache.length,t=o.allocUnsafe(e),r=-1;++r>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function a(e){this.h=e,this.state=n.alloc(16,0),this.cache=n.allocUnsafe(0)}a.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=o(i)},a.prototype.update=function(e){var t;for(this.cache=n.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},a.prototype.final=function(e,t){return this.cache.length&&this.ghash(n.concat([this.cache,i],16)),this.ghash(o([0,e,0,t])),this.state},t.exports=a},{"safe-buffer":290}],62:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],63:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":83}],64:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("buffer-xor");function o(e,t,r){var o=t.length,a=i(t,e._cache);return e._cache=e._cache.slice(o),e._prev=n.concat([e._prev,r?t:a]),a}r.encrypt=function(e,t,r){for(var i,a=n.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=n.allocUnsafe(0)),!(e._cache.length<=t.length)){a=n.concat([a,o(e,t,r)]);break}i=e._cache.length,a=n.concat([a,o(e,t.slice(0,i),r)]),t=t.slice(i)}return a}},{"buffer-xor":83,"safe-buffer":290}],65:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t,r){for(var n,i,a=-1,s=0;++a<8;)n=t&1<<7-a?128:0,s+=(128&(i=e._cipher.encryptBlock(e._prev)[0]^n))>>a%8,e._prev=o(e._prev,r?n:i);return s}function o(e,t){var r=e.length,i=-1,o=n.allocUnsafe(e.length);for(e=n.concat([e,n.from([t])]);++i>7;return o}r.encrypt=function(e,t,r){for(var o=t.length,a=n.allocUnsafe(o),s=-1;++s=0||!r.umod(e.prime1)||!r.umod(e.prime2);)r=new n(i(t));return r}t.exports=o,o.getr=a}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84,randombytes:270}],77:[function(e,t,r){t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":78}],78:[function(e,t,r){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],79:[function(e,t,r){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],80:[function(e,t,r){(function(r){var n=e("create-hash"),i=e("stream"),o=e("inherits"),a=e("./sign"),s=e("./verify"),u=e("./algorithms.json");function c(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function f(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function h(e){return new c(e)}function l(e){return new f(e)}Object.keys(u).forEach(function(e){u[e].id=new r(u[e].id,"hex"),u[e.toLowerCase()]=u[e]}),o(c,i.Writable),c.prototype._write=function(e,t,r){this._hash.update(e),r()},c.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},c.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),n=a(r,e,this._hashType,this._signType,this._tag);return t?n.toString(t):n},o(f,i.Writable),f.prototype._write=function(e,t,r){this._hash.update(e),r()},f.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},f.prototype.verify=function(e,t,n){"string"==typeof t&&(t=new r(t,n)),this.end();var i=this._hash.digest();return s(t,i,e,this._signType,this._tag)},t.exports={Sign:h,Verify:l,createSign:h,createVerify:l}}).call(this,e("buffer").Buffer)},{"./algorithms.json":78,"./sign":81,"./verify":82,buffer:84,"create-hash":91,inherits:180,stream:311}],81:[function(e,t,r){(function(r){var n=e("create-hmac"),i=e("browserify-rsa"),o=e("elliptic").ec,a=e("bn.js"),s=e("parse-asn1"),u=e("./curves.json");function c(e,t,i,o){if((e=new r(e.toArray())).length0&&r.ishrn(n),r}function h(e,t,i){var o,a;do{for(o=new r(0);8*o.length=t)throw new Error("invalid sig")}t.exports=function(e,t,u,c,f){var h=o(u);if("ec"===h.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var n=a[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),s=r.data.subjectPrivateKey.data;return o.verify(t,e,s)}(e,t,h)}if("dsa"===h.type){if("dsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var i=r.data.p,a=r.data.q,u=r.data.g,c=r.data.pub_key,f=o.signature.decode(e,"der"),h=f.s,l=f.r;s(h,a),s(l,a);var d=n.mont(i),p=h.invm(a);return 0===u.toRed(d).redPow(new n(t).mul(p).mod(a)).fromRed().mul(c.toRed(d).redPow(l.mul(p).mod(a)).fromRed()).mod(i).mod(a).cmp(l)}(e,t,h)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");t=r.concat([f,t]);for(var l=h.modulus.byteLength(),d=[1],p=0;t.length+d.length+2o)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=s.prototype,t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(e)}return u(e,t,r)}function u(e,t,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return F(e)?function(e,t,r){if(t<0||e.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function d(e,t){if(s.isBuffer(e))return e.length;if(q(e)||F(e))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return O(e).length;default:if(n)return L(e).length;t=(""+t).toLowerCase(),n=!0}}function p(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var o,a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var f=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function x(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return x(this,t,r);case"ascii":return S(this,t,r);case"latin1":case"binary":return M(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},s.prototype.compare=function(e,t,r,n,i){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),u=Math.min(o,a),c=this.slice(n,i),f=e.slice(t,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return m(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return g(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function S(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,r,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function B(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function C(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,8),i.write(e,t,r,n,52,8),r+8}s.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},s.prototype.readUInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeFloatLE=function(e,t,r){return P(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return P(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return C(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return C(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(e){return n.toByteArray(function(e){if((e=e.trim().replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function F(e){return e instanceof ArrayBuffer||null!=e&&null!=e.constructor&&"ArrayBuffer"===e.constructor.name&&"number"==typeof e.byteLength}function q(e){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(e)}function H(e){return e!=e}},{"base64-js":51,ieee754:178}],85:[function(e,t,r){t.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],86:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("stream").Transform,o=e("string_decoder").StringDecoder;function a(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(a,i),a.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},a.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},a.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},a.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},t.exports=a},{inherits:180,"safe-buffer":290,stream:311,string_decoder:317}],87:[function(e,t,r){(function(e){var r=function(){"use strict";function t(e,t){return null!=t&&e instanceof t}var r,n,i;try{r=Map}catch(e){r=function(){}}try{n=Set}catch(e){n=function(){}}try{i=Promise}catch(e){i=function(){}}function o(a,u,c,f,h){"object"==typeof u&&(c=u.depth,f=u.prototype,h=u.includeNonEnumerable,u=u.circular);var l=[],d=[],p=void 0!==e;return void 0===u&&(u=!0),void 0===c&&(c=1/0),function a(c,b){if(null===c)return null;if(0===b)return c;var y,m;if("object"!=typeof c)return c;if(t(c,r))y=new r;else if(t(c,n))y=new n;else if(t(c,i))y=new i(function(e,t){c.then(function(t){e(a(t,b-1))},function(e){t(a(e,b-1))})});else if(o.__isArray(c))y=[];else if(o.__isRegExp(c))y=new RegExp(c.source,s(c)),c.lastIndex&&(y.lastIndex=c.lastIndex);else if(o.__isDate(c))y=new Date(c.getTime());else{if(p&&e.isBuffer(c))return y=e.allocUnsafe?e.allocUnsafe(c.length):new e(c.length),c.copy(y),y;t(c,Error)?y=Object.create(c):void 0===f?(m=Object.getPrototypeOf(c),y=Object.create(m)):(y=Object.create(f),m=f)}if(u){var v=l.indexOf(c);if(-1!=v)return d[v];l.push(c),d.push(y)}for(var g in t(c,r)&&c.forEach(function(e,t){var r=a(t,b-1),n=a(e,b-1);y.set(r,n)}),t(c,n)&&c.forEach(function(e){var t=a(e,b-1);y.add(t)}),c){var w;m&&(w=Object.getOwnPropertyDescriptor(m,g)),w&&null==w.set||(y[g]=a(c[g],b-1))}if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(c);for(g=0;g<_.length;g++){var A=_[g];(!(x=Object.getOwnPropertyDescriptor(c,A))||x.enumerable||h)&&(y[A]=a(c[A],b-1),x.enumerable||Object.defineProperty(y,A,{enumerable:!1}))}}if(h){var E=Object.getOwnPropertyNames(c);for(g=0;g>>2),a=0,s=0;a>5]|=128<>>9<<4)]=t;for(var r=1732584193,n=-271733879,i=-1732584194,o=271733878,h=0;h>>32-s,r);var a,s}function a(e,t,r,n,i,a,s){return o(t&r|~t&n,e,t,i,a,s)}function s(e,t,r,n,i,a,s){return o(t&n|r&~n,e,t,i,a,s)}function u(e,t,r,n,i,a,s){return o(t^r^n,e,t,i,a,s)}function c(e,t,r,n,i,a,s){return o(r^(t|~n),e,t,i,a,s)}function f(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}t.exports=function(e){return n(e,i)}},{"./make-hash":92}],94:[function(e,t,r){"use strict";var n=e("inherits"),i=e("./legacy"),o=e("cipher-base"),a=e("safe-buffer").Buffer,s=e("create-hash/md5"),u=e("ripemd160"),c=e("sha.js"),f=a.alloc(128);function h(e,t){o.call(this,"digest"),"string"==typeof t&&(t=a.from(t));var r="sha512"===e||"sha384"===e?128:64;(this._alg=e,this._key=t,t.length>r)?t=("rmd160"===e?new u:c(e)).update(t).digest():t.lengths?t=e(t):t.length-1};f.prototype.append=function(e,t){e=s(e),t=u(t);var r=this.map[e];this.map[e]=r?r+","+t:t},f.prototype.delete=function(e){delete this.map[s(e)]},f.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},f.prototype.set=function(e,t){this.map[s(e)]=u(t)},f.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},f.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),c(e)},f.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),c(e)},f.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),c(e)},t.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);var o=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},b.call(y.prototype),b.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:0,statusText:""});return e.type="error",e};var a=[301,302,303,307,308];v.redirect=function(e,t){if(-1===a.indexOf(t))throw new RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},e.Headers=f,e.Request=y,e.Response=v,e.fetch=function(e,r){return new Promise(function(n,i){var o=new y(e,r),a=new XMLHttpRequest;a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new v(i,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&t.blob&&(a.responseType="blob"),o.headers.forEach(function(e,t){a.setRequestHeader(t,e)}),a.send(void 0===o._bodyInit?null:o._bodyInit)})},e.fetch.polyfill=!0}function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function u(e){return"string"!=typeof e&&(e=String(e)),e}function c(e){var r={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t.iterable&&(r[Symbol.iterator]=function(){return r}),r}function f(e){this.map={},e instanceof f?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function h(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function l(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function d(e){var t=new FileReader,r=l(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(t.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(t.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(t.arrayBuffer&&t.blob&&n(e))this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!t.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(e)&&!i(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=p(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},t.blob&&(this.blob=function(){var e=h(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var e,t,r,n=h(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=l(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function v(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}}(void 0!==e?e:this)}).call(n,void 0);var i=n.fetch;i.Response=n.Response,i.Request=n.Request,i.Headers=n.Headers;"object"==typeof t&&t.exports&&(t.exports=i,t.exports.default=i)},{}],97:[function(e,t,r){"use strict";r.randomBytes=r.rng=r.pseudoRandomBytes=r.prng=e("randombytes"),r.createHash=r.Hash=e("create-hash"),r.createHmac=r.Hmac=e("create-hmac");var n=e("browserify-sign/algos"),i=Object.keys(n),o=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(i);r.getHashes=function(){return o};var a=e("pbkdf2");r.pbkdf2=a.pbkdf2,r.pbkdf2Sync=a.pbkdf2Sync;var s=e("browserify-cipher");r.Cipher=s.Cipher,r.createCipher=s.createCipher,r.Cipheriv=s.Cipheriv,r.createCipheriv=s.createCipheriv,r.Decipher=s.Decipher,r.createDecipher=s.createDecipher,r.Decipheriv=s.Decipheriv,r.createDecipheriv=s.createDecipheriv,r.getCiphers=s.getCiphers,r.listCiphers=s.listCiphers;var u=e("diffie-hellman");r.DiffieHellmanGroup=u.DiffieHellmanGroup,r.createDiffieHellmanGroup=u.createDiffieHellmanGroup,r.getDiffieHellman=u.getDiffieHellman,r.createDiffieHellman=u.createDiffieHellman,r.DiffieHellman=u.DiffieHellman;var c=e("browserify-sign");r.createSign=c.createSign,r.Sign=c.Sign,r.createVerify=c.createVerify,r.Verify=c.Verify,r.createECDH=e("create-ecdh");var f=e("public-encrypt");r.publicEncrypt=f.publicEncrypt,r.privateEncrypt=f.privateEncrypt,r.publicDecrypt=f.publicDecrypt,r.privateDecrypt=f.privateDecrypt;var h=e("randomfill");r.randomFill=h.randomFill,r.randomFillSync=h.randomFillSync,r.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))},r.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},{"browserify-cipher":73,"browserify-sign":80,"browserify-sign/algos":77,"create-ecdh":90,"create-hash":91,"create-hmac":94,"diffie-hellman":105,pbkdf2:247,"public-encrypt":259,randombytes:270,randomfill:271}],98:[function(e,t,r){"use strict";var n=new RegExp("%[a-f0-9]{2}","gi"),i=new RegExp("(%[a-f0-9]{2})+","gi");function o(e,t){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],o(r),o(n))}function a(e){try{return decodeURIComponent(e)}catch(i){for(var t=e.match(n),r=1;r0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];r=a.r28shl(r,s),i=a.r28shl(i,s),a.pc2(r,i,e.keys,o)}},u.prototype._update=function(e,t,r,n){var i=this._desState,o=a.readUInt32BE(e,t),s=a.readUInt32BE(e,t+4);a.ip(o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,s,i.tmp,0):this._decrypt(i,o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],a.writeUInt32BE(r,o,n),a.writeUInt32BE(r,s,n+4)},u.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,o=l}a.rip(s,o,n,i)},u.prototype._decrypt=function(e,t,r,n,i){for(var o=r,s=t,u=e.keys.length-2;u>=0;u-=2){var c=e.keys[u],f=e.keys[u+1];a.expand(o,e.tmp,0),c^=e.tmp[0],f^=e.tmp[1];var h=a.substitute(c,f),l=o;o=(s^a.permute(h))>>>0,s=l}a.rip(o,s,n,i)}},{"../des":99,inherits:180,"minimalistic-assert":234}],103:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits"),o=e("../des"),a=o.Cipher,s=o.DES;function u(e){a.call(this,e);var t=new function(e,t){n.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),i=t.slice(8,16),o=t.slice(16,24);this.ciphers="encrypt"===e?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=t}i(u,a),t.exports=u,u.create=function(e){return new u(e)},u.prototype._update=function(e,t,r,n){var i=this._edeState;i.ciphers[0]._update(e,t,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},u.prototype._pad=s.prototype._pad,u.prototype._unpad=s.prototype._unpad},{"../des":99,inherits:180,"minimalistic-assert":234}],104:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,n){for(var i=0,o=0,a=6;a>=0;a-=2){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>>s+a&1}for(a=6;a>=0;a-=2){for(s=1;s<=25;s+=8)o<<=1,o|=t>>>s+a&1;for(s=1;s<=25;s+=8)o<<=1,o|=e>>>s+a&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(e,t,r,n){for(var i=0,o=0,a=0;a<4;a++)for(var s=24;s>=0;s-=8)i<<=1,i|=t>>>s+a&1,i<<=1,i|=e>>>s+a&1;for(a=4;a<8;a++)for(s=24;s>=0;s-=8)o<<=1,o|=t>>>s+a&1,o<<=1,o|=e>>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(e,t,r,n){for(var i=0,o=0,a=7;a>=5;a--){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+a&1}for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(a=1;a<=3;a++){for(s=0;s<=24;s+=8)o<<=1,o|=t>>s+a&1;for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1}for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,i){for(var o=0,a=0,s=n.length>>>1,u=0;u>>n[u]&1;for(u=s;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=a>>>0},r.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var n=e.toString(2);n.lengthe;)r.ishrn(1);if(r.isEven()&&r.iadd(s),r.testn(1)||r.iadd(u),t.cmp(u)){if(!t.cmp(c))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&m(p)&&m(r)&&a.test(p)&&a.test(r))return r}}},{"bn.js":53,"miller-rabin":233,randombytes:270}],108:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],109:[function(e,t,r){"use strict";var n=r;n.version=e("../package.json").version,n.utils=e("./elliptic/utils"),n.rand=e("brorand"),n.curve=e("./elliptic/curve"),n.curves=e("./elliptic/curves"),n.ec=e("./elliptic/ec"),n.eddsa=e("./elliptic/eddsa")},{"../package.json":124,"./elliptic/curve":112,"./elliptic/curves":115,"./elliptic/ec":116,"./elliptic/eddsa":119,"./elliptic/utils":123,brorand:54}],110:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.getNAF,a=i.getJSF,s=i.assert;function u(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){s(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=u;t--)c=(c<<1)+n[t];a.push(c)}for(var f=this.jpoint(null,null,null),h=this.jpoint(null,null,null),l=i;l>0;l--){for(u=0;u=0;c--){for(t=0;c>=0&&0===a[c];c--)t++;if(c>=0&&t++,u=u.dblp(t),c<0)break;var f=a[c];s(0!==f),u="affine"===e.type?f>0?u.mixedAdd(i[f-1>>1]):u.mixedAdd(i[-f-1>>1].neg()):f>0?u.add(i[f-1>>1]):u.add(i[-f-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){for(var s=this._wnafT1,u=this._wnafT2,c=this._wnafT3,f=0,h=0;h=1;h-=2){var d=h-1,p=h;if(1===s[d]&&1===s[p]){var b=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(b[1]=t[d].add(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].add(t[p].neg())):(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],m=a(r[d],r[p]);f=Math.max(m[0].length,f),c[d]=new Array(f),c[p]=new Array(f);for(var v=0;v=0;h--){for(var E=0;h>=0;){var x=!0;for(v=0;v=0&&E++,_=_.dblp(E),h<0)break;for(v=0;v0?k=u[v][S-1>>1]:S<0&&(k=u[v][-S-1>>1].neg()),_="affine"===k.type?_.mixedAdd(k):_.add(k))}}for(h=0;h=Math.ceil((e.bitLength()+1)/t.step)},c.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},f.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},f.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(r),s=n.redSub(t),u=i.redMul(a),c=o.redMul(s),f=i.redMul(s),h=a.redMul(o);return this.curve.point(u,c,h,f)},f.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var a=(c=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(a.redSub(this.curve.two)),t=a.redMul(c.redSub(o)),r=a.redSqr().redSub(a).redSub(a);else{var s=this.z.redSqr(),u=a.redSub(s).redISub(s);e=n.redSub(i).redISub(o).redMul(u),t=a.redMul(c.redSub(o)),r=a.redMul(u)}}else{var c=i.redAdd(o);s=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=c.redSub(s).redSub(s);e=this.curve._mulC(n.redISub(c)).redMul(u),t=this.curve._mulC(c).redMul(i.redISub(o)),r=c.redMul(u)}return this.curve.point(e,t,r)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},f.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=i.redSub(n),s=i.redAdd(n),u=r.redAdd(t),c=o.redMul(a),f=s.redMul(u),h=o.redMul(u),l=a.redMul(s);return this.curve.point(c,f,l,h)},f.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),c=i.redAdd(s),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),h=n.redMul(u).redMul(f);return this.curve.twisted?(t=n.redMul(c).redMul(a.redSub(this.curve._mulA(o))),r=u.redMul(c)):(t=n.redMul(c).redMul(a.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(h,t,r)},f.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},f.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},f.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},f.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},f.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()},f.prototype.getY=function(){return this.normalize(),this.y.fromRed()},f.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},f.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}return!1},f.prototype.toP=f.prototype.normalize,f.prototype.mixedAdd=f.prototype.add},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],112:[function(e,t,r){"use strict";var n=r;n.base=e("./base"),n.short=e("./short"),n.mont=e("./mont"),n.edwards=e("./edwards")},{"./base":110,"./edwards":111,"./mont":113,"./short":114}],113:[function(e,t,r){"use strict";var n=e("../curve"),i=e("bn.js"),o=e("inherits"),a=n.base,s=e("../../elliptic").utils;function u(e){a.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,r){a.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(u,a),t.exports=u,u.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},o(c,a.BasePoint),u.prototype.decodePoint=function(e,t){return this.point(s.toArray(e,t),1)},u.prototype.point=function(e,t){return new c(this,e,t)},u.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=i.redMul(n),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},c.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],114:[function(e,t,r){"use strict";var n=e("../curve"),i=e("../../elliptic"),o=e("bn.js"),a=e("inherits"),s=n.base,u=i.utils.assert;function c(e){s.call(this,"short",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function f(e,t,r,n){s.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new o(t,16),this.y=new o(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function h(e,t,r,n){s.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new o(0)):(this.x=new o(t,16),this.y=new o(r,16),this.z=new o(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}a(c,s),t.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new o(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new o(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?r=i[0]:(r=i[1],u(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new o(e.a,16),b:new o(e.b,16)}}):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:o.mont(e),r=new o(2).toRed(t).redInvm(),n=r.redNeg(),i=new o(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,r,n,i,a,s,u,c,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=e,d=this.n.clone(),p=new o(1),b=new o(0),y=new o(0),m=new o(1),v=0;0!==l.cmpn(0);){var g=d.div(l);c=d.sub(g.mul(l)),f=y.sub(g.mul(p));var w=m.sub(g.mul(b));if(!n&&c.cmp(h)<0)t=u.neg(),r=p,n=c.neg(),i=f;else if(n&&2==++v)break;u=c,d=l,l=c,y=p,p=f,m=b,b=w}a=c.neg(),s=f;var _=n.sqr().add(i.sqr());return a.sqr().add(s.sqr()).cmp(_)>=0&&(a=t,s=r),n.negative&&(n=n.neg(),i=i.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:n,b:i},{a:a,b:s}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(c).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},f.prototype.isInfinity=function(){return this.inf},f.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},f.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},f.prototype.getX=function(){return this.x.fromRed()},f.prototype.getY=function(){return this.y.fromRed()},f.prototype.mul=function(e){return e=new o(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},f.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},f.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},f.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},f.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},a(h,s.BasePoint),c.prototype.jpoint=function(e,t,r){return new h(this,e,t,r)},h.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},h.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},h.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),f=c.redMul(s),h=n.redMul(c),l=u.redSqr().redIAdd(f).redISub(h).redISub(h),d=u.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(l,d,p)},h.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),f=r.redMul(u),h=s.redSqr().redIAdd(c).redISub(f).redISub(f),l=s.redMul(f.redISub(h)).redISub(i.redMul(c)),d=this.z.redMul(a);return this.curve.jpoint(h,l,d)},h.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}return!1},h.prototype.inspect=function(){return this.isInfinity()?"":""},h.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],115:[function(e,t,r){"use strict";var n,i=r,o=e("hash.js"),a=e("../elliptic"),s=a.utils.assert;function u(e){"short"===e.type?this.curve=new a.curve.short(e):"edwards"===e.type?this.curve=new a.curve.edwards(e):this.curve=new a.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=e("./precomputed/secp256k1")}catch(e){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"../elliptic":109,"./precomputed/secp256k1":122,"hash.js":162}],116:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("hmac-drbg"),o=e("../../elliptic"),a=o.utils.assert,s=e("./key"),u=e("./signature");function c(e){if(!(this instanceof c))return new c(e);"string"==typeof e&&(a(o.curves.hasOwnProperty(e),"Unknown curve "+e),e=o.curves[e]),e instanceof o.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=c,c.prototype.keyPair=function(e){return new s(this,e)},c.prototype.keyFromPrivate=function(e,t){return s.fromPrivate(this,e,t)},c.prototype.keyFromPublic=function(e,t){return s.fromPublic(this,e,t)},c.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||o.rand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),a=this.n.sub(new n(2));;){var s=new n(t.generate(r));if(!(s.cmp(a)>0))return s.iaddn(1),this.keyFromPrivate(s)}},c.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},c.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),c=e.toArray("be",a),f=new i({hash:this.hash,entropy:s,nonce:c,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(f.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var m=d.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),v^=1),new u({r:y,s:m,recoveryParam:v})}}}}}},c.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new u(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,c=a.invm(this.n),f=c.mul(e).umod(this.n),h=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(f,r.getPublic(),h)).isInfinity()&&s.eqXToP(o):!(s=this.g.mulAdd(f,r.getPublic(),h)).isInfinity()&&0===s.getX().umod(this.n).cmp(o)},c.prototype.recoverPubKey=function(e,t,r,i){a((3&r)===r,"The recovery param is more than two bits"),t=new u(t,i);var o=this.n,s=new n(e),c=t.r,f=t.s,h=1&r,l=r>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");c=l?this.curve.pointFromX(c.add(this.curve.n),h):this.curve.pointFromX(c,h);var d=t.r.invm(o),p=o.sub(s).mul(d).umod(o),b=f.mul(d).umod(o);return this.g.mulAdd(p,c,b)},c.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new u(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":109,"./key":117,"./signature":118,"bn.js":53,"hmac-drbg":174}],117:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils.assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../../elliptic":109,"bn.js":53}],118:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new function(){this.place=0};if(48!==e[r.place++])return!1;if(s(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=s(e,r),a=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var u=s(e,r);if(e.length!==u+r.place)return!1;var c=e.slice(r.place,u+r.place);return 0===a[0]&&128&a[1]&&(a=a.slice(1)),0===c[0]&&128&c[1]&&(c=c.slice(1)),this.r=new n(a),this.s=new n(c),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=u(t),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),a=[48];return c(a,o.length),a=a.concat(o),i.encode(a,e)}},{"../../elliptic":109,"bn.js":53}],119:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("../../elliptic"),o=i.utils,a=o.assert,s=o.parseBytes,u=e("./key"),c=e("./signature");function f(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}t.exports=f,f.prototype.sign=function(e,t){e=s(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),u=n.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(e,t,r){e=s(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var s=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,c=t.andln(3)+i&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!=(s=e.andln(7)+n&7)&&5!==s||2!==c?u:-u,r[0].push(o),a=0==(1&c)?0:3!=(s=t.andln(7)+i&7)&&5!==s||2!==u?c:-c,r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},{"bn.js":53,"minimalistic-assert":234,"minimalistic-crypto-utils":235}],124:[function(e,t,r){t.exports={_from:"elliptic@^6.0.0",_id:"elliptic@6.4.0",_inBundle:!1,_integrity:"sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=",_location:"/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.0.0",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.0.0",saveSpec:null,fetchSpec:"^6.0.0"},_requiredBy:["/browserify-sign","/create-ecdh"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",_shasum:"cac9af8762c85836187003c8dfe193e5e2eae5df",_spec:"elliptic@^6.0.0",_where:"/Users/alexvlasov/Blockchain/web3swift_jsproxy/node_modules/browserify-sign",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.4.0"}},{}],125:[function(e,t,r){"use strict";const n=e("ethjs-util");function i(e){let t=n.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}t.exports={incrementHexNumber:function(e){return i(n.intToHex(parseInt(e,16)+1))},formatHex:i}},{"ethjs-util":155}],126:[function(e,t,r){const n=e("eth-query"),i=e("events"),o=e("pify"),a=e("./hexUtils"),s=a.incrementHexNumber,u=1e3,c=60*u;t.exports=class extends i{constructor(e={}){if(super(),!e.provider)throw new Error("RpcBlockTracker - no provider specified.");this._provider=e.provider,this._query=new n(e.provider),this._pollingInterval=e.pollingInterval||4*u,this._syncingTimeout=e.syncingTimeout||1*c,this._trackingBlock=null,this._trackingBlockTimestamp=null,this._currentBlock=null,this._isRunning=!1,this._performSync=this._performSync.bind(this),this._handleNewBlockNotification=this._handleNewBlockNotification.bind(this)}getTrackingBlock(){return this._trackingBlock}getCurrentBlock(){return this._currentBlock}async awaitCurrentBlock(){return this._currentBlock?this._currentBlock:(await new Promise(e=>this.once("latest",e)),this._currentBlock)}async start(e={}){this._isRunning||(this._isRunning=!0,e.fromBlock?await this._setTrackingBlock(await this._fetchBlockByNumber(e.fromBlock)):await this._setTrackingBlock(await this._fetchLatestBlock()),this._provider.on?await this._initSubscription():this._performSync().catch(e=>{e&&console.error(e)}))}async stop(){this._isRunning=!1,this._provider.on&&await this._removeSubscription()}async _setTrackingBlock(e){if(this._trackingBlock&&this._trackingBlock.hash===e.hash)return;const t=this._trackingBlockTimestamp,r=Date.now();t&&r-t>this._syncingTimeout?(this._trackingBlockTimestamp=null,await this._warpToLatest()):(this._trackingBlock=e,this._trackingBlockTimestamp=r,this.emit("block",e))}async _setCurrentBlock(e){if(this._currentBlock&&this._currentBlock.hash===e.hash)return;const t=this._currentBlock;this._currentBlock=e,this.emit("latest",e),this.emit("sync",{newBlock:e,oldBlock:t})}async _warpToLatest(){await this._setTrackingBlock(await this._fetchLatestBlock())}async _pollForNextBlock(){setTimeout(()=>this._performSync(),this._pollingInterval)}async _performSync(){if(!this._isRunning)return;const e=this.getTrackingBlock();if(!e)throw new Error("RpcBlockTracker - tracking block is missing");const t=s(e.number);try{const r=await this._fetchBlockByNumber(t);r?(await this._setTrackingBlock(r),this._performSync()):(await this._setCurrentBlock(e),this._pollForNextBlock())}catch(t){t.message.includes("index out of range")||t.message.includes("Couldn't find block by reference")?(await this._setCurrentBlock(e),this._pollForNextBlock()):(console.error(t),this._pollForNextBlock())}}async _handleNewBlockNotification(e,t){t.id==this._subscriptionId&&(e&&(this.emit("error",e),await this._removeSubscription()),await this._setTrackingBlock(await this._fetchBlockByNumber(t.result.number)))}async _initSubscription(){this._provider.on("data",this._handleNewBlockNotification);let e=await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_subscribe",params:["newHeads"]});this._subscriptionId=e.result}async _removeSubscription(){if(!this._subscriptionId)throw new Error("Not subscribed.");this._provider.removeListener("data",this._handleNewBlockNotification),await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_unsubscribe",params:[this._subscriptionId]}),delete this._subscriptionId}_fetchLatestBlock(){return o(this._query.getBlockByNumber).call(this._query,"latest",!0)}_fetchBlockByNumber(e){const t=a.formatHex(e);return o(this._query.getBlockByNumber).call(this._query,t,!0)}}},{"./hexUtils":125,"eth-query":135,events:157,pify:252}],127:[function(e,t,r){(function(t){var n=e("js-sha3").keccak_256,i=e("idna-uts46-hx");function o(e){return e?i.toUnicode(e,{useStd3ASCII:!0,transitional:!1}):e}r.hash=function(e){for(var r="",i=0;i<32;i++)r+="00";if(name=o(e),name){var a=name.split(".");for(i=a.length-1;i>=0;i--){var s=n(a[i]);r=n(new t(r+s,"hex"))}}return"0x"+r},r.normalize=o}).call(this,e("buffer").Buffer)},{buffer:84,"idna-uts46-hx":177,"js-sha3":128}],128:[function(e,t,r){(function(e,r){!function(){"use strict";var n="object"==typeof window?window:{};!n.JS_SHA3_NO_NODE_JS&&"object"==typeof e&&e.versions&&e.versions.node&&(n=r);for(var i=!n.JS_SHA3_NO_COMMON_JS&&"object"==typeof t&&t.exports,o="0123456789abcdef".split(""),a=[0,8,16,24],s=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],u=[224,256,384,512],c=["hex","buffer","arrayBuffer","array"],f=function(e,t,r){return function(n){return new _(e,t,e).update(n)[r]()}},h=function(e,t,r){return function(n,i){return new _(e,t,i).update(n)[r]()}},l=function(e,t){var r=f(e,t,"hex");r.create=function(){return new _(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}_.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,o=this.blocks,s=this.byteCount,u=this.blockCount,c=0,f=this.s;c>2]|=e[c]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(o[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=s){for(this.start=r-s,this.block=o[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+o[15&e]+o[e>>12&15]+o[e>>8&15]+o[e>>20&15]+o[e>>16&15]+o[e>>28&15]+o[e>>24&15];s%t==0&&(A(r),a=0)}return i&&(e=r[a],i>0&&(u+=o[e>>4&15]+o[15&e]),i>1&&(u+=o[e>>12&15]+o[e>>8&15]),i>2&&(u+=o[e>>20&15]+o[e>>16&15])),u},_.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&A(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var A=function(e){var t,r,n,i,o,a,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],a=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(a<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|a>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=a^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=s[n],e[1]^=s[n+1]};if(i)t.exports=p;else for(y=0;y{setTimeout(t,e)})}function c(e){const t=e.toString();return s.some(e=>t.includes(e))}async function f(e,t,r){const{fetchUrl:n,fetchParams:a}=h({network:e,req:t}),s=await o(n,a),u=await s.text();if(!s.ok)switch(s.status){case 405:throw new i.MethodNotFound;case 418:throw l("Request is being rate limited.");case 503:case 504:throw function(){let e="Gateway timeout. The request took too long to process. ";return e+="This can happen when querying logs over too wide a block range.",l("Gateway timeout. The request took too long to process. This can happen when querying logs over too wide a block range.")}();default:throw l(u)}if("eth_getBlockByNumber"===t.method&&"Not Found"===u)return void(r.result=null);const c=JSON.parse(u);r.result=c.result,r.error=c.error}function h({network:e,req:t}){const r=function(e){return{id:e.id,jsonrpc:e.jsonrpc,method:e.method,params:e.params}}(t),{method:n,params:i}=r,o={};let s=`https://api.infura.io/v1/jsonrpc/${e}`;if(a.includes(n))o.method="POST",o.headers={Accept:"application/json","Content-Type":"application/json"},o.body=JSON.stringify(r);else{o.method="GET",s+=`/${n}?params=${encodeURIComponent(JSON.stringify(i))}`}return{fetchUrl:s,fetchParams:o}}function l(e){const t=new Error(e);return new i.InternalError(t)}t.exports=function(e={}){const t=e.network||"mainnet",r=e.maxAttempts||5;if(!r)throw new Error(`Invalid value for 'maxAttempts': "${r}" (${typeof r})`);return n(async(e,n,i)=>{for(let i=1;i<=r;i++)try{await f(t,e,n);break}catch(e){if(!c(e))throw e;const t=r-i;if(!t){const t=`InfuraProvider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,r=new Error(t);throw r}await u(1e3)}})},t.exports.fetchConfigFromReq=h},{"cross-fetch":96,"json-rpc-engine/src/createAsyncMiddleware":187,"json-rpc-error":189}],131:[function(e,t,r){t.exports=function(e){return{sendAsync:e.handle.bind(e)}}},{}],132:[function(e,t,r){var n=function(e,t){for(var r=[],n=0;n>6|192);else{if(i>55295&&i<56320){if(++n==e.length)return null;var o=e.charCodeAt(n);if(o<56320||o>57343)return null;r+=t((i=65536+((1023&i)<<10)+(1023&o))>>18|240),r+=t(i>>12&63|128)}else r+=t(i>>12|224);r+=t(i>>6&63|128)}r+=t(63&i|128)}}return r},toString:function(e){for(var t="",r=0,o=i(e);r127){if(a>191&&a<224){if(r>=o)return null;a=(31&a)<<6|63&n(e,r)}else if(a>223&&a<240){if(r+1>=o)return null;a=(15&a)<<12|(63&n(e,r))<<6|63&n(e,++r)}else{if(!(a>239&&a<248))return null;if(r+2>=o)return null;a=(7&a)<<18|(63&n(e,r))<<12|(63&n(e,++r))<<6|63&n(e,++r)}++r}if(a<=65535)t+=String.fromCharCode(a);else{if(!(a<=1114111))return null;a-=65536,t+=String.fromCharCode(a>>10|55296),t+=String.fromCharCode(1023&a|56320)}}return t},fromNumber:function(e){var t=e.toString(16);return t.length%2==0?"0x"+t:"0x0"+t},toNumber:function(e){return parseInt(e.slice(2),16)},fromNat:function(e){return"0x0"===e?"0x":e.length%2==0?e:"0x0"+e.slice(2)},toNat:function(e){return"0"===e[2]?"0x"+e.slice(3):e},fromArray:a,toArray:o,fromUint8Array:function(e){return a([].slice.call(e,0))},toUint8Array:function(e){return new Uint8Array(o(e))}}},{"./array.js":132}],134:[function(e,t,r){var n="0123456789abcdef".split(""),i=[1,256,65536,16777216],o=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],s=function(e){var t,r,n,i,o,s,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=a[n],e[1]^=a[n+1]},u=function(e){return function(t){var r;if("0x"===t.slice(0,2)){r=[];for(var a=2,u=t.length;a>2]|=t[d]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|63&r)<=57344?(u[y>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<=c){for(e.start=y-c,e.block=u[f],y=0;y>2]|=i[3&y],e.lastByteIndex===c)for(u[0]=u[f],y=1;y>4&15]+n[15&p]+n[p>>12&15]+n[p>>8&15]+n[p>>20&15]+n[p>>16&15]+n[p>>28&15]+n[p>>24&15];m%f==0&&(s(l),y=0)}return"0x"+b}(function(e){return{blocks:[],reset:!0,block:0,start:0,blockCount:1600-(e<<1)>>5,outputBlocks:e>>5,s:(t=[0,0,0,0,0,0,0,0,0,0],[].concat(t,t,t,t,t))};var t}(e),r)}};t.exports={keccak256:u(256),keccak512:u(512),keccak256s:u(256),keccak512s:u(512)}},{}],135:[function(e,t,r){const n=e("xtend"),i=e("json-rpc-random-id")();function o(e){this.currentProvider=e}function a(e){return function(){var t=[].slice.call(arguments),r=t.pop();this.sendAsync({method:e,params:t},r)}}function s(e,t){return function(){var r=[].slice.call(arguments),n=r.pop();r.lengtho)throw new Error("Elements exceed array size: "+o);for(d in h=[],e=e.slice(0,e.lastIndexOf("[")),"string"==typeof t&&(t=JSON.parse(t)),t)h.push(l(e,t[d]));if("dynamic"===o){var p=l("uint256",t.length);h.unshift(p)}return r.concat(h)}if("bytes"===e)return t=new r(t),h=r.concat([l("uint256",t.length),t]),t.length%32!=0&&(h=r.concat([h,n.zeros(32-t.length%32)])),h;if(e.startsWith("bytes")){if((o=s(e))<1||o>32)throw new Error("Invalid bytes width: "+o);return n.setLengthRight(t,32)}if(e.startsWith("uint")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid uint width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied uint exceeds width: "+o+" vs "+a.bitLength());if(a<0)throw new Error("Supplied uint is negative");return a.toArrayLike(r,"be",32)}if(e.startsWith("int")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid int width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied int exceeds width: "+o+" vs "+a.bitLength());return a.toTwos(256).toArrayLike(r,"be",32)}if(e.startsWith("ufixed")){if(o=u(e),(a=f(t))<0)throw new Error("Supplied ufixed is negative");return l("uint256",a.mul(new i(2).pow(new i(o[1]))))}if(e.startsWith("fixed"))return o=u(e),l("int256",f(t).mul(new i(2).pow(new i(o[1]))));throw new Error("Unsupported or invalid type: "+e)}function d(e,t,n){var o,a,s,u;if("string"==typeof e&&(e=p(e)),"address"===e.name)return d(e.rawType,t,n).toArrayLike(r,"be",20).toString("hex");if("bool"===e.name)return d(e.rawType,t,n).toString()===new i(1).toString();if("string"===e.name){var c=d(e.rawType,t,n);return new r(c,"utf8").toString()}if(e.isArray){for(s=[],o=e.size,"dynamic"===e.size&&(o=d("uint256",t,n=d("uint256",t,n).toNumber()).toNumber(),n+=32),u=0;ue.size)throw new Error("Decoded int exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("int")){if((a=new i(t.slice(n,n+32),16,"be").fromTwos(256)).bitLength()>e.size)throw new Error("Decoded uint exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("ufixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("uint256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}if(e.name.startsWith("fixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("int256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}throw new Error("Unsupported or invalid type: "+e.name)}function p(e){var t,r,n;if(y(e)){t=c(e);var i=e.slice(0,e.lastIndexOf("["));return i=p(i),r={isArray:!0,name:e,size:t,memoryUsage:"dynamic"===t?32:i.memoryUsage*t,subArray:i}}switch(e){case"address":n="uint160";break;case"bool":n="uint8";break;case"string":n="bytes"}if(r={rawType:n,name:e,memoryUsage:32},e.startsWith("bytes")&&"bytes"!==e||e.startsWith("uint")||e.startsWith("int")?r.size=s(e):(e.startsWith("ufixed")||e.startsWith("fixed"))&&(r.size=u(e)),e.startsWith("bytes")&&"bytes"!==e&&(r.size<1||r.size>32))throw new Error("Invalid bytes width: "+r.size);if((e.startsWith("uint")||e.startsWith("int"))&&(r.size%8||r.size<8||r.size>256))throw new Error("Invalid int/uint width: "+r.size);return r}function b(e){return"string"===e||"bytes"===e||"dynamic"===c(e)}function y(e){return e.lastIndexOf("]")===e.length-1}function m(e,t){return e.startsWith("address")||e.startsWith("bytes")?"0x"+t.toString("hex"):t.toString()}o.eventID=function(e,t){var i=e+"("+t.map(a).join(",")+")";return n.sha3(new r(i))},o.methodID=function(e,t){return o.eventID(e,t).slice(0,4)},o.rawEncode=function(e,t){var n=[],i=[],o=0;e.forEach(function(e){if(y(e)){var t=c(e);o+="dynamic"!==t?32*t:32}else o+=32});for(var s=0;s32)throw new Error("Invalid bytes width: "+i);u.push(n.setLengthRight(l,i))}else if(h.startsWith("uint")){if((i=s(h))%8||i<8||i>256)throw new Error("Invalid uint width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied uint exceeds width: "+i+" vs "+o.bitLength());u.push(o.toArrayLike(r,"be",i/8))}else{if(!h.startsWith("int"))throw new Error("Unsupported or invalid type: "+h);if((i=s(h))%8||i<8||i>256)throw new Error("Invalid int width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied int exceeds width: "+i+" vs "+o.bitLength());u.push(o.toTwos(i).toArrayLike(r,"be",i/8))}}return r.concat(u)},o.soliditySHA3=function(e,t){return n.sha3(o.solidityPack(e,t))},o.soliditySHA256=function(e,t){return n.sha256(o.solidityPack(e,t))},o.solidityRIPEMD160=function(e,t){return n.ripemd160(o.solidityPack(e,t),!0)},o.fromSerpent=function(e){for(var t,r=[],n=0;n="0"&&t<="9");)o+=e[a]-"0",a++;n=a-1,r.push(o)}else if("i"===i)r.push("int256");else{if("a"!==i)throw new Error("Unsupported or invalid type: "+i);r.push("int256[]")}}return r},o.toSerpent=function(e){for(var t=[],r=0;r0){var r=this.raw.slice();this.v=this._chainId,this.r=0,this.s=0,t=this.raw,this.raw=r}else t=this.raw.slice(0,6);return n.rlphash(t)},e.prototype.getChainId=function(){return this._chainId},e.prototype.getSenderAddress=function(){if(this._from)return this._from;var e=this.getSenderPublicKey();return this._from=n.publicToAddress(e),this._from},e.prototype.getSenderPublicKey=function(){if(!(this._senderPubKey&&this._senderPubKey.length||this.verifySignature()))throw new Error("Invalid Signature");return this._senderPubKey},e.prototype.verifySignature=function(){var e=this.hash(!1);if(this._homestead&&1===new o(this.s).cmp(a))return!1;try{var t=n.bufferToInt(this.v);this._chainId>0&&(t-=2*this._chainId+8),this._senderPubKey=n.ecrecover(e,t,this.r,this.s)}catch(e){return!1}return!!this._senderPubKey},e.prototype.sign=function(e){var t=this.hash(!1),r=n.ecsign(t,e);this._chainId>0&&(r.v+=2*this._chainId+8),Object.assign(this,r)},e.prototype.getDataFee=function(){for(var e=this.raw[5],t=new o(0),r=0;r0&&t.push(["gas limit is too low. Need at least "+this.getBaseFee()]),void 0===e||!1===e?0===t.length:t.join(" ")},e}();t.exports=s}).call(this,e("buffer").Buffer)},{buffer:84,"ethereum-common/params.json":137,"ethereumjs-util":141}],141:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("keccak"),o=e("secp256k1"),a=e("assert"),s=e("rlp"),u=e("bn.js"),c=e("create-hash"),f=e("safe-buffer").Buffer;Object.assign(r,e("ethjs-util")),r.MAX_INTEGER=new u("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16),r.TWO_POW256=new u("10000000000000000000000000000000000000000000000000000000000000000",16),r.KECCAK256_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",r.SHA3_NULL_S=r.KECCAK256_NULL_S,r.KECCAK256_NULL=f.from(r.KECCAK256_NULL_S,"hex"),r.SHA3_NULL=r.KECCAK256_NULL,r.KECCAK256_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",r.SHA3_RLP_ARRAY_S=r.KECCAK256_RLP_ARRAY_S,r.KECCAK256_RLP_ARRAY=f.from(r.KECCAK256_RLP_ARRAY_S,"hex"),r.SHA3_RLP_ARRAY=r.KECCAK256_RLP_ARRAY,r.KECCAK256_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",r.SHA3_RLP_S=r.KECCAK256_RLP_S,r.KECCAK256_RLP=f.from(r.KECCAK256_RLP_S,"hex"),r.SHA3_RLP=r.KECCAK256_RLP,r.BN=u,r.rlp=s,r.secp256k1=o,r.zeros=function(e){return f.allocUnsafe(e).fill(0)},r.zeroAddress=function(){var e=r.zeros(20);return r.bufferToHex(e)},r.setLengthLeft=r.setLength=function(e,t,n){var i=r.zeros(t);return e=r.toBuffer(e),n?e.length0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e},r.toBuffer=function(e){if(!f.isBuffer(e))if(Array.isArray(e))e=f.from(e);else if("string"==typeof e)e=r.isHexString(e)?f.from(r.padToEven(r.stripHexPrefix(e)),"hex"):f.from(e);else if("number"==typeof e)e=r.intToBuffer(e);else if(null==e)e=f.allocUnsafe(0);else if(u.isBN(e))e=e.toArrayLike(f);else{if(!e.toArray)throw new Error("invalid type");e=f.from(e.toArray())}return e},r.bufferToInt=function(e){return new u(r.toBuffer(e)).toNumber()},r.bufferToHex=function(e){return"0x"+(e=r.toBuffer(e)).toString("hex")},r.fromSigned=function(e){return new u(e).fromTwos(256)},r.toUnsigned=function(e){return f.from(e.toTwos(256).toArray())},r.keccak=function(e,t){return e=r.toBuffer(e),t||(t=256),i("keccak"+t).update(e).digest()},r.keccak256=function(e){return r.keccak(e)},r.sha3=r.keccak,r.sha256=function(e){return e=r.toBuffer(e),c("sha256").update(e).digest()},r.ripemd160=function(e,t){e=r.toBuffer(e);var n=c("rmd160").update(e).digest();return!0===t?r.setLength(n,32):n},r.rlphash=function(e){return r.keccak(s.encode(e))},r.isValidPrivate=function(e){return o.privateKeyVerify(e)},r.isValidPublic=function(e,t){return 64===e.length?o.publicKeyVerify(f.concat([f.from([4]),e])):!!t&&o.publicKeyVerify(e)},r.pubToAddress=r.publicToAddress=function(e,t){return e=r.toBuffer(e),t&&64!==e.length&&(e=o.publicKeyConvert(e,!1).slice(1)),a(64===e.length),r.keccak(e).slice(-20)};var h=r.privateToPublic=function(e){return e=r.toBuffer(e),o.publicKeyCreate(e,!1).slice(1)};r.importPublic=function(e){return 64!==(e=r.toBuffer(e)).length&&(e=o.publicKeyConvert(e,!1).slice(1)),e},r.ecsign=function(e,t){var r=o.sign(e,t),n={};return n.r=r.signature.slice(0,32),n.s=r.signature.slice(32,64),n.v=r.recovery+27,n},r.hashPersonalMessage=function(e){var t=r.toBuffer("Ethereum Signed Message:\n"+e.length.toString());return r.keccak(f.concat([t,e]))},r.ecrecover=function(e,t,n,i){var a=f.concat([r.setLength(n,32),r.setLength(i,32)],64),s=t-27;if(0!==s&&1!==s)throw new Error("Invalid signature v value");var u=o.recover(e,a,s);return o.publicKeyConvert(u,!1).slice(1)},r.toRpcSig=function(e,t,n){if(27!==e&&28!==e)throw new Error("Invalid recovery id");return r.bufferToHex(f.concat([r.setLengthLeft(t,32),r.setLengthLeft(n,32),r.toBuffer(e-27)]))},r.fromRpcSig=function(e){if(65!==(e=r.toBuffer(e)).length)throw new Error("Invalid signature length");var t=e[64];return t<27&&(t+=27),{v:t,r:e.slice(0,32),s:e.slice(32,64)}},r.privateToAddress=function(e){return r.publicToAddress(h(e))},r.isValidAddress=function(e){return/^0x[0-9a-fA-F]{40}$/.test(e)},r.isZeroAddress=function(e){return r.zeroAddress()===r.addHexPrefix(e)},r.toChecksumAddress=function(e){e=r.stripHexPrefix(e).toLowerCase();for(var t=r.keccak(e).toString("hex"),n="0x",i=0;i=8?n+=e[i].toUpperCase():n+=e[i];return n},r.isValidChecksumAddress=function(e){return r.isValidAddress(e)&&r.toChecksumAddress(e)===e},r.generateAddress=function(e,t){return e=r.toBuffer(e),t=(t=new u(t)).isZero()?null:f.from(t.toArray()),r.rlphash([e,t]).slice(-20)},r.isPrecompiled=function(e){var t=r.unpad(e);return 1===t.length&&t[0]>=1&&t[0]<=8},r.addHexPrefix=function(e){return"string"!=typeof e?e:r.isHexPrefixed(e)?e:"0x"+e},r.isValidSignature=function(e,t,r,n){var i=new u("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16),o=new u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16);return 32===t.length&&32===r.length&&((27===e||28===e)&&(t=new u(t),r=new u(r),!(t.isZero()||t.gt(o)||r.isZero()||r.gt(o))&&(!1!==n||1!==new u(r).cmp(i))))},r.baToJSON=function(e){if(f.isBuffer(e))return"0x"+e.toString("hex");if(e instanceof Array){for(var t=[],n=0;n=i.length,"The field "+t.name+" must not have more "+t.length+" bytes")):t.allowZero&&0===i.length||!t.length||a(t.length===i.length,"The field "+t.name+" must have byte length of "+t.length),e.raw[n]=i}e._fields.push(t.name),Object.defineProperty(e,t.name,{enumerable:!0,configurable:!0,get:i,set:o}),t.default&&(e[t.name]=t.default),t.alias&&Object.defineProperty(e,t.alias,{enumerable:!1,configurable:!0,set:o,get:i})}),i)if("string"==typeof i&&(i=f.from(r.stripHexPrefix(i),"hex")),f.isBuffer(i)&&(i=s.decode(i)),Array.isArray(i)){if(i.length>e._fields.length)throw new Error("wrong number of fields in data");i.forEach(function(t,n){e[e._fields[n]]=r.toBuffer(t)})}else{if("object"!==(void 0===i?"undefined":n(i)))throw new Error("invalid data");var o=Object.keys(i);t.forEach(function(t){-1!==o.indexOf(t.name)&&(e[t.name]=i[t.name]),-1!==o.indexOf(t.alias)&&(e[t.alias]=i[t.alias])})}}},{assert:19,"bn.js":53,"create-hash":91,"ethjs-util":155,keccak:195,rlp:289,"safe-buffer":290,secp256k1:295}],142:[function(e,t,r){arguments[4][128][0].apply(r,arguments)},{_process:257,dup:128}],143:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var a=e("./address"),s=e("./bignumber"),u=e("./bytes"),c=e("./utf8"),f=e("./properties"),h=o(e("./errors")),l=new RegExp(/^bytes([0-9]*)$/),d=new RegExp(/^(u?int)([0-9]*)$/),p=new RegExp(/^(.*)\[([0-9]*)\]$/);r.defaultCoerceFunc=function(e,t){var r=e.match(d);return r&&parseInt(r[2])<=48?t.toNumber():t};var b=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"),y=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function m(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}function v(e,t){function r(t){throw new Error('unexpected character "'+e[t]+'" at position '+t+' in "'+e+'"')}for(var n={type:"",name:"",state:{allowType:!0}},i=n,o=0;o1){var i=r[1].match(b);if(""!=i[1].trim()||""!=i[3].trim())throw new Error("unexpected tokens");L(i[2]).forEach(function(e){t.outputs.push(v(e))})}return t}(e.trim()));throw new Error("unknown signature")};var w=function(){return function(e,t,r,n,i){this.coerceFunc=e,this.name=t,this.type=r,this.localName=n,this.dynamic=i}}(),_=function(e){function t(t){var r=e.call(this,t.coerceFunc,t.name,t.type,void 0,t.dynamic)||this;return f.defineReadOnly(r,"coder",t),r}return i(t,e),t.prototype.encode=function(e){return this.coder.encode(e)},t.prototype.decode=function(e,t){return this.coder.decode(e,t)},t}(w),A=function(e){function t(t,r){return e.call(this,t,"null","",r,!1)||this}return i(t,e),t.prototype.encode=function(e){return u.arrayify([])},t.prototype.decode=function(e,t){if(t>e.length)throw new Error("invalid null");return{consumed:0,value:this.coerceFunc("null",void 0)}},t}(w),E=function(e){function t(t,r,n,i){var o=this,a=(n?"int":"uint")+8*r;return(o=e.call(this,t,a,a,i,!1)||this).size=r,o.signed=n,o}return i(t,e),t.prototype.encode=function(e){try{var t=s.bigNumberify(e);return t=t.toTwos(8*this.size).maskn(8*this.size),this.signed&&(t=t.fromTwos(8*this.size).toTwos(256)),u.padZeros(u.arrayify(t),32)}catch(t){h.throwError("invalid number value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:e})}return null},t.prototype.decode=function(e,t){e.length32)throw new Error;t.set(r)}catch(t){h.throwError("invalid "+this.name+" value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:t.value||e})}return t},t.prototype.decode=function(e,t){return e.length=0?n:"")+"]",s=-1===n||r.dynamic;return(o=e.call(this,t,"array",a,i,s)||this).coder=r,o.length=n,o}return i(t,e),t.prototype.encode=function(e){Array.isArray(e)||h.throwError("expected array value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:"array",value:e});var t=this.length,r=new Uint8Array(0);-1===t&&(t=e.length,r=x.encode(t)),h.checkArgumentCount(t,e.length,"in coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i256||i%8!=0)&&h.throwError("invalid "+r[1]+" bit length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new E(e,i/8,"int"===r[1],t.name);if(r=t.type.match(l))return(0===(i=parseInt(r[1]))||i>32)&&h.throwError("invalid bytes length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new S(e,i,t.name);if(r=t.type.match(p)){var i=parseInt(r[2]||"-1");return(t=f.jsonCopy(t)).type=r[1],new N(e,D(e,t),i,t.name)}return"tuple"===t.type.substring(0,5)?function(e,t,r){t||(t=[]);var n=[];return t.forEach(function(t){n.push(D(e,t))}),new R(e,n,r)}(e,t.components,t.name):""===t.type?new A(e,t.name):(h.throwError("invalid type",h.INVALID_ARGUMENT,{arg:"type",value:t.type}),null)}var F=function(){function e(t){h.checkNew(this,e),t||(t=r.defaultCoerceFunc),f.defineReadOnly(this,"coerceFunc",t)}return e.prototype.encode=function(e,t){e.length!==t.length&&h.throwError("types/values length mismatch",h.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):e,r.push(D(this.coerceFunc,t))},this),u.hexlify(new R(this.coerceFunc,r,"_").encode(t))},e.prototype.decode=function(e,t){var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):f.jsonCopy(e),r.push(D(this.coerceFunc,t))},this),new R(this.coerceFunc,r,"_").decode(u.arrayify(t),0).value},e}();r.AbiCoder=F,r.defaultAbiCoder=new F},{"./address":144,"./bignumber":145,"./bytes":146,"./errors":147,"./properties":149,"./utf8":152}],144:[function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var i=n(e("bn.js")),o=e("./bytes"),a=e("./keccak256"),s=e("./rlp"),u=e("./errors");function c(e){"string"==typeof e&&e.match(/^0x[0-9A-Fa-f]{40}$/)||u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=o.arrayify(a.keccak256(r));for(var i=0;i<40;i+=2)r[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(15&r[i>>1])>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}for(var f={},h=0;h<10;h++)f[String(h)]=String(h);for(h=0;h<26;h++)f[String.fromCharCode(65+h)]=String(10+h);var l,d=Math.floor((l=9007199254740991,Math.log10?Math.log10(l):Math.log(l)/Math.LN10));function p(e){e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00";var t="";for(e.split("").forEach(function(e){t+=f[e]});t.length>=d;){var r=t.substring(0,d);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function b(e){var t=null;if("string"!=typeof e&&u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e}),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=c(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&u.throwError("bad address checksum",u.INVALID_ARGUMENT,{arg:"address",value:e});else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==p(e)&&u.throwError("bad icap checksum",u.INVALID_ARGUMENT,{arg:"address",value:e}),t=new i.default.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=c("0x"+t)}else u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});return t}r.getAddress=b,r.getIcapAddress=function(e){for(var t=new i.default.BN(b(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+p("XE00"+t)+t},r.getContractAddress=function(e){if(!e.from)throw new Error("missing from address");var t=e.nonce;return b("0x"+a.keccak256(s.encode([b(e.from),o.stripZeros(o.hexlify(t))])).substring(26))}},{"./bytes":146,"./errors":147,"./keccak256":148,"./rlp":150,"bn.js":53}],145:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=o(e("bn.js")),u=e("./bytes"),c=e("./properties"),f=e("./types"),h=a(e("./errors")),l=new s.default.BN(-1);function d(e){var t=e.toString(16);return"-"===t[0]?t.length%2==0?"-0x0"+t.substring(1):"-0x"+t.substring(1):t.length%2==1?"0x0"+t:"0x"+t}function p(e){return m(e)._bn}function b(e){return new y(d(e))}var y=function(e){function t(r){var n=e.call(this)||this;if(h.checkNew(n,t),"string"==typeof r)u.isHexString(r)?("0x"==r&&(r="0x0"),c.defineReadOnly(n,"_hex",r)):"-"===r[0]&&u.isHexString(r.substring(1))?c.defineReadOnly(n,"_hex",r):r.match(/^-?[0-9]*$/)?(""==r&&(r="0"),c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))):h.throwError("invalid BigNumber string value",h.INVALID_ARGUMENT,{arg:"value",value:r});else if("number"==typeof r){parseInt(String(r))!==r&&h.throwError("underflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"underflow",value:r,outputValue:parseInt(String(r))});try{c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}}else r instanceof t?c.defineReadOnly(n,"_hex",r._hex):r.toHexString?c.defineReadOnly(n,"_hex",d(p(r.toHexString()))):u.isArrayish(r)?c.defineReadOnly(n,"_hex",d(new s.default.BN(u.hexlify(r).substring(2),16))):h.throwError("invalid BigNumber value",h.INVALID_ARGUMENT,{arg:"value",value:r});return n}return i(t,e),Object.defineProperty(t.prototype,"_bn",{get:function(){return"-"===this._hex[0]?new s.default.BN(this._hex.substring(3),16).mul(l):new s.default.BN(this._hex.substring(2),16)},enumerable:!0,configurable:!0}),t.prototype.fromTwos=function(e){return b(this._bn.fromTwos(e))},t.prototype.toTwos=function(e){return b(this._bn.toTwos(e))},t.prototype.add=function(e){return b(this._bn.add(p(e)))},t.prototype.sub=function(e){return b(this._bn.sub(p(e)))},t.prototype.div=function(e){return m(e).isZero()&&h.throwError("division by zero",h.NUMERIC_FAULT,{operation:"divide",fault:"division by zero"}),b(this._bn.div(p(e)))},t.prototype.mul=function(e){return b(this._bn.mul(p(e)))},t.prototype.mod=function(e){return b(this._bn.mod(p(e)))},t.prototype.pow=function(e){return b(this._bn.pow(p(e)))},t.prototype.maskn=function(e){return b(this._bn.maskn(e))},t.prototype.eq=function(e){return this._bn.eq(p(e))},t.prototype.lt=function(e){return this._bn.lt(p(e))},t.prototype.lte=function(e){return this._bn.lte(p(e))},t.prototype.gt=function(e){return this._bn.gt(p(e))},t.prototype.gte=function(e){return this._bn.gte(p(e))},t.prototype.isZero=function(){return this._bn.isZero()},t.prototype.toNumber=function(){try{return this._bn.toNumber()}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}return null},t.prototype.toString=function(){return this._bn.toString(10)},t.prototype.toHexString=function(){return this._hex},t}(f.BigNumber);function m(e){return e instanceof y?e:new y(e)}r.bigNumberify=m,r.ConstantNegativeOne=m(-1),r.ConstantZero=m(0),r.ConstantOne=m(1),r.ConstantTwo=m(2),r.ConstantWeiPerEther=m("1000000000000000000")},{"./bytes":146,"./errors":147,"./properties":149,"./types":151,"bn.js":53}],146:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./errors");function i(e){return!!e._bn}function o(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return new Uint8Array(Array.prototype.slice.apply(e,t))},e)}function a(e){if(!e||parseInt(String(e.length))!=e.length||"string"==typeof e)return!1;for(var t=0;t=256||parseInt(String(r))!=r)return!1}return!0}function s(e){if(null==e&&n.throwError("cannot convert null value to array",n.INVALID_ARGUMENT,{arg:"value",value:e}),i(e)&&(e=e.toHexString()),"string"==typeof e){var t=e.match(/^(0x)?[0-9a-fA-F]*$/);t||n.throwError("invalid hexidecimal string",n.INVALID_ARGUMENT,{arg:"value",value:e}),"0x"!==t[1]&&n.throwError("hex string must have 0x prefix",n.INVALID_ARGUMENT,{arg:"value",value:e}),(e=e.substring(2)).length%2&&(e="0"+e);for(var r=[],s=0;s>4]+f[15&u])}return"0x"+o.join("")}return n.throwError("invalid hexlify value",null,{arg:"value",value:e}),"never"}function l(e,t){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length<2*t+2;)e="0x0"+e.substring(2);return e}function d(e){var t,r=0,i="0x",o="0x";if((t=e)&&null!=t.r&&null!=t.s){null==e.v&&null==e.recoveryParam&&n.throwError("at least on of recoveryParam or v must be specified",n.INVALID_ARGUMENT,{argument:"signature",value:e}),i=l(e.r,32),o=l(e.s,32),"string"==typeof(r=e.v)&&(r=parseInt(r,16));var a=e.recoveryParam;null==a&&null!=e.v&&(a=1-r%2),r=27+a}else{var u=s(e);if(65!==u.length)throw new Error("invalid signature");i=h(u.slice(0,32)),o=h(u.slice(32,64)),27!==(r=u[64])&&28!==r&&(r=27+r%2)}return{r:i,s:o,recoveryParam:r-27,v:r}}r.hexlify=h,r.hexDataLength=function(e){return c(e)&&e.length%2==0?(e.length-2)/2:null},r.hexDataSlice=function(e,t,r){return c(e)||n.throwError("invalid hex data",n.INVALID_ARGUMENT,{arg:"value",value:e}),e.length%2!=0&&n.throwError("hex data length must be even",n.INVALID_ARGUMENT,{arg:"value",value:e}),t=2+2*t,null!=r?"0x"+e.substring(t,t+2*r):"0x"+e.substring(t)},r.hexStripZeros=function(e){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length>3&&"0x0"===e.substring(0,3);)e="0x"+e.substring(3);return e},r.hexZeroPad=l,r.splitSignature=d,r.joinSignature=function(e){return h(u([(e=d(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}},{"./errors":147}],147:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.MISSING_NEW="MISSING_NEW",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.NUMERIC_FAULT="NUMERIC_FAULT",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION";var n=!1,i=!1;function o(e,t,n){if(i)throw new Error("unknown error");t||(t=r.UNKNOWN_ERROR),n||(n={});var o=[];Object.keys(n).forEach(function(e){try{o.push(e+"="+JSON.stringify(n[e]))}catch(t){o.push(e+"="+JSON.stringify(n[e].toString()))}});var a=e;o.length&&(e+=" ("+o.join(", ")+")");var s=new Error(e);throw s.reason=a,s.code=t,Object.keys(n).forEach(function(e){s[e]=n[e]}),s}r.throwError=o,r.checkNew=function(e,t){e instanceof t||o("missing new",r.MISSING_NEW,{name:t.name})},r.checkArgumentCount=function(e,t,n){n||(n=""),et&&o("too many arguments"+n,r.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})},r.setCensorship=function(e,t){n&&o("error censorship permanent",r.UNSUPPORTED_OPERATION,{operation:"setCersorship"}),i=!!e,n=!!t}},{}],148:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("js-sha3"),i=e("./bytes");r.keccak256=function(e){return"0x"+n.keccak_256(i.arrayify(e))}},{"./bytes":146,"js-sha3":142}],149:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defineReadOnly=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})},r.defineFrozen=function(e,t,r){var n=JSON.stringify(r);Object.defineProperty(e,t,{enumerable:!0,get:function(){return JSON.parse(n)}})},r.resolveProperties=function(e){var t={},r=[];return Object.keys(e).forEach(function(n){var i=e[n];i instanceof Promise?r.push(i.then(function(e){return t[n]=e,null})):t[n]=i}),Promise.all(r).then(function(){return t})},r.shallowCopy=function(e){var t={};for(var r in e)t[r]=e[r];return t},r.jsonCopy=function(e){return JSON.parse(JSON.stringify(e))}},{}],150:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./bytes");function i(e){for(var t=[];e;)t.unshift(255&e),e>>=8;return t}function o(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function s(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(r=e[t]-247)>e.length)throw new Error("too short");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("to short");return a(e,t,t+1+r,r+i)}if(e[t]>=192){if(t+1+(i=e[t]-192)>e.length)throw new Error("invalid rlp data");return a(e,t,t+1,i)}if(e[t]>=184){var r;if(t+1+(r=e[t]-183)>e.length)throw new Error("invalid rlp data");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("invalid rlp data");return{consumed:1+r+i,result:n.hexlify(e.slice(t+1+r,t+1+r+i))}}if(e[t]>=128){var i;if(t+1+(i=e[t]-128)>e.length)throw new Error("invlaid rlp data");return{consumed:1+i,result:n.hexlify(e.slice(t+1,t+1+i))}}return{consumed:1,result:n.hexlify(e[t])}}r.encode=function(e){return n.hexlify(function e(t){if(Array.isArray(t)){var r=[];return t.forEach(function(t){r=r.concat(e(t))}),r.length<=55?(r.unshift(192+r.length),r):((o=i(r.length)).unshift(247+o.length),o.concat(r))}var o,a=Array.prototype.slice.call(n.arrayify(t));return 1===a.length&&a[0]<=127?a:a.length<=55?(a.unshift(128+a.length),a):((o=i(a.length)).unshift(183+o.length),o.concat(a))}(e))},r.decode=function(e){var t=n.arrayify(e),r=s(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}},{"./bytes":146}],151:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=function(){return function(){}}();r.BigNumber=n;var i=function(){return function(){}}();r.Indexed=i;var o=function(){return function(){}}();r.MinimalProvider=o;var a=function(){return function(){}}();r.Signer=a;var s=function(){return function(){}}();r.HDNode=s},{}],152:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,i=e("./bytes");!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(n=r.UnicodeNormalizationForm||(r.UnicodeNormalizationForm={})),r.toUtf8Bytes=function(e,t){void 0===t&&(t=n.current),t!=n.current&&(e=e.normalize(t));for(var r=[],o=0,a=0;a>6|192,r[o++]=63&s|128):55296==(64512&s)&&a+1>18|240,r[o++]=s>>12&63|128,r[o++]=s>>6&63|128,r[o++]=63&s|128):(r[o++]=s>>12|224,r[o++]=s>>6&63|128,r[o++]=63&s|128)}return i.arrayify(r)},r.toUtf8String=function(e){e=i.arrayify(e);for(var t="",r=0;r>7!=0){if(n>>6!=2){var o=null;if(n>>5==6)o=1;else if(n>>4==14)o=2;else if(n>>3==30)o=3;else if(n>>2==62)o=4;else{if(n>>1!=126)continue;o=5}if(r+o>e.length){for(;r>6==2;r++);if(r!=e.length)continue;return t}var a,s=n&(1<<8-o-1)-1;for(a=0;a>6!=2)break;s=s<<6|63&u}a==o?s<=65535?t+=String.fromCharCode(s):(s-=65536,t+=String.fromCharCode(55296+(s>>10&1023),56320+(1023&s))):r--}}else t+=String.fromCharCode(n)}return t}},{"./bytes":146}],153:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("number-to-bn"),o=new n(0),a=new n(-1),s={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",Gwei:"1000000000",shannon:"1000000000",nanoether:"1000000000",nano:"1000000000",szabo:"1000000000000",microether:"1000000000000",micro:"1000000000000",finney:"1000000000000000",milliether:"1000000000000000",milli:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"};function u(e){var t=e?e.toLowerCase():"ether",r=s[t];if("string"!=typeof r)throw new Error("[ethjs-unit] the unit provided "+e+" doesn't exists, please use the one of the following units "+JSON.stringify(s,null,2));return new n(r,10)}function c(e){if("string"==typeof e){if(!e.match(/^-?[0-9.]+$/))throw new Error("while converting number to string, invalid number value '"+e+"', should be a number matching (^-?[0-9.]+).");return e}if("number"==typeof e)return String(e);if("object"==typeof e&&e.toString&&(e.toTwos||e.dividedToIntegerBy))return e.toPrecision?String(e.toPrecision()):e.toString(10);throw new Error("while converting number to string, invalid number value '"+e+"' type "+typeof e+".")}t.exports={unitMap:s,numberToString:c,getValueOfUnit:u,fromWei:function(e,t,r){var n=i(e),c=n.lt(o),f=u(t),h=s[t].length-1||1,l=r||{};c&&(n=n.mul(a));for(var d=n.mod(f).toString(10);d.length2)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal points");var l=h[0],d=h[1];if(l||(l="0"),d||(d="0"),d.length>o)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal places");for(;d.length=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{}],155:[function(e,t,r){(function(r){"use strict";var n=e("is-hex-prefixed"),i=e("strip-hex-prefix");function o(e){var t=e;if("string"!=typeof t)throw new Error("[ethjs-util] while padding to even, value must be string, is currently "+typeof t+", while padToEven.");return t.length%2&&(t="0"+t),t}function a(e){return"0x"+e.toString(16)}t.exports={arrayContainsArray:function(e,t,r){if(!0!==Array.isArray(e))throw new Error("[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '"+typeof e+"'");if(!0!==Array.isArray(t))throw new Error("[ethjs-util] method arrayContainsArray requires input 'subset' to be an array got type '"+typeof t+"'");return t[Boolean(r)?"some":"every"](function(t){return e.indexOf(t)>=0})},intToBuffer:function(e){var t=a(e);return new r(o(t.slice(2)),"hex")},getBinarySize:function(e){if("string"!=typeof e)throw new Error("[ethjs-util] while getting binary size, method getBinarySize requires input 'str' to be type String, got '"+typeof e+"'.");return r.byteLength(e,"utf8")},isHexPrefixed:n,stripHexPrefix:i,padToEven:o,intToHex:a,fromAscii:function(e){for(var t="",r=0;r0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var r,n,a,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(r=this._events[e]).length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=a;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){n=s;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],158:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("md5.js");t.exports=function(e,t,r,o){if(n.isBuffer(e)||(e=n.from(e,"binary")),t&&(n.isBuffer(t)||(t=n.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var a=r/8,s=n.alloc(a),u=n.alloc(o||0),c=n.alloc(0);a>0||o>0;){var f=new i;f.update(c),f.update(e),t&&f.update(t),c=f.digest();var h=0;if(a>0){var l=s.length-a;h=Math.min(a,c.length),c.copy(s,l,0,h),a-=h}if(h0){var d=u.length-o,p=Math.min(o,c.length-h);c.copy(u,d,h,h+p),o-=p}}return c.fill(0),{key:s,iv:u}}},{"md5.js":231,"safe-buffer":290}],159:[function(e,t,r){"use strict";var n=e("is-callable"),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.exports=function(e,t,r){if(!n(t))throw new TypeError("iterator must be a function");var a;arguments.length>=3&&(a=r),"[object Array]"===i.call(e)?function(e,t,r){for(var n=0,i=e.length;n=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},i.prototype._update=function(e){throw new Error("_update is not implemented")},i.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();return void 0!==e&&(t=t.toString(e)),t},i.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=i}).call(this,e("buffer").Buffer)},{buffer:84,inherits:180,stream:311}],162:[function(e,t,r){var n=r;n.utils=e("./hash/utils"),n.common=e("./hash/common"),n.sha=e("./hash/sha"),n.ripemd=e("./hash/ripemd"),n.hmac=e("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":163,"./hash/hmac":164,"./hash/ripemd":165,"./hash/sha":166,"./hash/utils":173}],163:[function(e,t,r){"use strict";var n=e("./utils"),i=e("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},{"../utils":173}],173:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits");function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function s(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=i,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,a=255&i;o?r.push(o,a):r.push(a)}else for(n=0;n>>0}return a},r.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},r.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},r.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},r.sum64_lo=function(e,t,r,n){return t+n>>>0},r.sum64_4_hi=function(e,t,r,n,i,o,a,s){var u=0,c=t;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},r.sum64_5_hi=function(e,t,r,n,i,o,a,s,u,c){var f=0,h=t;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,n,i,o,a,s,u,c){return t+n+o+s+c>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:180,"minimalistic-assert":234}],174:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("minimalistic-crypto-utils"),o=e("minimalistic-assert");function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}t.exports=a,a.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},a.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length\\$%@ءؤة\"'^|~⦅⦆・ゥャ¢£¬¦¥₩│←↑→↓■○𐐨𐐩𐐪𐐫𐐬𐐭𐐮𐐯𐐰𐐱𐐲𐐳𐐴𐐵𐐶𐐷𐐸𐐹𐐺𐐻𐐼𐐽𐐾𐐿𐑀𐑁𐑂𐑃𐑄𐑅𐑆𐑇𐑈𐑉𐑊𐑋𐑌𐑍𐑎𐑏𐓘𐓙𐓚𐓛𐓜𐓝𐓞𐓟𐓠𐓡𐓢𐓣𐓤𐓥𐓦𐓧𐓨𐓩𐓪𐓫𐓬𐓭𐓮𐓯𐓰𐓱𐓲𐓳𐓴𐓵𐓶𐓷𐓸𐓹𐓺𐓻𐳀𐳁𐳂𐳃𐳄𐳅𐳆𐳇𐳈𐳉𐳊𐳋𐳌𐳍𐳎𐳏𐳐𐳑𐳒𐳓𐳔𐳕𐳖𐳗𐳘𐳙𐳚𐳛𐳜𐳝𐳞𐳟𐳠𐳡𐳢𐳣𐳤𐳥𐳦𐳧𐳨𐳩𐳪𐳫𐳬𐳭𐳮𐳯𐳰𐳱𐳲𑣀𑣁𑣂𑣃𑣄𑣅𑣆𑣇𑣈𑣉𑣊𑣋𑣌𑣍𑣎𑣏𑣐𑣑𑣒𑣓𑣔𑣕𑣖𑣗𑣘𑣙𑣚𑣛𑣜𑣝𑣞𑣟ıȷ∇∂𞤢𞤣𞤤𞤥𞤦𞤧𞤨𞤩𞤪𞤫𞤬𞤭𞤮𞤯𞤰𞤱𞤲𞤳𞤴𞤵𞤶𞤷𞤸𞤹𞤺𞤻𞤼𞤽𞤾𞤿𞥀𞥁𞥂𞥃ٮڡٯ字双多解交映無前後再新初終販声吹演投捕遊指禁空合満申割営配得可丽丸乁𠄢你侻倂偺備像㒞𠘺兔兤具𠔜㒹內𠕋冗冤仌冬𩇟刃㓟刻剆剷㔕包匆卉博即卽卿𠨬灰及叟𠭣叫叱吆咞吸呈周咢哶唐啓啣善喫喳嗂圖圗噑噴壮城埴堍型堲報墬𡓤売壷夆夢奢𡚨𡛪姬娛娧姘婦㛮嬈嬾𡧈寃寘寳𡬘寿将㞁屠峀岍𡷤嵃𡷦嵮嵫嵼巡巢㠯巽帨帽幩㡢𢆃㡼庰庳庶𪎒𢌱舁弢㣇𣊸𦇚形彫㣣徚忍志忹悁㤺㤜𢛔惇慈慌慺憲憤憯懞戛扝抱拔捐𢬌挽拼捨掃揤𢯱搢揅掩㨮摩摾撝摷㩬敬𣀊旣書晉㬙㬈㫤冒冕最暜肭䏙朡杞杓𣏃㭉柺枅桒𣑭梎栟椔楂榣槪檨𣚣櫛㰘次𣢧歔㱎歲殟殻𣪍𡴋𣫺汎𣲼沿泍汧洖派浩浸涅𣴞洴港湮㴳滇𣻑淹潮𣽞𣾎濆瀹瀛㶖灊災灷炭𠔥煅𤉣熜爨牐𤘈犀犕𤜵𤠔獺王㺬玥㺸瑇瑜璅瓊㼛甤𤰶甾𤲒𢆟瘐𤾡𤾸𥁄㿼䀈𥃳𥃲𥄙𥄳眞真瞋䁆䂖𥐝硎䃣𥘦𥚚𥛅秫䄯穊穏𥥼𥪧䈂𥮫篆築䈧𥲀糒䊠糨糣紀𥾆絣䌁緇縂繅䌴𦈨𦉇䍙𦋙罺𦌾羕翺𦓚𦔣聠𦖨聰𣍟䏕育脃䐋脾媵𦞧𦞵𣎓𣎜舄辞䑫芑芋芝劳花芳芽苦𦬼茝荣莭茣莽菧荓菊菌菜𦰶𦵫𦳕䔫蓱蓳蔖𧏊蕤𦼬䕝䕡𦾱𧃒䕫虐虧虩蚩蚈蜎蛢蜨蝫螆蟡蠁䗹衠𧙧裗裞䘵裺㒻𧢮𧥦䚾䛇誠𧲨貫賁贛起𧼯𠠄跋趼跰𠣞軔𨗒𨗭邔郱鄑𨜮鄛鈸鋗鋘鉼鏹鐕𨯺開䦕閷𨵷䧦雃嶲霣𩅅𩈚䩮䩶韠𩐊䪲𩒖頩𩖶飢䬳餩馧駂駾䯎𩬰鱀鳽䳎䳭鵧𪃎䳸𪄅𪈎𪊑䵖黾鼅鼏鼖𪘀",mapChar:function(r){return r>=196608?r>=917760&&r<=917999?18874368:0:e[t[r>>4]][15&r]}}},"function"==typeof define&&define.amd?define([],function(){return i()}):"object"==typeof r?t.exports=i():n.uts46_map=i()},{}],177:[function(e,t,r){var n,i;n=this,i=function(e,t){function r(r,n,i){for(var o=[],a=e.ucs2.decode(r),s=0;s>23,l=f>>21&3,d=f>>5&65535,p=31&f,b=t.mapStr.substr(d,p);if(0===l||n&&1&h)throw new Error("Illegal char "+c);1===l?o.push(b):2===l?o.push(i?b:c):3===l&&o.push(c)}return o.join("").normalize("NFC")}function n(t,n,o){void 0===o&&(o=!1);var a=r(t,o,n).split(".");return(a=a.map(function(t){return t.startsWith("xn--")?i(t=e.decode(t.substring(4)),o,!1):i(t,o,n),t})).join(".")}function i(e,n,i){if("-"===e[2]&&"-"===e[3])throw new Error("Failed to validate "+e);if(e.startsWith("-")||e.endsWith("-"))throw new Error("Failed to validate "+e);if(e.includes("."))throw new Error("Failed to validate "+e);if(r(e,n,i)!==e)throw new Error("Failed to validate "+e);var o=e.codePointAt(0);if(t.mapChar(o)&2<<23)throw new Error("Label contains illegal character: "+o)}return{toUnicode:function(e,t){return void 0===t&&(t={}),n(e,!1,"useStd3ASCII"in t&&t.useStd3ASCII)},toAscii:function(t,r){void 0===r&&(r={});var i,o=!("transitional"in r)||r.transitional,a="useStd3ASCII"in r&&r.useStd3ASCII,s="verifyDnsLength"in r&&r.verifyDnsLength,u=n(t,o,a).split(".").map(e.toASCII),c=u.join(".");if(s){if(c.length<1||c.length>253)throw new Error("DNS name has wrong length: "+c);for(i=0;i63)throw new Error("DNS label has wrong length: "+f)}}return c}}},"function"==typeof define&&define.amd?define(["punycode","./idna-map"],function(e,t){return i(e,t)}):"object"==typeof r?t.exports=i(e("punycode"),e("./idna-map")):n.uts46=i(n.punycode,n.idna_map)},{"./idna-map":176,punycode:265}],178:[function(e,t,r){r.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,f=-7,h=r?i-1:0,l=r?-1:1,d=e[t+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=s;f>0;o=256*o+e[t+h],h+=l,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+e[t+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=c}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var a,s,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(a++,u/=2),a+h>=f?(s=0,a=f):a+h>=1?(s=(t*u-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;e[r+d]=255&a,d+=p,a/=256,c-=8);e[r+d-p]|=128*b}},{}],179:[function(e,t,r){var n=[].indexOf;t.exports=function(e,t){if(n)return e.indexOf(t);for(var r=0;r-32e3)throw new Error("Invalid error code");if(!(this instanceof f))return new f(e);i.call(this,"Server error",e)};n(f,i),i.ParseError=o,i.InvalidRequest=a,i.MethodNotFound=s,i.InvalidParams=u,i.InternalError=c,i.ServerError=f,t.exports=i},{inherits:180}],191:[function(e,t,r){t.exports=function(e){var t=(e=e||{}).max||Number.MAX_SAFE_INTEGER,r=void 0!==e.start?e.start:Math.floor(Math.random()*t);return function(){return r%=t,r++}}},{}],192:[function(e,t,r){r.parse=e("./lib/parse"),r.stringify=e("./lib/stringify")},{"./lib/parse":193,"./lib/stringify":194}],193:[function(e,t,r){var n,i,o,a,s={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},u=function(e){throw{name:"SyntaxError",message:e,at:n,text:o}},c=function(e){return e&&e!==i&&u("Expected '"+e+"' instead of '"+i+"'"),i=o.charAt(n),n+=1,i},f=function(){var e,t="";for("-"===i&&(t="-",c("-"));i>="0"&&i<="9";)t+=i,c();if("."===i)for(t+=".";c()&&i>="0"&&i<="9";)t+=i;if("e"===i||"E"===i)for(t+=i,c(),"-"!==i&&"+"!==i||(t+=i,c());i>="0"&&i<="9";)t+=i,c();if(e=+t,isFinite(e))return e;u("Bad number")},h=function(){var e,t,r,n="";if('"'===i)for(;c();){if('"'===i)return c(),n;if("\\"===i)if(c(),"u"===i){for(r=0,t=0;t<4&&(e=parseInt(c(),16),isFinite(e));t+=1)r=16*r+e;n+=String.fromCharCode(r)}else{if("string"!=typeof s[i])break;n+=s[i]}else n+=i}u("Bad string")},l=function(){for(;i&&i<=" ";)c()};a=function(){switch(l(),i){case"{":return function(){var e,t={};if("{"===i){if(c("{"),l(),"}"===i)return c("}"),t;for(;i;){if(e=h(),l(),c(":"),Object.hasOwnProperty.call(t,e)&&u('Duplicate key "'+e+'"'),t[e]=a(),l(),"}"===i)return c("}"),t;c(","),l()}}u("Bad object")}();case"[":return function(){var e=[];if("["===i){if(c("["),l(),"]"===i)return c("]"),e;for(;i;){if(e.push(a()),l(),"]"===i)return c("]"),e;c(","),l()}}u("Bad array")}();case'"':return h();case"-":return f();default:return i>="0"&&i<="9"?f():function(){switch(i){case"t":return c("t"),c("r"),c("u"),c("e"),!0;case"f":return c("f"),c("a"),c("l"),c("s"),c("e"),!1;case"n":return c("n"),c("u"),c("l"),c("l"),null}u("Unexpected '"+i+"'")}()}},t.exports=function(e,t){var r;return o=e,n=0,i=" ",r=a(),l(),i&&u("Syntax error"),"function"==typeof t?function e(r,n){var i,o,a=r[n];if(a&&"object"==typeof a)for(i in a)Object.prototype.hasOwnProperty.call(a,i)&&(void 0!==(o=e(a,i))?a[i]=o:delete a[i]);return t.call(r,n,a)}({"":r},""):r}},{}],194:[function(e,t,r){var n,i,o,a=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,s={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function u(e){return a.lastIndex=0,a.test(e)?'"'+e.replace(a,function(e){var t=s[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}t.exports=function(e,t,r){var a;if(n="",i="","number"==typeof r)for(a=0;a>>31),p=l^(a<<1|o>>>31),b=e[0]^d,y=e[1]^p,m=e[10]^d,v=e[11]^p,g=e[20]^d,w=e[21]^p,_=e[30]^d,A=e[31]^p,E=e[40]^d,x=e[41]^p;d=r^(s<<1|u>>>31),p=i^(u<<1|s>>>31);var k=e[2]^d,S=e[3]^p,M=e[12]^d,I=e[13]^p,T=e[22]^d,U=e[23]^p,j=e[32]^d,B=e[33]^p,P=e[42]^d,C=e[43]^p;d=o^(c<<1|f>>>31),p=a^(f<<1|c>>>31);var N=e[4]^d,R=e[5]^p,L=e[14]^d,O=e[15]^p,D=e[24]^d,F=e[25]^p,q=e[34]^d,H=e[35]^p,z=e[44]^d,K=e[45]^p;d=s^(h<<1|l>>>31),p=u^(l<<1|h>>>31);var V=e[6]^d,G=e[7]^p,W=e[16]^d,Y=e[17]^p,X=e[26]^d,Z=e[27]^p,J=e[36]^d,$=e[37]^p,Q=e[46]^d,ee=e[47]^p;d=c^(r<<1|i>>>31),p=f^(i<<1|r>>>31);var te=e[8]^d,re=e[9]^p,ne=e[18]^d,ie=e[19]^p,oe=e[28]^d,ae=e[29]^p,se=e[38]^d,ue=e[39]^p,ce=e[48]^d,fe=e[49]^p,he=b,le=y,de=v<<4|m>>>28,pe=m<<4|v>>>28,be=g<<3|w>>>29,ye=w<<3|g>>>29,me=A<<9|_>>>23,ve=_<<9|A>>>23,ge=E<<18|x>>>14,we=x<<18|E>>>14,_e=k<<1|S>>>31,Ae=S<<1|k>>>31,Ee=I<<12|M>>>20,xe=M<<12|I>>>20,ke=T<<10|U>>>22,Se=U<<10|T>>>22,Me=B<<13|j>>>19,Ie=j<<13|B>>>19,Te=P<<2|C>>>30,Ue=C<<2|P>>>30,je=R<<30|N>>>2,Be=N<<30|R>>>2,Pe=L<<6|O>>>26,Ce=O<<6|L>>>26,Ne=F<<11|D>>>21,Re=D<<11|F>>>21,Le=q<<15|H>>>17,Oe=H<<15|q>>>17,De=K<<29|z>>>3,Fe=z<<29|K>>>3,qe=V<<28|G>>>4,He=G<<28|V>>>4,ze=Y<<23|W>>>9,Ke=W<<23|Y>>>9,Ve=X<<25|Z>>>7,Ge=Z<<25|X>>>7,We=J<<21|$>>>11,Ye=$<<21|J>>>11,Xe=ee<<24|Q>>>8,Ze=Q<<24|ee>>>8,Je=te<<27|re>>>5,$e=re<<27|te>>>5,Qe=ne<<20|ie>>>12,et=ie<<20|ne>>>12,tt=ae<<7|oe>>>25,rt=oe<<7|ae>>>25,nt=se<<8|ue>>>24,it=ue<<8|se>>>24,ot=ce<<14|fe>>>18,at=fe<<14|ce>>>18;e[0]=he^~Ee&Ne,e[1]=le^~xe&Re,e[10]=qe^~Qe&be,e[11]=He^~et&ye,e[20]=_e^~Pe&Ve,e[21]=Ae^~Ce&Ge,e[30]=Je^~de&ke,e[31]=$e^~pe&Se,e[40]=je^~ze&tt,e[41]=Be^~Ke&rt,e[2]=Ee^~Ne&We,e[3]=xe^~Re&Ye,e[12]=Qe^~be&Me,e[13]=et^~ye&Ie,e[22]=Pe^~Ve&nt,e[23]=Ce^~Ge&it,e[32]=de^~ke&Le,e[33]=pe^~Se&Oe,e[42]=ze^~tt&me,e[43]=Ke^~rt&ve,e[4]=Ne^~We&ot,e[5]=Re^~Ye&at,e[14]=be^~Me&De,e[15]=ye^~Ie&Fe,e[24]=Ve^~nt&ge,e[25]=Ge^~it&we,e[34]=ke^~Le&Xe,e[35]=Se^~Oe&Ze,e[44]=tt^~me&Te,e[45]=rt^~ve&Ue,e[6]=We^~ot&he,e[7]=Ye^~at&le,e[16]=Me^~De&qe,e[17]=Ie^~Fe&He,e[26]=nt^~ge&_e,e[27]=it^~we&Ae,e[36]=Le^~Xe&Je,e[37]=Oe^~Ze&$e,e[46]=me^~Te&je,e[47]=ve^~Ue&Be,e[8]=ot^~he&Ee,e[9]=at^~le&xe,e[18]=De^~qe&Qe,e[19]=Fe^~He&et,e[28]=ge^~_e&Pe,e[29]=we^~Ae&Ce,e[38]=Xe^~Je&de,e[39]=Ze^~$e&pe,e[48]=Te^~je&ze,e[49]=Ue^~Be&Ke,e[0]^=n[2*t],e[1]^=n[2*t+1]}}},{}],200:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("./keccak-state-unroll");function o(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}o.prototype.initialize=function(e,t){for(var r=0;r<50;++r)this.state[r]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},o.prototype.absorb=function(e){for(var t=0;t>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(i.p1600(this.state),this.count=0);return t},o.prototype.copy=function(e){for(var t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},t.exports=o},{"./keccak-state-unroll":199,"safe-buffer":290}],201:[function(e,t,r){var n=e("./_root").Symbol;t.exports=n},{"./_root":217}],202:[function(e,t,r){var n=e("./_baseTimes"),i=e("./isArguments"),o=e("./isArray"),a=e("./isBuffer"),s=e("./_isIndex"),u=e("./isTypedArray"),c=Object.prototype.hasOwnProperty;t.exports=function(e,t){var r=o(e),f=!r&&i(e),h=!r&&!f&&a(e),l=!r&&!f&&!h&&u(e),d=r||f||h||l,p=d?n(e.length,String):[],b=p.length;for(var y in e)!t&&!c.call(e,y)||d&&("length"==y||h&&("offset"==y||"parent"==y)||l&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||s(y,b))||p.push(y);return p}},{"./_baseTimes":207,"./_isIndex":211,"./isArguments":219,"./isArray":220,"./isBuffer":222,"./isTypedArray":227}],203:[function(e,t,r){var n=e("./_Symbol"),i=e("./_getRawTag"),o=e("./_objectToString"),a="[object Null]",s="[object Undefined]",u=n?n.toStringTag:void 0;t.exports=function(e){return null==e?void 0===e?s:a:u&&u in Object(e)?i(e):o(e)}},{"./_Symbol":201,"./_getRawTag":210,"./_objectToString":215}],204:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isObjectLike"),o="[object Arguments]";t.exports=function(e){return i(e)&&n(e)==o}},{"./_baseGetTag":203,"./isObjectLike":226}],205:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isLength"),o=e("./isObjectLike"),a={};a["[object Float32Array]"]=a["[object Float64Array]"]=a["[object Int8Array]"]=a["[object Int16Array]"]=a["[object Int32Array]"]=a["[object Uint8Array]"]=a["[object Uint8ClampedArray]"]=a["[object Uint16Array]"]=a["[object Uint32Array]"]=!0,a["[object Arguments]"]=a["[object Array]"]=a["[object ArrayBuffer]"]=a["[object Boolean]"]=a["[object DataView]"]=a["[object Date]"]=a["[object Error]"]=a["[object Function]"]=a["[object Map]"]=a["[object Number]"]=a["[object Object]"]=a["[object RegExp]"]=a["[object Set]"]=a["[object String]"]=a["[object WeakMap]"]=!1,t.exports=function(e){return o(e)&&i(e.length)&&!!a[n(e)]}},{"./_baseGetTag":203,"./isLength":224,"./isObjectLike":226}],206:[function(e,t,r){var n=e("./_isPrototype"),i=e("./_nativeKeys"),o=Object.prototype.hasOwnProperty;t.exports=function(e){if(!n(e))return i(e);var t=[];for(var r in Object(e))o.call(e,r)&&"constructor"!=r&&t.push(r);return t}},{"./_isPrototype":212,"./_nativeKeys":213}],207:[function(e,t,r){t.exports=function(e,t){for(var r=-1,n=Array(e);++r-1&&e%1==0&&e-1&&e%1==0&&e<=n}},{}],225:[function(e,t,r){t.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},{}],226:[function(e,t,r){t.exports=function(e){return null!=e&&"object"==typeof e}},{}],227:[function(e,t,r){var n=e("./_baseIsTypedArray"),i=e("./_baseUnary"),o=e("./_nodeUtil"),a=o&&o.isTypedArray,s=a?i(a):n;t.exports=s},{"./_baseIsTypedArray":205,"./_baseUnary":208,"./_nodeUtil":214}],228:[function(e,t,r){var n=e("./_arrayLikeKeys"),i=e("./_baseKeys"),o=e("./isArrayLike");t.exports=function(e){return o(e)?n(e):i(e)}},{"./_arrayLikeKeys":202,"./_baseKeys":206,"./isArrayLike":221}],229:[function(e,t,r){t.exports=function(){}},{}],230:[function(e,t,r){t.exports=function(){return!1}},{}],231:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base"),o=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function s(e,t){return e<>>32-t}function u(e,t,r,n,i,o,a){return s(e+(t&r|~t&n)+i+o|0,a)+t|0}function c(e,t,r,n,i,o,a){return s(e+(t&n|r&~n)+i+o|0,a)+t|0}function f(e,t,r,n,i,o,a){return s(e+(t^r^n)+i+o|0,a)+t|0}function h(e,t,r,n,i,o,a){return s(e+(r^(t|~n))+i+o|0,a)+t|0}n(a,i),a.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,a=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,a=u(a,r=u(r,n,i,a,e[0],3614090360,7),n,i,e[1],3905402710,12),r,n,e[2],606105819,17),a,r,e[3],3250441966,22),i=u(i,a=u(a,r=u(r,n,i,a,e[4],4118548399,7),n,i,e[5],1200080426,12),r,n,e[6],2821735955,17),a,r,e[7],4249261313,22),i=u(i,a=u(a,r=u(r,n,i,a,e[8],1770035416,7),n,i,e[9],2336552879,12),r,n,e[10],4294925233,17),a,r,e[11],2304563134,22),i=u(i,a=u(a,r=u(r,n,i,a,e[12],1804603682,7),n,i,e[13],4254626195,12),r,n,e[14],2792965006,17),a,r,e[15],1236535329,22),i=c(i,a=c(a,r=c(r,n,i,a,e[1],4129170786,5),n,i,e[6],3225465664,9),r,n,e[11],643717713,14),a,r,e[0],3921069994,20),i=c(i,a=c(a,r=c(r,n,i,a,e[5],3593408605,5),n,i,e[10],38016083,9),r,n,e[15],3634488961,14),a,r,e[4],3889429448,20),i=c(i,a=c(a,r=c(r,n,i,a,e[9],568446438,5),n,i,e[14],3275163606,9),r,n,e[3],4107603335,14),a,r,e[8],1163531501,20),i=c(i,a=c(a,r=c(r,n,i,a,e[13],2850285829,5),n,i,e[2],4243563512,9),r,n,e[7],1735328473,14),a,r,e[12],2368359562,20),i=f(i,a=f(a,r=f(r,n,i,a,e[5],4294588738,4),n,i,e[8],2272392833,11),r,n,e[11],1839030562,16),a,r,e[14],4259657740,23),i=f(i,a=f(a,r=f(r,n,i,a,e[1],2763975236,4),n,i,e[4],1272893353,11),r,n,e[7],4139469664,16),a,r,e[10],3200236656,23),i=f(i,a=f(a,r=f(r,n,i,a,e[13],681279174,4),n,i,e[0],3936430074,11),r,n,e[3],3572445317,16),a,r,e[6],76029189,23),i=f(i,a=f(a,r=f(r,n,i,a,e[9],3654602809,4),n,i,e[12],3873151461,11),r,n,e[15],530742520,16),a,r,e[2],3299628645,23),i=h(i,a=h(a,r=h(r,n,i,a,e[0],4096336452,6),n,i,e[7],1126891415,10),r,n,e[14],2878612391,15),a,r,e[5],4237533241,21),i=h(i,a=h(a,r=h(r,n,i,a,e[12],1700485571,6),n,i,e[3],2399980690,10),r,n,e[10],4293915773,15),a,r,e[1],2240044497,21),i=h(i,a=h(a,r=h(r,n,i,a,e[8],1873313359,6),n,i,e[15],4264355552,10),r,n,e[6],2734768916,15),a,r,e[13],1309151649,21),i=h(i,a=h(a,r=h(r,n,i,a,e[4],4149444226,6),n,i,e[11],3174756917,10),r,n,e[2],718787259,15),a,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+a|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=a}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":232,inherits:180}],232:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("stream").Transform;function o(e){i.call(this),this._block=n.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}e("inherits")(o,i),o.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},o.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},o.prototype.update=function(e,t){if(function(e,t){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");n.isBuffer(e)||(e=n.from(e,t));for(var r=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},{inherits:180,"safe-buffer":290,stream:311}],233:[function(e,t,r){var n=e("bn.js"),i=e("brorand");function o(e){this.rand=e||new i.Rand}t.exports=o,o.create=function(e){return new o(e)},o.prototype._randbelow=function(e){var t=e.bitLength(),r=Math.ceil(t/8);do{var i=new n(this.rand.generate(r))}while(i.cmp(e)>=0);return i},o.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},o.prototype.test=function(e,t,r){var i=e.bitLength(),o=n.mont(e),a=new n(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var s=e.subn(1),u=0;!s.testn(u);u++);for(var c=e.shrn(u),f=s.toRed(o);t>0;t--){var h=this._randrange(new n(2),s);r&&r(h);var l=h.toRed(o).redPow(c);if(0!==l.cmp(a)&&0!==l.cmp(f)){for(var d=1;d0;t--){var f=this._randrange(new n(2),a),h=e.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(u);if(0!==l.cmp(o)&&0!==l.cmp(c)){for(var d=1;d>8,a=255&i;o?r.push(o,a):r.push(a)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},{}],236:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],237:[function(e,t,r){var n=e("bn.js"),i=e("strip-hex-prefix");t.exports=function(e){if("string"==typeof e||"number"==typeof e){var t=new n(1),r=String(e).toLowerCase().trim(),o="0x"===r.substr(0,2)||"-0x"===r.substr(0,3),a=i(r);if("-"===a.substr(0,1)&&(a=i(a.slice(1)),t=new n(-1,10)),!(a=""===a?"0":a).match(/^-?[0-9]+$/)&&a.match(/^[0-9A-Fa-f]+$/)||a.match(/^[a-fA-F]+$/)||!0===o&&a.match(/^[0-9A-Fa-f]+$/))return new n(a,16).mul(t);if((a.match(/^-?[0-9]+$/)||""===a)&&!1===o)return new n(a,10).mul(t)}else if("object"==typeof e&&e.toString&&!e.pop&&!e.push&&e.toString(10).match(/^-?[0-9]+$/)&&(e.mul||e.dividedToIntegerBy))return new n(e.toString(10),10);throw new Error("[number-to-bn] while converting number "+JSON.stringify(e)+" to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.")}},{"bn.js":236,"strip-hex-prefix":318}],238:[function(e,t,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,a,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),u=1;u0;)if(q+=r,r=e.charAt(o++),4===H?(N+=String.fromCharCode(parseInt(q,16)),H=0,c=o-1):H++,!r)break e;if('"'===r&&!L){D=F.pop()||p,N+=e.substring(c,o-1);break}if(!("\\"!==r||L||(L=!0,N+=e.substring(c,o-1),r=e.charAt(o++))))break;if(L){if(L=!1,"n"===r?N+="\n":"r"===r?N+="\r":"t"===r?N+="\t":"f"===r?N+="\f":"b"===r?N+="\b":"u"===r?(H=1,q=""):N+=r,r=e.charAt(o++),c=o-1,r)continue;break}h.lastIndex=o;var l=h.exec(e);if(!l){o=e.length+1,N+=e.substring(c,o-1);break}if(o=l.index+1,!(r=e.charAt(l.index))){N+=e.substring(c,o-1);break}}continue;case A:if(!r)continue;if("r"!==r)return W("Invalid true started with t"+r);D=E;continue;case E:if(!r)continue;if("u"!==r)return W("Invalid true started with tr"+r);D=x;continue;case x:if(!r)continue;if("e"!==r)return W("Invalid true started with tru"+r);a(!0),u(),D=F.pop()||p;continue;case k:if(!r)continue;if("a"!==r)return W("Invalid false started with f"+r);D=S;continue;case S:if(!r)continue;if("l"!==r)return W("Invalid false started with fa"+r);D=M;continue;case M:if(!r)continue;if("s"!==r)return W("Invalid false started with fal"+r);D=I;continue;case I:if(!r)continue;if("e"!==r)return W("Invalid false started with fals"+r);a(!1),u(),D=F.pop()||p;continue;case T:if(!r)continue;if("u"!==r)return W("Invalid null started with n"+r);D=U;continue;case U:if(!r)continue;if("l"!==r)return W("Invalid null started with nu"+r);D=j;continue;case j:if(!r)continue;if("l"!==r)return W("Invalid null started with nul"+r);a(null),u(),D=F.pop()||p;continue;case B:if("."!==r)return W("Leading zero not followed by .");R+=r,D=P;continue;case P:if(-1!=="0123456789".indexOf(r))R+=r;else if("."===r){if(-1!==R.indexOf("."))return W("Invalid number has two dots");R+=r}else if("e"===r||"E"===r){if(-1!==R.indexOf("e")||-1!==R.indexOf("E"))return W("Invalid number has two exponential");R+=r}else if("+"===r||"-"===r){if("e"!==n&&"E"!==n)return W("Invalid symbol in number");R+=r}else R&&(a(parseFloat(R)),u(),R=""),o--,D=F.pop()||p;continue;default:return W("Unknown state: "+D)}K>=C&&(X=0,N!==s&&N.length>f&&(W("Max buffer length exceeded: textNode"),X=Math.max(X,N.length)),R.length>f&&(W("Max buffer length exceeded: numberNode"),X=Math.max(X,R.length)),C=f-X+K);var X}),e(ce).on(function(){if(D==d)return a({}),u(),void(O=!0);D===p&&0===z||W("Unexpected end");N!==s&&(a(N),u(),N=s);O=!0})}var C,N,R,L,O,D,F,q,H,z,K,V=(C=d(function(e){return e.unshift(/^/),(t=RegExp(e.map(f("source")).join(""))).exec.bind(t);var t}),L=C(N=/(\$?)/,/([\w-_]+|\*)/,R=/(?:{([\w ]*?)})?/),O=C(N,/\["([^"]+)"\]/,R),D=C(N,/\[(\d+|\*)\]/,R),F=C(N,/()/,/{([\w ]*?)}/),q=C(/\.\./),H=C(/\./),z=C(N,/!/),K=C(/$/),function(e){return e(h(L,O,D,F),q,H,z,K)});function G(e,t){return{key:e,node:t}}var W=f("key"),Y=f("node"),X={};function Z(e){var t=e(ee).emit,r=e(te).emit,n=e(ae).emit,o=e(oe).emit;function a(e,t,r){Y(x(e))[t]=r}function s(e,r,n){e&&a(e,r,n);var i=A(G(r,n),e);return t(i),i}var u={};return u[le]=function(e,t){if(!e)return n(t),s(e,X,t);var r=function(e,t){var r=Y(x(e));return m(i,r)?s(e,v(r),t):e}(e,t),o=k(r),u=W(x(r));return a(o,u,t),A(G(u,t),o)},u[de]=function(e){return r(e),k(e)||o(Y(x(e)))},u[he]=s,u}var J=V(function(e,t,r,n,i){var a=1,s=2,f=3,l=c(W,x),d=c(Y,x);function b(e,t){return!!t[a]?p(e,x):e}function m(e){if(e==y)return y;return p(function(e){return l(e)!=X},c(e,k))}function g(){return function(e){return l(e)==X}}function w(e,t,r,n,i){var o=e(r);if(o){var a=function(e,t,r){return U(function(e,t){return t(e,r)},t,e)}(t,n,o);return i(r.substr(v(o[0])),a)}}function A(e,t){return u(w,e,t)}var E=h(A(e,M(b,function(e,t){var r=t[f];return r?p(c(u(_,S(r.split(/\W+/))),d),e):e},function(e,t){var r=t[s];return p(r&&"*"!=r?function(e){return l(e)==r}:y,e)},m)),A(t,M(function(e){if(e==y)return y;var t=g(),r=e,n=m(function(e){return i(e)}),i=h(t,r,n);return i})),A(r,M()),A(n,M(b,g)),A(i,M(function(e){return function(t){var r=e(t);return!0===r?x(t):r}})),function(e){throw o('"'+e+'" could not be tokenised')});function I(e,t){return t}function T(e,t){return E(e,t,e?T:I)}return function(e){try{return T(e,y)}catch(t){throw o('Could not compile "'+e+'" because '+t.message)}}});function $(e,t,r){var n,i;function o(e){return function(t){return t.id==e}}return{on:function(r,o){var a={listener:r,id:o||r};return t&&t.emit(e,r,a.id),n=A(a,n),i=A(r,i),this},emit:function(){!function e(t,r){t&&(x(t).apply(null,r),e(k(t),r))}(i,arguments)},un:function(t){var a;n=j(n,o(t),function(e){a=e}),a&&(i=j(i,function(e){return e==a.listener}),r&&r.emit(e,a.listener,a.id))},listeners:function(){return i},hasListener:function(e){return w(function e(t,r){return r&&(t(x(r))?x(r):e(t,k(r)))}(e?o(e):y,n))}}}var Q=1,ee=Q++,te=Q++,re=Q++,ne=Q++,ie="fail",oe=Q++,ae=Q++,se="start",ue="data",ce="end",fe=Q++,he=Q++,le=Q++,de=Q++;function pe(e,t,r){try{var n=a.parse(t)}catch(e){}return{statusCode:e,body:t,jsonBody:n,thrown:r}}function be(e,t){var r={node:e(te),path:e(ee)};function n(t,r,n){var i=e(t).emit;r.on(function(e){var t=n(e);!1!==t&&function(e,t,r){var n=B(r);e(t,I(k(T(W,n))),I(T(Y,n)))}(i,Y(t),e)},t),e("removeListener").on(function(n){n==t&&(e(n).listeners()||r.un(t))})}e("newListener").on(function(e){var i=/(node|path):(.*)/.exec(e);if(i){var o=r[i[1]];o.hasListener(e)||n(e,o,t(i[2]))}})}function ye(e,t){var r,n=/^(node|path):./,i=e(oe),o=e(ne).emit,a=e(re).emit,s=d(function(t,i){if(r[t])l(i,r[t]);else{var o=e(t),a=i[0];n.test(t)?c(o,a):o.on(a)}return r});function c(e,t,n){n=n||t;var i=f(t);return e.on(function(){var t=!1;r.forget=function(){t=!0},l(arguments,i),delete r.forget,t&&e.un(n)},n),r}function f(e){return function(){try{return e.apply(r,arguments)}catch(e){setTimeout(function(){throw e})}}}function h(t,r,n){var i;i="node"==t?function(e){return function(){var t=e.apply(this,arguments);w(t)&&(t==ge.drop?o():a(t))}}(n):n,c(function(t,r){return e(t+":"+r)}(t,r),i,n)}function p(e,t,n){return g(t)?h(e,t,n):function(e,t){for(var r in t)h(e,r,t[r])}(e,t),r}return e(ae).on(function(e){var t;r.root=(t=e,function(){return t})}),e(se).on(function(e,t){r.header=function(e){return e?t[e]:t}}),r={on:s,addListener:s,removeListener:function(t,n,o){if("done"==t)i.un(n);else if("node"==t||"path"==t)e.un(t+":"+n,o);else{var a=n;e(t).un(a)}return r},emit:e.emit,node:u(p,"node"),path:u(p,"path"),done:u(c,i),start:u(function(t,n){return e(t).on(f(n),n),r},se),fail:e(ie).on,abort:e(fe).emit,header:b,root:b,source:t}}function me(t,r,n,i,o){var a=function(){var e={},t=n("newListener"),r=n("removeListener");function n(n){return e[n]=$(n,t,r)}function i(t){return e[t]||n(t)}return["emit","on","un"].forEach(function(e){i[e]=d(function(t,r){l(r,i(t)[e])})}),i}();return r&&function(t,r,n,i,o,a,c){"use strict";var f=t(ue).emit,h=t(ie).emit,l=0,d=!0;function p(){var e=r.responseText,t=e.substr(l);t&&f(t),l=v(e)}t(fe).on(function(){r.onreadystatechange=null,r.abort()}),"onprogress"in r&&(r.onprogress=p),r.onreadystatechange=function(){function e(){try{d&&t(se).emit(r.status,(e=r.getAllResponseHeaders(),n={},e&&e.split("\r\n").forEach(function(e){var t=e.indexOf(": ");n[e.substring(0,t)]=e.substring(t+2)}),n)),d=!1}catch(e){}var e,n}switch(r.readyState){case 2:case 3:return e();case 4:e(),2==String(r.status)[0]?(p(),t(ce).emit()):h(pe(r.status,r.responseText))}};try{for(var b in r.open(n,i,!0),a)r.setRequestHeader(b,a[b]);(function(e,t){function r(t){return t.port||{"http:":80,"https:":443}[t.protocol||e.protocol]}return!!(t.protocol&&t.protocol!=e.protocol||t.host&&t.host!=e.host||t.host&&r(t)!=r(e))})(e.location,function(e){var t=/(\w+:)?(?:\/\/)([\w.-]+)?(?::(\d+))?\/?/.exec(e)||[];return{protocol:t[1]||"",host:t[2]||"",port:t[3]||""}}(i))||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.withCredentials=c,r.send(o)}catch(t){e.setTimeout(u(h,pe(s,s,t)),0)}}(a,new XMLHttpRequest,t,r,n,i,o),P(a),function(e,t){"use strict";var r,n={};function i(e){return function(t){r=e(r,t)}}for(var o in t)e(o).on(i(t[o]),n);e(re).on(function(e){var t=x(r),n=W(t),i=k(r);i&&(Y(x(i))[n]=e)}),e(ne).on(function(){var e=x(r),t=W(e),n=k(r);n&&delete Y(x(n))[t]}),e(fe).on(function(){for(var r in t)e(r).un(n)})}(a,Z(a)),be(a,J),ye(a,r)}function ve(e,t,r,n,i,o,s){return i=i?a.parse(a.stringify(i)):{},n?g(n)||(n=a.stringify(n),i["Content-Type"]=i["Content-Type"]||"application/json"):n=null,e(r||"GET",function(e,t){return!1===t&&(-1==e.indexOf("?")?e+="?":e+="&",e+="_="+(new Date).getTime()),e}(t,s),n,i,o||!1)}function ge(e){var t=M("resume","pause","pipe"),r=u(_,t);return e?r(e)||g(e)?ve(me,e):ve(me,e.url,e.method,e.body,e.headers,e.withCredentials,e.cached):me()}ge.drop=function(){return ge.drop},"function"==typeof define&&define.amd?define("oboe",[],function(){return ge}):"object"==typeof r?t.exports=ge:e.oboe=ge}(function(){try{return window}catch(e){return self}}(),Object,Array,Error,JSON)},{}],240:[function(e,t,r){r.endianness=function(){return"LE"},r.hostname=function(){return"undefined"!=typeof location?location.hostname:""},r.loadavg=function(){return[]},r.uptime=function(){return 0},r.freemem=function(){return Number.MAX_VALUE},r.totalmem=function(){return Number.MAX_VALUE},r.cpus=function(){return[]},r.type=function(){return"Browser"},r.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},r.networkInterfaces=r.getNetworkInterfaces=function(){return{}},r.arch=function(){return"javascript"},r.platform=function(){return"browser"},r.tmpdir=r.tmpDir=function(){return"/tmp"},r.EOL="\n",r.homedir=function(){return"/"}},{}],241:[function(e,t,r){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],242:[function(e,t,r){"use strict";var n=e("asn1.js");r.certificate=e("./certificate");var i=n.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});r.RSAPrivateKey=i;var o=n.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});r.RSAPublicKey=o;var a=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())});r.PublicKey=a;var s=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),u=n.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(s),this.key("subjectPrivateKey").octstr())});r.PrivateKey=u;var c=n.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});r.EncryptedPrivateKey=c;var f=n.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});r.DSAPrivateKey=f,r.DSAparam=n.define("DSAparam",function(){this.int()});var h=n.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(l),this.key("publicKey").optional().explicit(1).bitstr())});r.ECPrivateKey=h;var l=n.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});r.signature=n.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},{"./certificate":243,"asn1.js":5}],243:[function(e,t,r){"use strict";var n=e("asn1.js"),i=n.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),o=n.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),a=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional())}),s=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())}),u=n.define("RelativeDistinguishedName",function(){this.setof(o)}),c=n.define("RDNSequence",function(){this.seqof(u)}),f=n.define("Name",function(){this.choice({rdnSequence:this.use(c)})}),h=n.define("Validity",function(){this.seq().obj(this.key("notBefore").use(i),this.key("notAfter").use(i))}),l=n.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),d=n.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int(),this.key("serialNumber").int(),this.key("signature").use(a),this.key("issuer").use(f),this.key("validity").use(h),this.key("subject").use(f),this.key("subjectPublicKeyInfo").use(s),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(l).optional())}),p=n.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(a),this.key("signatureValue").bitstr())});t.exports=p},{"asn1.js":5}],244:[function(e,t,r){(function(r){var n=/Proc-Type: 4,ENCRYPTED\n\r?DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\n\r?\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?/m,i=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n/m,o=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?-----END \1-----$/m,a=e("evp_bytestokey"),s=e("browserify-aes");t.exports=function(e,t){var u,c=e.toString(),f=c.match(n);if(f){var h="aes"+f[1],l=new r(f[2],"hex"),d=new r(f[3].replace(/\r?\n/g,""),"base64"),p=a(t,l.slice(0,8),parseInt(f[1],10)).key,b=[],y=s.createDecipheriv(h,p,l);b.push(y.update(d)),b.push(y.final()),u=r.concat(b)}else{var m=c.match(o);u=new r(m[2].replace(/\r?\n/g,""),"base64")}return{tag:c.match(i)[1],data:u}}}).call(this,e("buffer").Buffer)},{"browserify-aes":58,buffer:84,evp_bytestokey:158}],245:[function(e,t,r){(function(r){var n=e("./asn1"),i=e("./aesid.json"),o=e("./fixProc"),a=e("browserify-aes"),s=e("pbkdf2");function u(e){var t;"object"!=typeof e||r.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=new r(e));var u,c,f=o(e,t),h=f.tag,l=f.data;switch(h){case"CERTIFICATE":c=n.certificate.decode(l,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(c||(c=n.PublicKey.decode(l,"der")),u=c.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPublicKey.decode(c.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return c.subjectPrivateKey=c.subjectPublicKey,{type:"ec",data:c};case"1.2.840.10040.4.1":return c.algorithm.params.pub_key=n.DSAparam.decode(c.subjectPublicKey.data,"der"),{type:"dsa",data:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"ENCRYPTED PRIVATE KEY":l=function(e,t){var n=e.algorithm.decrypt.kde.kdeparams.salt,o=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),u=i[e.algorithm.decrypt.cipher.algo.join(".")],c=e.algorithm.decrypt.cipher.iv,f=e.subjectPrivateKey,h=parseInt(u.split("-")[1],10)/8,l=s.pbkdf2Sync(t,n,o,h),d=a.createDecipheriv(u,l,c),p=[];return p.push(d.update(f)),p.push(d.final()),r.concat(p)}(l=n.EncryptedPrivateKey.decode(l,"der"),t);case"PRIVATE KEY":switch(u=(c=n.PrivateKey.decode(l,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPrivateKey.decode(c.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:c.algorithm.curve,privateKey:n.ECPrivateKey.decode(c.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return c.algorithm.params.priv_key=n.DSAparam.decode(c.subjectPrivateKey,"der"),{type:"dsa",params:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"RSA PUBLIC KEY":return n.RSAPublicKey.decode(l,"der");case"RSA PRIVATE KEY":return n.RSAPrivateKey.decode(l,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:n.DSAPrivateKey.decode(l,"der")};case"EC PRIVATE KEY":return{curve:(l=n.ECPrivateKey.decode(l,"der")).parameters.value,privateKey:l.privateKey};default:throw new Error("unknown key type "+h)}}t.exports=u,u.signature=n.signature}).call(this,e("buffer").Buffer)},{"./aesid.json":241,"./asn1":242,"./fixProc":244,"browserify-aes":58,buffer:84,pbkdf2:247}],246:[function(e,t,r){var n=e("trim"),i=e("for-each");t.exports=function(e){if(!e)return{};var t={};return i(n(e).split("\n"),function(e){var r,i=e.indexOf(":"),o=n(e.slice(0,i)).toLowerCase(),a=n(e.slice(i+1));void 0===t[o]?t[o]=a:(r=t[o],"[object Array]"===Object.prototype.toString.call(r)?t[o].push(a):t[o]=[t[o],a])}),t}},{"for-each":159,trim:324}],247:[function(e,t,r){r.pbkdf2=e("./lib/async"),r.pbkdf2Sync=e("./lib/sync")},{"./lib/async":248,"./lib/sync":251}],248:[function(e,t,r){(function(r,n){var i,o=e("./precondition"),a=e("./default-encoding"),s=e("./sync"),u=e("safe-buffer").Buffer,c=n.crypto&&n.crypto.subtle,f={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},h=[];function l(e,t,r,n,i){return c.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then(function(e){return c.deriveBits({name:"PBKDF2",salt:t,iterations:r,hash:{name:i}},e,n<<3)}).then(function(e){return u.from(e)})}t.exports=function(e,t,d,p,b,y){if(u.isBuffer(e)||(e=u.from(e,a)),u.isBuffer(t)||(t=u.from(t,a)),o(d,p),"function"==typeof b&&(y=b,b=void 0),"function"!=typeof y)throw new Error("No callback provided to pbkdf2");var m=f[(b=b||"sha1").toLowerCase()];if(!m||"function"!=typeof n.Promise)return r.nextTick(function(){var r;try{r=s(e,t,d,p,b)}catch(e){return y(e)}y(null,r)});!function(e,t){e.then(function(e){r.nextTick(function(){t(null,e)})},function(e){r.nextTick(function(){t(e)})})}(function(e){if(n.process&&!n.process.browser)return Promise.resolve(!1);if(!c||!c.importKey||!c.deriveBits)return Promise.resolve(!1);if(void 0!==h[e])return h[e];var t=l(i=i||u.alloc(8),i,10,128,e).then(function(){return!0}).catch(function(){return!1});return h[e]=t,t}(m).then(function(r){return r?l(e,t,d,p,m):s(e,t,d,p,b)}),y)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-encoding":249,"./precondition":250,"./sync":251,_process:257,"safe-buffer":290}],249:[function(e,t,r){(function(e){var r;e.browser?r="utf-8":r=parseInt(e.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary";t.exports=r}).call(this,e("_process"))},{_process:257}],250:[function(e,t,r){var n=Math.pow(2,30)-1;t.exports=function(e,t){if("number"!=typeof e)throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if("number"!=typeof t)throw new TypeError("Key length not a number");if(t<0||t>n||t!=t)throw new TypeError("Bad key length")}},{}],251:[function(e,t,r){var n=e("create-hash/md5"),i=e("ripemd160"),o=e("sha.js"),a=e("./precondition"),s=e("./default-encoding"),u=e("safe-buffer").Buffer,c=u.alloc(128),f={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function h(e,t,r){var a=function(e){return"rmd160"===e||"ripemd160"===e?i:"md5"===e?n:function(t){return o(e).update(t).digest()}}(e),s="sha512"===e||"sha384"===e?128:64;t.length>s?t=a(t):t.length1)for(var r=1;rp||new a(t).cmp(d.modulus)>=0)throw new Error("decryption error");l=f?c(new a(t),d):s(t,d);var b=new r(p-l.length);if(b.fill(0),l=r.concat([b,l],p),4===h)return function(e,t){e.modulus;var n=e.modulus.byteLength(),a=(t.length,u("sha1").update(new r("")).digest()),s=a.length;if(0!==t[0])throw new Error("decryption error");var c=t.slice(1,s+1),f=t.slice(s+1),h=o(c,i(f,s)),l=o(f,i(h,n-s-1));if(function(e,t){e=new r(e),t=new r(t);var n=0,i=e.length;e.length!==t.length&&(n++,i=Math.min(e.length,t.length));var o=-1;for(;++o=t.length){o++;break}var a=t.slice(2,i-1);t.slice(i-1,i);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;a.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,l,f);if(3===h)return l;throw new Error("unknown padding")}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245}],262:[function(e,t,r){(function(r){var n=e("parse-asn1"),i=e("randombytes"),o=e("create-hash"),a=e("./mgf"),s=e("./xor"),u=e("bn.js"),c=e("./withPublic"),f=e("browserify-rsa");t.exports=function(e,t,h){var l;l=e.padding?e.padding:h?1:4;var d,p=n(e);if(4===l)d=function(e,t){var n=e.modulus.byteLength(),c=t.length,f=o("sha1").update(new r("")).digest(),h=f.length,l=2*h;if(c>n-l-2)throw new Error("message too long");var d=new r(n-c-l-2);d.fill(0);var p=n-h-1,b=i(h),y=s(r.concat([f,d,new r([1]),t],p),a(b,p)),m=s(b,a(y,h));return new u(r.concat([new r([0]),m,y],n))}(p,t);else if(1===l)d=function(e,t,n){var o,a=t.length,s=e.modulus.byteLength();if(a>s-11)throw new Error("message too long");n?(o=new r(s-a-3)).fill(255):o=function(e,t){var n,o=new r(e),a=0,s=i(2*e),u=0;for(;a=0)throw new Error("data too long for modulus")}return h?f(d,p):c(d,p)}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245,randombytes:270}],263:[function(e,t,r){(function(r){var n=e("bn.js");t.exports=function(e,t){return new r(e.toRed(n.mont(t.modulus)).redPow(new n(t.publicExponent)).fromRed().toArray())}}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84}],264:[function(e,t,r){t.exports=function(e,t){for(var r=e.length,n=-1;++n= 0x80 (not a basic code point)","invalid-input":"Invalid input"},A=f-h,E=Math.floor,x=String.fromCharCode;function k(e){throw new RangeError(_[e])}function S(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function M(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+S((e=e.replace(w,".")).split("."),t).join(".")}function I(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=x((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=x(e)}).join("")}function U(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function j(e,t,r){var n=0;for(e=r?E(e/p):e>>1,e+=E(e/t);e>A*l>>1;n+=f)e=E(e/A);return E(n+(A+1)*e/(e+d))}function B(e){var t,r,n,i,o,a,s,u,d,p,v,g=[],w=e.length,_=0,A=y,x=b;for((r=e.lastIndexOf(m))<0&&(r=0),n=0;n=128&&k("not-basic"),g.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=w&&k("invalid-input"),((u=(v=e.charCodeAt(i++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:f)>=f||u>E((c-_)/a))&&k("overflow"),_+=u*a,!(u<(d=s<=x?h:s>=x+l?l:s-x));s+=f)a>E(c/(p=f-d))&&k("overflow"),a*=p;x=j(_-o,t=g.length+1,0==o),E(_/t)>c-A&&k("overflow"),A+=E(_/t),_%=t,g.splice(_++,0,A)}return T(g)}function P(e){var t,r,n,i,o,a,s,u,d,p,v,g,w,_,A,S=[];for(g=(e=I(e)).length,t=y,r=0,o=b,a=0;a=t&&vE((c-r)/(w=n+1))&&k("overflow"),r+=(s-t)*w,t=s,a=0;ac&&k("overflow"),v==t){for(u=r,d=f;!(u<(p=d<=o?h:d>=o+l?l:d-o));d+=f)A=u-p,_=f-p,S.push(x(U(p+A%_,0))),u=E(A/_);S.push(x(U(u,0))),o=j(r,w,n==i),r=0,++n}++r,++t}return S.join("")}if(s={version:"1.4.1",ucs2:{decode:I,encode:T},decode:B,encode:P,toASCII:function(e){return M(e,function(e){return g.test(e)?"xn--"+P(e):e})},toUnicode:function(e){return M(e,function(e){return v.test(e)?B(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return s});else if(i&&o)if(t.exports==i)o.exports=s;else for(u in s)s.hasOwnProperty(u)&&(i[u]=s[u]);else n.punycode=s}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],266:[function(e,t,r){"use strict";var n=e("strict-uri-encode"),i=e("object-assign"),o=e("decode-uri-component");function a(e,t){return t.encode?t.strict?n(e):encodeURIComponent(e):e}function s(e){var t=e.indexOf("?");return-1===t?"":e.slice(t+1)}function u(e,t){var r=function(e){var t;switch(e.arrayFormat){case"index":return function(e,r,n){t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return function(e,r,n){t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};default:return function(e,t,r){void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t=i({arrayFormat:"none"},t)),n=Object.create(null);return"string"!=typeof e?n:(e=e.trim().replace(/^[?#&]/,""))?(e.split("&").forEach(function(e){var t=e.replace(/\+/g," ").split("="),i=t.shift(),a=t.length>0?t.join("="):void 0;a=void 0===a?null:o(a),r(o(i),a,n)}),Object.keys(n).sort().reduce(function(e,t){var r=n[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=function e(t){return Array.isArray(t)?t.sort():"object"==typeof t?e(Object.keys(t)).sort(function(e,t){return Number(e)-Number(t)}).map(function(e){return t[e]}):t}(r):e[t]=r,e},Object.create(null))):n}r.extract=s,r.parse=u,r.stringify=function(e,t){!1===(t=i({encode:!0,strict:!0,arrayFormat:"none"},t)).sort&&(t.sort=function(){});var r=function(e){switch(e.arrayFormat){case"index":return function(t,r,n){return null===r?[a(t,e),"[",n,"]"].join(""):[a(t,e),"[",a(n,e),"]=",a(r,e)].join("")};case"bracket":return function(t,r){return null===r?a(t,e):[a(t,e),"[]=",a(r,e)].join("")};default:return function(t,r){return null===r?a(t,e):[a(t,e),"=",a(r,e)].join("")}}}(t);return e?Object.keys(e).sort(t.sort).map(function(n){var i=e[n];if(void 0===i)return"";if(null===i)return a(n,t);if(Array.isArray(i)){var o=[];return i.slice().forEach(function(e){void 0!==e&&o.push(r(n,e,o.length))}),o.join("&")}return a(n,t)+"="+a(i,t)}).filter(function(e){return e.length>0}).join("&"):""},r.parseUrl=function(e,t){return{url:e.split("?")[0]||"",query:u(s(e),t)}}},{"decode-uri-component":98,"object-assign":238,"strict-uri-encode":316}],267:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&",r=r||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(a,d)?i(a[d])?a[d].push(p):a[d]=[a[d],p]:a[d]=p}return a};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],268:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,s){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),function(a){var s=encodeURIComponent(n(a))+r;return i(e[a])?o(e[a],function(e){return s+encodeURIComponent(n(e))}).join(t):s+encodeURIComponent(n(e[a]))}).join(t):s?encodeURIComponent(n(s))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n65536)throw new Error("requested too many random bytes");var a=new n.Uint8Array(e);e>0&&o.getRandomValues(a);var s=i.from(a.buffer);if("function"==typeof t)return r.nextTick(function(){t(null,s)});return s}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,"safe-buffer":290}],271:[function(e,t,r){(function(t,n){"use strict";function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=e("safe-buffer"),a=e("randombytes"),s=o.Buffer,u=o.kMaxLength,c=n.crypto||n.msCrypto,f=Math.pow(2,32)-1;function h(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>f||e<0)throw new TypeError("offset must be a uint32");if(e>u||e>t)throw new RangeError("offset out of range")}function l(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>f||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>u)throw new RangeError("buffer too small")}function d(e,r,n,i){if(t.browser){var o=e.buffer,s=new Uint8Array(o,r,n);return c.getRandomValues(s),i?void t.nextTick(function(){i(null,e)}):e}if(!i)return a(n).copy(e,r),e;a(n,function(t,n){if(t)return i(t);n.copy(e,r),i(null,e)})}c&&c.getRandomValues||!t.browser?(r.randomFill=function(e,t,r,i){if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)i=t,t=0,r=e.length;else if("function"==typeof r)i=r,r=e.length-t;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return h(t,e.length),l(r,t,e.length),d(e,t,r,i)},r.randomFillSync=function(e,t,r){void 0===t&&(t=0);if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');h(t,e.length),void 0===r&&(r=e.length-t);return l(r,t,e.length),d(e,t,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,randombytes:270,"safe-buffer":290}],272:[function(e,t,r){t.exports=window.crypto},{}],273:[function(e,t,r){t.exports=e("crypto")},{crypto:272}],274:[function(e,t,r){t.exports=function(t,r){var n=e("./crypto.js"),i="function"==typeof r;if(t>65536){if(!i)throw new Error("Requested too many random bytes.");r(new Error("Requested too many random bytes."))}if(void 0!==n&&n.randomBytes){if(!i)return"0x"+n.randomBytes(t).toString("hex");n.randomBytes(t,function(e,t){e?r(u):r(null,"0x"+t.toString("hex"))})}else{var o;if(void 0!==n?o=n:"undefined"!=typeof msCrypto&&(o=msCrypto),o&&o.getRandomValues){var a=o.getRandomValues(new Uint8Array(t)),s="0x"+Array.from(a).map(function(e){return e.toString(16)}).join("");if(!i)return s;r(null,s)}else{var u=new Error('No "crypto" object available. This Browser doesn\'t support generating secure random bytes.');if(!i)throw u;r(u)}}}},{"./crypto.js":273}],275:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":276}],276:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick,i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=h;var o=e("core-util-is");o.inherits=e("inherits");var a=e("./_stream_readable"),s=e("./_stream_writable");o.inherits(h,a);for(var u=i(s.prototype),c=0;c0?("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),n?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):_(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?_(e,a,t,!1):S(e,a)):_(e,a,t,!1))):n||(a.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=A?e=A:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(d("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i(k,e):k(e))}function k(e){d("emit readable"),e.emit("readable"),U(e)}function S(e,t){t.readingMore||(t.readingMore=!0,i(M,e,t))}function M(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=c.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,a),0===(e-=a)){a===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function B(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i(P,t,e))}function P(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function C(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return d("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?B(this):x(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&B(this),null;var n,i=t.needReadable;return d("need readable",i),(0===t.length||t.length-e0?j(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&B(this)),null!==n&&this.emit("data",n),n},g.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},g.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,d("pipe count=%d opts=%j",o.pipesCount,t);var u=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?f:g;function c(t,r){d("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,d("cleanup"),e.removeListener("close",m),e.removeListener("finish",v),e.removeListener("drain",h),e.removeListener("error",y),e.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",g),n.removeListener("data",b),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||h())}function f(){d("onend"),e.end()}o.endEmitted?i(u):n.once("end",u),e.on("unpipe",c);var h=function(e){return function(){var t=e._readableState;d("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,U(e))}}(n);e.on("drain",h);var l=!1;var p=!1;function b(t){d("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==C(o.pipes,e))&&!l&&(d("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(t){d("onerror",t),g(),e.removeListener("error",y),0===s(e,"error")&&e.emit("error",t)}function m(){e.removeListener("finish",v),g()}function v(){d("onfinish"),e.removeListener("close",m),g()}function g(){d("unpipe"),n.unpipe(e)}return n.on("data",b),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?a(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",y),e.once("close",m),e.once("finish",v),e.emit("pipe",n),o.flowing||(d("pipe resume"),n.resume()),e},g.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:i;m.WritableState=y;var u=e("core-util-is");u.inherits=e("inherits");var c={deprecate:e("util-deprecate")},f=e("./internal/streams/stream"),h=e("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=e("./internal/streams/destroy");function b(){}function y(t,r){a=a||e("./_stream_duplex"),t=t||{};var n=r instanceof a;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var u=t.highWaterMark,c=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=u||0===u?u:n&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===t.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,o=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,o){--t.pendingcb,r?(i(o,n),i(E,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(o(n),e._writableState.errorEmitted=!0,e.emit("error",n),E(e,t))}(e,r,n,t,o);else{var a=_(r);a||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),n?s(g,e,r,a,o):g(e,r,a,o)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function m(t){if(a=a||e("./_stream_duplex"),!(d.call(m,this)||this instanceof a))return new m(t);this._writableState=new y(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),f.call(this)}function v(e,t,r,n,i,o,a){t.writelen=n,t.writecb=a,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function g(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),E(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),a=t.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,v(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,h=r.callback;if(v(e,t,!1,t.objectMode?1:c.length,c,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function A(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),E(e,t)})}function E(e,t){var r=_(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,i(A,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}u.inherits(m,f),y.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(y.prototype,"buffer",{get:c.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===m&&(e&&e._writableState instanceof y)}})):d=function(e){return e instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(e,t,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=e,h.isBuffer(n)||n instanceof l);return s&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof r&&(r=b),o.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),i(t,r)}(this,r):(s||function(e,t,r,n){var o=!0,a=!1;return null===r?a=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),i(n,a),o=!1),o}(this,o,e,r))&&(o.pendingcb++,a=function(e,t,r,n,i,o){if(!r){var a=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,r));return t}(t,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=t.objectMode?1:n.length;t.length+=s;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},m.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,E(e,t),r&&(t.finished?i(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),m.prototype.destroy=p.destroy,m.prototype._undestroy=p.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":276,"./internal/streams/destroy":282,"./internal/streams/stream":283,_process:257,"core-util-is":89,inherits:180,"process-nextick-args":256,"safe-buffer":290,"util-deprecate":330}],281:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,i,o=n.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,r=o,i=s,t.copy(r,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":290,util:55}],282:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick;function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var r=this,o=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return o||a?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||n(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n(i,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":256}],283:[function(e,t,r){t.exports=e("events").EventEmitter},{events:157}],284:[function(e,t,r){t.exports=e("./readable").PassThrough},{"./readable":285}],285:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":276,"./lib/_stream_passthrough.js":277,"./lib/_stream_readable.js":278,"./lib/_stream_transform.js":279,"./lib/_stream_writable.js":280}],286:[function(e,t,r){t.exports=e("./readable").Transform},{"./readable":285}],287:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":280}],288:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base");function o(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function a(e,t){return e<>>32-t}function s(e,t,r,n,i,o,s,u){return a(e+(t^r^n)+o+s|0,u)+i|0}function u(e,t,r,n,i,o,s,u){return a(e+(t&r|~t&n)+o+s|0,u)+i|0}function c(e,t,r,n,i,o,s,u){return a(e+((t|~r)^n)+o+s|0,u)+i|0}function f(e,t,r,n,i,o,s,u){return a(e+(t&n|r&~n)+o+s|0,u)+i|0}function h(e,t,r,n,i,o,s,u){return a(e+(t^(r|~n))+o+s|0,u)+i|0}n(o,i),o.prototype._update=function(){for(var e=new Array(16),t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,o=this._d,l=this._e;l=s(l,r=s(r,n,i,o,l,e[0],0,11),n,i=a(i,10),o,e[1],0,14),n=s(n=a(n,10),i=s(i,o=s(o,l,r,n,i,e[2],0,15),l,r=a(r,10),n,e[3],0,12),o,l=a(l,10),r,e[4],0,5),o=s(o=a(o,10),l=s(l,r=s(r,n,i,o,l,e[5],0,8),n,i=a(i,10),o,e[6],0,7),r,n=a(n,10),i,e[7],0,9),r=s(r=a(r,10),n=s(n,i=s(i,o,l,r,n,e[8],0,11),o,l=a(l,10),r,e[9],0,13),i,o=a(o,10),l,e[10],0,14),i=s(i=a(i,10),o=s(o,l=s(l,r,n,i,o,e[11],0,15),r,n=a(n,10),i,e[12],0,6),l,r=a(r,10),n,e[13],0,7),l=u(l=a(l,10),r=s(r,n=s(n,i,o,l,r,e[14],0,9),i,o=a(o,10),l,e[15],0,8),n,i=a(i,10),o,e[7],1518500249,7),n=u(n=a(n,10),i=u(i,o=u(o,l,r,n,i,e[4],1518500249,6),l,r=a(r,10),n,e[13],1518500249,8),o,l=a(l,10),r,e[1],1518500249,13),o=u(o=a(o,10),l=u(l,r=u(r,n,i,o,l,e[10],1518500249,11),n,i=a(i,10),o,e[6],1518500249,9),r,n=a(n,10),i,e[15],1518500249,7),r=u(r=a(r,10),n=u(n,i=u(i,o,l,r,n,e[3],1518500249,15),o,l=a(l,10),r,e[12],1518500249,7),i,o=a(o,10),l,e[0],1518500249,12),i=u(i=a(i,10),o=u(o,l=u(l,r,n,i,o,e[9],1518500249,15),r,n=a(n,10),i,e[5],1518500249,9),l,r=a(r,10),n,e[2],1518500249,11),l=u(l=a(l,10),r=u(r,n=u(n,i,o,l,r,e[14],1518500249,7),i,o=a(o,10),l,e[11],1518500249,13),n,i=a(i,10),o,e[8],1518500249,12),n=c(n=a(n,10),i=c(i,o=c(o,l,r,n,i,e[3],1859775393,11),l,r=a(r,10),n,e[10],1859775393,13),o,l=a(l,10),r,e[14],1859775393,6),o=c(o=a(o,10),l=c(l,r=c(r,n,i,o,l,e[4],1859775393,7),n,i=a(i,10),o,e[9],1859775393,14),r,n=a(n,10),i,e[15],1859775393,9),r=c(r=a(r,10),n=c(n,i=c(i,o,l,r,n,e[8],1859775393,13),o,l=a(l,10),r,e[1],1859775393,15),i,o=a(o,10),l,e[2],1859775393,14),i=c(i=a(i,10),o=c(o,l=c(l,r,n,i,o,e[7],1859775393,8),r,n=a(n,10),i,e[0],1859775393,13),l,r=a(r,10),n,e[6],1859775393,6),l=c(l=a(l,10),r=c(r,n=c(n,i,o,l,r,e[13],1859775393,5),i,o=a(o,10),l,e[11],1859775393,12),n,i=a(i,10),o,e[5],1859775393,7),n=f(n=a(n,10),i=f(i,o=c(o,l,r,n,i,e[12],1859775393,5),l,r=a(r,10),n,e[1],2400959708,11),o,l=a(l,10),r,e[9],2400959708,12),o=f(o=a(o,10),l=f(l,r=f(r,n,i,o,l,e[11],2400959708,14),n,i=a(i,10),o,e[10],2400959708,15),r,n=a(n,10),i,e[0],2400959708,14),r=f(r=a(r,10),n=f(n,i=f(i,o,l,r,n,e[8],2400959708,15),o,l=a(l,10),r,e[12],2400959708,9),i,o=a(o,10),l,e[4],2400959708,8),i=f(i=a(i,10),o=f(o,l=f(l,r,n,i,o,e[13],2400959708,9),r,n=a(n,10),i,e[3],2400959708,14),l,r=a(r,10),n,e[7],2400959708,5),l=f(l=a(l,10),r=f(r,n=f(n,i,o,l,r,e[15],2400959708,6),i,o=a(o,10),l,e[14],2400959708,8),n,i=a(i,10),o,e[5],2400959708,6),n=h(n=a(n,10),i=f(i,o=f(o,l,r,n,i,e[6],2400959708,5),l,r=a(r,10),n,e[2],2400959708,12),o,l=a(l,10),r,e[4],2840853838,9),o=h(o=a(o,10),l=h(l,r=h(r,n,i,o,l,e[0],2840853838,15),n,i=a(i,10),o,e[5],2840853838,5),r,n=a(n,10),i,e[9],2840853838,11),r=h(r=a(r,10),n=h(n,i=h(i,o,l,r,n,e[7],2840853838,6),o,l=a(l,10),r,e[12],2840853838,8),i,o=a(o,10),l,e[2],2840853838,13),i=h(i=a(i,10),o=h(o,l=h(l,r,n,i,o,e[10],2840853838,12),r,n=a(n,10),i,e[14],2840853838,5),l,r=a(r,10),n,e[1],2840853838,12),l=h(l=a(l,10),r=h(r,n=h(n,i,o,l,r,e[3],2840853838,13),i,o=a(o,10),l,e[8],2840853838,14),n,i=a(i,10),o,e[11],2840853838,11),n=h(n=a(n,10),i=h(i,o=h(o,l,r,n,i,e[6],2840853838,8),l,r=a(r,10),n,e[15],2840853838,5),o,l=a(l,10),r,e[13],2840853838,6),o=a(o,10);var d=this._a,p=this._b,b=this._c,y=this._d,m=this._e;m=h(m,d=h(d,p,b,y,m,e[5],1352829926,8),p,b=a(b,10),y,e[14],1352829926,9),p=h(p=a(p,10),b=h(b,y=h(y,m,d,p,b,e[7],1352829926,9),m,d=a(d,10),p,e[0],1352829926,11),y,m=a(m,10),d,e[9],1352829926,13),y=h(y=a(y,10),m=h(m,d=h(d,p,b,y,m,e[2],1352829926,15),p,b=a(b,10),y,e[11],1352829926,15),d,p=a(p,10),b,e[4],1352829926,5),d=h(d=a(d,10),p=h(p,b=h(b,y,m,d,p,e[13],1352829926,7),y,m=a(m,10),d,e[6],1352829926,7),b,y=a(y,10),m,e[15],1352829926,8),b=h(b=a(b,10),y=h(y,m=h(m,d,p,b,y,e[8],1352829926,11),d,p=a(p,10),b,e[1],1352829926,14),m,d=a(d,10),p,e[10],1352829926,14),m=f(m=a(m,10),d=h(d,p=h(p,b,y,m,d,e[3],1352829926,12),b,y=a(y,10),m,e[12],1352829926,6),p,b=a(b,10),y,e[6],1548603684,9),p=f(p=a(p,10),b=f(b,y=f(y,m,d,p,b,e[11],1548603684,13),m,d=a(d,10),p,e[3],1548603684,15),y,m=a(m,10),d,e[7],1548603684,7),y=f(y=a(y,10),m=f(m,d=f(d,p,b,y,m,e[0],1548603684,12),p,b=a(b,10),y,e[13],1548603684,8),d,p=a(p,10),b,e[5],1548603684,9),d=f(d=a(d,10),p=f(p,b=f(b,y,m,d,p,e[10],1548603684,11),y,m=a(m,10),d,e[14],1548603684,7),b,y=a(y,10),m,e[15],1548603684,7),b=f(b=a(b,10),y=f(y,m=f(m,d,p,b,y,e[8],1548603684,12),d,p=a(p,10),b,e[12],1548603684,7),m,d=a(d,10),p,e[4],1548603684,6),m=f(m=a(m,10),d=f(d,p=f(p,b,y,m,d,e[9],1548603684,15),b,y=a(y,10),m,e[1],1548603684,13),p,b=a(b,10),y,e[2],1548603684,11),p=c(p=a(p,10),b=c(b,y=c(y,m,d,p,b,e[15],1836072691,9),m,d=a(d,10),p,e[5],1836072691,7),y,m=a(m,10),d,e[1],1836072691,15),y=c(y=a(y,10),m=c(m,d=c(d,p,b,y,m,e[3],1836072691,11),p,b=a(b,10),y,e[7],1836072691,8),d,p=a(p,10),b,e[14],1836072691,6),d=c(d=a(d,10),p=c(p,b=c(b,y,m,d,p,e[6],1836072691,6),y,m=a(m,10),d,e[9],1836072691,14),b,y=a(y,10),m,e[11],1836072691,12),b=c(b=a(b,10),y=c(y,m=c(m,d,p,b,y,e[8],1836072691,13),d,p=a(p,10),b,e[12],1836072691,5),m,d=a(d,10),p,e[2],1836072691,14),m=c(m=a(m,10),d=c(d,p=c(p,b,y,m,d,e[10],1836072691,13),b,y=a(y,10),m,e[0],1836072691,13),p,b=a(b,10),y,e[4],1836072691,7),p=u(p=a(p,10),b=u(b,y=c(y,m,d,p,b,e[13],1836072691,5),m,d=a(d,10),p,e[8],2053994217,15),y,m=a(m,10),d,e[6],2053994217,5),y=u(y=a(y,10),m=u(m,d=u(d,p,b,y,m,e[4],2053994217,8),p,b=a(b,10),y,e[1],2053994217,11),d,p=a(p,10),b,e[3],2053994217,14),d=u(d=a(d,10),p=u(p,b=u(b,y,m,d,p,e[11],2053994217,14),y,m=a(m,10),d,e[15],2053994217,6),b,y=a(y,10),m,e[0],2053994217,14),b=u(b=a(b,10),y=u(y,m=u(m,d,p,b,y,e[5],2053994217,6),d,p=a(p,10),b,e[12],2053994217,9),m,d=a(d,10),p,e[2],2053994217,12),m=u(m=a(m,10),d=u(d,p=u(p,b,y,m,d,e[13],2053994217,9),b,y=a(y,10),m,e[9],2053994217,12),p,b=a(b,10),y,e[7],2053994217,5),p=s(p=a(p,10),b=u(b,y=u(y,m,d,p,b,e[10],2053994217,15),m,d=a(d,10),p,e[14],2053994217,8),y,m=a(m,10),d,e[12],0,8),y=s(y=a(y,10),m=s(m,d=s(d,p,b,y,m,e[15],0,5),p,b=a(b,10),y,e[10],0,12),d,p=a(p,10),b,e[4],0,9),d=s(d=a(d,10),p=s(p,b=s(b,y,m,d,p,e[1],0,12),y,m=a(m,10),d,e[5],0,5),b,y=a(y,10),m,e[8],0,14),b=s(b=a(b,10),y=s(y,m=s(m,d,p,b,y,e[7],0,6),d,p=a(p,10),b,e[6],0,8),m,d=a(d,10),p,e[2],0,13),m=s(m=a(m,10),d=s(d,p=s(p,b,y,m,d,e[13],0,6),b,y=a(y,10),m,e[14],0,5),p,b=a(b,10),y,e[0],0,15),p=s(p=a(p,10),b=s(b,y=s(y,m,d,p,b,e[3],0,13),m,d=a(d,10),p,e[9],0,11),y,m=a(m,10),d,e[11],0,11),y=a(y,10);var v=this._b+i+y|0;this._b=this._c+o+m|0,this._c=this._d+l+d|0,this._d=this._e+r+p|0,this._e=this._a+n+b|0,this._a=v},o.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=o}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":161,inherits:180}],289:[function(e,t,r){const n=e("assert"),i=e("safe-buffer").Buffer;function o(e,t){if("00"===e.slice(0,2))throw new Error("invalid RLP: extra zeros");return parseInt(e,t)}function a(e,t){if(e<56)return i.from([e+t]);var r=u(e),n=u(t+55+r.length/2);return i.from(n+r,"hex")}function s(e){return"0x"===e.slice(0,2)}function u(e){var t=e.toString(16);return t.length%2&&(t="0"+t),t}function c(e){if(!i.isBuffer(e))if("string"==typeof e)e=s(e)?i.from(((r="string"!=typeof(n=e)?n:s(n)?n.slice(2):n).length%2&&(r="0"+r),r),"hex"):i.from(e);else if("number"==typeof e)e?(t=u(e),e=i.from(t,"hex")):e=i.from([]);else if(null==e)e=i.from([]);else{if(!e.toArray)throw new Error("invalid type");e=i.from(e.toArray())}var t,r,n;return e}r.encode=function(e){if(e instanceof Array){for(var t=[],n=0;nt.length)throw new Error("invalid rlp: total length is larger than the data");if(0===(s=t.slice(n,h)).length)throw new Error("invalid rlp, List has a invalid length");for(;s.length;)u=e(s),c.push(u.data),s=u.remainder;return{data:c,remainder:t.slice(h)}}(e=c(e));return t?r:(n.equal(r.remainder.length,0,"invalid remainder"),r.data)},r.getLength=function(e){if(!e||0===e.length)return i.from([]);var t=(e=c(e))[0];if(t<=127)return e.length;if(t<=183)return t-127;if(t<=191)return t-182;if(t<=247)return t-191;var r=t-246;return r+o(e.slice(1,r).toString("hex"),16)}},{assert:19,"safe-buffer":290}],290:[function(e,t,r){var n=e("buffer"),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function a(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,r),r.Buffer=a),o(i,a),a.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:84}],291:[function(e,t,r){const n=e("util"),i=e("events/");var o="object"==typeof Reflect?Reflect:null,a=o&&"function"==typeof o.apply?o.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};function s(){i.call(this)}function u(e,t,r){try{a(e,t,r)}catch(e){setTimeout(()=>{throw e})}}t.exports=s,n.inherits(s,i),s.prototype.emit=function(e){for(var t=[],r=1;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var s=i[e];if(void 0===s)return!1;if("function"==typeof s)u(s,this,t);else{var c=s.length,f=function(e,t){for(var r=new Array(t),n=0;n0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=function(){for(var e=[],t=0;t0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var c=u.length,f=p(u,c);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return l(this,e,!0)},s.prototype.rawListeners=function(e){return l(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},{}],293:[function(e,t,r){t.exports=e("scryptsy")},{scryptsy:294}],294:[function(e,t,r){(function(r){var n=e("pbkdf2").pbkdf2Sync,i=2147483647;function o(e,t,n,i,o){if(r.isBuffer(e)&&r.isBuffer(n))e.copy(n,i,t,t+o);else for(;o--;)n[i++]=e[t++]}t.exports=function(e,t,a,s,u,c,f){if(0===a||0!=(a&a-1))throw Error("N must be > 0 and a power of 2");if(a>i/128/s)throw Error("Parameter N is too large");if(s>i/128/u)throw Error("Parameter r is too large");var h,l=new r(256*s),d=new r(128*s*a),p=new Int32Array(16),b=new Int32Array(16),y=new r(64),m=n(e,t,1,128*u*s,"sha256");if(f){var v=u*a*2,g=0;h=function(){++g%1e3==0&&f({current:g,total:v,percent:g/v*100})}}for(var w=0;w>>32-t}function x(e){var t;for(t=0;t<16;t++)p[t]=(255&e[4*t+0])<<0,p[t]|=(255&e[4*t+1])<<8,p[t]|=(255&e[4*t+2])<<16,p[t]|=(255&e[4*t+3])<<24;for(o(p,0,b,0,16),t=8;t>0;t-=2)b[4]^=E(b[0]+b[12],7),b[8]^=E(b[4]+b[0],9),b[12]^=E(b[8]+b[4],13),b[0]^=E(b[12]+b[8],18),b[9]^=E(b[5]+b[1],7),b[13]^=E(b[9]+b[5],9),b[1]^=E(b[13]+b[9],13),b[5]^=E(b[1]+b[13],18),b[14]^=E(b[10]+b[6],7),b[2]^=E(b[14]+b[10],9),b[6]^=E(b[2]+b[14],13),b[10]^=E(b[6]+b[2],18),b[3]^=E(b[15]+b[11],7),b[7]^=E(b[3]+b[15],9),b[11]^=E(b[7]+b[3],13),b[15]^=E(b[11]+b[7],18),b[1]^=E(b[0]+b[3],7),b[2]^=E(b[1]+b[0],9),b[3]^=E(b[2]+b[1],13),b[0]^=E(b[3]+b[2],18),b[6]^=E(b[5]+b[4],7),b[7]^=E(b[6]+b[5],9),b[4]^=E(b[7]+b[6],13),b[5]^=E(b[4]+b[7],18),b[11]^=E(b[10]+b[9],7),b[8]^=E(b[11]+b[10],9),b[9]^=E(b[8]+b[11],13),b[10]^=E(b[9]+b[8],18),b[12]^=E(b[15]+b[14],7),b[13]^=E(b[12]+b[15],9),b[14]^=E(b[13]+b[12],13),b[15]^=E(b[14]+b[13],18);for(t=0;t<16;++t)p[t]=b[t]+p[t];for(t=0;t<16;t++){var r=4*t;e[r+0]=p[t]>>0&255,e[r+1]=p[t]>>8&255,e[r+2]=p[t]>>16&255,e[r+3]=p[t]>>24&255}}function k(e,t,r,n,i){for(var o=0;o=r)throw RangeError(n)}}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":181}],297:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("bip66"),o=n.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),a=n.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(e,t,r){var i=n.from(r?o:a);return e.copy(i,r?8:9),t.copy(i,r?181:214),i},r.privateKeyImport=function(e){var t=e.length,r=0;if(!(t2||t1?e[r+n-2]<<8:0);if(!(t<(r+=n)+i||t32||t1&&0===t[o]&&!(128&t[o+1]);--r,++o);for(var a=n.concat([n.from([0]),e.s]),s=33,u=0;s>1&&0===a[u]&&!(128&a[u+1]);--s,++u);return i.encode(t.slice(o),a.slice(u))},r.signatureImport=function(e){var t=n.alloc(32,0),r=n.alloc(32,0);try{var o=i.decode(e);if(33===o.r.length&&0===o.r[0]&&(o.r=o.r.slice(1)),o.r.length>32)throw new Error("R length is too long");if(33===o.s.length&&0===o.s[0]&&(o.s=o.s.slice(1)),o.s.length>32)throw new Error("S length is too long")}catch(e){return}return o.r.copy(t,32-o.r.length),o.s.copy(r,32-o.s.length),{r:t,s:r}},r.signatureImportLax=function(e){var t=n.alloc(32,0),r=n.alloc(32,0),i=e.length,o=0;if(48===e[o++]){var a=e[o++];if(!(128&a&&(o+=a-128)>i)&&2===e[o++]){var s=e[o++];if(128&s){if(o+(a=s-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(s=0;a>0;o+=1,a-=1)s=(s<<8)+e[o]}if(!(s>i-o)){var u=o;if(o+=s,2===e[o++]){var c=e[o++];if(128&c){if(o+(a=c-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(c=0;a>0;o+=1,a-=1)c=(c<<8)+e[o]}if(!(c>i-o)){var f=o;for(o+=c;s>0&&0===e[u];s-=1,u+=1);if(!(s>32)){var h=e.slice(u,u+s);for(h.copy(t,32-h.length);c>0&&0===e[f];c-=1,f+=1);if(!(c>32)){var l=e.slice(f,f+c);return l.copy(r,32-l.length),{r:t,s:r}}}}}}}}}},{bip66:52,"safe-buffer":290}],298:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("create-hash"),o=e("bn.js"),a=e("elliptic").ec,s=e("../messages.json"),u=new a("secp256k1"),c=u.curve;function f(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new o(t);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),u.keyPair({pub:{x:r,y:n}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new o(t),i=new o(r);if(n.cmp(c.p)>=0||i.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),i=i.toRed(c.red),(6===e||7===e)&&i.isOdd()!==(7===e))return null;var a=n.redSqr().redIMul(n);return i.redSqr().redISub(a.redIAdd(c.b)).isZero()?u.keyPair({pub:{x:n,y:i}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}r.privateKeyVerify=function(e){var t=new o(e);return t.cmp(c.n)<0&&!t.isZero()},r.privateKeyExport=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.privateKeyNegate=function(e){var t=new o(e);return t.isZero()?n.alloc(32):c.n.sub(t).umod(c.n).toArrayLike(n,"be",32)},r.privateKeyModInverse=function(e){var t=new o(e);if(t.cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(c.n).toArrayLike(n,"be",32)},r.privateKeyTweakAdd=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new o(e)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(n,"be",32)},r.privateKeyTweakMul=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new o(e)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(n,"be",32)},r.publicKeyCreate=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.publicKeyConvert=function(e,t){var r=f(e);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return n.from(r.getPublic(t,!0))},r.publicKeyVerify=function(e){return null!==f(e)},r.publicKeyTweakAdd=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return n.from(c.g.mul(t).add(i.pub).encode(!0,r))},r.publicKeyTweakMul=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return n.from(i.pub.mul(t).encode(!0,r))},r.publicKeyCombine=function(e,t){for(var r=new Array(e.length),i=0;i=0||r.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var i=n.from(e);return 1===r.cmp(u.nh)&&c.n.sub(r).toArrayLike(n,"be",32).copy(i,32),i},r.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new o(t).cmp(c.n)>=0||new o(r).cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},r.signatureImport=function(e){var t=new o(e.r);t.cmp(c.n)>=0&&(t=new o(0));var r=new o(e.s);return r.cmp(c.n)>=0&&(r=new o(0)),n.concat([t.toArrayLike(n,"be",32),r.toArrayLike(n,"be",32)])},r.sign=function(e,t,r,i){if("function"==typeof r){var a=r;r=function(r){var u=a(e,t,null,i,r);if(!n.isBuffer(u)||32!==u.length)throw new Error(s.ECDSA_SIGN_FAIL);return new o(u)}}var f=new o(t);if(f.cmp(c.n)>=0||f.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var h=u.sign(e,t,{canonical:!0,k:r,pers:i});return{signature:n.concat([h.r.toArrayLike(n,"be",32),h.s.toArrayLike(n,"be",32)]),recovery:h.recoveryParam}},r.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},i=new o(n.r),a=new o(n.s);if(i.cmp(c.n)>=0||a.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===a.cmp(u.nh)||i.isZero()||a.isZero())return!1;var h=f(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return u.verify(e,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(e,t,r,i){var a={r:t.slice(0,32),s:t.slice(32,64)},f=new o(a.r),h=new o(a.s);if(f.cmp(c.n)>=0||h.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(f.isZero()||h.isZero())throw new Error;var l=u.recoverPubKey(e,a,r);return n.from(l.encode(!0,i))}catch(e){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(e,t){var n=r.ecdhUnsafe(e,t,!0);return i("sha256").update(n).digest()},r.ecdhUnsafe=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var a=new o(t);if(a.cmp(c.n)>=0||a.isZero())throw new Error(s.ECDH_FAIL);return n.from(i.pub.mul(a).encode(!0,r))}},{"../messages.json":300,"bn.js":53,"create-hash":91,elliptic:109,"safe-buffer":290}],299:[function(e,t,r){"use strict";var n=e("./assert"),i=e("./der"),o=e("./messages.json");function a(e,t){return void 0===e?t:(n.isBoolean(e,o.COMPRESSED_TYPE_INVALID),e)}t.exports=function(e){return{privateKeyVerify:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0);var s=e.privateKeyExport(t,r);return i.privateKeyExport(t,s,r)},privateKeyImport:function(t){if(n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),(t=i.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakAdd(t,r,i)},publicKeyTweakMul:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakMul(t,r,i)},publicKeyCombine:function(t,r){n.isArray(t,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(t,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=2&&("function"==typeof arguments[1]?r.task=arguments[1]:r.n=arguments[1]);var n=r.task;if(r.task=function(){n(t.leave)},t.current+r.n-e>t.capacity)return 1===e&&(t.current--,t.firstHere=!1),t.queue.push(r);t.current+=r.n-e,r.task(t.leave),1===e&&(t.firstHere=!1)},leave:function(e){if(e=e||1,t.current-=e,t.queue.length){var r=t.queue[0];r.n+t.current>t.capacity||(t.queue.shift(),t.current+=r.n,i(r.task))}else if(t.current<0)throw new Error("leave called too many times.")},available:function(e){return e=e||1,t.current+e<=t.capacity}};return t}void 0!==e&&e&&"function"==typeof e.nextTick&&(i=e.nextTick),"object"==typeof r?t.exports=o:"function"==typeof define&&define.amd?define(function(){return o}):n.semaphore=o}(this)}).call(this,e("_process"))},{_process:257}],302:[function(e,t,r){"use strict";t.exports="function"==typeof setImmediate?setImmediate:function(){var e=[].slice.apply(arguments);e.splice(1,0,0),setTimeout.apply(null,e)}},{}],303:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t){this._block=n.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}i.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=n.from(e,t));for(var r=this._block,i=this._blockSize,o=e.length,a=this._len,s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},{"safe-buffer":290}],304:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":305,"./sha1":306,"./sha224":307,"./sha256":308,"./sha384":309,"./sha512":310}],305:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((t=n)<<5|t>>>27)+f(d,i,o,s)+u+r[l]+a[d];u=s,s=o,o=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],306:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function h(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=(t=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=c(n)+h(p,i,o,s)+u+r[d]+a[p]|0;u=s,s=o,o=f(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],307:[function(e,t,r){var n=e("inherits"),i=e("./sha256"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}n(u,i),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=u},{"./hash":303,"./sha256":308,inherits:180,"safe-buffer":290}],308:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function l(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(u,i),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,m=0;m<16;++m)r[m]=e.readInt32BE(4*m);for(;m<64;++m)r[m]=0|(((t=r[m-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[m-7]+d(r[m-15])+r[m-16];for(var v=0;v<64;++v){var g=y+l(u)+c(u,p,b)+a[v]+r[v]|0,w=h(n)+f(n,i,o)|0;y=b,b=p,p=u,u=s+g|0,s=o,o=i,i=n,n=g+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},u.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],309:[function(e,t,r){var n=e("inherits"),i=e("./sha512"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}n(u,i),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=u},{"./hash":303,"./sha512":310,inherits:180,"safe-buffer":290}],310:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function l(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function y(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function m(e,t){return e>>>0>>0?1:0}n(u,i),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,s=0|this._eh,u=0|this._fh,v=0|this._gh,g=0|this._hh,w=0|this._al,_=0|this._bl,A=0|this._cl,E=0|this._dl,x=0|this._el,k=0|this._fl,S=0|this._gl,M=0|this._hl,I=0;I<32;I+=2)t[I]=e.readInt32BE(4*I),t[I+1]=e.readInt32BE(4*I+4);for(;I<160;I+=2){var T=t[I-30],U=t[I-30+1],j=d(T,U),B=p(U,T),P=b(T=t[I-4],U=t[I-4+1]),C=y(U,T),N=t[I-14],R=t[I-14+1],L=t[I-32],O=t[I-32+1],D=B+R|0,F=j+N+m(D,B)|0;F=(F=F+P+m(D=D+C|0,C)|0)+L+m(D=D+O|0,O)|0,t[I]=F,t[I+1]=D}for(var q=0;q<160;q+=2){F=t[q],D=t[q+1];var H=f(r,n,i),z=f(w,_,A),K=h(r,w),V=h(w,r),G=l(s,x),W=l(x,s),Y=a[q],X=a[q+1],Z=c(s,u,v),J=c(x,k,S),$=M+W|0,Q=g+G+m($,M)|0;Q=(Q=(Q=Q+Z+m($=$+J|0,J)|0)+Y+m($=$+X|0,X)|0)+F+m($=$+D|0,D)|0;var ee=V+z|0,te=K+H+m(ee,V)|0;g=v,M=S,v=u,S=k,u=s,k=x,s=o+Q+m(x=E+$|0,E)|0,o=i,E=A,i=n,A=_,n=r,_=w,r=Q+te+m(w=$+ee|0,$)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+A|0,this._dl=this._dl+E|0,this._el=this._el+x|0,this._fl=this._fl+k|0,this._gl=this._gl+S|0,this._hl=this._hl+M|0,this._ah=this._ah+r+m(this._al,w)|0,this._bh=this._bh+n+m(this._bl,_)|0,this._ch=this._ch+i+m(this._cl,A)|0,this._dh=this._dh+o+m(this._dl,E)|0,this._eh=this._eh+s+m(this._el,x)|0,this._fh=this._fh+u+m(this._fl,k)|0,this._gh=this._gh+v+m(this._gl,S)|0,this._hh=this._hh+g+m(this._hl,M)|0},u.prototype._hash=function(){var e=o.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],311:[function(e,t,r){t.exports=i;var n=e("events").EventEmitter;function i(){n.call(this)}e("inherits")(i,n),i.Readable=e("readable-stream/readable.js"),i.Writable=e("readable-stream/writable.js"),i.Duplex=e("readable-stream/duplex.js"),i.Transform=e("readable-stream/transform.js"),i.PassThrough=e("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,e.end())}function u(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(f(),0===n.listenerCount(this,"error"))throw e}function f(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),e.removeListener("close",f)}return r.on("error",c),e.on("error",c),r.on("end",f),r.on("close",f),e.on("close",f),e.emit("pipe",r),e}},{events:157,inherits:180,"readable-stream/duplex.js":275,"readable-stream/passthrough.js":284,"readable-stream/readable.js":285,"readable-stream/transform.js":286,"readable-stream/writable.js":287}],312:[function(e,t,r){(function(t){var n=e("./lib/request"),i=e("./lib/response"),o=e("xtend"),a=e("builtin-status-codes"),s=e("url"),u=r;u.request=function(e,r){e="string"==typeof e?s.parse(e):o(e);var i=-1===t.location.protocol.search(/^https?:$/)?"http:":"",a=e.protocol||i,u=e.hostname||e.host,c=e.port,f=e.path||"/";u&&-1!==u.indexOf(":")&&(u="["+u+"]"),e.url=(u?a+"//"+u:"")+(c?":"+c:"")+f,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var h=new n(e);return r&&h.on("response",r),h},u.get=function(e,t){var r=u.request(e,t);return r.end(),r},u.ClientRequest=n,u.IncomingMessage=i,u.Agent=function(){},u.Agent.defaultMaxSockets=4,u.STATUS_CODES=a,u.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/request":314,"./lib/response":315,"builtin-status-codes":85,url:327,xtend:423}],313:[function(e,t,r){(function(e){r.fetch=s(e.fetch)&&s(e.ReadableStream),r.writableStream=s(e.WritableStream),r.abortController=s(e.AbortController),r.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),r.blobConstructor=!0}catch(e){}var t;function n(){if(void 0!==t)return t;if(e.XMLHttpRequest){t=new e.XMLHttpRequest;try{t.open("GET",e.XDomainRequest?"/":"https://example.com")}catch(e){t=null}}else t=null;return t}function i(e){var t=n();if(!t)return!1;try{return t.responseType=e,t.responseType===e}catch(e){}return!1}var o=void 0!==e.ArrayBuffer,a=o&&s(e.ArrayBuffer.prototype.slice);function s(e){return"function"==typeof e}r.arraybuffer=r.fetch||o&&i("arraybuffer"),r.msstream=!r.fetch&&a&&i("ms-stream"),r.mozchunkedarraybuffer=!r.fetch&&o&&i("moz-chunked-arraybuffer"),r.overrideMimeType=r.fetch||!!n()&&s(n().overrideMimeType),r.vbArray=s(e.VBArray),t=null}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],314:[function(e,t,r){(function(r,n,i){var o=e("./capability"),a=e("inherits"),s=e("./response"),u=e("readable-stream"),c=e("to-arraybuffer"),f=s.IncomingMessage,h=s.readyStates;var l=t.exports=function(e){var t,r=this;u.Writable.call(r),r._opts=e,r._body=[],r._headers={},e.auth&&r.setHeader("Authorization","Basic "+new i(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){r.setHeader(t,e.headers[t])});var n=!0;if("disable-fetch"===e.mode||"requestTimeout"in e&&!o.abortController)n=!1,t=!0;else if("prefer-streaming"===e.mode)t=!1;else if("allow-wrong-content-type"===e.mode)t=!o.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");t=!0}r._mode=function(e,t){return o.fetch&&t?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&e?"arraybuffer":o.vbArray&&e?"text:vbarray":"text"}(t,n),r.on("finish",function(){r._onFinish()})};a(l,u.Writable),l.prototype.setHeader=function(e,t){var r=e.toLowerCase();-1===d.indexOf(r)&&(this._headers[r]={name:e,value:t})},l.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},l.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},l.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,a=e._headers,s=null;"GET"!==t.method&&"HEAD"!==t.method&&(s=o.arraybuffer?c(i.concat(e._body)):o.blobConstructor?new n.Blob(e._body.map(function(e){return c(e)}),{type:(a["content-type"]||{}).value||""}):i.concat(e._body).toString());var u=[];if(Object.keys(a).forEach(function(e){var t=a[e].name,r=a[e].value;Array.isArray(r)?r.forEach(function(e){u.push([t,e])}):u.push([t,r])}),"fetch"===e._mode){var f=null;if(o.abortController){var l=new AbortController;f=l.signal,e._fetchAbortController=l,"requestTimeout"in t&&0!==t.requestTimeout&&n.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},t.requestTimeout)}n.fetch(e._opts.url,{method:e._opts.method,headers:u,body:s||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin",signal:f}).then(function(t){e._fetchResponse=t,e._connect()},function(t){e.emit("error",t)})}else{var d=e._xhr=new n.XMLHttpRequest;try{d.open(e._opts.method,e._opts.url,!0)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}"responseType"in d&&(d.responseType=e._mode.split(":")[0]),"withCredentials"in d&&(d.withCredentials=!!t.withCredentials),"text"===e._mode&&"overrideMimeType"in d&&d.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in t&&(d.timeout=t.requestTimeout,d.ontimeout=function(){e.emit("requestTimeout")}),u.forEach(function(e){d.setRequestHeader(e[0],e[1])}),e._response=null,d.onreadystatechange=function(){switch(d.readyState){case h.LOADING:case h.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(d.onprogress=function(){e._onXHRProgress()}),d.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{d.send(s)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}}}},l.prototype._onXHRProgress=function(){(function(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}})(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},l.prototype._connect=function(){var e=this;e._destroyed||(e._response=new f(e._xhr,e._fetchResponse,e._mode),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},l.prototype._write=function(e,t,r){this._body.push(e),r()},l.prototype.abort=l.prototype.destroy=function(){this._destroyed=!0,this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},l.prototype.end=function(e,t,r){"function"==typeof e&&(r=e,e=void 0),u.Writable.prototype.end.call(this,e,t,r)},l.prototype.flushHeaders=function(){},l.prototype.setTimeout=function(){},l.prototype.setNoDelay=function(){},l.prototype.setSocketKeepAlive=function(){};var d=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,"./response":315,_process:257,buffer:84,inherits:180,"readable-stream":285,"to-arraybuffer":323}],315:[function(e,t,r){(function(t,n,i){var o=e("./capability"),a=e("inherits"),s=e("readable-stream"),u=r.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},c=r.IncomingMessage=function(e,r,n){var a=this;if(s.Readable.call(a),a._mode=n,a.headers={},a.rawHeaders=[],a.trailers={},a.rawTrailers=[],a.on("end",function(){t.nextTick(function(){a.emit("close")})}),"fetch"===n){if(a._fetchResponse=r,a.url=r.url,a.statusCode=r.status,a.statusMessage=r.statusText,r.headers.forEach(function(e,t){a.headers[t.toLowerCase()]=e,a.rawHeaders.push(t,e)}),o.writableStream){var u=new WritableStream({write:function(e){return new Promise(function(t,r){a._destroyed||(a.push(new i(e))?t():a._resumeFetch=t)})},close:function(){a._destroyed||a.push(null)},abort:function(e){a._destroyed||a.emit("error",e)}});try{return void r.body.pipeTo(u)}catch(e){}}var c=r.body.getReader();!function e(){c.read().then(function(t){a._destroyed||(t.done?a.push(null):(a.push(new i(t.value)),e()))}).catch(function(e){a._destroyed||a.emit("error",e)})}()}else{if(a._xhr=e,a._pos=0,a.url=e.responseURL,a.statusCode=e.status,a.statusMessage=e.statusText,e.getAllResponseHeaders().split(/\r?\n/).forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var r=t[1].toLowerCase();"set-cookie"===r?(void 0===a.headers[r]&&(a.headers[r]=[]),a.headers[r].push(t[2])):void 0!==a.headers[r]?a.headers[r]+=", "+t[2]:a.headers[r]=t[2],a.rawHeaders.push(t[1],t[2])}}),a._charset="x-user-defined",!o.overrideMimeType){var f=a.rawHeaders["mime-type"];if(f){var h=f.match(/;\s*charset=([^;])(;|$)/);h&&(a._charset=h[1].toLowerCase())}a._charset||(a._charset="utf-8")}}};a(c,s.Readable),c.prototype._read=function(){var e=this._resumeFetch;e&&(this._resumeFetch=null,e())},c.prototype._onXHRProgress=function(){var e=this,t=e._xhr,r=null;switch(e._mode){case"text:vbarray":if(t.readyState!==u.DONE)break;try{r=new n.VBArray(t.responseBody).toArray()}catch(e){}if(null!==r){e.push(new i(r));break}case"text":try{r=t.responseText}catch(t){e._mode="text:vbarray";break}if(r.length>e._pos){var o=r.substr(e._pos);if("x-user-defined"===e._charset){for(var a=new i(o.length),s=0;se._pos&&(e.push(new i(new Uint8Array(c.result.slice(e._pos)))),e._pos=c.result.byteLength)},c.onload=function(){e.push(null)},c.readAsArrayBuffer(r)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,_process:257,buffer:84,inherits:180,"readable-stream":285}],316:[function(e,t,r){"use strict";t.exports=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}},{}],317:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=f,this.end=h,t=3;break;default:return this.write=l,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:-1}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�".repeat(r);if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�".repeat(r+1);if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�".repeat(r+2)}}(this,e,t);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function l(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}r.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":290}],318:[function(e,t,r){var n=e("is-hex-prefixed");t.exports=function(e){return"string"!=typeof e?e:n(e)?e.slice(2):e}},{"is-hex-prefixed":185}],319:[function(e,t,r){var n=function(){throw"This swarm.js function isn't available on the browser."},i={readFile:n},o={download:n,safeDownloadArchived:n,directoryTree:n},a={platform:n,arch:n},s={join:n,slice:n},u={spawn:n},c={lookup:n},f=e("xhr-request-promise"),h=e("eth-lib/lib/bytes"),l=e("./swarm-hash.js"),d=e("./pick.js"),p=e("./swarm");t.exports=p({fsp:i,files:o,os:a,path:s,child_process:u,defaultArchives:{},mimetype:c,request:f,downloadUrl:null,bytes:h,hash:l,pick:d})},{"./pick.js":320,"./swarm":322,"./swarm-hash.js":321,"eth-lib/lib/bytes":133,"xhr-request-promise":411}],320:[function(e,t,r){var n=function(e){return function(){return new Promise(function(t,r){var n=function(r){var n={},i=r.target.files.length,o=0;[].map.call(r.target.files,function(r){var a=new FileReader;a.onload=function(a){var s=new Uint8Array(a.target.result);if("directory"===e){var u=r.webkitRelativePath;n[u.slice(u.indexOf("/")+1)]={type:"text/plain",data:s},++o===i&&t(n)}else if("file"===e){var c=r.webkitRelativePath;t({type:mimetype.lookup(c),data:s})}else t(s)},a.readAsArrayBuffer(r)})},i=void 0;"directory"===e?((i=document.createElement("input")).addEventListener("change",n),i.type="file",i.webkitdirectory=!0,i.mozdirectory=!0,i.msdirectory=!0,i.odirectory=!0,i.directory=!0):((i=document.createElement("input")).addEventListener("change",n),i.type="file");var o=document.createEvent("MouseEvents");o.initEvent("click",!0,!1),i.dispatchEvent(o)})}};t.exports={data:n("data"),file:n("file"),directory:n("directory")}},{}],321:[function(e,t,r){var n=e("eth-lib/lib/hash").keccak256,i=e("eth-lib/lib/bytes"),o=function(e,t){var r=i.reverse(i.pad(6,i.fromNumber(e))),o=i.flatten([r,"0x0000",t]);return n(o).slice(2)};t.exports=function e(t){"string"==typeof t&&"0x"!==t.slice(0,2)?t=i.fromString(t):"string"!=typeof t&&void 0!==t.length&&(t=i.fromUint8Array(t));var r=i.length(t);if(r<=4096)return o(r,t);for(var n=4096;128*n0){var a=i.join(r,o);n.push(g(e)(t[o])(a))}return Promise.all(n).then(function(){return r})})}}},_=function(e){return function(t){return u(e+"/bzzr:/",{body:"string"==typeof t?L(t):t,method:"POST"})}},A=function(e){return function(t){return function(r){return function(n){return function i(o){var a="/"===r[0]?r:"/"+r,s=e+"/bzz:/"+t+a,c={method:"PUT",headers:{"Content-Type":n.type},body:n.data};return u(s,c).then(function(e){if(-1!==e.indexOf("error"))throw e;return e}).catch(function(e){return o>0&&i(o-1)})}(3)}}}},E=function(e){return function(t){return k(e)({"":t})}},x=function(e){return function(r){return t.readFile(r).then(function(t){return E(e)({type:a.lookup(r),data:t})})}},k=function(e){return function(t){return _(e)("{}").then(function(r){return Object.keys(t).reduce(function(r,n){return r.then(function(r){return function(n){return A(e)(n)(r)(t[r])}}(n))},Promise.resolve(r))})}},S=function(e){return function(r){return t.readFile(r).then(_(e))}},M=function(e){return function(n){return function(i){return r.directoryTree(i).then(function(e){return Promise.all(e.map(function(e){return t.readFile(e)})).then(function(t){var r=e.map(function(e){return e.slice(i.length)}),n=e.map(function(e){return a.lookup(e)||"text/plain"});return d(r)(t.map(function(e,t){return{type:n[t],data:e}}))})}).then(function(e){return(t=n?{"":e[n]}:{},function(e){var r={};for(var n in t)r[n]=t[n];for(var i in e)r[i]=e[i];return r})(e);var t}).then(k(e))}}},I=function(e){return function(t){if("data"===t.pick)return l.data().then(_(e));if("file"===t.pick)return l.file().then(E(e));if("directory"===t.pick)return l.directory().then(k(e));if(t.path)switch(t.kind){case"data":return S(e)(t.path);case"file":return x(e)(t.path);case"directory":return M(e)(t.defaultFile)(t.path)}else{if(t.length||"string"==typeof t)return _(e)(t);if(t instanceof Object)return k(e)(t)}return Promise.reject(new Error("Bad arguments"))}},T=function(e){return function(t){return function(r){return C(e)(t).then(function(n){return n?r?w(e)(t)(r):v(e)(t):r?g(e)(t)(r):b(e)(t)})}}},U=function(e,t){var i=n.platform().replace("win32","windows")+"-"+("x64"===n.arch()?"amd64":"386"),o=(t||s)[i],a=c+o.archive+".tar.gz",u=o.archiveMD5,f=o.binaryMD5;return r.safeDownloadArchived(a)(u)(f)(e)},j=function(e){return new Promise(function(t,r){var n=o.spawn,i=function(e){return function(t){return-1!==(""+t).indexOf(e)}},a=e.account,s=e.password,u=e.dataDir,c=e.ensApi,f=e.privateKey,h=0,l=n(e.binPath,["--bzzaccount",a||f,"--datadir",u,"--ens-api",c]),d=function(e){0===h&&i("Passphrase")(e)?setTimeout(function(){h=1,l.stdin.write(s+"\n")},500):i("Swarm http proxy started")(e)&&(h=2,clearTimeout(p),t(l))};l.stdout.on("data",d),l.stderr.on("data",d);var p=setTimeout(function(){return r(new Error("Couldn't start swarm process."))},2e4)})},B=function(e){return new Promise(function(t,r){e.stderr.removeAllListeners("data"),e.stdout.removeAllListeners("data"),e.stdin.removeAllListeners("error"),e.removeAllListeners("error"),e.removeAllListeners("exit"),e.kill("SIGINT");var n=setTimeout(function(){return e.kill("SIGKILL")},8e3);e.once("close",function(){clearTimeout(n),t()})})},P=function(e){return _(e)("test").then(function(e){return"c9a99c7d326dcc6316f32fe2625b311f6dc49a175e6877681ded93137d3569e7"===e}).catch(function(){return!1})},C=function(e){return function(t){return b(e)(t).then(function(e){try{return!!JSON.parse(R(e)).entries}catch(e){return!1}})}},N=function(e){return function(t,r,n,i,o){var a;return void 0!==t&&(a=e(t)),void 0!==r&&(a=e(r)),void 0!==n&&(a=e(n)),void 0!==i&&(a=e(i)),void 0!==o&&(a=e(o)),a}},R=function(e){return f.toString(f.fromUint8Array(e))},L=function(e){return f.toUint8Array(f.fromString(e))},O=function(e){return{download:function(t,r){return T(e)(t)(r)},downloadData:N(b(e)),downloadDataToDisk:N(g(e)),downloadDirectory:N(v(e)),downloadDirectoryToDisk:N(w(e)),downloadEntries:N(y(e)),downloadRoutes:N(m(e)),isAvailable:function(){return P(e)},upload:function(t){return I(e)(t)},uploadData:N(_(e)),uploadFile:N(E(e)),uploadFileFromDisk:N(E(e)),uploadDataFromDisk:N(S(e)),uploadDirectory:N(k(e)),uploadDirectoryFromDisk:N(M(e)),uploadToManifest:N(A(e)),pick:l,hash:h,fromString:L,toString:R}};return{at:O,local:function(e){return function(t){return P("http://localhost:8500").then(function(r){return r?t(O("http://localhost:8500")).then(function(){}):U(e.binPath,e.archives).onData(function(t){return(e.onProgress||function(){})(t.length)}).then(function(){return j(e)}).then(function(e){return t(O("http://localhost:8500")).then(function(){return e})}).then(B)})}},download:T,downloadBinary:U,downloadData:b,downloadDataToDisk:g,downloadDirectory:v,downloadDirectoryToDisk:w,downloadEntries:y,downloadRoutes:m,isAvailable:P,startProcess:j,stopProcess:B,upload:I,uploadData:_,uploadDataFromDisk:S,uploadFile:E,uploadFileFromDisk:x,uploadDirectory:k,uploadDirectoryFromDisk:M,uploadToManifest:A,pick:l,hash:h,fromString:L,toString:R}}},{}],323:[function(e,t,r){var n=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(n.isBuffer(e)){for(var t=new Uint8Array(e.length),r=e.length,i=0;i=0&&t<=A};function k(e){return function(t,r,n,i){r=m(r,i,4);var o=!x(t)&&y.keys(t),a=(o||t).length,s=e>0?0:a-1;return arguments.length<3&&(n=t[o?o[s]:s],s+=e),function(t,r,n,i,o,a){for(;o>=0&&o=0},y.invoke=function(e,t){var r=u.call(arguments,2),n=y.isFunction(t);return y.map(e,function(e){var i=n?t:e[t];return null==i?i:i.apply(e,r)})},y.pluck=function(e,t){return y.map(e,y.property(t))},y.where=function(e,t){return y.filter(e,y.matcher(t))},y.findWhere=function(e,t){return y.find(e,y.matcher(t))},y.max=function(e,t,r){var n,i,o=-1/0,a=-1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;so&&(o=n);else t=v(t,r),y.each(e,function(e,r,n){((i=t(e,r,n))>a||i===-1/0&&o===-1/0)&&(o=e,a=i)});return o},y.min=function(e,t,r){var n,i,o=1/0,a=1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;sn||void 0===r)return 1;if(r0?0:i-1;o>=0&&o0?a=o>=0?o:Math.max(o+s,a):s=o>=0?Math.min(o+1,s):o+s+1;else if(r&&o&&s)return n[o=r(n,i)]===i?o:-1;if(i!=i)return(o=t(u.call(n,a,s),y.isNaN))>=0?o+a:-1;for(o=e>0?a:s-1;o>=0&&ot?(a&&(clearTimeout(a),a=null),s=c,o=e.apply(n,i),a||(n=i=null)):a||!1===r.trailing||(a=setTimeout(u,f)),o}},y.debounce=function(e,t,r){var n,i,o,a,s,u=function(){var c=y.now()-a;c=0?n=setTimeout(u,t-c):(n=null,r||(s=e.apply(o,i),n||(o=i=null)))};return function(){o=this,i=arguments,a=y.now();var c=r&&!n;return n||(n=setTimeout(u,t)),c&&(s=e.apply(o,i),o=i=null),s}},y.wrap=function(e,t){return y.partial(t,e)},y.negate=function(e){return function(){return!e.apply(this,arguments)}},y.compose=function(){var e=arguments,t=e.length-1;return function(){for(var r=t,n=e[t].apply(this,arguments);r--;)n=e[r].call(this,n);return n}},y.after=function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},y.before=function(e,t){var r;return function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=null),r}},y.once=y.partial(y.before,2);var j=!{toString:null}.propertyIsEnumerable("toString"),B=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];function P(e,t){var r=B.length,n=e.constructor,i=y.isFunction(n)&&n.prototype||o,a="constructor";for(y.has(e,a)&&!y.contains(t,a)&&t.push(a);r--;)(a=B[r])in e&&e[a]!==i[a]&&!y.contains(t,a)&&t.push(a)}y.keys=function(e){if(!y.isObject(e))return[];if(l)return l(e);var t=[];for(var r in e)y.has(e,r)&&t.push(r);return j&&P(e,t),t},y.allKeys=function(e){if(!y.isObject(e))return[];var t=[];for(var r in e)t.push(r);return j&&P(e,t),t},y.values=function(e){for(var t=y.keys(e),r=t.length,n=Array(r),i=0;i":">",'"':""","'":"'","`":"`"},R=y.invert(N),L=function(e){var t=function(t){return e[t]},r="(?:"+y.keys(e).join("|")+")",n=RegExp(r),i=RegExp(r,"g");return function(e){return e=null==e?"":""+e,n.test(e)?e.replace(i,t):e}};y.escape=L(N),y.unescape=L(R),y.result=function(e,t,r){var n=null==e?void 0:e[t];return void 0===n&&(n=r),y.isFunction(n)?n.call(e):n};var O=0;y.uniqueId=function(e){var t=++O+"";return e?e+t:t},y.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var D=/(.)^/,F={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},q=/\\|'|\r|\n|\u2028|\u2029/g,H=function(e){return"\\"+F[e]};y.template=function(e,t,r){!t&&r&&(t=r),t=y.defaults({},t,y.templateSettings);var n=RegExp([(t.escape||D).source,(t.interpolate||D).source,(t.evaluate||D).source].join("|")+"|$","g"),i=0,o="__p+='";e.replace(n,function(t,r,n,a,s){return o+=e.slice(i,s).replace(q,H),i=s+t.length,r?o+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":n?o+="'+\n((__t=("+n+"))==null?'':__t)+\n'":a&&(o+="';\n"+a+"\n__p+='"),t}),o+="';\n",t.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{var a=new Function(t.variable||"obj","_",o)}catch(e){throw e.source=o,e}var s=function(e){return a.call(this,e,y)},u=t.variable||"obj";return s.source="function("+u+"){\n"+o+"}",s},y.chain=function(e){var t=y(e);return t._chain=!0,t};var z=function(e,t){return e._chain?y(t).chain():t};y.mixin=function(e){y.each(y.functions(e),function(t){var r=y[t]=e[t];y.prototype[t]=function(){var e=[this._wrapped];return s.apply(e,arguments),z(this,r.apply(y,e))}})},y.mixin(y),y.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=i[e];y.prototype[e]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==e&&"splice"!==e||0!==r.length||delete r[0],z(this,r)}}),y.each(["concat","join","slice"],function(e){var t=i[e];y.prototype[e]=function(){return z(this,t.apply(this._wrapped,arguments))}}),y.prototype.value=function(){return this._wrapped},y.prototype.valueOf=y.prototype.toJSON=y.prototype.value,y.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return y})}).call(this)},{}],326:[function(e,t,r){t.exports=function(e,t){if(t){t=(t=t.trim().replace(/^(\?|#|&)/,""))?"?"+t:t;var r=e.split(/[\?\#]/),n=r[0];t&&/\:\/\/[^\/]*$/.test(n)&&(n+="/");var i=e.match(/(\#.*)$/);e=n+t,i&&(e+=i[0])}return e}},{}],327:[function(e,t,r){"use strict";var n=e("punycode"),i=e("./util");function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}r.parse=g,r.resolve=function(e,t){return g(e,!1,!0).resolve(t)},r.resolveObject=function(e,t){return e?g(e,!1,!0).resolveObject(t):t},r.format=function(e){i.isString(e)&&(e=g(e));return e instanceof o?e.format():o.prototype.format.call(e)},r.Url=o;var a=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=e("querystring");function g(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o127?P+="x":P+=B[C];if(!P.match(d)){var R=U.slice(0,M),L=U.slice(M+1),O=B.match(p);O&&(R.push(O[1]),L.unshift(O[2])),L.length&&(g="/"+L.join(".")+g),this.hostname=R.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),T||(this.hostname=n.toASCII(this.hostname));var D=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+D,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==g[0]&&(g="/"+g))}if(!b[A])for(M=0,j=f.length;M0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift());return r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!E.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var k=E.slice(-1)[0],S=(r.host||e.host||E.length>1)&&("."===k||".."===k)||""===k,M=0,I=E.length;I>=0;I--)"."===(k=E[I])?E.splice(I,1):".."===k?(E.splice(I,1),M++):M&&(E.splice(I,1),M--);if(!_&&!A)for(;M--;M)E.unshift("..");!_||""===E[0]||E[0]&&"/"===E[0].charAt(0)||E.unshift(""),S&&"/"!==E.join("/").substr(-1)&&E.push("");var T,U=""===E[0]||E[0]&&"/"===E[0].charAt(0);x&&(r.hostname=r.host=U?"":E.length?E.shift():"",(T=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift()));return(_=_||r.host&&E.length)&&!U&&E.unshift(""),E.length?r.pathname=E.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":328,punycode:265,querystring:269}],328:[function(e,t,r){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],329:[function(e,t,r){(function(e){!function(n){var i="object"==typeof r&&r,o="object"==typeof t&&t&&t.exports==i&&t,a="object"==typeof e&&e;a.global!==a&&a.window!==a||(n=a);var s,u,c,f=String.fromCharCode;function h(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i=55296&&e<=57343)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value")}function d(e,t){return f(e>>t&63|128)}function p(e){if(0==(4294967168&e))return f(e);var t="";return 0==(4294965248&e)?t=f(e>>6&31|192):0==(4294901760&e)?(l(e),t=f(e>>12&15|224),t+=d(e,6)):0==(4292870144&e)&&(t=f(e>>18&7|240),t+=d(e,12),t+=d(e,6)),t+=f(63&e|128)}function b(){if(c>=u)throw Error("Invalid byte index");var e=255&s[c];if(c++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function y(){var e,t;if(c>u)throw Error("Invalid byte index");if(c==u)return!1;if(e=255&s[c],c++,0==(128&e))return e;if(192==(224&e)){if((t=(31&e)<<6|b())>=128)return t;throw Error("Invalid continuation byte")}if(224==(240&e)){if((t=(15&e)<<12|b()<<6|b())>=2048)return l(t),t;throw Error("Invalid continuation byte")}if(240==(248&e)&&(t=(15&e)<<18|b()<<12|b()<<6|b())>=65536&&t<=1114111)return t;throw Error("Invalid UTF-8 detected")}var m={version:"2.0.0",encode:function(e){for(var t=h(e),r=t.length,n=-1,i="";++n65535&&(i+=f((t-=65536)>>>10&1023|55296),t=56320|1023&t),i+=f(t);return i}(r)}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return m});else if(i&&!i.nodeType)if(o)o.exports=m;else{var v={}.hasOwnProperty;for(var g in m)v.call(m,g)&&(i[g]=m[g])}else n.utf8=m}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],330:[function(e,t,r){(function(e){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],331:[function(e,t,r){arguments[4][180][0].apply(r,arguments)},{dup:180}],332:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],333:[function(e,t,r){(function(t,n){var i=/%[sdj%]/g;r.format=function(e){if(!m(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(t)?n.showHidden=t:t&&r._extend(n,t),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,e,n.depth)}function u(e,t){var r=s.styles[t];return r?"["+s.colors[r][0]+"m"+e+"["+s.colors[r][1]+"m":e}function c(e,t){return e}function f(e,t,n){if(e.customInspect&&t&&E(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return m(i)||(i=f(e,i,n)),i}var o=function(e,t){if(v(t))return e.stylize("undefined","undefined");if(m(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(y(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(b(t))return e.stylize("null","null")}(e,t);if(o)return o;var a=Object.keys(t),s=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),A(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return h(t);if(0===a.length){if(E(t)){var u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","special")}if(g(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(_(t))return e.stylize(Date.prototype.toString.call(t),"date");if(A(t))return h(t)}var c,w="",x=!1,k=["{","}"];(d(t)&&(x=!0,k=["[","]"]),E(t))&&(w=" [Function"+(t.name?": "+t.name:"")+"]");return g(t)&&(w=" "+RegExp.prototype.toString.call(t)),_(t)&&(w=" "+Date.prototype.toUTCString.call(t)),A(t)&&(w=" "+h(t)),0!==a.length||x&&0!=t.length?n<0?g(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=x?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(c,w,k)):k[0]+w+k[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),M(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=b(r)?f(e,u.value,null):f(e,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n")):s=e.stylize("[Circular]","special")),v(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function b(e){return null===e}function y(e){return"number"==typeof e}function m(e){return"string"==typeof e}function v(e){return void 0===e}function g(e){return w(e)&&"[object RegExp]"===x(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===x(e)}function A(e){return w(e)&&("[object Error]"===x(e)||e instanceof Error)}function E(e){return"function"==typeof e}function x(e){return Object.prototype.toString.call(e)}function k(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(v(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=t.pid;a[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else a[e]=function(){};return a[e]},r.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(e){return null==e},r.isNumber=y,r.isString=m,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=v,r.isRegExp=g,r.isObject=w,r.isDate=_,r.isError=A,r.isFunction=E,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[k(e.getHours()),k(e.getMinutes()),k(e.getSeconds())].join(":"),[e.getDate(),S[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":332,_process:257,inherits:331}],334:[function(require,module,exports){var indexOf=require("indexof"),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},c.prototype.getCall=function(e){return n.isFunction(this.call)?this.call(e):this.call},c.prototype.extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},c.prototype.validateArgs=function(e){if(e.length!==this.params)throw i.InvalidNumberOfParams(e.length,this.params,this.name)},c.prototype.formatInput=function(e){var t=this;return this.inputFormatter?this.inputFormatter.map(function(r,n){return r?r.call(t,e[n]):e[n]}):e},c.prototype.formatOutput=function(e){var t=this;return n.isArray(e)?e.map(function(e){return t.outputFormatter&&e?t.outputFormatter(e):e}):this.outputFormatter&&e?this.outputFormatter(e):e},c.prototype.toPayload=function(e){var t=this.getCall(e),r=this.extractCallback(e),n=this.formatInput(e);this.validateArgs(n);var i={method:t,params:n,callback:r};return this.transformPayload&&(i=this.transformPayload(i)),i},c.prototype._confirmTransaction=function(e,t,r){var i=this,f=!1,h=!0,l=0,d=0,p=null,b="",y=n.isObject(r.params[0])&&r.params[0].gas?r.params[0].gas:null,m=n.isObject(r.params[0])&&r.params[0].data&&r.params[0].from&&!r.params[0].to,v=[new c({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:o.outputTransactionReceiptFormatter}),new c({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[o.inputAddressFormatter,o.inputDefaultBlockNumberFormatter]}),new u({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:o.outputBlockFormatter}}})],g={};n.each(v,function(e){e.attachToObject(g),e.requestManager=i.requestManager});var w=function(r,n,o,u,c){if(!o)return c||(c={unsubscribe:function(){clearInterval(p)}}),(r?s.resolve(r):g.getTransactionReceipt(t)).catch(function(t){c.unsubscribe(),f=!0,a._fireError({message:"Failed to check for transaction receipt:",data:t},e.eventEmitter,e.reject)}).then(function(t){if(!t||!t.blockHash)throw new Error("Receipt missing or blockHash null");return i.extraFormatters&&i.extraFormatters.receiptFormatter&&(t=i.extraFormatters.receiptFormatter(t)),e.eventEmitter.listeners("confirmation").length>0&&(void 0!==r&&0===d||e.eventEmitter.emit("confirmation",d,t),h=!1,25===++d&&(c.unsubscribe(),e.eventEmitter.removeAllListeners())),t}).then(function(t){if(m&&!f){if(!t.contractAddress)return h&&(c.unsubscribe(),f=!0),void a._fireError(new Error("The transaction receipt didn't contain a contract address."),e.eventEmitter,e.reject);g.getCode(t.contractAddress,function(r,n){n&&(n.length>2?(e.eventEmitter.emit("receipt",t),i.extraFormatters&&i.extraFormatters.contractDeployFormatter?e.resolve(i.extraFormatters.contractDeployFormatter(t)):e.resolve(t),h&&e.eventEmitter.removeAllListeners()):a._fireError(new Error("The contract code couldn't be stored, please check your gas limit."),e.eventEmitter,e.reject),h&&c.unsubscribe(),f=!0)})}return t}).then(function(t){m||f||(t.outOfGas||y&&y===t.gasUsed||!0!==t.status&&"0x1"!==t.status&&void 0!==t.status?(b=JSON.stringify(t,null,2),!1===t.status||"0x0"===t.status?a._fireError(new Error("Transaction has been reverted by the EVM:\n"+b),e.eventEmitter,e.reject):a._fireError(new Error("Transaction ran out of gas. Please provide more gas:\n"+b),e.eventEmitter,e.reject)):(e.eventEmitter.emit("receipt",t),e.resolve(t),h&&e.eventEmitter.removeAllListeners()),h&&c.unsubscribe(),f=!0)}).catch(function(){l++,n?l-1>=750&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject)):l-1>=50&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject))});c.unsubscribe(),f=!0,a._fireError({message:"Failed to subscribe to new newBlockHeaders to confirm the transaction receipts.",data:o},e.eventEmitter,e.reject)},_=function(e){n.isFunction(this.requestManager.provider.on)?g.subscribe("newBlockHeaders",w.bind(null,e,!1)):p=setInterval(w.bind(null,e,!0),1e3)}.bind(this);g.getTransactionReceipt(t).then(function(t){t&&t.blockHash?(e.eventEmitter.listeners("confirmation").length>0&&_(t),w(t,!1)):f||_()}).catch(function(){f||_()})};var f=function(e,t){return n.isNumber(e)?t.wallet[e]:n.isObject(e)&&e.address&&e.privateKey?e:t.wallet[e.toLowerCase()]};c.prototype.buildCall=function(){var e=this,t="eth_sendTransaction"===e.call||"eth_sendRawTransaction"===e.call,r=function(){var r=s(!t),i=e.toPayload(Array.prototype.slice.call(arguments)),o=function(n,o){try{o=e.formatOutput(o)}catch(e){n=e}if(o instanceof Error&&(n=o),n)return n.error&&(n=n.error),a._fireError(n,r.eventEmitter,r.reject,i.callback);i.callback&&i.callback(null,o),t?(r.eventEmitter.emit("transactionHash",o),e._confirmTransaction(r,o,i)):n||r.resolve(o)},u=function(t){var r=n.extend({},i,{method:"eth_sendRawTransaction",params:[t.rawTransaction]});e.requestManager.send(r,o)},h=function(e,t){var i;if(t&&t.accounts&&t.accounts.wallet&&t.accounts.wallet.length)if("eth_sendTransaction"===e.method){var a=e.params[0];if((i=f(n.isObject(a)?a.from:null,t.accounts))&&i.privateKey)return t.accounts.signTransaction(n.omit(a,"from"),i.privateKey).then(u)}else if("eth_sign"===e.method){var s=e.params[1];if((i=f(e.params[0],t.accounts))&&i.privateKey){var c=t.accounts.sign(s,i.privateKey);return e.callback&&e.callback(null,c.signature),void r.resolve(c.signature)}}return t.requestManager.send(e,o)};t&&n.isObject(i.params[0])&&void 0===i.params[0].gasPrice?new c({name:"getGasPrice",call:"eth_gasPrice",params:0}).createFunction(e.requestManager)(function(t,r){r&&(i.params[0].gasPrice=r),h(i,e)}):h(i,e);return r.eventEmitter};return r.method=e,r.request=this.request.bind(this),r},c.prototype.request=function(){var e=this.toPayload(Array.prototype.slice.call(arguments));return e.format=this.formatOutput.bind(this),e},t.exports=c},{underscore:325,"web3-core-helpers":338,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-utils":403}],340:[function(e,t,r){"use strict";var n=e("eventemitter3"),i=e("any-promise"),o=function(e){var t,r,o=new i(function(){t=arguments[0],r=arguments[1]});if(e)return{resolve:t,reject:r,eventEmitter:o};var a=new n;return o._events=a._events,o.emit=a.emit,o.on=a.on,o.once=a.once,o.off=a.off,o.listeners=a.listeners,o.addListener=a.addListener,o.removeListener=a.removeListener,o.removeAllListeners=a.removeAllListeners,{resolve:t,reject:r,eventEmitter:o}};o.resolve=function(e){var t=o(!0);return t.resolve(e),t.eventEmitter},t.exports=o},{"any-promise":2,eventemitter3:156}],341:[function(e,t,r){"use strict";var n=e("./jsonrpc"),i=e("web3-core-helpers").errors,o=function(e){this.requestManager=e,this.requests=[]};o.prototype.add=function(e){this.requests.push(e)},o.prototype.execute=function(){var e=this.requests;this.requestManager.sendBatch(e,function(t,r){r=r||[],e.map(function(e,t){return r[t]||{}}).forEach(function(t,r){if(e[r].callback){if(t&&t.error)return e[r].callback(i.ErrorResponse(t));if(!n.isValidResponse(t))return e[r].callback(i.InvalidResponse(t));try{e[r].callback(null,e[r].format?e[r].format(t.result):t.result)}catch(t){e[r].callback(t)}}})})},t.exports=o},{"./jsonrpc":344,"web3-core-helpers":338}],342:[function(e,t,r){"use strict";var n=null,i=window;void 0!==i.ethereumProvider?n=i.ethereumProvider:void 0!==i.web3&&i.web3.currentProvider&&(i.web3.currentProvider.sendAsync&&(i.web3.currentProvider.send=i.web3.currentProvider.sendAsync,delete i.web3.currentProvider.sendAsync),!i.web3.currentProvider.on&&i.web3.currentProvider.connection&&"ipcProviderWrapper"===i.web3.currentProvider.connection.constructor.name&&(i.web3.currentProvider.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.connection.on("data",function(e){var r="";e=e.toString();try{r=JSON.parse(e)}catch(r){return t(new Error("Couldn't parse response data"+e))}r.id||-1===r.method.indexOf("_subscription")||t(null,r)});break;default:this.connection.on(e,t)}}),n=i.web3.currentProvider),t.exports=n},{}],343:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("./jsonrpc.js"),a=e("./batch.js"),s=e("./givenProvider.js"),u=function e(t){this.provider=null,this.providers=e.providers,this.setProvider(t),this.subscriptions={}};u.givenProvider=s,u.providers={WebsocketProvider:e("web3-providers-ws"),HttpProvider:e("web3-providers-http"),IpcProvider:e("web3-providers-ipc")},u.prototype.setProvider=function(e,t){var r=this;if(e&&"string"==typeof e&&this.providers)if(/^http(s)?:\/\//i.test(e))e=new this.providers.HttpProvider(e);else if(/^ws(s)?:\/\//i.test(e))e=new this.providers.WebsocketProvider(e);else if(e&&"object"==typeof t&&"function"==typeof t.connect)e=new this.providers.IpcProvider(e,t);else if(e)throw new Error("Can't autodetect provider for \""+e+'"');this.provider&&this.provider.connected&&this.clearSubscriptions(),this.provider=e||null,this.provider&&this.provider.on&&this.provider.on("data",function(e,t){(e=e||t).method&&r.subscriptions[e.params.subscription]&&r.subscriptions[e.params.subscription].callback&&r.subscriptions[e.params.subscription].callback(null,e.params.result)})},u.prototype.send=function(e,t){if(t=t||function(){},!this.provider)return t(i.InvalidProvider());var r=o.toPayload(e.method,e.params);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,n){return n&&n.id&&r.id!==n.id?t(new Error('Wrong response id "'+n.id+'" (expected: "'+r.id+'") in '+JSON.stringify(r))):e?t(e):n&&n.error?t(i.ErrorResponse(n)):o.isValidResponse(n)?void t(null,n.result):t(i.InvalidResponse(n))})},u.prototype.sendBatch=function(e,t){if(!this.provider)return t(i.InvalidProvider());var r=o.toBatchPayload(e);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,r){return e?t(e):n.isArray(r)?void t(null,r):t(i.InvalidResponse(r))})},u.prototype.addSubscription=function(e,t,r,n){if(!this.provider.on)throw new Error("The provider doesn't support subscriptions: "+this.provider.constructor.name);this.subscriptions[e]={callback:n,type:r,name:t}},u.prototype.removeSubscription=function(e,t){this.subscriptions[e]&&(this.send({method:this.subscriptions[e].type+"_unsubscribe",params:[e]},t),delete this.subscriptions[e])},u.prototype.clearSubscriptions=function(e){var t=this;Object.keys(this.subscriptions).forEach(function(r){e&&"syncing"===t.subscriptions[r].name||t.removeSubscription(r)}),this.provider.reset&&this.provider.reset()},t.exports={Manager:u,BatchManager:a}},{"./batch.js":341,"./givenProvider.js":342,"./jsonrpc.js":344,underscore:325,"web3-core-helpers":338,"web3-providers-http":398,"web3-providers-ipc":399,"web3-providers-ws":400}],344:[function(e,t,r){"use strict";var n={messageId:0,toPayload:function(e,t){if(!e)throw new Error('JSONRPC method should be specified for params: "'+JSON.stringify(t)+'"!');return n.messageId++,{jsonrpc:"2.0",id:n.messageId,method:e,params:t||[]}},isValidResponse:function(e){return Array.isArray(e)?e.every(t):t(e);function t(e){return!(!e||e.error||"2.0"!==e.jsonrpc||"number"!=typeof e.id&&"string"!=typeof e.id||void 0===e.result)}},toBatchPayload:function(e){return e.map(function(e){return n.toPayload(e.method,e.params)})}};t.exports=n},{}],345:[function(e,t,r){"use strict";var n=e("./subscription.js"),i=function(e){this.name=e.name,this.type=e.type,this.subscriptions=e.subscriptions||{},this.requestManager=null};i.prototype.setRequestManager=function(e){this.requestManager=e},i.prototype.attachToObject=function(e){var t=this.buildCall(),r=this.name.split(".");r.length>1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},i.prototype.buildCall=function(){var e=this;return function(){e.subscriptions[arguments[0]]||console.warn("Subscription "+JSON.stringify(arguments[0])+" doesn't exist. Subscribing anyway.");var t=new n({subscription:e.subscriptions[arguments[0]],requestManager:e.requestManager,type:e.type});return t.subscribe.apply(t,arguments)}},t.exports={subscriptions:i,subscription:n}},{"./subscription.js":346}],346:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("eventemitter3");function a(e){o.call(this),this.id=null,this.callback=n.identity,this.arguments=null,this._reconnectIntervalId=null,this.options={subscription:e.subscription,type:e.type,requestManager:e.requestManager}}a.prototype=Object.create(o.prototype),a.prototype.constructor=a,a.prototype._extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},a.prototype._validateArgs=function(e){var t=this.options.subscription;if(t||(t={}),t.params||(t.params=0),e.length!==t.params)throw i.InvalidNumberOfParams(e.length,t.params+1,e[0])},a.prototype._formatInput=function(e){var t=this.options.subscription;return t&&t.inputFormatter?t.inputFormatter.map(function(t,r){return t?t(e[r]):e[r]}):e},a.prototype._formatOutput=function(e){var t=this.options.subscription;return t&&t.outputFormatter&&e?t.outputFormatter(e):e},a.prototype._toPayload=function(e){var t=[];if(this.callback=this._extractCallback(e)||n.identity,this.subscriptionMethod||(this.subscriptionMethod=e.shift(),this.options.subscription.subscriptionName&&(this.subscriptionMethod=this.options.subscription.subscriptionName)),this.arguments||(this.arguments=this._formatInput(e),this._validateArgs(this.arguments),e=[]),t.push(this.subscriptionMethod),t=t.concat(this.arguments),e.length)throw new Error("Only a callback is allowed as parameter on an already instantiated subscription.");return{method:this.options.type+"_subscribe",params:t}},a.prototype.unsubscribe=function(e){this.options.requestManager.removeSubscription(this.id,e),this.id=null,this.removeAllListeners(),clearInterval(this._reconnectIntervalId)},a.prototype.subscribe=function(){var e=this,t=Array.prototype.slice.call(arguments),r=this._toPayload(t);if(!r)return this;if(!this.options.requestManager.provider){var i=new Error("No provider set.");return this.callback(i,null,this),this.emit("error",i),this}if(!this.options.requestManager.provider.on){var o=new Error("The current provider doesn't support subscriptions: "+this.options.requestManager.provider.constructor.name);return this.callback(o,null,this),this.emit("error",o),this}return this.id&&this.unsubscribe(),this.options.params=r.params[1],"logs"===r.params[0]&&n.isObject(r.params[1])&&r.params[1].hasOwnProperty("fromBlock")&&isFinite(r.params[1].fromBlock)&&this.options.requestManager.send({method:"eth_getLogs",params:[r.params[1]]},function(t,r){t?(e.callback(t,null,e),e.emit("error",t)):r.forEach(function(t){var r=e._formatOutput(t);e.callback(null,r,e),e.emit("data",r)})}),"object"==typeof r.params[1]&&delete r.params[1].fromBlock,this.options.requestManager.send(r,function(t,i){!t&&i?(e.id=i,e.options.requestManager.addSubscription(e.id,r.params[0],e.options.type,function(t,r){t?(e.options.requestManager.removeSubscription(e.id),e.options.requestManager.provider.once&&(e._reconnectIntervalId=setInterval(function(){e.options.requestManager.provider.reconnect&&e.options.requestManager.provider.reconnect()},500),e.options.requestManager.provider.once("connect",function(){clearInterval(e._reconnectIntervalId),e.subscribe(e.callback)})),e.emit("error",t),e.callback(t,null,e)):(n.isArray(r)||(r=[r]),r.forEach(function(t){var r=e._formatOutput(t);if(n.isFunction(e.options.subscription.subscriptionHandler))return e.options.subscription.subscriptionHandler.call(e,r);e.emit("data",r),e.callback(null,r,e)}))})):(e.callback(t,null,e),e.emit("error",t))}),this},t.exports=a},{eventemitter3:156,underscore:325,"web3-core-helpers":338}],347:[function(e,t,r){"use strict";var n=e("web3-core-helpers").formatters,i=e("web3-core-method"),o=e("web3-utils");t.exports=function(e){var t=function(t){var r;return t.property?(e[t.property]||(e[t.property]={}),r=e[t.property]):r=e,t.methods&&t.methods.forEach(function(t){t instanceof i||(t=new i(t)),t.attachToObject(r),t.setRequestManager(e._requestManager)}),e};return t.formatters=n,t.utils=o,t.Method=i,t}},{"web3-core-helpers":338,"web3-core-method":339,"web3-utils":403}],348:[function(e,t,r){"use strict";var n=e("web3-core-requestmanager"),i=e("./extend.js");t.exports={packageInit:function(e,t){if(t=Array.prototype.slice.call(t),!e)throw new Error('You need to instantiate using the "new" keyword.');Object.defineProperty(e,"currentProvider",{get:function(){return e._provider},set:function(t){return e.setProvider(t)},enumerable:!0,configurable:!0}),t[0]&&t[0]._requestManager?e._requestManager=new n.Manager(t[0].currentProvider):(e._requestManager=new n.Manager,e._requestManager.setProvider(t[0],t[1])),e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers,e._provider=e._requestManager.provider,e.setProvider||(e.setProvider=function(t,r){return e._requestManager.setProvider(t,r),e._provider=e._requestManager.provider,!0}),e.BatchRequest=n.BatchManager.bind(null,e._requestManager),e.extend=i(e)},addProviders:function(e){e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers}}},{"./extend.js":347,"web3-core-requestmanager":343}],349:[function(e,t,r){var n=e("underscore"),i=e("web3-utils"),o=new(0,e("ethers/utils/abi-coder").AbiCoder)(function(e,t){return!e.match(/^u?int/)||n.isArray(t)||n.isObject(t)&&"BN"===t.constructor.name?t:t.toString()});function a(){}var s=function(){};s.prototype.encodeFunctionSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e).slice(0,10)},s.prototype.encodeEventSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e)},s.prototype.encodeParameter=function(e,t){return this.encodeParameters([e],[t])},s.prototype.encodeParameters=function(e,t){return o.encode(this.mapTypes(e),t)},s.prototype.mapTypes=function(e){var t=this,r=[];return e.forEach(function(e){if(t.isSimplifiedStructFormat(e)){var n=Object.keys(e)[0];r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}else r.push(e)}),r},s.prototype.isSimplifiedStructFormat=function(e){return"object"==typeof e&&void 0===e.components&&void 0===e.name},s.prototype.mapStructNameAndType=function(e){var t="tuple";return e.indexOf("[]")>-1&&(t="tuple[]",e=e.slice(0,-2)),{type:t,name:e}},s.prototype.mapStructToCoderFormat=function(e){var t=this,r=[];return Object.keys(e).forEach(function(n){"object"!=typeof e[n]?r.push({name:n,type:e[n]}):r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}),r},s.prototype.encodeFunctionCall=function(e,t){return this.encodeFunctionSignature(e)+this.encodeParameters(e.inputs,t).replace("0x","")},s.prototype.decodeParameter=function(e,t){return this.decodeParameters([e],t)[0]},s.prototype.decodeParameters=function(e,t){if(!t||"0x"===t||"0X"===t)throw new Error("Returned values aren't valid, did it run Out of Gas?");var r=o.decode(this.mapTypes(e),"0x"+t.replace(/0x/i,"")),i=new a;return i.__length__=0,e.forEach(function(e,t){var o=r[i.__length__];o="0x"===o?null:o,i[t]=o,n.isObject(e)&&e.name&&(i[e.name]=o),i.__length__++}),i},s.prototype.decodeLog=function(e,t,r){var i=this;r=n.isArray(r)?r:[r],t=t||"";var o=[],s=[],u=0;e.forEach(function(e,t){e.indexed?(s[t]=["bool","int","uint","address","fixed","ufixed"].find(function(t){return-1!==e.type.indexOf(t)})?i.decodeParameter(e.type,r[u]):r[u],u++):o[t]=e});var c=t,f=c?this.decodeParameters(o,c):[],h=new a;return h.__length__=0,e.forEach(function(e,t){h[t]="string"===e.type?"":null,void 0!==f[t]&&(h[t]=f[t]),void 0!==s[t]&&(h[t]=s[t]),e.name&&(h[e.name]=h[t]),h.__length__++}),h};var u=new s;t.exports=u},{"ethers/utils/abi-coder":143,underscore:325,"web3-utils":403}],350:[function(e,t,r){(function(r){var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=e("./bytes"),o=e("./nat"),a=e("elliptic"),s=(e("./rlp"),new a.ec("secp256k1")),u=e("./hash"),c=u.keccak256,f=u.keccak256s,h=function(e){for(var t=f(e.slice(2)),r="0x",n=0;n<40;n++)r+=parseInt(t[n+2],16)>7?e[n+2].toUpperCase():e[n+2];return r},l=function(e){var t=new r(e.slice(2),"hex"),n="0x"+s.keyFromPrivate(t).getPublic(!1,"hex").slice(2),i=c(n);return{address:h("0x"+i.slice(-40)),privateKey:e}},d=function(e){var t=n(e,3),r=t[0],o=i.pad(32,t[1]),a=i.pad(32,t[2]);return i.flatten([o,a,r])},p=function(e){return[i.slice(64,i.length(e),e),i.slice(0,32,e),i.slice(32,64,e)]},b=function(e){return function(t,n){var a=s.keyFromPrivate(new r(n.slice(2),"hex")).sign(new r(t.slice(2),"hex"),{canonical:!0});return d([o.fromString(i.fromNumber(e+a.recoveryParam)),i.pad(32,i.fromNat("0x"+a.r.toString(16))),i.pad(32,i.fromNat("0x"+a.s.toString(16)))])}},y=b(27);t.exports={create:function(e){var t=c(i.concat(i.random(32),e||i.random(32))),r=i.concat(i.concat(i.random(32),t),i.random(32)),n=c(r);return l(n)},toChecksum:h,fromPrivate:l,sign:y,makeSigner:b,recover:function(e,t){var n=p(t),o={v:i.toNumber(n[0]),r:n[1].slice(2),s:n[2].slice(2)},a="0x"+s.recoverPubKey(new r(e.slice(2),"hex"),o,o.v<2?o.v:1-o.v%2).encode("hex",!1).slice(2),u=c(a);return h("0x"+u.slice(-40))},encodeSignature:d,decodeSignature:p}}).call(this,e("buffer").Buffer)},{"./bytes":352,"./hash":353,"./nat":354,"./rlp":355,buffer:84,elliptic:109}],351:[function(e,t,r){arguments[4][132][0].apply(r,arguments)},{dup:132}],352:[function(e,t,r){arguments[4][133][0].apply(r,arguments)},{"./array.js":351,dup:133}],353:[function(e,t,r){arguments[4][134][0].apply(r,arguments)},{dup:134}],354:[function(e,t,r){var n=e("bn.js"),i=e("./bytes"),o=function(e){return new n(e.slice(2),16)},a=function(e){var t="0x"+("0x"===e.slice(0,2)?new n(e.slice(2),16):new n(e,10)).toString("hex");return"0x0"===t?"0x":t},s=function(e){return"string"==typeof e?/^0x/.test(e)?e:"0x"+e:"0x"+new n(e).toString("hex")},u=function(e){return o(e).toNumber()},c=function(e){return function(t,r){return"0x"+o(t)[e](o(r)).toString("hex")}},f=c("add"),h=c("mul"),l=c("div"),d=c("sub");t.exports={toString:function(e){return o(e).toString(10)},fromString:a,toNumber:u,fromNumber:s,toEther:function(e){return u(l(e,a("10000000000")))/1e8},fromEther:function(e){return h(s(Math.floor(1e8*e)),a("10000000000"))},toUint256:function(e){return i.pad(32,e)},add:f,mul:h,div:l,sub:d}},{"./bytes":352,"bn.js":53}],355:[function(e,t,r){t.exports={encode:function(e){var t=function(e){return(t=e.toString(16)).length%2==0?t:"0"+t;var t},r=function(e,r){return e<56?t(r+e):t(r+t(e).length/2+55)+t(e)};return"0x"+function e(t){if("string"==typeof t){var n=t.slice(2);return(2!=n.length||n>="80"?r(n.length/2,128):"")+n}var i=t.map(e).join("");return r(i.length/2,192)+i}(e)},decode:function(e){var t=2,r=function(){if(t>=e.length)throw"";var r=e.slice(t,t+2);return r<"80"?(t+=2,"0x"+r):r<"c0"?i():o()},n=function(){var r=parseInt(e.slice(t,t+=2),16)%64;return r<56?r:parseInt(e.slice(t,t+=2*(r-55)),16)},i=function(){var r=n();return"0x"+e.slice(t,t+=2*r)},o=function(){for(var e=2*n()+t,i=[];t>>((3&t)<<3)&255;return i}}t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],357:[function(e,t,r){for(var n=e("./rng"),i=[],o={},a=0;a<256;a++)i[a]=(a+256).toString(16).substr(1),o[i[a]]=a;function s(e,t){var r=t||0,n=i;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var u=n(),c=[1|u[0],u[1],u[2],u[3],u[4],u[5]],f=16383&(u[6]<<8|u[7]),h=0,l=0;function d(e,t,r){var i=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||n)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var a=0;a<16;a++)t[i+a]=o[a];return t||s(o)}var p=d;p.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:f,a=void 0!==e.msecs?e.msecs:(new Date).getTime(),u=void 0!==e.nsecs?e.nsecs:l+1,d=a-h+(u-l)/1e4;if(d<0&&void 0===e.clockseq&&(o=o+1&16383),(d<0||a>h)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");h=a,l=u,f=o;var p=(1e4*(268435455&(a+=122192928e5))+u)%4294967296;i[n++]=p>>>24&255,i[n++]=p>>>16&255,i[n++]=p>>>8&255,i[n++]=255&p;var b=a/4294967296*1e4&268435455;i[n++]=b>>>8&255,i[n++]=255&b,i[n++]=b>>>24&15|16,i[n++]=b>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var y=e.node||c,m=0;m<6;m++)i[n+m]=y[m];return t||s(i)},p.v4=d,p.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=o[e])});i<16;)t[n+i++]=0;return t},p.unparse=s,t.exports=p},{"./rng":356}],358:[function(e,t,r){(function(r,n){"use strict";var i=e("underscore"),o=e("web3-core"),a=e("web3-core-method"),s=e("any-promise"),u=e("eth-lib/lib/account"),c=e("eth-lib/lib/hash"),f=e("eth-lib/lib/rlp"),h=e("eth-lib/lib/nat"),l=e("eth-lib/lib/bytes"),d=e(void 0===r?"crypto-browserify":"crypto"),p=e("scrypt.js"),b=e("uuid"),y=e("web3-utils"),m=e("web3-core-helpers"),v=function(e){return i.isUndefined(e)||i.isNull(e)},g=function(e){for(;e&&e.startsWith("0x0");)e="0x"+e.slice(3);return e},w=function(e){return e.length%2==1&&(e=e.replace("0x","0x0")),e},_=function(){var e=this;o.packageInit(this,arguments),delete this.BatchRequest,delete this.extend;var t=[new a({name:"getId",call:"net_version",params:0,outputFormatter:y.hexToNumber}),new a({name:"getGasPrice",call:"eth_gasPrice",params:0}),new a({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[function(e){if(y.isAddress(e))return e;throw new Error("Address "+e+' is not a valid address to get the "transactionCount".')},function(){return"latest"}]})];this._ethereumCall={},i.each(t,function(t){t.attachToObject(e._ethereumCall),t.setRequestManager(e._requestManager)}),this.wallet=new A(this)};function A(e){this._accounts=e,this.length=0,this.defaultKeyName="web3js_wallet"}_.prototype._addAccountFunctions=function(e){var t=this;return e.signTransaction=function(r,n){return t.signTransaction(r,e.privateKey,n)},e.sign=function(r){return t.sign(r,e.privateKey)},e.encrypt=function(r,n){return t.encrypt(e.privateKey,r,n)},e},_.prototype.create=function(e){return this._addAccountFunctions(u.create(e||y.randomHex(32)))},_.prototype.privateKeyToAccount=function(e){return this._addAccountFunctions(u.fromPrivate(e))},_.prototype.signTransaction=function(e,t,r){var n,o=!1;if(r=r||function(){},!e)return o=new Error("No transaction object given!"),r(o),s.reject(o);function a(e){if(e.gas||e.gasLimit||(o=new Error('"gas" is missing')),(e.nonce<0||e.gas<0||e.gasPrice<0||e.chainId<0)&&(o=new Error("Gas, gasPrice, nonce or chainId is lower than 0")),o)return r(o),s.reject(o);try{var i=e=m.formatters.inputCallFormatter(e);i.to=e.to||"0x",i.data=e.data||"0x",i.value=e.value||"0x",i.chainId=y.numberToHex(e.chainId);var a=f.encode([l.fromNat(i.nonce),l.fromNat(i.gasPrice),l.fromNat(i.gas),i.to.toLowerCase(),l.fromNat(i.value),i.data,l.fromNat(i.chainId||"0x1"),"0x","0x"]),d=c.keccak256(a),p=u.makeSigner(2*h.toNumber(i.chainId||"0x1")+35)(c.keccak256(a),t),b=f.decode(a).slice(0,6).concat(u.decodeSignature(p));b[6]=w(g(b[6])),b[7]=w(g(b[7])),b[8]=w(g(b[8]));var v=f.encode(b),_=f.decode(v);n={messageHash:d,v:g(_[6]),r:g(_[7]),s:g(_[8]),rawTransaction:v}}catch(e){return r(e),s.reject(e)}return r(null,n),n}return void 0!==e.nonce&&void 0!==e.chainId&&void 0!==e.gasPrice?s.resolve(a(e)):s.all([v(e.chainId)?this._ethereumCall.getId():e.chainId,v(e.gasPrice)?this._ethereumCall.getGasPrice():e.gasPrice,v(e.nonce)?this._ethereumCall.getTransactionCount(this.privateKeyToAccount(t).address):e.nonce]).then(function(t){if(v(t[0])||v(t[1])||v(t[2]))throw new Error('One of the values "chainId", "gasPrice", or "nonce" couldn\'t be fetched: '+JSON.stringify(t));return a(i.extend(e,{chainId:t[0],gasPrice:t[1],nonce:t[2]}))})},_.prototype.recoverTransaction=function(e){var t=f.decode(e),r=u.encodeSignature(t.slice(6,9)),n=l.toNumber(t[6]),i=n<35?[]:[l.fromNumber(n-35>>1),"0x","0x"],o=t.slice(0,6).concat(i),a=f.encode(o);return u.recover(c.keccak256(a),r)},_.prototype.hashMessage=function(e){var t=y.isHexStrict(e)?y.hexToBytes(e):e,r=n.from(t),i="Ethereum Signed Message:\n"+t.length,o=n.from(i),a=n.concat([o,r]);return c.keccak256s(a)},_.prototype.sign=function(e,t){var r=this.hashMessage(e),n=u.sign(r,t),i=u.decodeSignature(n);return{message:e,messageHash:r,v:i[0],r:i[1],s:i[2],signature:n}},_.prototype.recover=function(e,t,r){var n=[].slice.apply(arguments);return i.isObject(e)?this.recover(e.messageHash,u.encodeSignature([e.v,e.r,e.s]),!0):(r||(e=this.hashMessage(e)),n.length>=4?(r=n.slice(-1)[0],r=!!i.isBoolean(r)&&!!r,this.recover(e,u.encodeSignature(n.slice(1,4)),r)):u.recover(e,t))},_.prototype.decrypt=function(e,t,r){if(!i.isString(t))throw new Error("No password given.");var o,a,s=i.isObject(e)?e:JSON.parse(r?e.toLowerCase():e);if(3!==s.version)throw new Error("Not a valid V3 wallet");if("scrypt"===s.crypto.kdf)a=s.crypto.kdfparams,o=p(new n(t),new n(a.salt,"hex"),a.n,a.r,a.p,a.dklen);else{if("pbkdf2"!==s.crypto.kdf)throw new Error("Unsupported key derivation scheme");if("hmac-sha256"!==(a=s.crypto.kdfparams).prf)throw new Error("Unsupported parameters to PBKDF2");o=d.pbkdf2Sync(new n(t),new n(a.salt,"hex"),a.c,a.dklen,"sha256")}var u=new n(s.crypto.ciphertext,"hex");if(y.sha3(n.concat([o.slice(16,32),u])).replace("0x","")!==s.crypto.mac)throw new Error("Key derivation failed - possibly wrong password");var c=d.createDecipheriv(s.crypto.cipher,o.slice(0,16),new n(s.crypto.cipherparams.iv,"hex")),f="0x"+n.concat([c.update(u),c.final()]).toString("hex");return this.privateKeyToAccount(f)},_.prototype.encrypt=function(e,t,r){var i,o=this.privateKeyToAccount(e),a=(r=r||{}).salt||d.randomBytes(32),s=r.iv||d.randomBytes(16),u=r.kdf||"scrypt",c={dklen:r.dklen||32,salt:a.toString("hex")};if("pbkdf2"===u)c.c=r.c||262144,c.prf="hmac-sha256",i=d.pbkdf2Sync(new n(t),a,c.c,c.dklen,"sha256");else{if("scrypt"!==u)throw new Error("Unsupported kdf");c.n=r.n||8192,c.r=r.r||8,c.p=r.p||1,i=p(new n(t),a,c.n,c.r,c.p,c.dklen)}var f=d.createCipheriv(r.cipher||"aes-128-ctr",i.slice(0,16),s);if(!f)throw new Error("Unsupported cipher");var h=n.concat([f.update(new n(o.privateKey.replace("0x",""),"hex")),f.final()]),l=y.sha3(n.concat([i.slice(16,32),new n(h,"hex")])).replace("0x","");return{version:3,id:b.v4({random:r.uuid||d.randomBytes(16)}),address:o.address.toLowerCase().replace("0x",""),crypto:{ciphertext:h.toString("hex"),cipherparams:{iv:s.toString("hex")},cipher:r.cipher||"aes-128-ctr",kdf:u,kdfparams:c,mac:l.toString("hex")}}},A.prototype._findSafeIndex=function(e){return e=e||0,i.has(this,e)?this._findSafeIndex(e+1):e},A.prototype._currentIndexes=function(){return Object.keys(this).map(function(e){return parseInt(e)}).filter(function(e){return e<9e20})},A.prototype.create=function(e,t){for(var r=0;r=2?t.slice(2):t;var r=h.decodeParameters(e,t);return 1===r.__length__?r[0]:(delete r.__length__,r)},l.prototype.deploy=function(e,t){if((e=e||{}).arguments=e.arguments||[],!(e=this._getOrSetDefaultOptions(e)).data)return a._fireError(new Error('No "data" specified in neither the given options, nor the default options.'),null,null,t);var r=n.find(this.options.jsonInterface,function(e){return"constructor"===e.type})||{};return r.signature="constructor",this._createTxObject.apply({method:r,parent:this,deployData:e.data,_ethAccounts:this.constructor._ethAccounts},e.arguments)},l.prototype._generateEventOptions=function(){var e=Array.prototype.slice.call(arguments),t=this._getCallback(e),r=n.isObject(e[e.length-1])?e.pop():{},i=n.isString(e[0])?e[0]:"allevents";if(!(i="allevents"===i.toLowerCase()?{name:"ALLEVENTS",jsonInterface:this.options.jsonInterface}:this.options.jsonInterface.find(function(e){return"event"===e.type&&(e.name===i||e.signature==="0x"+i.replace("0x",""))})))throw new Error('Event "'+i.name+"\" doesn't exist in this contract.");if(!a.isAddress(this.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return{params:this._encodeEventABI(i,r),event:i,callback:t}},l.prototype.clone=function(){return new this.constructor(this.options.jsonInterface,this.options.address,this.options)},l.prototype.once=function(e,t,r){var i=Array.prototype.slice.call(arguments);if(!(r=this._getCallback(i)))throw new Error("Once requires a callback as the second parameter.");t&&delete t.fromBlock,this._on(e,t,function(e,t,i){i.unsubscribe(),n.isFunction(r)&&r(e,t,i)})},l.prototype._on=function(){var e=this._generateEventOptions.apply(this,arguments);this._checkListener("newListener",e.event.name,e.callback),this._checkListener("removeListener",e.event.name,e.callback);var t=new s({subscription:{params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event),subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},type:"eth",requestManager:this._requestManager});return t.subscribe("logs",e.params,e.callback||function(){}),t},l.prototype.getPastEvents=function(){var e=this._generateEventOptions.apply(this,arguments),t=new o({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event)});t.setRequestManager(this._requestManager);var r=t.buildCall();return t=null,r(e.params,e.callback)},l.prototype._createTxObject=function(){var e=Array.prototype.slice.call(arguments),t={};if("function"===this.method.type&&(t.call=this.parent._executeMethod.bind(t,"call"),t.call.request=this.parent._executeMethod.bind(t,"call",!0)),t.send=this.parent._executeMethod.bind(t,"send"),t.send.request=this.parent._executeMethod.bind(t,"send",!0),t.encodeABI=this.parent._encodeMethodABI.bind(t),t.estimateGas=this.parent._executeMethod.bind(t,"estimate"),e&&this.method.inputs&&e.length!==this.method.inputs.length){if(this.nextMethod)return this.nextMethod.apply(null,e);throw c.InvalidNumberOfParams(e.length,this.method.inputs.length,this.method.name)}return t.arguments=e||[],t._method=this.method,t._parent=this.parent,t._ethAccounts=this.parent.constructor._ethAccounts||this._ethAccounts,this.deployData&&(t._deployData=this.deployData),t},l.prototype._processExecuteArguments=function(e,t){var r={};if(r.type=e.shift(),r.callback=this._parent._getCallback(e),"call"===r.type&&!0!==e[e.length-1]&&(n.isString(e[e.length-1])||isFinite(e[e.length-1]))&&(r.defaultBlock=e.pop()),r.options=n.isObject(e[e.length-1])?e.pop():{},r.generateRequest=!0===e[e.length-1]&&e.pop(),r.options=this._parent._getOrSetDefaultOptions(r.options),r.options.data=this.encodeABI(),!this._deployData&&!a.isAddress(this._parent.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return this._deployData||(r.options.to=this._parent.options.address),r.options.data?r:a._fireError(new Error("Couldn't find a matching contract method, or the number of parameters is wrong."),t.eventEmitter,t.reject,r.callback)},l.prototype._executeMethod=function(){var e=this,t=this._parent._processExecuteArguments.call(this,Array.prototype.slice.call(arguments),r),r=f("send"!==t.type),i=e.constructor._ethAccounts||e._ethAccounts;if(t.generateRequest){var s={params:[u.inputCallFormatter.call(this._parent,t.options)],callback:t.callback};return"call"===t.type?(s.params.push(u.inputDefaultBlockNumberFormatter.call(this._parent,t.defaultBlock)),s.method="eth_call",s.format=this._parent._decodeMethodReturn.bind(null,this._method.outputs)):s.method="eth_sendTransaction",s}switch(t.type){case"estimate":return new o({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[u.inputCallFormatter],outputFormatter:a.hexToNumber,requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.callback);case"call":return new o({name:"call",call:"eth_call",params:2,inputFormatter:[u.inputCallFormatter,u.inputDefaultBlockNumberFormatter],outputFormatter:function(t){return e._parent._decodeMethodReturn(e._method.outputs,t)},requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.defaultBlock,t.callback);case"send":if(!a.isAddress(t.options.from))return a._fireError(new Error('No "from" address specified in neither the given options, nor the default options.'),r.eventEmitter,r.reject,t.callback);if(n.isBoolean(this._method.payable)&&!this._method.payable&&t.options.value&&t.options.value>0)return a._fireError(new Error("Can not send value to non-payable contract method or constructor"),r.eventEmitter,r.reject,t.callback);var c={receiptFormatter:function(t){if(n.isArray(t.logs)){var r=n.map(t.logs,function(t){return e._parent._decodeEventABI.call({name:"ALLEVENTS",jsonInterface:e._parent.options.jsonInterface},t)});t.events={};var i=0;r.forEach(function(e){e.event?t.events[e.event]?Array.isArray(t.events[e.event])?t.events[e.event].push(e):t.events[e.event]=[t.events[e.event],e]:t.events[e.event]=e:(t.events[i]=e,i++)}),delete t.logs}return t},contractDeployFormatter:function(t){var r=e._parent.clone();return r.options.address=t.contractAddress,r}};return new o({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[u.inputTransactionFormatter],requestManager:e._parent._requestManager,accounts:e.constructor._ethAccounts||e._ethAccounts,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock,extraFormatters:c}).createFunction()(t.options,t.callback)}},t.exports=l},{underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-utils":403}],360:[function(e,t,r){"use strict";var n=e("./config"),i=e("./contracts/Registry"),o=e("./lib/ResolverMethodHandler");function a(e){this.eth=e}Object.defineProperty(a.prototype,"registry",{get:function(){return new i(this)},enumerable:!0}),Object.defineProperty(a.prototype,"resolverMethodHandler",{get:function(){return new o(this.registry)},enumerable:!0}),a.prototype.resolver=function(e){return this.registry.resolver(e)},a.prototype.getAddress=function(e,t){return this.resolverMethodHandler.method(e,"addr",[]).call(t)},a.prototype.setAddress=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setAddr",[t]).send(r,n)},a.prototype.getPubkey=function(e,t){return this.resolverMethodHandler.method(e,"pubkey",[],t).call(t)},a.prototype.setPubkey=function(e,t,r,n,i){return this.resolverMethodHandler.method(e,"setPubkey",[t,r]).send(n,i)},a.prototype.getContent=function(e,t){return this.resolverMethodHandler.method(e,"content",[]).call(t)},a.prototype.setContent=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setContent",[t]).send(r,n)},a.prototype.getMultihash=function(e,t){return this.resolverMethodHandler.method(e,"multihash",[]).call(t)},a.prototype.setMultihash=function(e,t,r,n){return this.resolverMethodHandler.method(e,"multihash",[t]).send(r,n)},a.prototype.checkNetwork=function(){var e=this;return e.eth.getBlock("latest").then(function(t){var r=new Date/1e3-t.timestamp;if(r>3600)throw new Error("Network not synced; last block was "+r+" seconds ago");return e.eth.net.getNetworkType()}).then(function(e){var t=n.addresses[e];if(void 0===t)throw new Error("ENS is not supported on network "+e);return t})},t.exports=a},{"./config":361,"./contracts/Registry":362,"./lib/ResolverMethodHandler":364}],361:[function(e,t,r){"use strict";t.exports={addresses:{main:"0x314159265dD8dbb310642f98f50C066173C1259b",ropsten:"0x112234455c3a32fd11230c42e7bccd4a84e02010",rinkeby:"0xe7410170f87102df0055eb195163a03b7f2bff4a"}}},{}],362:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-eth-contract"),o=e("eth-ens-namehash"),a=e("web3-core-promievent"),s=e("../ressources/ABI/Registry"),u=e("../ressources/ABI/Resolver");function c(e){var t=this;this.ens=e,this.contract=e.checkNetwork().then(function(e){var r=new i(s,e);return r.setProvider(t.ens.eth.currentProvider),r})}c.prototype.owner=function(e,t){var r=new a(!0);return this.contract.then(function(i){i.methods.owner(o.hash(e)).call().then(function(e){r.resolve(e),n.isFunction(t)&&t(e)}).catch(function(e){r.reject(e),n.isFunction(t)&&t(e)})}),r.eventEmitter},c.prototype.resolver=function(e){var t=this;return this.contract.then(function(t){return t.methods.resolver(o.hash(e)).call()}).then(function(e){var r=new i(u,e);return r.setProvider(t.ens.eth.currentProvider),r})},t.exports=c},{"../ressources/ABI/Registry":365,"../ressources/ABI/Resolver":366,"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340,"web3-eth-contract":359}],363:[function(e,t,r){"use strict";var n=e("./ENS");t.exports=n},{"./ENS":360}],364:[function(e,t,r){"use strict";var n=e("web3-core-promievent"),i=e("eth-ens-namehash"),o=e("underscore");function a(e){this.registry=e}a.prototype.method=function(e,t,r,n){return{call:this.call.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this}),send:this.send.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this})}},a.prototype.call=function(e){var t=this,r=new n,i=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){t.parent.handleCall(r,n.methods[t.methodName],i,e)}).catch(function(e){r.reject(e)}),r.eventEmitter},a.prototype.send=function(e,t){var r=this,i=new n,o=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){r.parent.handleSend(i,n.methods[r.methodName],o,e,t)}).catch(function(e){i.reject(e)}),i.eventEmitter},a.prototype.handleCall=function(e,t,r,n){return t.apply(this,r).call().then(function(t){e.resolve(t),o.isFunction(n)&&n(t)}).catch(function(t){e.reject(t),o.isFunction(n)&&n(t)}),e},a.prototype.handleSend=function(e,t,r,n,i){return t.apply(this,r).send(n).on("transactionHash",function(t){e.eventEmitter.emit("transactionHash",t)}).on("confirmation",function(t,r){e.eventEmitter.emit("confirmation",t,r)}).on("receipt",function(t){e.eventEmitter.emit("receipt",t),e.resolve(t),o.isFunction(i)&&i(t)}).on("error",function(t){e.eventEmitter.emit("error",t),e.reject(t),o.isFunction(i)&&i(t)}),e},a.prototype.prepareArguments=function(e,t){var r=i.hash(e);return t.length>0?(t.unshift(r),t):[r]},t.exports=a},{"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340}],365:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"resolver",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"owner",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"label",type:"bytes32"},{name:"owner",type:"address"}],name:"setSubnodeOwner",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"ttl",type:"uint64"}],name:"setTTL",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"ttl",outputs:[{name:"",type:"uint64"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"resolver",type:"address"}],name:"setResolver",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"owner",type:"address"}],name:"setOwner",outputs:[],payable:!1,type:"function"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"label",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"NewOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"resolver",type:"address"}],name:"NewResolver",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"ttl",type:"uint64"}],name:"NewTTL",type:"event"}]},{}],366:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"interfaceID",type:"bytes4"}],name:"supportsInterface",outputs:[{name:"",type:"bool"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"},{name:"contentTypes",type:"uint256"}],name:"ABI",outputs:[{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes"}],name:"setMultihash",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"multihash",outputs:[{name:"",type:"bytes"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"setPubkey",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"content",outputs:[{name:"ret",type:"bytes32"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"addr",outputs:[{name:"ret",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],name:"setABI",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"name",outputs:[{name:"ret",type:"string"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"name",type:"string"}],name:"setName",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes32"}],name:"setContent",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"pubkey",outputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"addr",type:"address"}],name:"setAddr",outputs:[],payable:!1,type:"function"},{inputs:[{name:"ensAddr",type:"address"}],payable:!1,type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"a",type:"address"}],name:"AddrChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"hash",type:"bytes32"}],name:"ContentChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"name",type:"string"}],name:"NameChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"contentType",type:"uint256"}],name:"ABIChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"x",type:"bytes32"},{indexed:!1,name:"y",type:"bytes32"}],name:"PubkeyChanged",type:"event"}]},{}],367:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],368:[function(e,t,r){"use strict";var n=e("web3-utils"),i=e("bn.js"),o=function(e){var t="A".charCodeAt(0),r="Z".charCodeAt(0);return(e=(e=e.toUpperCase()).substr(4)+e.substr(0,4)).split("").map(function(e){var n=e.charCodeAt(0);return n>=t&&n<=r?n-t+10:e}).join("")},a=function(e){for(var t,r=e;r.length>2;)t=r.slice(0,9),r=parseInt(t,10)%97+r.slice(t.length);return parseInt(r,10)%97},s=function(e){this._iban=e};s.toAddress=function(e){if(!(e=new s(e)).isDirect())throw new Error("IBAN is indirect and can't be converted");return e.toAddress()},s.toIban=function(e){return s.fromAddress(e).toString()},s.fromAddress=function(e){if(!n.isAddress(e))throw new Error("Provided address is not a valid address: "+e);e=e.replace("0x","").replace("0X","");var t=function(e,t){for(var r=e;r.length<2*t;)r="0"+r;return r}(new i(e,16).toString(36),15);return s.fromBban(t.toUpperCase())},s.fromBban=function(e){var t=("0"+(98-a(o("XE00"+e)))).slice(-2);return new s("XE"+t+e)},s.createIndirect=function(e){return s.fromBban("ETH"+e.institution+e.identifier)},s.isValid=function(e){return new s(e).isValid()},s.prototype.isValid=function(){return/^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban)&&1===a(o(this._iban))},s.prototype.isDirect=function(){return 34===this._iban.length||35===this._iban.length},s.prototype.isIndirect=function(){return 20===this._iban.length},s.prototype.checksum=function(){return this._iban.substr(2,2)},s.prototype.institution=function(){return this.isIndirect()?this._iban.substr(7,4):""},s.prototype.client=function(){return this.isIndirect()?this._iban.substr(11):""},s.prototype.toAddress=function(){if(this.isDirect()){var e=this._iban.substr(4),t=new i(e,36);return n.toChecksumAddress(t.toString(16,20))}return""},s.prototype.toString=function(){return this._iban},t.exports=s},{"bn.js":367,"web3-utils":403}],369:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=e("web3-net"),s=e("web3-core-helpers").formatters,u=function(){var e=this;n.packageInit(this,arguments),this.net=new a(this.currentProvider);var t=null,r="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return t},set:function(e){return e&&(t=o.toChecksumAddress(s.inputAddressFormatter(e))),u.forEach(function(e){e.defaultAccount=t}),e},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return r},set:function(e){return r=e,u.forEach(function(e){e.defaultBlock=r}),e},enumerable:!0});var u=[new i({name:"getAccounts",call:"personal_listAccounts",params:0,outputFormatter:o.toChecksumAddress}),new i({name:"newAccount",call:"personal_newAccount",params:1,inputFormatter:[null],outputFormatter:o.toChecksumAddress}),new i({name:"unlockAccount",call:"personal_unlockAccount",params:3,inputFormatter:[s.inputAddressFormatter,null,null]}),new i({name:"lockAccount",call:"personal_lockAccount",params:1,inputFormatter:[s.inputAddressFormatter]}),new i({name:"importRawKey",call:"personal_importRawKey",params:2}),new i({name:"sendTransaction",call:"personal_sendTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"signTransaction",call:"personal_signTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"sign",call:"personal_sign",params:3,inputFormatter:[s.inputSignFormatter,s.inputAddressFormatter,null]}),new i({name:"ecRecover",call:"personal_ecRecover",params:2,inputFormatter:[s.inputSignFormatter,null]})];u.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};n.addProviders(u),t.exports=u},{"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-net":372,"web3-utils":403}],370:[function(e,t,r){"use strict";var n=e("underscore");t.exports=function(e){var t,r=this;return this.net.getId().then(function(e){return t=e,r.getBlock(0)}).then(function(r){var i="private";return"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"===r.hash&&1===t&&(i="main"),"0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303"===r.hash&&2===t&&(i="morden"),"0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"===r.hash&&3===t&&(i="ropsten"),"0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177"===r.hash&&4===t&&(i="rinkeby"),"0xa3c565fc15c7478862d50ccd6561e3c06b24cc509bf388941c25ea985ce32cb9"===r.hash&&42===t&&(i="kovan"),n.isFunction(e)&&e(null,i),i}).catch(function(t){if(!n.isFunction(e))throw t;e(t)})}},{underscore:325}],371:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core"),o=e("web3-core-helpers"),a=e("web3-core-subscriptions").subscriptions,s=e("web3-core-method"),u=e("web3-utils"),c=e("web3-net"),f=e("web3-eth-ens"),h=e("web3-eth-personal"),l=e("web3-eth-contract"),d=e("web3-eth-iban"),p=e("web3-eth-accounts"),b=e("web3-eth-abi"),y=e("./getNetworkType.js"),m=o.formatters,v=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},g=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},w=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},_=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},A=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"},E=function(){var e=this;i.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments),e.personal.setProvider.apply(e,arguments),e.accounts.setProvider.apply(e,arguments),e.Contract.setProvider(e.currentProvider,e.accounts)};var r=null,o="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return r},set:function(t){return t&&(r=u.toChecksumAddress(m.inputAddressFormatter(t))),e.Contract.defaultAccount=r,e.personal.defaultAccount=r,k.forEach(function(e){e.defaultAccount=r}),t},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return o},set:function(t){return o=t,e.Contract.defaultBlock=o,e.personal.defaultBlock=o,k.forEach(function(e){e.defaultBlock=o}),t},enumerable:!0}),this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new c(this.currentProvider),this.net.getNetworkType=y.bind(this),this.accounts=new p(this.currentProvider),this.personal=new h(this.currentProvider),this.personal.defaultAccount=this.defaultAccount;var E=this,x=function(){l.apply(this,arguments);var e=this,t=E.setProvider;E.setProvider=function(){t.apply(E,arguments),i.packageInit(e,[E.currentProvider])}};x.setProvider=function(){l.setProvider.apply(this,arguments)},(x.prototype=Object.create(l.prototype)).constructor=x,this.Contract=x,this.Contract.defaultAccount=this.defaultAccount,this.Contract.defaultBlock=this.defaultBlock,this.Contract.setProvider(this.currentProvider,this.accounts),this.Iban=d,this.abi=b,this.ens=new f(this);var k=[new s({name:"getNodeInfo",call:"web3_clientVersion"}),new s({name:"getProtocolVersion",call:"eth_protocolVersion",params:0}),new s({name:"getCoinbase",call:"eth_coinbase",params:0}),new s({name:"isMining",call:"eth_mining",params:0}),new s({name:"getHashrate",call:"eth_hashrate",params:0,outputFormatter:u.hexToNumber}),new s({name:"isSyncing",call:"eth_syncing",params:0,outputFormatter:m.outputSyncingFormatter}),new s({name:"getGasPrice",call:"eth_gasPrice",params:0,outputFormatter:m.outputBigNumberFormatter}),new s({name:"getAccounts",call:"eth_accounts",params:0,outputFormatter:u.toChecksumAddress}),new s({name:"getBlockNumber",call:"eth_blockNumber",params:0,outputFormatter:u.hexToNumber}),new s({name:"getBalance",call:"eth_getBalance",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:m.outputBigNumberFormatter}),new s({name:"getStorageAt",call:"eth_getStorageAt",params:3,inputFormatter:[m.inputAddressFormatter,u.numberToHex,m.inputDefaultBlockNumberFormatter]}),new s({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"getBlock",call:v,params:2,inputFormatter:[m.inputBlockNumberFormatter,function(e){return!!e}],outputFormatter:m.outputBlockFormatter}),new s({name:"getUncle",call:w,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputBlockFormatter}),new s({name:"getBlockTransactionCount",call:_,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getBlockUncleCount",call:A,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getTransaction",call:"eth_getTransactionByHash",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionFromBlock",call:g,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionReceiptFormatter}),new s({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"sendSignedTransaction",call:"eth_sendRawTransaction",params:1,inputFormatter:[null]}),new s({name:"signTransaction",call:"eth_signTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sign",call:"eth_sign",params:2,inputFormatter:[m.inputSignFormatter,m.inputAddressFormatter],transformPayload:function(e){return e.params.reverse(),e}}),new s({name:"call",call:"eth_call",params:2,inputFormatter:[m.inputCallFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[m.inputCallFormatter],outputFormatter:u.hexToNumber}),new s({name:"submitWork",call:"eth_submitWork",params:3}),new s({name:"getWork",call:"eth_getWork",params:0}),new s({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter}),new a({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:m.outputBlockFormatter},pendingTransactions:{subscriptionName:"newPendingTransactions",params:0},logs:{params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter,subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},syncing:{params:0,outputFormatter:m.outputSyncingFormatter,subscriptionHandler:function(e){var t=this;!0!==this._isSyncing?(this._isSyncing=!0,this.emit("changed",t._isSyncing),n.isFunction(this.callback)&&this.callback(null,t._isSyncing,this),setTimeout(function(){t.emit("data",e),n.isFunction(t.callback)&&t.callback(null,e,t)},0)):(this.emit("data",e),n.isFunction(t.callback)&&this.callback(null,e,this),clearTimeout(this._isSyncingTimeout),this._isSyncingTimeout=setTimeout(function(){e.currentBlock>e.highestBlock-200&&(t._isSyncing=!1,t.emit("changed",t._isSyncing),n.isFunction(t.callback)&&t.callback(null,t._isSyncing,t))},500))}}}})];k.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager,e.accounts),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};i.addProviders(E),t.exports=E},{"./getNetworkType.js":370,underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-eth-accounts":358,"web3-eth-contract":359,"web3-eth-ens":363,"web3-eth-iban":368,"web3-eth-personal":369,"web3-net":372,"web3-utils":403}],372:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=function(){var e=this;n.packageInit(this,arguments),[new i({name:"getId",call:"net_version",params:0,outputFormatter:o.hexToNumber}),new i({name:"isListening",call:"net_listening",params:0}),new i({name:"getPeerCount",call:"net_peerCount",params:0,outputFormatter:o.hexToNumber})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(a),t.exports=a},{"web3-core":348,"web3-core-method":339,"web3-utils":403}],373:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits,o=e("ethereumjs-util"),a=e("eth-block-tracker"),s=e("async/map"),u=e("async/eachSeries"),c=e("./util/stoplight.js");e("./util/rpc-cache-utils.js"),e("./util/create-payload.js");function f(e){const t=this;n.call(t),t.setMaxListeners(30),e=e||{};const r={sendAsync:t._handleAsync.bind(t)},i=e.blockTrackerProvider||r;t._blockTracker=e.blockTracker||new a({provider:i,pollingInterval:e.pollingInterval||4e3}),t._blockTracker.on("block",e=>{const r=function(e){return{number:o.toBuffer(e.number),hash:o.toBuffer(e.hash),parentHash:o.toBuffer(e.parentHash),nonce:o.toBuffer(e.nonce),mixHash:o.toBuffer(e.mixHash),sha3Uncles:o.toBuffer(e.sha3Uncles),logsBloom:o.toBuffer(e.logsBloom),transactionsRoot:o.toBuffer(e.transactionsRoot),stateRoot:o.toBuffer(e.stateRoot),receiptsRoot:o.toBuffer(e.receiptRoot||e.receiptsRoot),miner:o.toBuffer(e.miner),difficulty:o.toBuffer(e.difficulty),totalDifficulty:o.toBuffer(e.totalDifficulty),size:o.toBuffer(e.size),extraData:o.toBuffer(e.extraData),gasLimit:o.toBuffer(e.gasLimit),gasUsed:o.toBuffer(e.gasUsed),timestamp:o.toBuffer(e.timestamp),transactions:e.transactions}}(e);t._setCurrentBlock(r)}),t._blockTracker.on("block",t.emit.bind(t,"rawBlock")),t._blockTracker.on("sync",t.emit.bind(t,"sync")),t._blockTracker.on("latest",t.emit.bind(t,"latest")),t._ready=new c,t._blockTracker.once("block",()=>{t._ready.go()}),t.currentBlock=null,t._providers=[]}t.exports=f,i(f,n),f.prototype.start=function(e=function(){}){this._blockTracker.start().then(e).catch(e)},f.prototype.stop=function(){this._blockTracker.stop()},f.prototype.addProvider=function(e){this._providers.push(e),e.setEngine(this)},f.prototype.send=function(e){throw new Error("Web3ProviderEngine does not support synchronous requests.")},f.prototype.sendAsync=function(e,t){const r=this;r._ready.await(function(){Array.isArray(e)?s(e,r._handleAsync.bind(r),t):r._handleAsync(e,t)})},f.prototype._handleAsync=function(e,t){var r=this,n=-1,i=null,o=null,a=[];function s(r,n){o=r,i=n,u(a,function(e,t){e?e(o,i,t):t()},function(){var r={id:e.id,jsonrpc:e.jsonrpc,result:i};null!=o?(r.error={message:o.stack||o.message||o,code:-32e3},t(o,r)):t(null,r)})}!function t(i){n+=1;a.unshift(i);if(n>=r._providers.length)s(new Error('Request for method "'+e.method+'" not handled by any subprovider. Please check your subprovider configuration to ensure this method is handled.'));else try{var o=r._providers[n];o.handleRequest(e,t,s)}catch(e){s(e)}}()},f.prototype._setCurrentBlock=function(e){this.currentBlock=e,this.emit("block",e)}},{"./util/create-payload.js":391,"./util/rpc-cache-utils.js":394,"./util/stoplight.js":396,"async/eachSeries":25,"async/map":41,"eth-block-tracker":126,"ethereumjs-util":141,events:157,util:333}],374:[function(e,t,r){var n="undefined"!=typeof JSON?JSON:e("jsonify");t.exports=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var r=t.space||"";"number"==typeof r&&(r=Array(r+1).join(" "));var a,s="boolean"==typeof t.cycles&&t.cycles,u=t.replacer||function(e,t){return t},c=t.cmp&&(a=t.cmp,function(e){return function(t,r){var n={key:t,value:e[t]},i={key:r,value:e[r]};return a(n,i)}}),f=[];return function e(t,a,h,l){var d=r?"\n"+new Array(l+1).join(r):"",p=r?": ":":";if(h&&h.toJSON&&"function"==typeof h.toJSON&&(h=h.toJSON()),void 0!==(h=u.call(t,a,h))){if("object"!=typeof h||null===h)return n.stringify(h);if(i(h)){for(var b=[],y=0;y dist/ProviderEngine.js","bundle-zero":"browserify -s ZeroClientProvider -e zero.js -t [ babelify --presets [ es2015 ] ] > dist/ZeroClientProvider.js",prepublish:"npm run build && npm run bundle",test:"node test/index.js"},version:"14.1.0"}},{}],376:[function(e,t,r){const n=e("util").inherits,i=e("ethereumjs-util"),o=i.BN,a=e("clone"),s=e("../util/rpc-cache-utils.js"),u=e("../util/stoplight.js"),c=e("./subprovider.js");function f(e){e=e||{},this._ready=new u,this.strategies={perma:new l({eth_getTransactionByHash:p,eth_getTransactionReceipt:p}),block:new d(this),fork:new d(this)}}function h(){var e=this;e.cache={};var t=setInterval(function(){e.cache={}},6e5);t.unref&&t.unref()}function l(e){this.strategy=new h,this.conditionals=e}function d(){this.cache={}}function p(e){if(!e)return!1;if(!e.blockHash)return!1;var t;return(t=e.blockHash,new o(i.toBuffer(t))).gt(new o(0))}t.exports=f,n(f,c),f.prototype.setEngine=function(e){const t=this;function r(e){var r=t.currentBlock;t.currentBlock=e,r&&(t.strategies.block.cacheRollOff(r),t.strategies.fork.cacheRollOff(r))}t.engine=e,e.once("block",function(n){t.currentBlock=n,t._ready.go(),e.on("block",r)})},f.prototype.handleRequest=function(e,t,r){const n=this;return e.skipCache?t():"eth_getBlockByNumber"===e.method&&"latest"===e.params[0]?t():void n._ready.await(function(){n._handleRequest(e,t,r)})},f.prototype._handleRequest=function(e,t,r){const n=this;var o=s.cacheTypeForPayload(e),a=this.strategies[o];if(!a)return t();if(!a.canCache(e))return t();var u,c=s.blockTagForPayload(e);c||(c="latest"),u="earliest"===c?"0x00":"latest"===c?i.bufferToHex(n.currentBlock.number):c,a.hitCheck(e,u,r,function(){t(function(t,r,n){if(t)return n();a.cacheResult(e,r,u,n)})})},h.prototype.hitCheck=function(e,t,r,n){var i,o,u,c,f=s.cacheIdentifierForPayload(e),h=this.cache[f];return h&&(i=t,o=h.blockNumber,u=parseInt(i,16),c=parseInt(o,16),(u===c?0:u>c?1:-1)>=0)?r(null,a(h.result)):n()},h.prototype.cacheResult=function(e,t,r,n){var i=s.cacheIdentifierForPayload(e);if(t){var o=a(t);this.cache[i]={blockNumber:r,result:o}}n()},h.prototype.canCache=function(e){return s.canCache(e)},l.prototype.hitCheck=function(e,t,r,n){return this.strategy.hitCheck(e,t,r,n)},l.prototype.cacheResult=function(e,t,r,n){var i=this.conditionals[e.method];i?i(t)?this.strategy.cacheResult(e,t,r,n):n():this.strategy.cacheResult(e,t,r,n)},l.prototype.canCache=function(e){return this.strategy.canCache(e)},d.prototype.getBlockCacheForPayload=function(e,t){const r=Number.parseInt(t,16);let n=this.cache[r];if(!n){const e={};this.cache[r]=e,n=e}return n},d.prototype.hitCheck=function(e,t,r,n){var i=this.getBlockCacheForPayload(e,t);if(!i)return n();var o=i[s.cacheIdentifierForPayload(e)];return o?r(null,o):n()},d.prototype.cacheResult=function(e,t,r,n){t&&(this.getBlockCacheForPayload(e,r)[s.cacheIdentifierForPayload(e)]=t);n()},d.prototype.canCache=function(e){return!!s.canCache(e)&&"pending"!==s.blockTagForPayload(e)},d.prototype.cacheRollOff=function(e){const t=this,r=i.bufferToHex(e.number),n=Number.parseInt(r,16);Object.keys(t.cache).map(Number).filter(e=>e<=n).forEach(e=>delete t.cache[e])}},{"../util/rpc-cache-utils.js":394,"../util/stoplight.js":396,"./subprovider.js":387,clone:87,"ethereumjs-util":141,util:333}],377:[function(e,t,r){const n=e("util").inherits,i=e("xtend"),o=e("./fixture.js"),a=e("../package.json").version;function s(e){var t=i({web3_clientVersion:"ProviderEngine/v"+a+"/javascript",net_listening:!0,eth_hashrate:"0x00",eth_mining:!1},e=e||{});o.call(this,t)}t.exports=s,n(s,o)},{"../package.json":375,"./fixture.js":380,util:333,xtend:423}],378:[function(e,t,r){const n=e("cross-fetch"),i=e("util").inherits,o=e("async/retry"),a=e("async/waterfall"),s=e("async/asyncify"),u=e("json-rpc-error"),c=e("promise-to-callback"),f=e("../util/create-payload.js"),h=e("./subprovider.js"),l=["Gateway timeout","ETIMEDOUT","SyntaxError"];function d(e){this.rpcUrl=e.rpcUrl,this.originHttpHeaderKey=e.originHttpHeaderKey}function p(e){const t=e.toString();return l.some(e=>t.includes(e))}t.exports=d,i(d,h),d.prototype.handleRequest=function(e,t,r){const n=this,i=e.origin,a=f(e);delete a.origin;const s={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(a)};n.originHttpHeaderKey&&i&&(s.headers[n.originHttpHeaderKey]=i),o({times:5,interval:1e3,errorFilter:p},e=>n._submitRequest(s,e),(e,t)=>{if(e&&p(e)){const t=`FetchSubprovider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,n=new Error(t);return r(n)}return r(e,t)})},d.prototype._submitRequest=function(e,t){const r=this.rpcUrl;c(n(r,e))((e,r)=>{if(e)return t(e);a([function(e){switch(r.status){case 405:return e(new u.MethodNotFound);case 418:return e(function(){const e=new Error("Request is being rate limited.");return new u.InternalError(e)}());case 503:case 504:return e(function(){let e="Gateway timeout. The request took too long to process. ";const t=new Error(e+="This can happen when querying logs over too wide a block range.");return new u.InternalError(t)}());default:return e()}},e=>c(r.text())(e),s(e=>JSON.parse(e)),function(e,t){if(200!==r.status)return t(new u.InternalError(e));if(e.error)return t(new u.InternalError(e.error));t(null,e.result)}],t)})}},{"../util/create-payload.js":391,"./subprovider.js":387,"async/asyncify":20,"async/retry":43,"async/waterfall":44,"cross-fetch":96,"json-rpc-error":189,"promise-to-callback":258,util:333}],379:[function(e,t,r){const n=e("async"),i=e("util").inherits,o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/stoplight.js"),u=e("events").EventEmitter;function c(e){e=e||{};const t=this;t.filterIndex=0,t.filters={},t.filterDestroyHandlers={},t.asyncBlockHandlers={},t.asyncPendingBlockHandlers={},t._ready=new s,t._ready.setMaxListeners(e.maxFilters||25),t._ready.go(),t.pendingBlockTimeout=e.pendingBlockTimeout||4e3,t.checkForPendingBlocksActive=!1,setTimeout(function(){t.engine.on("block",function(e){t._ready.stop();var r=v(t.asyncBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,function(e){e&&console.error(e),t._ready.go()})})})}function f(e){u.apply(this),this.type="block",this.engine=e.engine,this.blockNumber=e.blockNumber,this.updates=[]}function h(e){u.apply(this),this.type="log",this.fromBlock=void 0!==e.fromBlock?e.fromBlock:"latest",this.toBlock=void 0!==e.toBlock?e.toBlock:"latest";var t=e.address&&(Array.isArray(e.address)?e.address:[e.address]);this.address=t&&t.map(d),this.topics=e.topics||[],this.updates=[],this.allResults=[]}function l(){u.apply(this),this.type="pendingTx",this.updates=[],this.allResults=[]}function d(e){return"0x"===e.slice(0,2)?e:"0x"+e}function p(e){return o.intToHex(e)}function b(e){return Number(e)}function y(e){return function(e){let t=o.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}(e.toString("hex"))}function m(e){return e&&-1===["earliest","latest","pending"].indexOf(e)}function v(e){return Object.keys(e).map(function(t){return e[t]})}t.exports=c,i(c,a),c.prototype.handleRequest=function(e,t,r){const n=this;switch(e.method){case"eth_newBlockFilter":return void n.newBlockFilter(r);case"eth_newPendingTransactionFilter":return n.newPendingTransactionFilter(r),void n.checkForPendingBlocks();case"eth_newFilter":return void n.newLogFilter(e.params[0],r);case"eth_getFilterChanges":return void n._ready.await(function(){n.getFilterChanges(e.params[0],r)});case"eth_getFilterLogs":return void n._ready.await(function(){n.getFilterLogs(e.params[0],r)});case"eth_uninstallFilter":return void n._ready.await(function(){n.uninstallFilter(e.params[0],r)});default:return void t()}},c.prototype.newBlockFilter=function(e){const t=this;t._getBlockNumber(function(r,n){if(r)return e(r);var i=new f({blockNumber:n}),o=i.update.bind(i);t.engine.on("block",o);t.filterIndex++,t.filters[t.filterIndex]=i,t.filterDestroyHandlers[t.filterIndex]=function(){t.engine.removeListener("block",o)};var a=p(t.filterIndex);e(null,a)})},c.prototype.newLogFilter=function(e,t){const r=this;r._getBlockNumber(function(n,i){if(n)return t(n);var o=new h(e),a=o.update.bind(o);r.filterIndex++,r.asyncBlockHandlers[r.filterIndex]=function(e,t){r._logsForBlock(e,function(e,r){if(e)return t(e);a(r),t()})},r.filters[r.filterIndex]=o;var s=p(r.filterIndex);t(null,s)})},c.prototype.newPendingTransactionFilter=function(e){const t=this;var r=new l,n=r.update.bind(r);t.filterIndex++,t.asyncPendingBlockHandlers[t.filterIndex]=function(e,r){t._txHashesForBlock(e,function(e,t){if(e)return r(e);n(t),r()})},t.filters[t.filterIndex]=r,e(null,p(t.filterIndex))},c.prototype.getFilterChanges=function(e,t){var r=Number.parseInt(e,16),n=this.filters[r];if(n||console.warn("FilterSubprovider - no filter with that id:",e),!n)return t(null,[]);var i=n.getChanges();n.clearChanges(),t(null,i)},c.prototype.getFilterLogs=function(e,t){const r=this;var n=Number.parseInt(e,16),i=r.filters[n];if(i||console.warn("FilterSubprovider - no filter with that id:",e),!i)return t(null,[]);if("log"===i.type)r.emitPayload({method:"eth_getLogs",params:[{fromBlock:i.fromBlock,toBlock:i.toBlock,address:i.address,topics:i.topics}]},function(e,r){if(e)return t(e);t(null,r.result)});else{t(null,[])}},c.prototype.uninstallFilter=function(e,t){var r=Number.parseInt(e,16);if(this.filters[r]){this.filters[r].removeAllListeners();var n=this.filterDestroyHandlers[r];delete this.filters[r],delete this.asyncBlockHandlers[r],delete this.asyncPendingBlockHandlers[r],delete this.filterDestroyHandlers[r],n&&n(),t(null,!0)}else t(null,!1)},c.prototype.checkForPendingBlocks=function(){const e=this;e.checkForPendingBlocksActive||!!Object.keys(e.asyncPendingBlockHandlers).length&&(e.checkForPendingBlocksActive=!0,e.emitPayload({method:"eth_getBlockByNumber",params:["pending",!0]},function(t,r){if(t)return e.checkForPendingBlocksActive=!1,void console.error(t);e.onNewPendingBlock(r.result,function(t){t&&console.error(t),e.checkForPendingBlocksActive=!1,setTimeout(e.checkForPendingBlocks.bind(e),e.pendingBlockTimeout)})}))},c.prototype.onNewPendingBlock=function(e,t){var r=v(this.asyncPendingBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,t)},c.prototype._getBlockNumber=function(e){e(null,y(this.engine.currentBlock.number))},c.prototype._logsForBlock=function(e,t){var r=y(e.number);this.emitPayload({method:"eth_getLogs",params:[{fromBlock:r,toBlock:r}]},function(e,r){return e?t(e):r.error?t(r.error):void t(null,r.result)})},c.prototype._txHashesForBlock=function(e,t){var r=e.transactions;if(0===r.length)return t(null,[]);"string"==typeof r[0]?t(null,r):t(null,r.map(e=>e.hash))},i(f,u),f.prototype.update=function(e){var t="0x"+e.hash.toString("hex");this.updates.push(t),this.emit("data",e)},f.prototype.getChanges=function(){return this.updates},f.prototype.clearChanges=function(){this.updates=[]},i(h,u),h.prototype.validateLog=function(e){return!(m(this.fromBlock)&&b(this.fromBlock)>=b(e.blockNumber))&&(!(m(this.toBlock)&&b(this.toBlock)<=b(e.blockNumber))&&(!(this.address&&!this.address.map(e=>e.toLowerCase()).includes(e.address.toLowerCase()))&&this.topics.reduce(function(t,r,n){if(!t)return!1;if(!r)return!0;var i=e.topics[n];return!!i&&(Array.isArray(r)?r:[r]).filter(function(e){return i.toLowerCase()===e.toLowerCase()}).length>0},!0)))},h.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateLog(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},h.prototype.getChanges=function(){return this.updates},h.prototype.getAllResults=function(){return this.allResults},h.prototype.clearChanges=function(){this.updates=[]},i(l,u),l.prototype.validateUnique=function(e){return-1===this.allResults.indexOf(e)},l.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateUnique(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},l.prototype.getChanges=function(){return this.updates},l.prototype.getAllResults=function(){return this.allResults},l.prototype.clearChanges=function(){this.updates=[]}},{"../util/stoplight.js":396,"./subprovider.js":387,async:21,"ethereumjs-util":141,events:157,util:333}],380:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){e=e||{},this.staticResponses=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){var n=this.staticResponses[e.method];"function"==typeof n?n(e,t,r):void 0!==n?setTimeout(()=>r(null,n)):t()}},{"./subprovider.js":387,util:333}],381:[function(e,t,r){const n=e("async/waterfall"),i=e("async/parallel"),o=e("util").inherits,a=e("ethereumjs-util"),s=e("eth-sig-util"),u=e("xtend"),c=e("semaphore"),f=e("./subprovider.js"),h=e("../util/estimate-gas.js"),l=/^[0-9A-Fa-f]+$/g;function d(e){this.nonceLock=c(1),e.getAccounts&&(this.getAccounts=e.getAccounts),e.processTransaction&&(this.processTransaction=e.processTransaction),e.processMessage&&(this.processMessage=e.processMessage),e.processPersonalMessage&&(this.processPersonalMessage=e.processPersonalMessage),e.processTypedMessage&&(this.processTypedMessage=e.processTypedMessage),this.approveTransaction=e.approveTransaction||this.autoApprove,this.approveMessage=e.approveMessage||this.autoApprove,this.approvePersonalMessage=e.approvePersonalMessage||this.autoApprove,this.approveTypedMessage=e.approveTypedMessage||this.autoApprove,e.signTransaction&&(this.signTransaction=e.signTransaction||y("signTransaction")),e.signMessage&&(this.signMessage=e.signMessage||y("signMessage")),e.signPersonalMessage&&(this.signPersonalMessage=e.signPersonalMessage||y("signPersonalMessage")),e.signTypedMessage&&(this.signTypedMessage=e.signTypedMessage||y("signTypedMessage")),e.recoverPersonalSignature&&(this.recoverPersonalSignature=e.recoverPersonalSignature),e.publishTransaction&&(this.publishTransaction=e.publishTransaction)}function p(e){return e.toLowerCase()}function b(e){return"string"==typeof e&&("0x"===e.slice(0,2)&&e.slice(2).match(l))}function y(e){return function(t,r){r(new Error('ProviderEngine - HookedWalletSubprovider - Must provide "'+e+'" fn in constructor options'))}}t.exports=d,o(d,f),d.prototype.handleRequest=function(e,t,r){const i=this;let o,s,c,f,h;switch(i._parityRequests={},i._parityRequestCount=0,e.method){case"eth_coinbase":return void i.getAccounts(function(e,t){if(e)return r(e);let n=t[0]||null;r(null,n)});case"eth_accounts":return void i.getAccounts(function(e,t){if(e)return r(e);r(null,t)});case"eth_sendTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processTransaction(o,e)],r);case"eth_signTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processSignTransaction(o,e)],r);case"eth_sign":return h=e.params[0],f=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateMessage(s,e),e=>i.processMessage(s,e)],r);case"personal_sign":const l=e.params[0];if(function(e){const t=a.addHexPrefix(e);return!a.isValidAddress(t)&&b(e)}(e.params[1])&&function(e){const t=a.addHexPrefix(e);return a.isValidAddress(t)}(l)){let t="The eth_personalSign method requires params ordered ";t+="[message, address]. This was previously handled incorrectly, ",t+="and has been corrected automatically. ",t+="Please switch this param order for smooth behavior in the future.",console.warn(t),h=e.params[0],f=e.params[1]}else f=e.params[0],h=e.params[1];return c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validatePersonalMessage(s,e),e=>i.processPersonalMessage(s,e)],r);case"personal_ecRecover":f=e.params[0];let d=e.params[1];return c=e.params[2]||{},s=u(c,{sig:d,data:f}),void i.recoverPersonalSignature(s,r);case"eth_signTypedData":return f=e.params[0],h=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateTypedMessage(s,e),e=>i.processTypedMessage(s,e)],r);case"parity_postTransaction":return o=e.params[0],void i.parityPostTransaction(o,r);case"parity_postSign":return h=e.params[0],f=e.params[1],void i.parityPostSign(h,f,r);case"parity_checkRequest":const p=e.params[0];return void i.parityCheckRequest(p,r);case"parity_defaultAccount":return void i.getAccounts(function(e,t){if(e)return r(e);const n=t[0]||null;r(null,n)});default:return void t()}},d.prototype.getAccounts=function(e){e(null,[])},d.prototype.processTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeAndSubmitTx(e,t)],t)},d.prototype.processSignTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeTx(e,t)],t)},d.prototype.processMessage=function(e,t){const r=this;n([t=>r.approveMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signMessage(e,t)],t)},d.prototype.processPersonalMessage=function(e,t){const r=this;n([t=>r.approvePersonalMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signPersonalMessage(e,t)],t)},d.prototype.processTypedMessage=function(e,t){const r=this;n([t=>r.approveTypedMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signTypedMessage(e,t)],t)},d.prototype.autoApprove=function(e,t){t(null,!0)},d.prototype.checkApproval=function(e,t,r){r(t?null:new Error("User denied "+e+" signature."))},d.prototype.parityPostTransaction=function(e,t){const r=this,n=`0x${r._parityRequestCount.toString(16)}`;r._parityRequestCount++,r.emitPayload({method:"eth_sendTransaction",params:[e]},function(e,t){if(e)return void(r._parityRequests[n]={error:e});const i=t.result;r._parityRequests[n]=i}),t(null,n)},d.prototype.parityPostSign=function(e,t,r){const n=this,i=`0x${n._parityRequestCount.toString(16)}`;n._parityRequestCount++,n.emitPayload({method:"eth_sign",params:[e,t]},function(e,t){if(e)return void(n._parityRequests[i]={error:e});const r=t.result;n._parityRequests[i]=r}),r(null,i)},d.prototype.parityCheckRequest=function(e,t){const r=this._parityRequests[e]||null;return r?r.error?t(r.error):void t(null,r):t(null,null)},d.prototype.recoverPersonalSignature=function(e,t){let r;try{r=s.recoverPersonalSignature(e)}catch(e){return t(e)}t(null,r)},d.prototype.validateTransaction=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign transaction."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign transaction for this address: "${e.from}"`))})},d.prototype.validateMessage=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign message."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validatePersonalMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign personal message.")):void 0===e.data?t(new Error("Undefined message - message required to sign personal message.")):b(e.data)?void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))}):t(new Error("HookedWalletSubprovider - validateMessage - message was not encoded as hex."))},d.prototype.validateTypedMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign typed data.")):void 0===e.data?t(new Error("Undefined data - message required to sign typed data.")):void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validateSender=function(e,t){if(!e)return t(null,!1);this.getAccounts(function(r,n){if(r)return t(r);const i=-1!==n.map(p).indexOf(e.toLowerCase());t(null,i)})},d.prototype.finalizeAndSubmitTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r),r.publishTransaction.bind(r)],function(e,n){if(r.nonceLock.leave(),e)return t(e);t(null,n)})})},d.prototype.finalizeTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r)],function(n,i){if(r.nonceLock.leave(),n)return t(n);t(null,{raw:i,tx:e})})})},d.prototype.publishTransaction=function(e,t){this.emitPayload({method:"eth_sendRawTransaction",params:[e]},function(e,r){if(e)return t(e);t(null,r.result)})},d.prototype.fillInTxExtras=function(e,t){const r=this,n=e.from,o={};void 0===e.gasPrice&&(o.gasPrice=r.emitPayload.bind(r,{method:"eth_gasPrice",params:[]})),void 0===e.nonce&&(o.nonce=r.emitPayload.bind(r,{method:"eth_getTransactionCount",params:[n,"pending"]})),void 0===e.gas&&(o.gas=h.bind(null,r.engine,function(e){return{from:e.from,to:e.to,value:e.value,data:e.data,gas:e.gas,gasPrice:e.gasPrice,nonce:e.nonce}}(e))),i(o,function(r,n){if(r)return t(r);const i={};n.gasPrice&&(i.gasPrice=n.gasPrice.result),n.nonce&&(i.nonce=n.nonce.result),n.gas&&(i.gas=n.gas),t(null,u(e,i))})}},{"../util/estimate-gas.js":392,"./subprovider.js":387,"async/parallel":42,"async/waterfall":44,"eth-sig-util":136,"ethereumjs-util":141,semaphore:301,util:333,xtend:423}],382:[function(e,t,r){const n=e("../util/rpc-cache-utils.js").cacheIdentifierForPayload,i=e("./subprovider.js");t.exports=class extends i{constructor(e){super(),this.inflightRequests={}}addEngine(e){this.engine=e}handleRequest(e,t,r){const i=n(e,{includeBlockRef:!0});if(!i)return t();let o=this.inflightRequests[i];o?o.push(r):(o=[],this.inflightRequests[i]=o,t((e,t,r)=>{delete this.inflightRequests[i],o.forEach(r=>r(e,t)),r(e,t)}))}}},{"../util/rpc-cache-utils.js":394,"./subprovider.js":387}],383:[function(e,t,r){const n=e("eth-json-rpc-infura/src/createProvider"),i=e("./provider.js");t.exports=class extends i{constructor(e={}){super(n(e))}}},{"./provider.js":385,"eth-json-rpc-infura/src/createProvider":129}],384:[function(e,t,r){(function(r){const n=e("util").inherits,i=e("ethereumjs-tx"),o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/rpc-cache-utils").blockTagForPayload;function u(e){this.nonceCache={}}t.exports=u,n(u,a),u.prototype.handleRequest=function(e,t,n){const a=this;switch(e.method){case"eth_getTransactionCount":var u=s(e),c=e.params[0].toLowerCase(),f=a.nonceCache[c];return void("pending"===u?f?n(null,f):t(function(e,t,r){if(e)return r();void 0===a.nonceCache[c]&&(a.nonceCache[c]=t),r()}):t());case"eth_sendRawTransaction":return void t(function(t,n,s){if(t)return s();var u=e.params[0],c=(o.stripHexPrefix(u),new r(o.stripHexPrefix(u),"hex"),new i(new r(o.stripHexPrefix(u),"hex"))),f="0x"+c.getSenderAddress().toString("hex").toLowerCase(),h=o.bufferToInt(c.nonce),l=(++h).toString(16);l.length%2&&(l="0"+l),l="0x"+l,a.nonceCache[f]=l,s()});default:return void t()}}}).call(this,e("buffer").Buffer)},{"../util/rpc-cache-utils":394,"./subprovider.js":387,buffer:84,"ethereumjs-tx":140,"ethereumjs-util":141,util:333}],385:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){if(!e)throw new Error("ProviderSubprovider - no provider specified");if(!e.sendAsync)throw new Error("ProviderSubprovider - specified provider does not have a sendAsync method");this.provider=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){this.provider.sendAsync(e,function(e,t){return e?r(e):t.error?r(new Error(t.error.message)):void r(null,t.result)})}},{"./subprovider.js":387,util:333}],386:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js"),o=(e("xtend"),e("ethereumjs-util"));function a(e){}t.exports=a,n(a,i),a.prototype.handleRequest=function(e,t,r){var n=e.params[0];if("object"==typeof n&&!Array.isArray(n)){var i=function(e){return s.reduce(function(t,r){return r in e&&(Array.isArray(e[r])?t[r]=e[r].map(function(e){return u(e)}):t[r]=u(e[r])),t},{})}(n);e.params[0]=i}t()};var s=["from","to","value","data","gas","gasPrice","nonce","fromBlock","toBlock","address","topics"];function u(e){switch(e){case"latest":case"pending":case"earliest":return e;default:return"string"==typeof e?o.addHexPrefix(e.toLowerCase()):e}}},{"./subprovider.js":387,"ethereumjs-util":141,util:333,xtend:423}],387:[function(e,t,r){const n=e("../util/create-payload.js");function i(){}t.exports=i,i.prototype.setEngine=function(e){const t=this;t.engine=e,e.on("block",function(e){t.currentBlock=e})},i.prototype.handleRequest=function(e,t,r){throw new Error("Subproviders should override `handleRequest`.")},i.prototype.emitPayload=function(e,t){this.engine.sendAsync(n(e),t)}},{"../util/create-payload.js":391}],388:[function(e,t,r){const n=e("events").EventEmitter,i=e("./filters.js"),o=e("../util/rpc-hex-encoding.js"),a=e("util").inherits,s=e("ethereumjs-util");function u(e){e=e||{},n.apply(this,Array.prototype.slice.call(arguments)),i.apply(this,[e]),this.subscriptions={}}a(u,i),Object.assign(u.prototype,n.prototype),u.prototype.constructor=u,u.prototype.eth_subscribe=function(e,t){const r=this;let n=()=>{},i=e.params[0];switch(i){case"logs":let o=e.params[1];n=r.newLogFilter.bind(r,o);break;case"newPendingTransactions":n=r.newPendingTransactionFilter.bind(r);break;case"newHeads":n=r.newBlockFilter.bind(r);break;case"syncing":default:return void t(new Error("unsupported subscription type"))}n(function(e,n){if(e)return t(e);const o=Number.parseInt(n,16);r.subscriptions[o]=i,r.filters[o].on("data",function(e){Array.isArray(e)||(e=[e]);var t=r._notificationHandler.bind(r,n,i);e.forEach(t),r.filters[o].clearChanges()}),"newPendingTransactions"===i&&r.checkForPendingBlocks(),t(null,n)})},u.prototype.eth_unsubscribe=function(e,t){const r=this;let n=e.params[0];const i=Number.parseInt(n,16);if(r.subscriptions[i]){r.subscriptions[i];r.uninstallFilter(n,function(e,n){delete r.subscriptions[i],t(e,n)})}else t(new Error(`Subscription ID ${n} not found.`))},u.prototype._notificationHandler=function(e,t,r){const n=this;"newHeads"===t&&(r=n._notificationResultFromBlock(r)),n.emit("data",null,{jsonrpc:"2.0",method:"eth_subscription",params:{subscription:e,result:r}})},u.prototype._notificationResultFromBlock=function(e){return{hash:s.bufferToHex(e.hash),parentHash:s.bufferToHex(e.parentHash),sha3Uncles:s.bufferToHex(e.sha3Uncles),miner:s.bufferToHex(e.miner),stateRoot:s.bufferToHex(e.stateRoot),transactionsRoot:s.bufferToHex(e.transactionsRoot),receiptsRoot:s.bufferToHex(e.receiptsRoot),logsBloom:s.bufferToHex(e.logsBloom),difficulty:o.intToQuantityHex(s.bufferToInt(e.difficulty)),number:o.intToQuantityHex(s.bufferToInt(e.number)),gasLimit:o.intToQuantityHex(s.bufferToInt(e.gasLimit)),gasUsed:o.intToQuantityHex(s.bufferToInt(e.gasUsed)),nonce:e.nonce?s.bufferToHex(e.nonce):null,mixHash:s.bufferToHex(e.mixHash),timestamp:o.intToQuantityHex(s.bufferToInt(e.timestamp)),extraData:s.bufferToHex(e.extraData)}},u.prototype.handleRequest=function(e,t,r){switch(e.method){case"eth_subscribe":this.eth_subscribe(e,r);break;case"eth_unsubscribe":this.eth_unsubscribe(e,r);break;default:i.prototype.handleRequest.apply(this,Array.prototype.slice.call(arguments))}},t.exports=u},{"../util/rpc-hex-encoding.js":395,"./filters.js":379,"ethereumjs-util":141,events:157,util:333}],389:[function(e,t,r){(function(r){const n=e("backoff"),i=e("events"),o=(e("util").inherits,r.WebSocket||e("ws")),a=e("./subprovider"),s=e("../util/create-payload");class u extends a{constructor({rpcUrl:e,debug:t,origin:r}){super(),i.call(this),Object.defineProperties(this,{_backoff:{value:n.exponential({randomisationFactor:.2,maxDelay:5e3})},_connectTime:{value:null,writable:!0},_log:{value:t?(...e)=>console.info.apply(console,["[WSProvider]",...e]):()=>{}},_origin:{value:r},_pendingRequests:{value:new Map},_socket:{value:null,writable:!0},_unhandledRequests:{value:[]},_url:{value:e}}),this._handleSocketClose=this._handleSocketClose.bind(this),this._handleSocketMessage=this._handleSocketMessage.bind(this),this._handleSocketOpen=this._handleSocketOpen.bind(this),this._backoff.on("ready",()=>{this._openSocket()}),this._openSocket()}handleRequest(e,t,r){if(!this._socket||this._socket.readyState!==o.OPEN)return this._unhandledRequests.push(Array.from(arguments)),void this._log("Socket not open. Request queued.");this._pendingRequests.set(e.id,[e,r]);const n=s(e);delete n.origin,this._socket.send(JSON.stringify(n)),this._log(`Sent: ${n.method} #${n.id}`)}_handleSocketClose({reason:e,code:t}){this._log(`Socket closed, code ${t} (${e||"no reason"})`),this._connectTime&&Date.now()-this._connectTime>5e3&&this._backoff.reset(),this._socket.removeEventListener("close",this._handleSocketClose),this._socket.removeEventListener("message",this._handleSocketMessage),this._socket.removeEventListener("open",this._handleSocketOpen),this._socket=null,this._backoff.backoff()}_handleSocketMessage(e){let t;try{t=JSON.parse(e.data)}catch(e){return void this._log("Received a message that is not valid JSON:",t)}if(void 0===t.id)return this.emit("data",null,t);if(!this._pendingRequests.has(t.id))return;const[r,n]=this._pendingRequests.get(t.id);if(this._pendingRequests.delete(t.id),this._log(`Received: ${r.method} #${t.id}`),t.error)return n(new Error(t.error.message));n(null,t.result)}_handleSocketOpen(){this._log("Socket open."),this._connectTime=Date.now(),this._pendingRequests.forEach(([e,t])=>{this._unhandledRequests.push([e,null,t])}),this._pendingRequests.clear(),this._unhandledRequests.splice(0,this._unhandledRequests.length).forEach(e=>{this.handleRequest.apply(this,e)})}_openSocket(){this._log("Opening socket..."),this._socket=new o(this._url,null,{origin:this._origin}),this._socket.addEventListener("close",this._handleSocketClose),this._socket.addEventListener("message",this._handleSocketMessage),this._socket.addEventListener("open",this._handleSocketOpen)}}Object.assign(u.prototype,i.prototype),t.exports=u}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util/create-payload":391,"./subprovider":387,backoff:45,events:157,util:333,ws:55}],390:[function(e,t,r){t.exports=function(e,t){if(!e)throw t||"Assertion failed"}},{}],391:[function(e,t,r){const n=e("./random-id.js"),i=e("xtend");t.exports=function(e){return i({id:n(),jsonrpc:"2.0",params:[]},e)}},{"./random-id.js":393,xtend:423}],392:[function(e,t,r){const n=e("./create-payload.js");t.exports=function(e,t,r){e.sendAsync(n({method:"eth_estimateGas",params:[t]}),function(e,t){if(e)return"no contract code at given address"===e.message?r(null,"0xcf08"):r(e);r(null,t.result)})}},{"./create-payload.js":391}],393:[function(e,t,r){const n=3;t.exports=function(){var e=(new Date).getTime()*Math.pow(10,n),t=Math.floor(Math.random()*Math.pow(10,n));return e+t}},{}],394:[function(e,t,r){const n=e("json-stable-stringify");function i(e){return"never"!==s(e)}function o(e){var t=a(e);return t>=e.params.length?e.params:"eth_getBlockByNumber"===e.method?e.params.slice(1):e.params.slice(0,t)}function a(e){switch(e.method){case"eth_getStorageAt":return 2;case"eth_getBalance":case"eth_getCode":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":return 1;case"eth_getBlockByNumber":return 0;default:return}}function s(e){switch(e.method){case"web3_clientVersion":case"web3_sha3":case"eth_protocolVersion":case"eth_getBlockTransactionCountByHash":case"eth_getUncleCountByBlockHash":case"eth_getCode":case"eth_getBlockByHash":case"eth_getTransactionByHash":case"eth_getTransactionByBlockHashAndIndex":case"eth_getTransactionReceipt":case"eth_getUncleByBlockHashAndIndex":case"eth_getCompilers":case"eth_compileLLL":case"eth_compileSolidity":case"eth_compileSerpent":case"shh_version":return"perma";case"eth_getBlockByNumber":case"eth_getBlockTransactionCountByNumber":case"eth_getUncleCountByBlockNumber":case"eth_getTransactionByBlockNumberAndIndex":case"eth_getUncleByBlockNumberAndIndex":return"fork";case"eth_gasPrice":case"eth_blockNumber":case"eth_getBalance":case"eth_getStorageAt":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":case"eth_getFilterLogs":case"eth_getLogs":case"net_peerCount":return"block";case"net_version":case"net_peerCount":case"net_listening":case"eth_syncing":case"eth_sign":case"eth_coinbase":case"eth_mining":case"eth_hashrate":case"eth_accounts":case"eth_sendTransaction":case"eth_sendRawTransaction":case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_getFilterChanges":case"eth_getWork":case"eth_submitWork":case"eth_submitHashrate":case"db_putString":case"db_getString":case"db_putHex":case"db_getHex":case"shh_post":case"shh_newIdentity":case"shh_hasIdentity":case"shh_newGroup":case"shh_addToGroup":case"shh_newFilter":case"shh_uninstallFilter":case"shh_getFilterChanges":case"shh_getMessages":return"never"}}t.exports={cacheIdentifierForPayload:function(e,t={}){if(!i(e))return null;const{includeBlockRef:r}=t,a=r?e.params:o(e);return e.method+":"+n(a)},canCache:i,blockTagForPayload:function(e){var t=a(e);if(t>=e.params.length)return null;return e.params[t]},paramsWithoutBlockTag:o,blockTagParamIndex:a,cacheTypeForPayload:s}},{"json-stable-stringify":374}],395:[function(e,t,r){(function(r){const n=e("ethereumjs-util"),i=e("./assert.js");t.exports={intToQuantityHex:function(e){i("number"==typeof e&&e===Math.floor(e),"intToQuantityHex arg must be an integer");var t=n.toBuffer(e).toString("hex");"0"===t[0]&&(t=t.substring(1));return n.addHexPrefix(t)},quantityHexToInt:function(e){i("string"==typeof e,"arg to quantityHexToInt must be a string");var t=n.stripHexPrefix(e);t.length%2!=0&&(t="0"+t);var o=new r(t,"hex");return n.bufferToInt(o)}}}).call(this,e("buffer").Buffer)},{"./assert.js":390,buffer:84,"ethereumjs-util":141}],396:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits;function o(){n.call(this),this.isLocked=!0}t.exports=o,i(o,n),o.prototype.go=function(){this.isLocked=!1,this.emit("unlock")},o.prototype.stop=function(){this.isLocked=!0,this.emit("lock")},o.prototype.await=function(e){const t=this;t.isLocked?t.once("unlock",e):setTimeout(e)}},{events:157,util:333}],397:[function(e,t,r){const n=e("./index.js"),i=e("./subproviders/default-fixture.js"),o=e("./subproviders/nonce-tracker.js"),a=e("./subproviders/cache.js"),s=e("./subproviders/filters.js"),u=e("./subproviders/subscriptions"),c=e("./subproviders/inflight-cache"),f=e("./subproviders/hooked-wallet.js"),h=e("./subproviders/sanitizer.js"),l=e("./subproviders/infura.js"),d=e("./subproviders/fetch.js"),p=e("./subproviders/websocket.js");t.exports=function(e={}){const t=function({rpcUrl:e}){if(!e)return;switch(e.split(":")[0].toLowerCase()){case"http":case"https":return"http";case"ws":case"wss":return"ws";default:throw new Error(`ProviderEngine - unrecognized protocol in "${e}"`)}}(e),r=new n(e.engineParams),b=new i(e.static);r.addProvider(b),r.addProvider(new o);const y=new h;r.addProvider(y);const m=new a;if(r.addProvider(m),"ws"===t){const e=new s;r.addProvider(e)}else{const e=new u;e.on("data",(e,t)=>{r.emit("data",e,t)}),r.addProvider(e)}const v=new c;r.addProvider(v);const g=new f({getAccounts:e.getAccounts,processTransaction:e.processTransaction,approveTransaction:e.approveTransaction,signTransaction:e.signTransaction,publishTransaction:e.publishTransaction,processMessage:e.processMessage,approveMessage:e.approveMessage,signMessage:e.signMessage,processPersonalMessage:e.processPersonalMessage,processTypedMessage:e.processTypedMessage,approvePersonalMessage:e.approvePersonalMessage,approveTypedMessage:e.approveTypedMessage,signPersonalMessage:e.signPersonalMessage,signTypedMessage:e.signTypedMessage,personalRecoverSigner:e.personalRecoverSigner});r.addProvider(g);const w=e.dataSubprovider||function(e,t){const{rpcUrl:r,debug:n}=t;if(!e)return new l;if("http"===e)return new d({rpcUrl:r,debug:n});if("ws"===e)return new p({rpcUrl:r,debug:n});throw new Error(`ProviderEngine - unrecognized connectionType "${e}"`)}(t,e);"ws"===t&&w.on("data",(e,t)=>{r.emit("data",e,t)});r.addProvider(w),e.stopped||r.start();return r}},{"./index.js":373,"./subproviders/cache.js":376,"./subproviders/default-fixture.js":377,"./subproviders/fetch.js":378,"./subproviders/filters.js":379,"./subproviders/hooked-wallet.js":381,"./subproviders/inflight-cache":382,"./subproviders/infura.js":383,"./subproviders/nonce-tracker.js":384,"./subproviders/sanitizer.js":386,"./subproviders/subscriptions":388,"./subproviders/websocket.js":389}],398:[function(e,t,r){var n=e("web3-core-helpers").errors,i=e("xhr2-cookies").XMLHttpRequest,o=e("http"),a=e("https"),s=function(e,t){t=t||{},this.host=e||"http://localhost:8545","https"===this.host.substring(0,5)?this.httpsAgent=new a.Agent({keepAlive:!0}):this.httpAgent=new o.Agent({keepAlive:!0}),this.timeout=t.timeout||0,this.headers=t.headers,this.connected=!1};s.prototype._prepareRequest=function(){var e=new i;return e.nodejsSet({httpsAgent:this.httpsAgent,httpAgent:this.httpAgent}),e.open("POST",this.host,!0),e.setRequestHeader("Content-Type","application/json"),e.timeout=this.timeout&&1!==this.timeout?this.timeout:0,e.withCredentials=!0,this.headers&&this.headers.forEach(function(t){e.setRequestHeader(t.name,t.value)}),e},s.prototype.send=function(e,t){var r=this,i=this._prepareRequest();i.onreadystatechange=function(){if(4===i.readyState&&1!==i.timeout){var e=i.responseText,o=null;try{e=JSON.parse(e)}catch(e){o=n.InvalidResponse(i.responseText)}r.connected=!0,t(o,e)}},i.ontimeout=function(){r.connected=!1,t(n.ConnectionTimeout(this.timeout))};try{i.send(JSON.stringify(e))}catch(e){this.connected=!1,t(n.InvalidConnection(this.host))}},s.prototype.disconnect=function(){},t.exports=s},{http:312,https:175,"web3-core-helpers":338,"xhr2-cookies":418}],399:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("oboe"),a=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],this.path=e,this.connected=!1,this.connection=t.connect({path:this.path}),this.addDefaultEvents();var i=function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,t||-1===e.method.indexOf("_subscription")?r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t]):r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)})};"Socket"===t.constructor.name?o(this.connection).done(i):this.connection.on("data",function(e){r._parseResponse(e.toString()).forEach(i)})};a.prototype.addDefaultEvents=function(){var e=this;this.connection.on("connect",function(){e.connected=!0}),this.connection.on("close",function(){e.connected=!1}),this.connection.on("error",function(){e._timeout()}),this.connection.on("end",function(){e._timeout()}),this.connection.on("timeout",function(){e._timeout()})},a.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},a.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n},a.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on IPC")),delete this.responseCallbacks[e])},a.prototype.reconnect=function(){this.connection.connect({path:this.path})},a.prototype.send=function(e,t){this.connection.writable||this.connection.connect({path:this.path}),this.connection.write(JSON.stringify(e)),this._addResponseCallback(e,t)},a.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;default:this.connection.on(e,t)}},a.prototype.once=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");this.connection.once(e,t)},a.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)});break;default:this.connection.removeListener(e,t)}},a.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;default:this.connection.removeAllListeners(e)}},a.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.connection.removeAllListeners("error"),this.connection.removeAllListeners("end"),this.connection.removeAllListeners("timeout"),this.addDefaultEvents()},t.exports=a},{oboe:239,underscore:325,"web3-core-helpers":338}],400:[function(e,t,r){(function(r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=null,a=null,s=null;if("undefined"!=typeof window&&void 0!==window.WebSocket)o=function(e,t){return new window.WebSocket(e,t)},a=btoa,s=function(e){return new URL(e)};else{o=e("websocket").w3cwebsocket,a=function(e){return r(e).toString("base64")};var u=e("url");if(u.URL){var c=u.URL;s=function(e){return new c(e)}}else s=e("url").parse}var f=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],t=t||{},this._customTimeout=t.timeout;var i=s(e),u=t.headers||{},c=t.protocol||void 0;i.username&&i.password&&(u.authorization="Basic "+a(i.username+":"+i.password));var f=t.clientConfig||void 0;i.auth&&(u.authorization="Basic "+a(i.auth)),this.connection=new o(e,c,void 0,u,void 0,f),this.addDefaultEvents(),this.connection.onmessage=function(e){var t="string"==typeof e.data?e.data:"";r._parseResponse(t).forEach(function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,!t&&e&&e.method&&-1!==e.method.indexOf("_subscription")?r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)}):r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t])})},Object.defineProperty(this,"connected",{get:function(){return this.connection&&this.connection.readyState===this.connection.OPEN},enumerable:!0})};f.prototype.addDefaultEvents=function(){var e=this;this.connection.onerror=function(){e._timeout()},this.connection.onclose=function(){e._timeout(),e.reset()}},f.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},f.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n;var o=this;this._customTimeout&&setTimeout(function(){o.responseCallbacks[r]&&(o.responseCallbacks[r](i.ConnectionTimeout(o._customTimeout)),delete o.responseCallbacks[r])},this._customTimeout)},f.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on WS")),delete this.responseCallbacks[e])},f.prototype.send=function(e,t){var r=this;if(this.connection.readyState!==this.connection.CONNECTING){if(this.connection.readyState!==this.connection.OPEN)return console.error("connection not open on send()"),"function"==typeof this.connection.onerror?this.connection.onerror(new Error("connection not open")):console.error("no error callback"),void t(new Error("connection not open"));this.connection.send(JSON.stringify(e)),this._addResponseCallback(e,t)}else setTimeout(function(){r.send(e,t)},10)},f.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;case"connect":this.connection.onopen=t;break;case"end":this.connection.onclose=t;break;case"error":this.connection.onerror=t}},f.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)})}},f.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;case"connect":this.connection.onopen=null;break;case"end":this.connection.onclose=null;break;case"error":this.connection.onerror=null}},f.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.addDefaultEvents()},f.prototype.disconnect=function(){this.connection&&this.connection.close()},t.exports=f}).call(this,e("buffer").Buffer)},{buffer:84,underscore:325,url:327,"web3-core-helpers":338,websocket:408}],401:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-subscriptions").subscriptions,o=e("web3-core-method"),a=e("web3-net"),s=function(){var e=this;n.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments)},this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new a(this.currentProvider),[new i({name:"subscribe",type:"shh",subscriptions:{messages:{params:1}}}),new o({name:"getVersion",call:"shh_version",params:0}),new o({name:"getInfo",call:"shh_info",params:0}),new o({name:"setMaxMessageSize",call:"shh_setMaxMessageSize",params:1}),new o({name:"setMinPoW",call:"shh_setMinPoW",params:1}),new o({name:"markTrustedPeer",call:"shh_markTrustedPeer",params:1}),new o({name:"newKeyPair",call:"shh_newKeyPair",params:0}),new o({name:"addPrivateKey",call:"shh_addPrivateKey",params:1}),new o({name:"deleteKeyPair",call:"shh_deleteKeyPair",params:1}),new o({name:"hasKeyPair",call:"shh_hasKeyPair",params:1}),new o({name:"getPublicKey",call:"shh_getPublicKey",params:1}),new o({name:"getPrivateKey",call:"shh_getPrivateKey",params:1}),new o({name:"newSymKey",call:"shh_newSymKey",params:0}),new o({name:"addSymKey",call:"shh_addSymKey",params:1}),new o({name:"generateSymKeyFromPassword",call:"shh_generateSymKeyFromPassword",params:1}),new o({name:"hasSymKey",call:"shh_hasSymKey",params:1}),new o({name:"getSymKey",call:"shh_getSymKey",params:1}),new o({name:"deleteSymKey",call:"shh_deleteSymKey",params:1}),new o({name:"newMessageFilter",call:"shh_newMessageFilter",params:1}),new o({name:"getFilterMessages",call:"shh_getFilterMessages",params:1}),new o({name:"deleteMessageFilter",call:"shh_deleteMessageFilter",params:1}),new o({name:"post",call:"shh_post",params:1,inputFormatter:[null]}),new o({name:"unsubscribe",call:"shh_unsubscribe",params:1})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(s),t.exports=s},{"web3-core":348,"web3-core-method":339,"web3-core-subscriptions":345,"web3-net":372}],402:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],403:[function(e,t,r){var n=e("underscore"),i=e("ethjs-unit"),o=e("./utils.js"),a=e("./soliditySha3.js"),s=e("randomhex"),u=function(e,t){var r=[];return t.forEach(function(t){if("object"==typeof t.components){if("tuple"!==t.type.substring(0,5))throw new Error("components found but type is not tuple; report on GitHub");var i="",o=t.type.indexOf("[");o>=0&&(i=t.type.substring(o));var a=u(e,t.components);n.isArray(a)&&e?r.push("tuple("+a.join(",")+")"+i):e?r.push("("+a+")"):r.push("("+a.join(",")+")"+i)}else r.push(t.type)}),r},c=function(e){if(!o.isHexStrict(e))throw new Error("The parameter must be a valid HEX string.");var t="",r=0,n=e.length;for("0x"===e.substring(0,2)&&(r=2);r7?r+=e[n].toUpperCase():r+=e[n];return r},toHex:o.toHex,toBN:o.toBN,bytesToHex:o.bytesToHex,hexToBytes:o.hexToBytes,hexToNumberString:o.hexToNumberString,hexToNumber:o.hexToNumber,toDecimal:o.hexToNumber,numberToHex:o.numberToHex,fromDecimal:o.numberToHex,hexToUtf8:o.hexToUtf8,hexToString:o.hexToUtf8,toUtf8:o.hexToUtf8,utf8ToHex:o.utf8ToHex,stringToHex:o.utf8ToHex,fromUtf8:o.utf8ToHex,hexToAscii:c,toAscii:c,asciiToHex:f,fromAscii:f,unitMap:i.unitMap,toWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.toWei(e,t):i.toWei(e,t).toString(10)},fromWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.fromWei(e,t):i.fromWei(e,t).toString(10)},padLeft:o.leftPad,leftPad:o.leftPad,padRight:o.rightPad,rightPad:o.rightPad,toTwosComplement:o.toTwosComplement}},{"./soliditySha3.js":404,"./utils.js":405,"ethjs-unit":153,randomhex:274,underscore:325}],404:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("./utils.js"),a=function(e){var t=typeof e;if("string"===t)return o.isHexStrict(e)?new i(e.replace(/0x/i,""),16):new i(e,10);if("number"===t)return new i(e);if(o.isBigNumber(e))return new i(e.toString(10));if(o.isBN(e))return e;throw new Error(e+" is not a number")},s=function(e,t,r){var n,s,u;if("bytes"===(e=(u=e).startsWith("int[")?"int256"+u.slice(3):"int"===u?"int256":u.startsWith("uint[")?"uint256"+u.slice(4):"uint"===u?"uint256":u.startsWith("fixed[")?"fixed128x128"+u.slice(5):"fixed"===u?"fixed128x128":u.startsWith("ufixed[")?"ufixed128x128"+u.slice(6):"ufixed"===u?"ufixed128x128":u)){if(t.replace(/^0x/i,"").length%2!=0)throw new Error("Invalid bytes characters "+t.length);return t}if("string"===e)return o.utf8ToHex(t);if("bool"===e)return t?"01":"00";if(e.startsWith("address")){if(n=r?64:40,!o.isAddress(t))throw new Error(t+" is not a valid address, or the checksum is invalid.");return o.leftPad(t.toLowerCase(),n)}if(n=function(e){var t=/^\D+(\d+).*$/.exec(e);return t?parseInt(t[1],10):null}(e),e.startsWith("bytes")){if(!n)throw new Error("bytes[] not yet supported in solidity");if(r&&(n=32),n<1||n>32||n256)throw new Error("Invalid uint"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied uint exceeds width: "+n+" vs "+s.bitLength());if(s.lt(new i(0)))throw new Error("Supplied uint "+s.toString()+" is negative");return n?o.leftPad(s.toString("hex"),n/8*2):s}if(e.startsWith("int")){if(n%8||n<8||n>256)throw new Error("Invalid int"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied int exceeds width: "+n+" vs "+s.bitLength());return s.lt(new i(0))?s.toTwos(n).toString("hex"):n?o.leftPad(s.toString("hex"),n/8*2):s}throw new Error("Unsupported or invalid type: "+e)},u=function(e){if(n.isArray(e))throw new Error("Autodetection of array types is not supported.");var t,r,a="";if(n.isObject(e)&&(e.hasOwnProperty("v")||e.hasOwnProperty("t")||e.hasOwnProperty("value")||e.hasOwnProperty("type"))?(t=e.hasOwnProperty("t")?e.t:e.type,a=e.hasOwnProperty("v")?e.v:e.value):(t=o.toHex(e,!0),a=o.toHex(e),t.startsWith("int")||t.startsWith("uint")||(t="bytes")),!t.startsWith("int")&&!t.startsWith("uint")||"string"!=typeof a||/^(-)?0x/i.test(a)||(a=new i(a)),n.isArray(a)){if((r=function(e){var t=/^\D+\d*\[(\d+)\]$/.exec(e);return t?parseInt(t[1],10):null}(t))&&a.length!==r)throw new Error(t+" is not matching the given array "+JSON.stringify(a));r=a.length}return n.isArray(a)?a.map(function(e){return s(t,e,r).toString("hex").replace("0x","")}).join(""):s(t,a,r).toString("hex").replace("0x","")};t.exports=function(){var e=Array.prototype.slice.call(arguments),t=n.map(e,u);return o.sha3("0x"+t.join(""))}},{"./utils.js":405,"bn.js":402,underscore:325}],405:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("number-to-bn"),a=e("utf8"),s=e("eth-lib/lib/hash"),u=function(e){return e instanceof i||e&&e.constructor&&"BN"===e.constructor.name},c=function(e){return e&&e.constructor&&"BigNumber"===e.constructor.name},f=function(e){try{return o.apply(null,arguments)}catch(t){throw new Error(t+' Given value: "'+e+'"')}},h=function(e){return!!/^(0x)?[0-9a-f]{40}$/i.test(e)&&(!(!/^(0x|0X)?[0-9a-f]{40}$/.test(e)&&!/^(0x|0X)?[0-9A-F]{40}$/.test(e))||l(e))},l=function(e){e=e.replace(/^0x/i,"");for(var t=m(e.toLowerCase()).replace(/^0x/i,""),r=0;r<40;r++)if(parseInt(t[r],16)>7&&e[r].toUpperCase()!==e[r]||parseInt(t[r],16)<=7&&e[r].toLowerCase()!==e[r])return!1;return!0},d=function(e){var t="";e=(e=(e=(e=(e=a.encode(e)).replace(/^(?:\u0000)*/,"")).split("").reverse().join("")).replace(/^(?:\u0000)*/,"")).split("").reverse().join("");for(var r=0;r>>4).toString(16)),t.push((15&e[r]).toString(16));return"0x"+t.join("")},isHex:function(e){return(n.isString(e)||n.isNumber(e))&&/^(-0x|0x)?[0-9a-f]*$/i.test(e)},isHexStrict:y,leftPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+new Array(i).join(r||"0")+e},rightPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+e+new Array(i).join(r||"0")},toTwosComplement:function(e){return"0x"+f(e).toTwos(256).toString(16,64)},sha3:m}},{"bn.js":402,"eth-lib/lib/hash":134,"number-to-bn":237,underscore:325,utf8:329}],406:[function(e,t,r){t.exports={_from:"web3@1.0.0-beta.36",_id:"web3@1.0.0-beta.36",_inBundle:!1,_integrity:"sha512-fZDunw1V0AQS27r5pUN3eOVP7u8YAvyo6vOapdgVRolAu5LgaweP7jncYyLINqIX9ZgWdS5A090bt+ymgaYHsw==",_location:"/web3",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"web3@1.0.0-beta.36",name:"web3",escapedName:"web3",rawSpec:"1.0.0-beta.36",saveSpec:null,fetchSpec:"1.0.0-beta.36"},_requiredBy:["#USER","/"],_resolved:"https://registry.npmjs.org/web3/-/web3-1.0.0-beta.36.tgz",_shasum:"2954da9e431124c88396025510d840ba731c8373",_spec:"web3@1.0.0-beta.36",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy",author:{name:"ethereum.org"},authors:[{name:"Fabian Vogelsteller",email:"fabian@ethereum.org",homepage:"http://frozeman.de"},{name:"Marek Kotewicz",email:"marek@parity.io",url:"https://github.com/debris"},{name:"Marian Oancea",url:"https://github.com/cubedro"},{name:"Gav Wood",email:"g@parity.io",homepage:"http://gavwood.com"},{name:"Jeffery Wilcke",email:"jeffrey.wilcke@ethereum.org",url:"https://github.com/obscuren"}],bugs:{url:"https://github.com/ethereum/web3.js/issues"},bundleDependencies:!1,dependencies:{"web3-bzz":"1.0.0-beta.36","web3-core":"1.0.0-beta.36","web3-eth":"1.0.0-beta.36","web3-eth-personal":"1.0.0-beta.36","web3-net":"1.0.0-beta.36","web3-shh":"1.0.0-beta.36","web3-utils":"1.0.0-beta.36"},deprecated:!1,description:"Ethereum JavaScript API",keywords:["Ethereum","JavaScript","API"],license:"LGPL-3.0",main:"src/index.js",name:"web3",namespace:"ethereum",repository:{type:"git",url:"https://github.com/ethereum/web3.js/tree/master/packages/web3"},version:"1.0.0-beta.36"}},{}],407:[function(e,t,r){"use strict";var n=e("../package.json").version,i=e("web3-core"),o=e("web3-eth"),a=e("web3-net"),s=e("web3-eth-personal"),u=e("web3-shh"),c=e("web3-bzz"),f=e("web3-utils"),h=function(){var e=this;i.packageInit(this,arguments),this.version=n,this.utils=f,this.eth=new o(this),this.shh=new u(this),this.bzz=new c(this);var t=this.setProvider;this.setProvider=function(r,n){return t.apply(e,arguments),this.eth.setProvider(r,n),this.shh.setProvider(r,n),this.bzz.setProvider(r),!0}};h.version=n,h.utils=f,h.modules={Eth:o,Net:a,Personal:s,Shh:u,Bzz:c},i.addProviders(h),t.exports=h},{"../package.json":406,"web3-bzz":335,"web3-core":348,"web3-eth":371,"web3-eth-personal":369,"web3-net":372,"web3-shh":401,"web3-utils":403}],408:[function(e,t,r){var n=function(){return this||{}}(),i=n.WebSocket||n.MozWebSocket,o=e("./version");function a(e,t){return t?new i(e,t):new i(e)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(e){Object.defineProperty(a,e,{get:function(){return i[e]}})}),t.exports={w3cwebsocket:i?a:null,version:o}},{"./version":409}],409:[function(e,t,r){t.exports=e("../package.json").version},{"../package.json":410}],410:[function(e,t,r){t.exports={_from:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_id:"websocket@1.0.26",_inBundle:!1,_integrity:"",_location:"/websocket",_phantomChildren:{},_requested:{type:"git",raw:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",name:"websocket",escapedName:"websocket",rawSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",saveSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",fetchSpec:"git://github.com/frozeman/WebSocket-Node.git",gitCommittish:"browserifyCompatible"},_requiredBy:["/web3-providers-ws"],_resolved:"git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",_spec:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy/node_modules/web3-providers-ws",author:{name:"Brian McKelvey",email:"brian@worlize.com",url:"https://www.worlize.com/"},browser:"lib/browser.js",bugs:{url:"https://github.com/theturtle32/WebSocket-Node/issues"},bundleDependencies:!1,config:{verbose:!1},contributors:[{name:"Iñaki Baz Castillo",email:"ibc@aliax.net",url:"http://dev.sipdoc.net"}],dependencies:{debug:"^2.2.0",nan:"^2.3.3","typedarray-to-buffer":"^3.1.2",yaeti:"^0.0.6"},deprecated:!1,description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",devDependencies:{"buffer-equal":"^1.0.0",faucet:"^0.0.1",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-jshint":"^2.0.4",jshint:"^2.0.0","jshint-stylish":"^2.2.1",tape:"^4.0.1"},directories:{lib:"./lib"},engines:{node:">=0.10.0"},homepage:"https://github.com/theturtle32/WebSocket-Node",keywords:["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],license:"Apache-2.0",main:"index",name:"websocket",repository:{type:"git",url:"git+https://github.com/theturtle32/WebSocket-Node.git"},scripts:{gulp:"gulp",install:"(node-gyp rebuild 2> builderror.log) || (exit 0)",test:"faucet test/unit"},version:"1.0.26"}},{}],411:[function(e,t,r){var n=e("xhr-request");t.exports=function(e,t){return new Promise(function(r,i){n(e,t,function(e,t){e?i(e):r(t)})})}},{"xhr-request":412}],412:[function(e,t,r){var n=e("query-string"),i=e("url-set-query"),o=e("object-assign"),a=e("./lib/ensure-header.js"),s=e("./lib/request.js"),u="application/json",c=function(){};t.exports=function(e,t,r){if(!e||"string"!=typeof e)throw new TypeError("must specify a URL");"function"==typeof t&&(r=t,t={});if(r&&"function"!=typeof r)throw new TypeError("expected cb to be undefined or a function");r=r||c;var f=(t=t||{}).json?"json":"text",h=(t=o({responseType:f},t)).headers||{},l=(t.method||"GET").toUpperCase(),d=t.query;d&&("string"!=typeof d&&(d=n.stringify(d)),e=i(e,d));"json"===t.responseType&&a(h,"Accept",u);t.json&&"GET"!==l&&"HEAD"!==l&&(a(h,"Content-Type",u),t.body=JSON.stringify(t.body));return t.method=l,t.url=e,t.headers=h,delete t.query,delete t.json,s(t,r)}},{"./lib/ensure-header.js":413,"./lib/request.js":415,"object-assign":238,"query-string":266,"url-set-query":326}],413:[function(e,t,r){t.exports=function(e,t,r){var n=t.toLowerCase();e[t]||e[n]||(e[t]=r)}},{}],414:[function(e,t,r){t.exports=function(e,t){return t?{statusCode:t.statusCode,headers:t.headers,method:e.method,url:e.url,rawRequest:t.rawRequest?t.rawRequest:t}:null}},{}],415:[function(e,t,r){var n=e("xhr"),i=e("./normalize-response"),o=function(){};t.exports=function(e,t){delete e.uri;var r=!1;"json"===e.responseType&&(e.responseType="text",r=!0);var a=n(e,function(n,a,s){if(r&&!n)try{var u=a.rawRequest.responseText;s=JSON.parse(u)}catch(e){n=e}a=i(e,a),t(n,n?null:s,a),t=o}),s=a.onabort;return a.onabort=function(){var e=s.apply(a,Array.prototype.slice.call(arguments));return t(new Error("XHR Aborted")),t=o,e},a}},{"./normalize-response":414,xhr:416}],416:[function(e,t,r){"use strict";var n=e("global/window"),i=e("is-function"),o=e("parse-headers"),a=e("xtend");function s(e,t,r){var n=e;return i(t)?(r=t,"string"==typeof e&&(n={uri:e})):n=a(t,{uri:e}),n.callback=r,n}function u(e,t,r){return c(t=s(e,t,r))}function c(e){if(void 0===e.callback)throw new Error("callback argument missing");var t=!1,r=function(r,n,i){t||(t=!0,e.callback(r,n,i))};function n(e){return clearTimeout(f),e instanceof Error||(e=new Error(""+(e||"Unknown XMLHttpRequest Error"))),e.statusCode=0,r(e,m)}function i(){if(!s){var t;clearTimeout(f),t=e.useXDR&&void 0===c.status?200:1223===c.status?204:c.status;var n=m,i=null;return 0!==t?(n={body:function(){var e=void 0;if(e=c.response?c.response:c.responseText||function(e){try{if("document"===e.responseType)return e.responseXML;var t=e.responseXML&&"parsererror"===e.responseXML.documentElement.nodeName;if(""===e.responseType&&!t)return e.responseXML}catch(e){}return null}(c),y)try{e=JSON.parse(e)}catch(e){}return e}(),statusCode:t,method:l,headers:{},url:h,rawRequest:c},c.getAllResponseHeaders&&(n.headers=o(c.getAllResponseHeaders()))):i=new Error("Internal XMLHttpRequest Error"),r(i,n,n.body)}}var a,s,c=e.xhr||null;c||(c=e.cors||e.useXDR?new u.XDomainRequest:new u.XMLHttpRequest);var f,h=c.url=e.uri||e.url,l=c.method=e.method||"GET",d=e.body||e.data,p=c.headers=e.headers||{},b=!!e.sync,y=!1,m={body:void 0,headers:{},statusCode:0,method:l,url:h,rawRequest:c};if("json"in e&&!1!==e.json&&(y=!0,p.accept||p.Accept||(p.Accept="application/json"),"GET"!==l&&"HEAD"!==l&&(p["content-type"]||p["Content-Type"]||(p["Content-Type"]="application/json"),d=JSON.stringify(!0===e.json?d:e.json))),c.onreadystatechange=function(){4===c.readyState&&setTimeout(i,0)},c.onload=i,c.onerror=n,c.onprogress=function(){},c.onabort=function(){s=!0},c.ontimeout=n,c.open(l,h,!b,e.username,e.password),b||(c.withCredentials=!!e.withCredentials),!b&&e.timeout>0&&(f=setTimeout(function(){if(!s){s=!0,c.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT",n(e)}},e.timeout)),c.setRequestHeader)for(a in p)p.hasOwnProperty(a)&&c.setRequestHeader(a,p[a]);else if(e.headers&&!function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}(e.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in e&&(c.responseType=e.responseType),"beforeSend"in e&&"function"==typeof e.beforeSend&&e.beforeSend(c),c.send(d||null),c}t.exports=u,t.exports.default=u,u.XMLHttpRequest=n.XMLHttpRequest||function(){},u.XDomainRequest="withCredentials"in new u.XMLHttpRequest?u.XMLHttpRequest:n.XDomainRequest,function(e,t){for(var r=0;r=0)return this._url=this._parseUrl(t.headers.location),this._method="GET",this._loweredHeaders["content-type"]&&(delete this._headers[this._loweredHeaders["content-type"]],delete this._loweredHeaders["content-type"]),null!=this._headers["Content-Type"]&&delete this._headers["Content-Type"],delete this._headers["Content-Length"],this.upload._reset(),this._finalizeHeaders(),void this._sendHxxpRequest();this._response=t,this._response.on("data",function(e){return n._onHttpResponseData(t,e)}),this._response.on("end",function(){return n._onHttpResponseEnd(t)}),this._response.on("close",function(){return n._onHttpResponseClose(t)}),this.responseUrl=this._url.href.split("#")[0],this.status=t.statusCode,this.statusText=s.STATUS_CODES[this.status],this._parseResponseHeaders(t);var i=this._responseHeaders["content-length"]||"";this._totalBytes=+i,this._lengthComputable=!!i,this._setReadyState(r.HEADERS_RECEIVED)}},r.prototype._onHttpResponseData=function(e,t){this._response===e&&(this._responseParts.push(new n(t)),this._loadedBytes+=t.length,this.readyState!==r.LOADING&&this._setReadyState(r.LOADING),this._dispatchProgress("progress"))},r.prototype._onHttpResponseEnd=function(e){this._response===e&&(this._parseResponse(),this._request=null,this._response=null,this._setReadyState(r.DONE),this._dispatchProgress("load"),this._dispatchProgress("loadend"))},r.prototype._onHttpResponseClose=function(e){if(this._response===e){var t=this._request;this._setError(),t.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend")}},r.prototype._onHttpTimeout=function(e){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("timeout"),this._dispatchProgress("loadend"))},r.prototype._onHttpRequestError=function(e,t){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend"))},r.prototype._dispatchProgress=function(e){var t=new r.ProgressEvent(e);t.lengthComputable=this._lengthComputable,t.loaded=this._loadedBytes,t.total=this._totalBytes,this.dispatchEvent(t)},r.prototype._setError=function(){this._request=null,this._response=null,this._responseHeaders=null,this._responseParts=null},r.prototype._parseUrl=function(e,t,r){var n=null==this.nodejsBaseUrl?e:f.resolve(this.nodejsBaseUrl,e),i=f.parse(n,!1,!0);i.hash=null;var o=(i.auth||"").split(":"),a=o[0],s=o[1];return(a||s||t||r)&&(i.auth=(t||a||"")+":"+(r||s||"")),i},r.prototype._parseResponseHeaders=function(e){for(var t in this._responseHeaders={},e.headers){var r=t.toLowerCase();this._privateHeaders[r]||(this._responseHeaders[r]=e.headers[t])}null!=this._mimeOverride&&(this._responseHeaders["content-type"]=this._mimeOverride)},r.prototype._parseResponse=function(){var e=n.concat(this._responseParts);switch(this._responseParts=null,this.responseType){case"json":this.responseText=null;try{this.response=JSON.parse(e.toString("utf-8"))}catch(e){this.response=null}return;case"buffer":return this.responseText=null,void(this.response=e);case"arraybuffer":this.responseText=null;for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),i=0;i0&&(window.web3.eth.defaultAccount=t[0])})}window.ethereum=s}}},console.log("JS bridging rpc url access"),"undefined"!=typeof window&&window.bridge?window.bridge.post("getRPCurl",{},function(e,r){r&&t(r.description,null),t(null,e.rpcURL)}):(console.log("No bridge to native code is found"),t(!0,null))}()},{"./wk.bridge":424,web3:407,"web3-provider-engine/zero.js":397}],2:[function(e,t,r){t.exports=e("./register")().Promise},{"./register":4}],3:[function(e,t,r){"use strict";var n=null;t.exports=function(e,t){return function(r,i){r=r||null;var o=!1!==(i=i||{}).global;if(null===n&&o&&(n=e["@@any-promise/REGISTRATION"]||null),null!==n&&null!==r&&n.implementation!==r)throw new Error('any-promise already defined as "'+n.implementation+'". You can only register an implementation before the first call to require("any-promise") and an implementation cannot be changed');return null===n&&(n=null!==r&&void 0!==i.Promise?{Promise:i.Promise,implementation:r}:t(r),o&&(e["@@any-promise/REGISTRATION"]=n)),n}}},{}],4:[function(e,t,r){"use strict";t.exports=e("./loader")(window,function(){if(void 0===window.Promise)throw new Error("any-promise browser requires a polyfill or explicit registration e.g: require('any-promise/register/bluebird')");return{Promise:window.Promise,implementation:"window.Promise"}})},{"./loader":3}],5:[function(e,t,r){var n=r;n.bignum=e("bn.js"),n.define=e("./asn1/api").define,n.base=e("./asn1/base"),n.constants=e("./asn1/constants"),n.decoders=e("./asn1/decoders"),n.encoders=e("./asn1/encoders")},{"./asn1/api":6,"./asn1/base":8,"./asn1/constants":12,"./asn1/decoders":14,"./asn1/encoders":17,"bn.js":53}],6:[function(e,t,r){var n=e("../asn1"),i=e("inherits");function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}r.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(t){var r;try{r=e("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){r=function(e){this._initNamed(e)}}return i(r,t),r.prototype._initNamed=function(e){t.call(this,e)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(n.decoders[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(n.encoders[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},{"../asn1":5,inherits:180,vm:334}],7:[function(e,t,r){var n=e("inherits"),i=e("../base").Reporter,o=e("buffer").Buffer;function a(e,t){i.call(this,t),o.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function s(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return e instanceof s||(e=new s(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=o.byteLength(e);else{if(!o.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}n(a,i),r.DecoderBuffer=a,a.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},a.prototype.restore=function(e){var t=new a(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,i.prototype.restore.call(this,e.reporter),t},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},a.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new a(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},a.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},r.EncoderBuffer=s,s.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length?e:(Array.isArray(this.value)?this.value.forEach(function(r){r.join(e,t),t+=r.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):o.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},{"../base":8,buffer:84,inherits:180}],8:[function(e,t,r){var n=r;n.Reporter=e("./reporter").Reporter,n.DecoderBuffer=e("./buffer").DecoderBuffer,n.EncoderBuffer=e("./buffer").EncoderBuffer,n.Node=e("./node")},{"./buffer":7,"./node":9,"./reporter":10}],9:[function(e,t,r){var n=e("../base").Reporter,i=e("../base").EncoderBuffer,o=e("../base").DecoderBuffer,a=e("minimalistic-assert"),s=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],u=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function c(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}t.exports=c;var f=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){var e=this._baseState,t={};f.forEach(function(r){t[r]=e[r]});var r=new this.constructor(t.parent);return r._baseState=t,r},c.prototype._wrap=function(){var e=this._baseState;u.forEach(function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}},this)},c.prototype._init=function(e){var t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter(function(e){return e._baseState.parent===this},this),a.equal(t.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(e){var t=this._baseState,r=e.filter(function(e){return e instanceof this.constructor},this);e=e.filter(function(e){return!(e instanceof this.constructor)},this),0!==r.length&&(a(null===t.children),t.children=r,r.forEach(function(e){e._baseState.parent=this},this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map(function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach(function(r){r==(0|r)&&(r|=0);var n=e[r];t[n]=r}),t}))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(e){c.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}}),s.forEach(function(e){c.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(r),this}}),c.prototype.use=function(e){a(e);var t=this._baseState;return a(null===t.use),t.use=e,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(e){var t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},c.prototype.explicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},c.prototype.implicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},c.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},c.prototype.key=function(e){var t=this._baseState;return a(null===t.key),t.key=e,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(e){var t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map(function(t){return e[t]})),this},c.prototype.contains=function(e){var t=this._baseState;return a(null===t.use),t.contains=e,this},c.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var n,i=r.default,a=!0,s=null;if(null!==r.key&&(s=e.enterKey(r.key)),r.optional){var u=null;if(null!==r.explicit?u=r.explicit:null!==r.implicit?u=r.implicit:null!==r.tag&&(u=r.tag),null!==u||r.any){if(a=this._peekTag(e,u,r.any),e.isError(a))return a}else{var c=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(c)}}if(r.obj&&a&&(n=e.enterObject()),a){if(null!==r.explicit){var f=this._decodeTag(e,r.explicit);if(e.isError(f))return f;e=f}var h=e.offset;if(null===r.use&&null===r.choice){if(r.any)c=e.save();var l=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(l))return l;r.any?i=e.raw(c):e=l}if(t&&t.track&&null!==r.tag&&t.track(e.path(),h,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),i=r.any?i:null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),e.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach(function(r){r._decode(e,t)}),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var d=new o(i);i=this._getUse(r.contains,e._reporterState.obj)._decode(d,t)}}return r.obj&&a&&(i=e.leaveObject(n)),null===r.key||null===i&&!0!==a?null!==s&&e.exitKey(s):e.leaveKey(s,r.key,i),i},c.prototype._decodeGeneric=function(e,t,r){var n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},c.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},c.prototype._decodeChoice=function(e,t){var r=this._baseState,n=null,i=!1;return Object.keys(r.choice).some(function(o){var a=e.save(),s=r.choice[o];try{var u=s._decode(e,t);if(e.isError(u))return!1;n={type:o,value:u},i=!0}catch(t){return e.restore(a),!1}return!0},this),i?n:e.error("Choice not matched")},c.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},c.prototype._encode=function(e,t,r){var n=this._baseState;if(null===n.default||n.default!==e){var i=this._encodeValue(e,t,r);if(void 0!==i&&!this._skipDefault(i,t,r))return i}},c.prototype._encodeValue=function(e,t,r){var i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);var o=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}var a=null,s=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)a=this._getUse(i.contains,r)._encode(e,t),s=!0;else if(i.children)a=i.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i},this).filter(function(e){return e}),a=this._createEncoderBuffer(a);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var u=this.clone();u._baseState.implicit=null,a=this._createEncoderBuffer(e.map(function(r){var n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)},u))}else null!==i.use?o=this._getUse(i.use,r)._encode(e,t):(a=this._encodePrimitive(i.tag,e),s=!0);if(!i.any&&null===i.choice){var c=null!==i.implicit?i.implicit:i.tag,f=null===i.implicit?"universal":"context";null===c?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(c,s,f,a))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},c.prototype._encodeChoice=function(e,t){var r=this._baseState,n=r.choice[e.type];return n||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},c.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},c.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},c.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},{"../base":8,"minimalistic-assert":234}],10:[function(e,t,r){var n=e("inherits");function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}r.Reporter=i,i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,r){var n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){var t,r=this._reporterState,n=e instanceof o;if(t=n?e:new o(r.path.map(function(e){return"["+JSON.stringify(e)+"]"}).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},i.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},n(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{inherits:180}],11:[function(e,t,r){var n=e("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=n._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=n._reverse(r.tag)},{"../constants":12}],12:[function(e,t,r){var n=r;n._reverse=function(e){var t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r|=0);var n=e[r];t[n]=r}),t},n.der=e("./der")},{"./der":11}],13:[function(e,t,r){var n=e("inherits"),i=e("../../asn1"),o=i.base,a=i.bignum,s=i.constants.der;function u(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){o.Node.call(this,"der",e)}function f(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var n=s.tagClass[r>>6],i=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:s.tag[r]}}function h(e,t,r){var n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;var i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(var o=0;o=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=s.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(n.length<128)return(o=new i(2))[0]=a,o[1]=n.length,this._createEncoderBuffer([o,n]);for(var u=1,c=n.length;c>=256;c>>=8)u++;(o=new i(2+u))[0]=a,o[1]=128|u;c=1+u;for(var f=n.length;f>0;c--,f>>=8)o[c]=255&f;return this._createEncoderBuffer([o,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new i(2*e.length),n=0;n=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var o=0;for(n=0;n=128;a>>=7)o++}var s=new i(o),u=s.length-1;for(n=e.length-1;n>=0;n--){a=e[n];for(s[u--]=127&a;(a>>=7)>0;)s[u--]=128|127&a}return this._createEncoderBuffer(s)},c.prototype._encodeTime=function(e,t){var r,n=new Date(e);return"gentime"===t?r=[f(n.getFullYear()),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[f(n.getFullYear()%100),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!i.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new i(r)}if(i.isBuffer(e)){var n=e.length;0===e.length&&n++;var o=new i(n);return e.copy(o),0===e.length&&(o[0]=0),this._createEncoderBuffer(o)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);n=1;for(var a=e;a>=256;a>>=8)n++;for(a=(o=new Array(n)).length-1;a>=0;a--)o[a]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new i(o))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){var n,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,r).join()),o.length!==i.defaultBuffer.length)return!1;for(n=0;n=0;c--)if(f[c]!==h[c])return!1;for(c=f.length-1;c>=0;c--)if(u=f[c],!v(e[u],t[u],r,n))return!1;return!0}(e,t,r,a))}return r?e===t:e==t}function g(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function w(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function _(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&y(i,r,"Missing expected exception"+n);var a="string"==typeof n,s=!e&&i&&!r;if((!e&&o.isError(i)&&a&&w(i,r)||s)&&y(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(i,r)||!e&&i)throw i}h.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=p(b((t=this).actual),128)+" "+t.operator+" "+p(b(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=d(r),a=i.indexOf("\n"+o);if(a>=0){var s=i.indexOf("\n",a+1);i=i.substring(s+1)}this.stack=i}}},o.inherits(h.AssertionError,Error),h.fail=y,h.ok=m,h.equal=function(e,t,r){e!=t&&y(e,t,r,"==",h.equal)},h.notEqual=function(e,t,r){e==t&&y(e,t,r,"!=",h.notEqual)},h.deepEqual=function(e,t,r){v(e,t,!1)||y(e,t,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(e,t,r){v(e,t,!0)||y(e,t,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(e,t,r){v(e,t,!1)&&y(e,t,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function e(t,r,n){v(t,r,!0)&&y(t,r,n,"notDeepStrictEqual",e)},h.strictEqual=function(e,t,r){e!==t&&y(e,t,r,"===",h.strictEqual)},h.notStrictEqual=function(e,t,r){e===t&&y(e,t,r,"!==",h.notStrictEqual)},h.throws=function(e,t,r){_(!0,e,t,r)},h.doesNotThrow=function(e,t,r){_(!1,e,t,r)},h.ifError=function(e){if(e)throw e};var A=Object.keys||function(e){var t=[];for(var r in e)a.call(e,r)&&t.push(r);return t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":333}],20:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){return(0,i.default)(function(t,r){var i;try{i=e.apply(this,t)}catch(e){return r(e)}(0,n.default)(i)&&"function"==typeof i.then?i.then(function(e){s(r,null,e)},function(e){s(r,e.message?e:new Error(e))}):r(null,i)})};var n=a(e("lodash/isObject")),i=a(e("./internal/initialParams")),o=a(e("./internal/setImmediate"));function a(e){return e&&e.__esModule?e:{default:e}}function s(e,t,r){try{e(t,r)}catch(e){(0,o.default)(u,e)}}function u(e){throw e}t.exports=r.default},{"./internal/initialParams":31,"./internal/setImmediate":37,"lodash/isObject":225}],21:[function(e,t,r){(function(e,n){!function(e,n){"object"==typeof r&&void 0!==t?n(r):"function"==typeof define&&define.amd?define(["exports"],n):n(e.async=e.async||{})}(this,function(r){"use strict";function i(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i-1&&e%1==0&&e<=L}function D(e){return null!=e&&O(e.length)&&!function(e){if(!s(e))return!1;var t=B(e);return t==C||t==N||t==P||t==R}(e)}var F={};function q(){}function H(e){return function(){if(null!==e){var t=e;e=null,t.apply(this,arguments)}}}var z="function"==typeof Symbol&&Symbol.iterator,K=function(e){return z&&e[z]&&e[z]()};function V(e){return null!=e&&"object"==typeof e}var G="[object Arguments]";function W(e){return V(e)&&B(e)==G}var Y=Object.prototype,X=Y.hasOwnProperty,Z=Y.propertyIsEnumerable,J=W(function(){return arguments}())?W:function(e){return V(e)&&X.call(e,"callee")&&!Z.call(e,"callee")},$=Array.isArray;var Q="object"==typeof r&&r&&!r.nodeType&&r,ee=Q&&"object"==typeof t&&t&&!t.nodeType&&t,te=ee&&ee.exports===Q?A.Buffer:void 0,re=(te?te.isBuffer:void 0)||function(){return!1},ne=9007199254740991,ie=/^(?:0|[1-9]\d*)$/;function oe(e,t){return!!(t=null==t?ne:t)&&("number"==typeof e||ie.test(e))&&e>-1&&e%1==0&&e2&&(n=i(arguments,1)),t){var c={};Fe(o,function(e,t){c[t]=e}),c[e]=n,s=!0,u=Object.create(null),r(t,c)}else o[e]=n,Le(u[e]||[],function(e){e()}),d()});a++;var c=v(t[t.length-1]);t.length>1?c(o,n):c(n)}(e,t)})}function d(){if(0===c.length&&0===a)return r(null,o);for(;c.length&&a=0&&r.push(n)}),r}Fe(e,function(t,r){if(!$(t))return l(r,[t]),void f.push(r);var n=t.slice(0,t.length-1),i=n.length;if(0===i)return l(r,t),void f.push(r);h[r]=i,Le(n,function(o){if(!e[o])throw new Error("async.auto task `"+r+"` has a non-existent dependency `"+o+"` in "+n.join(", "));!function(e,t){var r=u[e];r||(r=u[e]=[]);r.push(t)}(o,function(){0===--i&&l(r,t)})})}),function(){var e,t=0;for(;f.length;)e=f.pop(),t++,Le(p(e),function(e){0==--h[e]&&f.push(e)});if(t!==n)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),d()};function Ke(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r=n?e:function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n-1;);return r}(i,o),function(e,t){for(var r=e.length;r--&&He(t,e[r],0)>-1;);return r}(i,o)+1).join("")}var ht=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,lt=/,/,dt=/(=.+)?(\s*)$/,pt=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;function bt(e,t){var r={};Fe(e,function(e,t){var n,i,o=m(e),a=!o&&1===e.length||o&&0===e.length;if($(e))n=e.slice(0,-1),e=e[e.length-1],r[t]=n.concat(n.length>0?s:e);else if(a)r[t]=e;else{if(n=i=(i=(i=(i=(i=e).toString().replace(pt,"")).match(ht)[2].replace(" ",""))?i.split(lt):[]).map(function(e){return ft(e.replace(dt,""))}),0===e.length&&!o&&0===n.length)throw new Error("autoInject task functions require explicit parameters.");o||n.pop(),r[t]=n.concat(s)}function s(t,r){var i=Ke(n,function(e){return t[e]});i.push(r),v(e).apply(null,i)}}),ze(r,t)}function yt(){this.head=this.tail=null,this.length=0}function mt(e,t){e.length=1,e.head=e.tail=t}function vt(e,t,r){if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var n=v(e),i=0,o=[],a=!1;function s(e,t,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(f.started=!0,$(e)||(e=[e]),0===e.length&&f.idle())return l(function(){f.drain()});for(var n=0,i=e.length;n0&&o.splice(s,1),a.callback.apply(a,arguments),null!=t&&f.error(t,a.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()}}var c=!1,f={_tasks:new yt,concurrency:t,payload:r,saturated:q,unsaturated:q,buffer:t/4,empty:q,drain:q,error:q,started:!1,paused:!1,push:function(e,t){s(e,!1,t)},kill:function(){f.drain=q,f._tasks.empty()},unshift:function(e,t){s(e,!0,t)},remove:function(e){f._tasks.remove(e)},process:function(){if(!c){for(c=!0;!f.paused&&i2&&(o=i(arguments,1)),n[t]=o,r(e)})},function(e){r(e,n)})}function br(e,t){pr(Ie,e,t)}function yr(e,t,r){pr(Ee(t),e,r)}var mr=function(e,t){var r=v(e);return vt(function(e,t){r(e[0],t)},t,1)},vr=function(e,t){var r=mr(e,t);return r.push=function(e,t,n){if(null==n&&(n=q),"function"!=typeof n)throw new Error("task callback must be a function");if(r.started=!0,$(e)||(e=[e]),0===e.length)return l(function(){r.drain()});t=t||0;for(var i=r._tasks.head;i&&t>=i.priority;)i=i.next;for(var o=0,a=e.length;on?1:0}je(e,function(e,t){n(e,function(r,n){if(r)return t(r);t(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);r(null,Ke(t.sort(i),Zt("value")))})}function Nr(e,t,r){var n=v(e);return a(function(i,o){var a,s=!1;i.push(function(){s||(o.apply(null,arguments),clearTimeout(a))}),a=setTimeout(function(){var t=e.name||"anonymous",n=new Error('Callback function "'+t+'" timed out.');n.code="ETIMEDOUT",r&&(n.info=r),s=!0,o(n)},t),n.apply(null,i)})}var Rr=Math.ceil,Lr=Math.max;function Or(e,t,r,n){var i=v(r);Ce(function(e,t,r,n){for(var i=-1,o=Lr(Rr((t-e)/(r||1)),0),a=Array(o);o--;)a[n?o:++i]=e,e+=r;return a}(0,e,1),t,i,n)}var Dr=ke(Or,1/0),Fr=ke(Or,1);function qr(e,t,r,n){arguments.length<=3&&(n=r,r=t,t=$(e)?[]:{}),n=H(n||q);var i=v(r);Ie(e,function(e,r,n){i(t,e,r,n)},function(e){n(e,t)})}function Hr(e,t){var r,n=null;t=t||q,Kt(e,function(e,t){v(e)(function(e,o){r=arguments.length>2?i(arguments,1):o,n=e,t(!e)})},function(){t(n,r)})}function zr(e){return function(){return(e.unmemoized||e).apply(null,arguments)}}function Kr(e,t,r){r=Ae(r||q);var n=v(t);if(!e())return r(null);var o=function(t){if(t)return r(t);if(e())return n(o);var a=i(arguments,1);r.apply(null,[null].concat(a))};n(o)}function Vr(e,t,r){Kr(function(){return!e.apply(this,arguments)},t,r)}var Gr=function(e,t){if(t=H(t||q),!$(e))return t(new Error("First argument to waterfall must be an array of functions"));if(!e.length)return t();var r=0;function n(t){var n=v(e[r++]);t.push(Ae(o)),n.apply(null,t)}function o(o){if(o||r===e.length)return t.apply(null,arguments);n(i(arguments,1))}n([])},Wr={apply:o,applyEach:Be,applyEachSeries:Re,asyncify:d,auto:ze,autoInject:bt,cargo:gt,compose:Et,concat:St,concatLimit:kt,concatSeries:Mt,constant:It,detect:Bt,detectLimit:Pt,detectSeries:Ct,dir:Rt,doDuring:Lt,doUntil:Dt,doWhilst:Ot,during:Ft,each:Ht,eachLimit:zt,eachOf:Ie,eachOfLimit:xe,eachOfSeries:wt,eachSeries:Kt,ensureAsync:Vt,every:Wt,everyLimit:Yt,everySeries:Xt,filter:er,filterLimit:tr,filterSeries:rr,forever:nr,groupBy:or,groupByLimit:ir,groupBySeries:ar,log:sr,map:je,mapLimit:Ce,mapSeries:Ne,mapValues:cr,mapValuesLimit:ur,mapValuesSeries:fr,memoize:lr,nextTick:dr,parallel:br,parallelLimit:yr,priorityQueue:vr,queue:mr,race:gr,reduce:_t,reduceRight:wr,reflect:_r,reflectAll:Ar,reject:xr,rejectLimit:kr,rejectSeries:Sr,retry:Ir,retryable:Tr,seq:At,series:Ur,setImmediate:l,some:jr,someLimit:Br,someSeries:Pr,sortBy:Cr,timeout:Nr,times:Dr,timesLimit:Or,timesSeries:Fr,transform:qr,tryEach:Hr,unmemoize:zr,until:Vr,waterfall:Gr,whilst:Kr,all:Wt,allLimit:Yt,allSeries:Xt,any:jr,anyLimit:Br,anySeries:Pr,find:Bt,findLimit:Pt,findSeries:Ct,forEach:Ht,forEachSeries:Kt,forEachLimit:zt,forEachOf:Ie,forEachOfSeries:wt,forEachOfLimit:xe,inject:_t,foldl:_t,foldr:wr,select:er,selectLimit:tr,selectSeries:rr,wrapSync:d};r.default=Wr,r.apply=o,r.applyEach=Be,r.applyEachSeries=Re,r.asyncify=d,r.auto=ze,r.autoInject=bt,r.cargo=gt,r.compose=Et,r.concat=St,r.concatLimit=kt,r.concatSeries=Mt,r.constant=It,r.detect=Bt,r.detectLimit=Pt,r.detectSeries=Ct,r.dir=Rt,r.doDuring=Lt,r.doUntil=Dt,r.doWhilst=Ot,r.during=Ft,r.each=Ht,r.eachLimit=zt,r.eachOf=Ie,r.eachOfLimit=xe,r.eachOfSeries=wt,r.eachSeries=Kt,r.ensureAsync=Vt,r.every=Wt,r.everyLimit=Yt,r.everySeries=Xt,r.filter=er,r.filterLimit=tr,r.filterSeries=rr,r.forever=nr,r.groupBy=or,r.groupByLimit=ir,r.groupBySeries=ar,r.log=sr,r.map=je,r.mapLimit=Ce,r.mapSeries=Ne,r.mapValues=cr,r.mapValuesLimit=ur,r.mapValuesSeries=fr,r.memoize=lr,r.nextTick=dr,r.parallel=br,r.parallelLimit=yr,r.priorityQueue=vr,r.queue=mr,r.race=gr,r.reduce=_t,r.reduceRight=wr,r.reflect=_r,r.reflectAll=Ar,r.reject=xr,r.rejectLimit=kr,r.rejectSeries=Sr,r.retry=Ir,r.retryable=Tr,r.seq=At,r.series=Ur,r.setImmediate=l,r.some=jr,r.someLimit=Br,r.someSeries=Pr,r.sortBy=Cr,r.timeout=Nr,r.times=Dr,r.timesLimit=Or,r.timesSeries=Fr,r.transform=qr,r.tryEach=Hr,r.unmemoize=zr,r.until=Vr,r.waterfall=Gr,r.whilst=Kr,r.all=Wt,r.allLimit=Yt,r.allSeries=Xt,r.any=jr,r.anyLimit=Br,r.anySeries=Pr,r.find=Bt,r.findLimit=Pt,r.findSeries=Ct,r.forEach=Ht,r.forEachSeries=Kt,r.forEachLimit=zt,r.forEachOf=Ie,r.forEachOfSeries=wt,r.forEachOfLimit=xe,r.inject=_t,r.foldl=_t,r.foldr=wr,r.select=er,r.selectLimit=tr,r.selectSeries=rr,r.wrapSync=d,Object.defineProperty(r,"__esModule",{value:!0})})}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257}],22:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r,a){(0,n.default)(t)(e,(0,i.default)((0,o.default)(r)),a)};var n=a(e("./internal/eachOfLimit")),i=a(e("./internal/withoutIndex")),o=a(e("./internal/wrapAsync"));function a(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./internal/eachOfLimit":29,"./internal/withoutIndex":39,"./internal/wrapAsync":40}],23:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r){((0,n.default)(e)?l:d)(e,(0,f.default)(t),r)};var n=h(e("lodash/isArrayLike")),i=h(e("./internal/breakLoop")),o=h(e("./eachOfLimit")),a=h(e("./internal/doLimit")),s=h(e("lodash/noop")),u=h(e("./internal/once")),c=h(e("./internal/onlyOnce")),f=h(e("./internal/wrapAsync"));function h(e){return e&&e.__esModule?e:{default:e}}function l(e,t,r){r=(0,u.default)(r||s.default);var n=0,o=0,a=e.length;function f(e,t){e?r(e):++o!==a&&t!==i.default||r(null)}for(0===a&&r(null);n2&&(n=(0,o.default)(arguments,1)),s[t]=n,r(e)})},function(e){r(e,s)})};var n=s(e("lodash/noop")),i=s(e("lodash/isArrayLike")),o=s(e("./slice")),a=s(e("./wrapAsync"));function s(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./slice":38,"./wrapAsync":40,"lodash/isArrayLike":221,"lodash/noop":229}],37:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.hasNextTick=r.hasSetImmediate=void 0,r.fallback=c,r.wrap=f;var n,i=e("./slice"),o=(n=i)&&n.__esModule?n:{default:n};var a,s=r.hasSetImmediate="function"==typeof setImmediate&&setImmediate,u=r.hasNextTick="object"==typeof t&&"function"==typeof t.nextTick;function c(e){setTimeout(e,0)}function f(e){return function(t){var r=(0,o.default)(arguments,1);e(function(){t.apply(null,r)})}}a=s?setImmediate:u?t.nextTick:c,r.default=f(a)}).call(this,e("_process"))},{"./slice":38,_process:257}],38:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i0,"Expected a maximum number of retry greater than 0 but got %s.",e),this.maxNumberOfRetry_=e},o.prototype.backoff=function(e){i.checkState(-1===this.timeoutID_,"Backoff in progress."),this.backoffNumber_===this.maxNumberOfRetry_?(this.emit("fail",e),this.reset()):(this.backoffDelay_=this.backoffStrategy_.next(),this.timeoutID_=setTimeout(this.handlers.backoff,this.backoffDelay_),this.emit("backoff",this.backoffNumber_,this.backoffDelay_,e))},o.prototype.onBackoff_=function(){this.timeoutID_=-1,this.emit("ready",this.backoffNumber_,this.backoffDelay_),this.backoffNumber_++},o.prototype.reset=function(){this.backoffNumber_=0,this.backoffStrategy_.reset(),clearTimeout(this.timeoutID_),this.timeoutID_=-1},t.exports=o},{events:157,precond:253,util:333}],47:[function(e,t,r){var n=e("events"),i=e("precond"),o=e("util"),a=e("./backoff"),s=e("./strategy/fibonacci");function u(e,t,r){n.EventEmitter.call(this),i.checkIsFunction(e,"Expected fn to be a function."),i.checkIsArray(t,"Expected args to be an array."),i.checkIsFunction(r,"Expected callback to be a function."),this.function_=e,this.arguments_=t,this.callback_=r,this.lastResult_=[],this.numRetries_=0,this.backoff_=null,this.strategy_=null,this.failAfter_=-1,this.retryPredicate_=u.DEFAULT_RETRY_PREDICATE_,this.state_=u.State_.PENDING}o.inherits(u,n.EventEmitter),u.State_={PENDING:0,RUNNING:1,COMPLETED:2,ABORTED:3},u.DEFAULT_RETRY_PREDICATE_=function(e){return!0},u.prototype.isPending=function(){return this.state_==u.State_.PENDING},u.prototype.isRunning=function(){return this.state_==u.State_.RUNNING},u.prototype.isCompleted=function(){return this.state_==u.State_.COMPLETED},u.prototype.isAborted=function(){return this.state_==u.State_.ABORTED},u.prototype.setStrategy=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.strategy_=e,this},u.prototype.retryIf=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.retryPredicate_=e,this},u.prototype.getLastResult=function(){return this.lastResult_.concat()},u.prototype.getNumRetries=function(){return this.numRetries_},u.prototype.failAfter=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.failAfter_=e,this},u.prototype.abort=function(){this.isCompleted()||this.isAborted()||(this.isRunning()&&this.backoff_.reset(),this.state_=u.State_.ABORTED,this.lastResult_=[new Error("Backoff aborted.")],this.emit("abort"),this.doCallback_())},u.prototype.start=function(e){i.checkState(!this.isAborted(),"FunctionCall is aborted."),i.checkState(this.isPending(),"FunctionCall already started.");var t=this.strategy_||new s;this.backoff_=e?e(t):new a(t),this.backoff_.on("ready",this.doCall_.bind(this,!0)),this.backoff_.on("fail",this.doCallback_.bind(this)),this.backoff_.on("backoff",this.handleBackoff_.bind(this)),this.failAfter_>0&&this.backoff_.failAfter(this.failAfter_),this.state_=u.State_.RUNNING,this.doCall_(!1)},u.prototype.doCall_=function(e){e&&this.numRetries_++;var t=["call"].concat(this.arguments_);n.EventEmitter.prototype.emit.apply(this,t);var r=this.handleFunctionCallback_.bind(this);this.function_.apply(null,this.arguments_.concat(r))},u.prototype.doCallback_=function(){this.callback_.apply(null,this.lastResult_)},u.prototype.handleFunctionCallback_=function(){if(!this.isAborted()){var e=Array.prototype.slice.call(arguments);this.lastResult_=e,n.EventEmitter.prototype.emit.apply(this,["callback"].concat(e));var t=e[0];t&&this.retryPredicate_(t)?this.backoff_.backoff(t):(this.state_=u.State_.COMPLETED,this.doCallback_())}},u.prototype.handleBackoff_=function(e,t,r){this.emit("backoff",e,t,r)},t.exports=u},{"./backoff":46,"./strategy/fibonacci":49,events:157,precond:253,util:333}],48:[function(e,t,r){var n=e("util"),i=e("precond"),o=e("./strategy");function a(e){o.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay(),this.factor_=a.DEFAULT_FACTOR,e&&void 0!==e.factor&&(i.checkArgument(e.factor>1,"Exponential factor should be greater than 1 but got %s.",e.factor),this.factor_=e.factor)}n.inherits(a,o),a.DEFAULT_FACTOR=2,a.prototype.next_=function(){return this.backoffDelay_=Math.min(this.nextBackoffDelay_,this.getMaxDelay()),this.nextBackoffDelay_=this.backoffDelay_*this.factor_,this.backoffDelay_},a.prototype.reset_=function(){this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()},t.exports=a},{"./strategy":50,precond:253,util:333}],49:[function(e,t,r){var n=e("util"),i=e("./strategy");function o(e){i.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}n.inherits(o,i),o.prototype.next_=function(){var e=Math.min(this.nextBackoffDelay_,this.getMaxDelay());return this.nextBackoffDelay_+=this.backoffDelay_,this.backoffDelay_=e,e},o.prototype.reset_=function(){this.nextBackoffDelay_=this.getInitialDelay(),this.backoffDelay_=0},t.exports=o},{"./strategy":50,util:333}],50:[function(e,t,r){e("events"),e("util");function n(e){return null!=e}function i(e){if(n((e=e||{}).initialDelay)&&e.initialDelay<1)throw new Error("The initial timeout must be greater than 0.");if(n(e.maxDelay)&&e.maxDelay<1)throw new Error("The maximal timeout must be greater than 0.");if(this.initialDelay_=e.initialDelay||100,this.maxDelay_=e.maxDelay||1e4,this.maxDelay_<=this.initialDelay_)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");if(n(e.randomisationFactor)&&(e.randomisationFactor<0||e.randomisationFactor>1))throw new Error("The randomisation factor must be between 0 and 1.");this.randomisationFactor_=e.randomisationFactor||0}i.prototype.getMaxDelay=function(){return this.maxDelay_},i.prototype.getInitialDelay=function(){return this.initialDelay_},i.prototype.next=function(){var e=this.next_(),t=1+Math.random()*this.randomisationFactor_;return Math.round(e*t)},i.prototype.next_=function(){throw new Error("BackoffStrategy.next_() unimplemented.")},i.prototype.reset=function(){this.reset_()},i.prototype.reset_=function(){throw new Error("BackoffStrategy.reset_() unimplemented.")},t.exports=i},{events:157,util:333}],51:[function(e,t,r){"use strict";r.byteLength=function(e){return 3*e.length/4-c(e)},r.toByteArray=function(e){var t,r,n,a,s,u=e.length;a=c(e),s=new o(3*u/4-a),r=a>0?u-4:u;var f=0;for(t=0;t>16&255,s[f++]=n>>8&255,s[f++]=255&n;2===a?(n=i[e.charCodeAt(t)]<<2|i[e.charCodeAt(t+1)]>>4,s[f++]=255&n):1===a&&(n=i[e.charCodeAt(t)]<<10|i[e.charCodeAt(t+1)]<<4|i[e.charCodeAt(t+2)]>>2,s[f++]=n>>8&255,s[f++]=255&n);return s},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o="",a=[],s=0,u=r-i;su?u:s+16383));1===i?(t=e[r-1],o+=n[t>>2],o+=n[t<<4&63],o+="=="):2===i&&(t=(e[r-2]<<8)+e[r-1],o+=n[t>>10],o+=n[t>>4&63],o+=n[t<<2&63],o+="=");return a.push(o),a.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function f(e,t,r){for(var i,o,a=[],s=t;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],52:[function(e,t,r){var n=e("safe-buffer").Buffer;t.exports={check:function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))},decode:function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");var r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},encode:function(e,t){var r=e.length,i=t.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(i>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+r]=2,o[5+r]=t.length,t.copy(o,6+r),o}}},{"safe-buffer":290}],53:[function(e,t,r){!function(t,r){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var a;"object"==typeof t?t.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{a=e("buffer").Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:55}],54:[function(e,t,r){var n;function i(e){this.rand=e}if(t.exports=function(e){return n||(n=new i(null)),n.generate(e)},t.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^t[m++],a=c[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^t[m++],s=c[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^t[m++],u=c[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^t[m++],d=o,p=a,b=s,y=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^t[m++],a=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^t[m++],s=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[m++],u=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^t[m++],[o>>>=0,a>>>=0,s>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],u=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,u=0;u<256;++u){var c=s^s<<1^s<<2^s<<3^s<<4;c=c>>>8^255&c^99,r[a]=c,n[c]=a;var f=e[a],h=e[f],l=e[h],d=257*e[c]^16843008*c;i[0][a]=d<<24|d>>>8,i[1][a]=d<<16|d>>>16,i[2][a]=d<<8|d>>>24,i[3][a]=d,d=16843009*l^65537*h^257*f^16843008*a,o[0][c]=d<<24|d>>>8,o[1][c]=d<<16|d>>>16,o[2][c]=d<<8|d>>>24,o[3][c]=d,0===a?a=s=1:(a=f^e[e[e[l^f]]],s^=e[e[s]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(e){this._key=i(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a],a^=s[o/t|0]<<24):t>6&&o%t==4&&(a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a]),i[o]=i[o-t]^a}for(var c=[],f=0;f>>24]]^u.INV_SUB_MIX[1][u.SBOX[l>>>16&255]]^u.INV_SUB_MIX[2][u.SBOX[l>>>8&255]]^u.INV_SUB_MIX[3][u.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},c.prototype.encryptBlockRaw=function(e){return a(e=i(e),this._keySchedule,u.SUB_MIX,u.SBOX,this._nRounds)},c.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=n.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},c.prototype.decryptBlock=function(e){var t=(e=i(e))[1];e[1]=e[3],e[3]=t;var r=a(e,this._invKeySchedule,u.INV_SUB_MIX,u.INV_SBOX,this._nRounds),o=n.allocUnsafe(16);return o.writeUInt32BE(r[0],0),o.writeUInt32BE(r[3],4),o.writeUInt32BE(r[2],8),o.writeUInt32BE(r[1],12),o},c.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},t.exports.AES=c},{"safe-buffer":290}],57:[function(e,t,r){var n=e("./aes"),i=e("safe-buffer").Buffer,o=e("cipher-base"),a=e("inherits"),s=e("./ghash"),u=e("buffer-xor"),c=e("./incr32");function f(e,t,r,a){o.call(this);var u=i.alloc(4,0);this._cipher=new n.AES(t);var f=this._cipher.encryptBlock(u);this._ghash=new s(f),r=function(e,t,r){if(12===t.length)return e._finID=i.concat([t,i.from([0,0,0,1])]),i.concat([t,i.from([0,0,0,2])]);var n=new s(r),o=t.length,a=o%16;n.update(t),a&&(a=16-a,n.update(i.alloc(a,0))),n.update(i.alloc(8,0));var u=8*o,f=i.alloc(8);f.writeUIntBE(u,0,8),n.update(f),e._finID=n.state;var h=i.from(e._finID);return c(h),h}(this,r,f),this._prev=i.from(r),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=a,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}a(f,o),f.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=i.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},f.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=u(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var n=Math.min(e.length,t.length),i=0;i16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},h.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(e,t){var r=o[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(t,!1,r.key,r.iv);return l(e,n.key,n.iv)},r.createDecipheriv=l},{"./aes":56,"./authCipher":57,"./modes":69,"./streamCipher":72,"cipher-base":86,evp_bytestokey:158,inherits:180,"safe-buffer":290}],60:[function(e,t,r){var n=e("./modes"),i=e("./authCipher"),o=e("safe-buffer").Buffer,a=e("./streamCipher"),s=e("cipher-base"),u=e("./aes"),c=e("evp_bytestokey");function f(e,t,r){s.call(this),this._cache=new l,this._cipher=new u.AES(t),this._prev=o.from(r),this._mode=e,this._autopadding=!0}e("inherits")(f,s),f.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get();)r=this._mode.encrypt(this,t),n.push(r);return o.concat(n)};var h=o.alloc(16,16);function l(){this.cache=o.allocUnsafe(0)}function d(e,t,r){var s=n[e.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=o.from(t)),t.length!==s.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=o.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new a(s.module,t,r):"auth"===s.type?new i(s.module,t,r):new f(s.module,t,r)}f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(h))throw this._cipher.scrub(),new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},l.prototype.add=function(e){this.cache=o.concat([this.cache,e])},l.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},l.prototype.flush=function(){for(var e=16-this.cache.length,t=o.allocUnsafe(e),r=-1;++r>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function a(e){this.h=e,this.state=n.alloc(16,0),this.cache=n.allocUnsafe(0)}a.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=o(i)},a.prototype.update=function(e){var t;for(this.cache=n.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},a.prototype.final=function(e,t){return this.cache.length&&this.ghash(n.concat([this.cache,i],16)),this.ghash(o([0,e,0,t])),this.state},t.exports=a},{"safe-buffer":290}],62:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],63:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":83}],64:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("buffer-xor");function o(e,t,r){var o=t.length,a=i(t,e._cache);return e._cache=e._cache.slice(o),e._prev=n.concat([e._prev,r?t:a]),a}r.encrypt=function(e,t,r){for(var i,a=n.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=n.allocUnsafe(0)),!(e._cache.length<=t.length)){a=n.concat([a,o(e,t,r)]);break}i=e._cache.length,a=n.concat([a,o(e,t.slice(0,i),r)]),t=t.slice(i)}return a}},{"buffer-xor":83,"safe-buffer":290}],65:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t,r){for(var n,i,a=-1,s=0;++a<8;)n=t&1<<7-a?128:0,s+=(128&(i=e._cipher.encryptBlock(e._prev)[0]^n))>>a%8,e._prev=o(e._prev,r?n:i);return s}function o(e,t){var r=e.length,i=-1,o=n.allocUnsafe(e.length);for(e=n.concat([e,n.from([t])]);++i>7;return o}r.encrypt=function(e,t,r){for(var o=t.length,a=n.allocUnsafe(o),s=-1;++s=0||!r.umod(e.prime1)||!r.umod(e.prime2);)r=new n(i(t));return r}t.exports=o,o.getr=a}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84,randombytes:270}],77:[function(e,t,r){t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":78}],78:[function(e,t,r){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],79:[function(e,t,r){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],80:[function(e,t,r){(function(r){var n=e("create-hash"),i=e("stream"),o=e("inherits"),a=e("./sign"),s=e("./verify"),u=e("./algorithms.json");function c(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function f(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function h(e){return new c(e)}function l(e){return new f(e)}Object.keys(u).forEach(function(e){u[e].id=new r(u[e].id,"hex"),u[e.toLowerCase()]=u[e]}),o(c,i.Writable),c.prototype._write=function(e,t,r){this._hash.update(e),r()},c.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},c.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),n=a(r,e,this._hashType,this._signType,this._tag);return t?n.toString(t):n},o(f,i.Writable),f.prototype._write=function(e,t,r){this._hash.update(e),r()},f.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},f.prototype.verify=function(e,t,n){"string"==typeof t&&(t=new r(t,n)),this.end();var i=this._hash.digest();return s(t,i,e,this._signType,this._tag)},t.exports={Sign:h,Verify:l,createSign:h,createVerify:l}}).call(this,e("buffer").Buffer)},{"./algorithms.json":78,"./sign":81,"./verify":82,buffer:84,"create-hash":91,inherits:180,stream:311}],81:[function(e,t,r){(function(r){var n=e("create-hmac"),i=e("browserify-rsa"),o=e("elliptic").ec,a=e("bn.js"),s=e("parse-asn1"),u=e("./curves.json");function c(e,t,i,o){if((e=new r(e.toArray())).length0&&r.ishrn(n),r}function h(e,t,i){var o,a;do{for(o=new r(0);8*o.length=t)throw new Error("invalid sig")}t.exports=function(e,t,u,c,f){var h=o(u);if("ec"===h.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var n=a[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),s=r.data.subjectPrivateKey.data;return o.verify(t,e,s)}(e,t,h)}if("dsa"===h.type){if("dsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var i=r.data.p,a=r.data.q,u=r.data.g,c=r.data.pub_key,f=o.signature.decode(e,"der"),h=f.s,l=f.r;s(h,a),s(l,a);var d=n.mont(i),p=h.invm(a);return 0===u.toRed(d).redPow(new n(t).mul(p).mod(a)).fromRed().mul(c.toRed(d).redPow(l.mul(p).mod(a)).fromRed()).mod(i).mod(a).cmp(l)}(e,t,h)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");t=r.concat([f,t]);for(var l=h.modulus.byteLength(),d=[1],p=0;t.length+d.length+2o)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=s.prototype,t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(e)}return u(e,t,r)}function u(e,t,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return F(e)?function(e,t,r){if(t<0||e.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function d(e,t){if(s.isBuffer(e))return e.length;if(q(e)||F(e))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return O(e).length;default:if(n)return L(e).length;t=(""+t).toLowerCase(),n=!0}}function p(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var o,a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var f=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function x(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return x(this,t,r);case"ascii":return S(this,t,r);case"latin1":case"binary":return M(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},s.prototype.compare=function(e,t,r,n,i){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),u=Math.min(o,a),c=this.slice(n,i),f=e.slice(t,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return m(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return g(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function S(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,r,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function B(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function C(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,8),i.write(e,t,r,n,52,8),r+8}s.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},s.prototype.readUInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeFloatLE=function(e,t,r){return P(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return P(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return C(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return C(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(e){return n.toByteArray(function(e){if((e=e.trim().replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function F(e){return e instanceof ArrayBuffer||null!=e&&null!=e.constructor&&"ArrayBuffer"===e.constructor.name&&"number"==typeof e.byteLength}function q(e){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(e)}function H(e){return e!=e}},{"base64-js":51,ieee754:178}],85:[function(e,t,r){t.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],86:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("stream").Transform,o=e("string_decoder").StringDecoder;function a(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(a,i),a.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},a.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},a.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},a.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},t.exports=a},{inherits:180,"safe-buffer":290,stream:311,string_decoder:317}],87:[function(e,t,r){(function(e){var r=function(){"use strict";function t(e,t){return null!=t&&e instanceof t}var r,n,i;try{r=Map}catch(e){r=function(){}}try{n=Set}catch(e){n=function(){}}try{i=Promise}catch(e){i=function(){}}function o(a,u,c,f,h){"object"==typeof u&&(c=u.depth,f=u.prototype,h=u.includeNonEnumerable,u=u.circular);var l=[],d=[],p=void 0!==e;return void 0===u&&(u=!0),void 0===c&&(c=1/0),function a(c,b){if(null===c)return null;if(0===b)return c;var y,m;if("object"!=typeof c)return c;if(t(c,r))y=new r;else if(t(c,n))y=new n;else if(t(c,i))y=new i(function(e,t){c.then(function(t){e(a(t,b-1))},function(e){t(a(e,b-1))})});else if(o.__isArray(c))y=[];else if(o.__isRegExp(c))y=new RegExp(c.source,s(c)),c.lastIndex&&(y.lastIndex=c.lastIndex);else if(o.__isDate(c))y=new Date(c.getTime());else{if(p&&e.isBuffer(c))return y=e.allocUnsafe?e.allocUnsafe(c.length):new e(c.length),c.copy(y),y;t(c,Error)?y=Object.create(c):void 0===f?(m=Object.getPrototypeOf(c),y=Object.create(m)):(y=Object.create(f),m=f)}if(u){var v=l.indexOf(c);if(-1!=v)return d[v];l.push(c),d.push(y)}for(var g in t(c,r)&&c.forEach(function(e,t){var r=a(t,b-1),n=a(e,b-1);y.set(r,n)}),t(c,n)&&c.forEach(function(e){var t=a(e,b-1);y.add(t)}),c){var w;m&&(w=Object.getOwnPropertyDescriptor(m,g)),w&&null==w.set||(y[g]=a(c[g],b-1))}if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(c);for(g=0;g<_.length;g++){var A=_[g];(!(x=Object.getOwnPropertyDescriptor(c,A))||x.enumerable||h)&&(y[A]=a(c[A],b-1),x.enumerable||Object.defineProperty(y,A,{enumerable:!1}))}}if(h){var E=Object.getOwnPropertyNames(c);for(g=0;g>>2),a=0,s=0;a>5]|=128<>>9<<4)]=t;for(var r=1732584193,n=-271733879,i=-1732584194,o=271733878,h=0;h>>32-s,r);var a,s}function a(e,t,r,n,i,a,s){return o(t&r|~t&n,e,t,i,a,s)}function s(e,t,r,n,i,a,s){return o(t&n|r&~n,e,t,i,a,s)}function u(e,t,r,n,i,a,s){return o(t^r^n,e,t,i,a,s)}function c(e,t,r,n,i,a,s){return o(r^(t|~n),e,t,i,a,s)}function f(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}t.exports=function(e){return n(e,i)}},{"./make-hash":92}],94:[function(e,t,r){"use strict";var n=e("inherits"),i=e("./legacy"),o=e("cipher-base"),a=e("safe-buffer").Buffer,s=e("create-hash/md5"),u=e("ripemd160"),c=e("sha.js"),f=a.alloc(128);function h(e,t){o.call(this,"digest"),"string"==typeof t&&(t=a.from(t));var r="sha512"===e||"sha384"===e?128:64;(this._alg=e,this._key=t,t.length>r)?t=("rmd160"===e?new u:c(e)).update(t).digest():t.lengths?t=e(t):t.length-1};f.prototype.append=function(e,t){e=s(e),t=u(t);var r=this.map[e];this.map[e]=r?r+","+t:t},f.prototype.delete=function(e){delete this.map[s(e)]},f.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},f.prototype.set=function(e,t){this.map[s(e)]=u(t)},f.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},f.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),c(e)},f.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),c(e)},f.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),c(e)},t.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);var o=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},b.call(y.prototype),b.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:0,statusText:""});return e.type="error",e};var a=[301,302,303,307,308];v.redirect=function(e,t){if(-1===a.indexOf(t))throw new RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},e.Headers=f,e.Request=y,e.Response=v,e.fetch=function(e,r){return new Promise(function(n,i){var o=new y(e,r),a=new XMLHttpRequest;a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new v(i,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&t.blob&&(a.responseType="blob"),o.headers.forEach(function(e,t){a.setRequestHeader(t,e)}),a.send(void 0===o._bodyInit?null:o._bodyInit)})},e.fetch.polyfill=!0}function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function u(e){return"string"!=typeof e&&(e=String(e)),e}function c(e){var r={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t.iterable&&(r[Symbol.iterator]=function(){return r}),r}function f(e){this.map={},e instanceof f?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function h(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function l(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function d(e){var t=new FileReader,r=l(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(t.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(t.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(t.arrayBuffer&&t.blob&&n(e))this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!t.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(e)&&!i(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=p(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},t.blob&&(this.blob=function(){var e=h(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var e,t,r,n=h(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=l(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function v(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}}(void 0!==e?e:this)}).call(n,void 0);var i=n.fetch;i.Response=n.Response,i.Request=n.Request,i.Headers=n.Headers;"object"==typeof t&&t.exports&&(t.exports=i,t.exports.default=i)},{}],97:[function(e,t,r){"use strict";r.randomBytes=r.rng=r.pseudoRandomBytes=r.prng=e("randombytes"),r.createHash=r.Hash=e("create-hash"),r.createHmac=r.Hmac=e("create-hmac");var n=e("browserify-sign/algos"),i=Object.keys(n),o=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(i);r.getHashes=function(){return o};var a=e("pbkdf2");r.pbkdf2=a.pbkdf2,r.pbkdf2Sync=a.pbkdf2Sync;var s=e("browserify-cipher");r.Cipher=s.Cipher,r.createCipher=s.createCipher,r.Cipheriv=s.Cipheriv,r.createCipheriv=s.createCipheriv,r.Decipher=s.Decipher,r.createDecipher=s.createDecipher,r.Decipheriv=s.Decipheriv,r.createDecipheriv=s.createDecipheriv,r.getCiphers=s.getCiphers,r.listCiphers=s.listCiphers;var u=e("diffie-hellman");r.DiffieHellmanGroup=u.DiffieHellmanGroup,r.createDiffieHellmanGroup=u.createDiffieHellmanGroup,r.getDiffieHellman=u.getDiffieHellman,r.createDiffieHellman=u.createDiffieHellman,r.DiffieHellman=u.DiffieHellman;var c=e("browserify-sign");r.createSign=c.createSign,r.Sign=c.Sign,r.createVerify=c.createVerify,r.Verify=c.Verify,r.createECDH=e("create-ecdh");var f=e("public-encrypt");r.publicEncrypt=f.publicEncrypt,r.privateEncrypt=f.privateEncrypt,r.publicDecrypt=f.publicDecrypt,r.privateDecrypt=f.privateDecrypt;var h=e("randomfill");r.randomFill=h.randomFill,r.randomFillSync=h.randomFillSync,r.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))},r.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},{"browserify-cipher":73,"browserify-sign":80,"browserify-sign/algos":77,"create-ecdh":90,"create-hash":91,"create-hmac":94,"diffie-hellman":105,pbkdf2:247,"public-encrypt":259,randombytes:270,randomfill:271}],98:[function(e,t,r){"use strict";var n=new RegExp("%[a-f0-9]{2}","gi"),i=new RegExp("(%[a-f0-9]{2})+","gi");function o(e,t){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],o(r),o(n))}function a(e){try{return decodeURIComponent(e)}catch(i){for(var t=e.match(n),r=1;r0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];r=a.r28shl(r,s),i=a.r28shl(i,s),a.pc2(r,i,e.keys,o)}},u.prototype._update=function(e,t,r,n){var i=this._desState,o=a.readUInt32BE(e,t),s=a.readUInt32BE(e,t+4);a.ip(o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,s,i.tmp,0):this._decrypt(i,o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],a.writeUInt32BE(r,o,n),a.writeUInt32BE(r,s,n+4)},u.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,o=l}a.rip(s,o,n,i)},u.prototype._decrypt=function(e,t,r,n,i){for(var o=r,s=t,u=e.keys.length-2;u>=0;u-=2){var c=e.keys[u],f=e.keys[u+1];a.expand(o,e.tmp,0),c^=e.tmp[0],f^=e.tmp[1];var h=a.substitute(c,f),l=o;o=(s^a.permute(h))>>>0,s=l}a.rip(o,s,n,i)}},{"../des":99,inherits:180,"minimalistic-assert":234}],103:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits"),o=e("../des"),a=o.Cipher,s=o.DES;function u(e){a.call(this,e);var t=new function(e,t){n.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),i=t.slice(8,16),o=t.slice(16,24);this.ciphers="encrypt"===e?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=t}i(u,a),t.exports=u,u.create=function(e){return new u(e)},u.prototype._update=function(e,t,r,n){var i=this._edeState;i.ciphers[0]._update(e,t,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},u.prototype._pad=s.prototype._pad,u.prototype._unpad=s.prototype._unpad},{"../des":99,inherits:180,"minimalistic-assert":234}],104:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,n){for(var i=0,o=0,a=6;a>=0;a-=2){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>>s+a&1}for(a=6;a>=0;a-=2){for(s=1;s<=25;s+=8)o<<=1,o|=t>>>s+a&1;for(s=1;s<=25;s+=8)o<<=1,o|=e>>>s+a&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(e,t,r,n){for(var i=0,o=0,a=0;a<4;a++)for(var s=24;s>=0;s-=8)i<<=1,i|=t>>>s+a&1,i<<=1,i|=e>>>s+a&1;for(a=4;a<8;a++)for(s=24;s>=0;s-=8)o<<=1,o|=t>>>s+a&1,o<<=1,o|=e>>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(e,t,r,n){for(var i=0,o=0,a=7;a>=5;a--){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+a&1}for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(a=1;a<=3;a++){for(s=0;s<=24;s+=8)o<<=1,o|=t>>s+a&1;for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1}for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,i){for(var o=0,a=0,s=n.length>>>1,u=0;u>>n[u]&1;for(u=s;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=a>>>0},r.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var n=e.toString(2);n.lengthe;)r.ishrn(1);if(r.isEven()&&r.iadd(s),r.testn(1)||r.iadd(u),t.cmp(u)){if(!t.cmp(c))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&m(p)&&m(r)&&a.test(p)&&a.test(r))return r}}},{"bn.js":53,"miller-rabin":233,randombytes:270}],108:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],109:[function(e,t,r){"use strict";var n=r;n.version=e("../package.json").version,n.utils=e("./elliptic/utils"),n.rand=e("brorand"),n.curve=e("./elliptic/curve"),n.curves=e("./elliptic/curves"),n.ec=e("./elliptic/ec"),n.eddsa=e("./elliptic/eddsa")},{"../package.json":124,"./elliptic/curve":112,"./elliptic/curves":115,"./elliptic/ec":116,"./elliptic/eddsa":119,"./elliptic/utils":123,brorand:54}],110:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.getNAF,a=i.getJSF,s=i.assert;function u(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){s(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=u;t--)c=(c<<1)+n[t];a.push(c)}for(var f=this.jpoint(null,null,null),h=this.jpoint(null,null,null),l=i;l>0;l--){for(u=0;u=0;c--){for(t=0;c>=0&&0===a[c];c--)t++;if(c>=0&&t++,u=u.dblp(t),c<0)break;var f=a[c];s(0!==f),u="affine"===e.type?f>0?u.mixedAdd(i[f-1>>1]):u.mixedAdd(i[-f-1>>1].neg()):f>0?u.add(i[f-1>>1]):u.add(i[-f-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){for(var s=this._wnafT1,u=this._wnafT2,c=this._wnafT3,f=0,h=0;h=1;h-=2){var d=h-1,p=h;if(1===s[d]&&1===s[p]){var b=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(b[1]=t[d].add(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].add(t[p].neg())):(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],m=a(r[d],r[p]);f=Math.max(m[0].length,f),c[d]=new Array(f),c[p]=new Array(f);for(var v=0;v=0;h--){for(var E=0;h>=0;){var x=!0;for(v=0;v=0&&E++,_=_.dblp(E),h<0)break;for(v=0;v0?k=u[v][S-1>>1]:S<0&&(k=u[v][-S-1>>1].neg()),_="affine"===k.type?_.mixedAdd(k):_.add(k))}}for(h=0;h=Math.ceil((e.bitLength()+1)/t.step)},c.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},f.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},f.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(r),s=n.redSub(t),u=i.redMul(a),c=o.redMul(s),f=i.redMul(s),h=a.redMul(o);return this.curve.point(u,c,h,f)},f.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var a=(c=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(a.redSub(this.curve.two)),t=a.redMul(c.redSub(o)),r=a.redSqr().redSub(a).redSub(a);else{var s=this.z.redSqr(),u=a.redSub(s).redISub(s);e=n.redSub(i).redISub(o).redMul(u),t=a.redMul(c.redSub(o)),r=a.redMul(u)}}else{var c=i.redAdd(o);s=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=c.redSub(s).redSub(s);e=this.curve._mulC(n.redISub(c)).redMul(u),t=this.curve._mulC(c).redMul(i.redISub(o)),r=c.redMul(u)}return this.curve.point(e,t,r)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},f.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=i.redSub(n),s=i.redAdd(n),u=r.redAdd(t),c=o.redMul(a),f=s.redMul(u),h=o.redMul(u),l=a.redMul(s);return this.curve.point(c,f,l,h)},f.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),c=i.redAdd(s),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),h=n.redMul(u).redMul(f);return this.curve.twisted?(t=n.redMul(c).redMul(a.redSub(this.curve._mulA(o))),r=u.redMul(c)):(t=n.redMul(c).redMul(a.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(h,t,r)},f.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},f.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},f.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},f.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},f.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()},f.prototype.getY=function(){return this.normalize(),this.y.fromRed()},f.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},f.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}return!1},f.prototype.toP=f.prototype.normalize,f.prototype.mixedAdd=f.prototype.add},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],112:[function(e,t,r){"use strict";var n=r;n.base=e("./base"),n.short=e("./short"),n.mont=e("./mont"),n.edwards=e("./edwards")},{"./base":110,"./edwards":111,"./mont":113,"./short":114}],113:[function(e,t,r){"use strict";var n=e("../curve"),i=e("bn.js"),o=e("inherits"),a=n.base,s=e("../../elliptic").utils;function u(e){a.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,r){a.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(u,a),t.exports=u,u.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},o(c,a.BasePoint),u.prototype.decodePoint=function(e,t){return this.point(s.toArray(e,t),1)},u.prototype.point=function(e,t){return new c(this,e,t)},u.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=i.redMul(n),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},c.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],114:[function(e,t,r){"use strict";var n=e("../curve"),i=e("../../elliptic"),o=e("bn.js"),a=e("inherits"),s=n.base,u=i.utils.assert;function c(e){s.call(this,"short",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function f(e,t,r,n){s.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new o(t,16),this.y=new o(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function h(e,t,r,n){s.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new o(0)):(this.x=new o(t,16),this.y=new o(r,16),this.z=new o(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}a(c,s),t.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new o(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new o(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?r=i[0]:(r=i[1],u(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new o(e.a,16),b:new o(e.b,16)}}):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:o.mont(e),r=new o(2).toRed(t).redInvm(),n=r.redNeg(),i=new o(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,r,n,i,a,s,u,c,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=e,d=this.n.clone(),p=new o(1),b=new o(0),y=new o(0),m=new o(1),v=0;0!==l.cmpn(0);){var g=d.div(l);c=d.sub(g.mul(l)),f=y.sub(g.mul(p));var w=m.sub(g.mul(b));if(!n&&c.cmp(h)<0)t=u.neg(),r=p,n=c.neg(),i=f;else if(n&&2==++v)break;u=c,d=l,l=c,y=p,p=f,m=b,b=w}a=c.neg(),s=f;var _=n.sqr().add(i.sqr());return a.sqr().add(s.sqr()).cmp(_)>=0&&(a=t,s=r),n.negative&&(n=n.neg(),i=i.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:n,b:i},{a:a,b:s}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(c).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},f.prototype.isInfinity=function(){return this.inf},f.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},f.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},f.prototype.getX=function(){return this.x.fromRed()},f.prototype.getY=function(){return this.y.fromRed()},f.prototype.mul=function(e){return e=new o(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},f.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},f.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},f.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},f.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},a(h,s.BasePoint),c.prototype.jpoint=function(e,t,r){return new h(this,e,t,r)},h.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},h.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},h.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),f=c.redMul(s),h=n.redMul(c),l=u.redSqr().redIAdd(f).redISub(h).redISub(h),d=u.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(l,d,p)},h.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),f=r.redMul(u),h=s.redSqr().redIAdd(c).redISub(f).redISub(f),l=s.redMul(f.redISub(h)).redISub(i.redMul(c)),d=this.z.redMul(a);return this.curve.jpoint(h,l,d)},h.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}return!1},h.prototype.inspect=function(){return this.isInfinity()?"":""},h.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],115:[function(e,t,r){"use strict";var n,i=r,o=e("hash.js"),a=e("../elliptic"),s=a.utils.assert;function u(e){"short"===e.type?this.curve=new a.curve.short(e):"edwards"===e.type?this.curve=new a.curve.edwards(e):this.curve=new a.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=e("./precomputed/secp256k1")}catch(e){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"../elliptic":109,"./precomputed/secp256k1":122,"hash.js":162}],116:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("hmac-drbg"),o=e("../../elliptic"),a=o.utils.assert,s=e("./key"),u=e("./signature");function c(e){if(!(this instanceof c))return new c(e);"string"==typeof e&&(a(o.curves.hasOwnProperty(e),"Unknown curve "+e),e=o.curves[e]),e instanceof o.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=c,c.prototype.keyPair=function(e){return new s(this,e)},c.prototype.keyFromPrivate=function(e,t){return s.fromPrivate(this,e,t)},c.prototype.keyFromPublic=function(e,t){return s.fromPublic(this,e,t)},c.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||o.rand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),a=this.n.sub(new n(2));;){var s=new n(t.generate(r));if(!(s.cmp(a)>0))return s.iaddn(1),this.keyFromPrivate(s)}},c.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},c.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),c=e.toArray("be",a),f=new i({hash:this.hash,entropy:s,nonce:c,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(f.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var m=d.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),v^=1),new u({r:y,s:m,recoveryParam:v})}}}}}},c.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new u(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,c=a.invm(this.n),f=c.mul(e).umod(this.n),h=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(f,r.getPublic(),h)).isInfinity()&&s.eqXToP(o):!(s=this.g.mulAdd(f,r.getPublic(),h)).isInfinity()&&0===s.getX().umod(this.n).cmp(o)},c.prototype.recoverPubKey=function(e,t,r,i){a((3&r)===r,"The recovery param is more than two bits"),t=new u(t,i);var o=this.n,s=new n(e),c=t.r,f=t.s,h=1&r,l=r>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");c=l?this.curve.pointFromX(c.add(this.curve.n),h):this.curve.pointFromX(c,h);var d=t.r.invm(o),p=o.sub(s).mul(d).umod(o),b=f.mul(d).umod(o);return this.g.mulAdd(p,c,b)},c.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new u(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":109,"./key":117,"./signature":118,"bn.js":53,"hmac-drbg":174}],117:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils.assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../../elliptic":109,"bn.js":53}],118:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new function(){this.place=0};if(48!==e[r.place++])return!1;if(s(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=s(e,r),a=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var u=s(e,r);if(e.length!==u+r.place)return!1;var c=e.slice(r.place,u+r.place);return 0===a[0]&&128&a[1]&&(a=a.slice(1)),0===c[0]&&128&c[1]&&(c=c.slice(1)),this.r=new n(a),this.s=new n(c),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=u(t),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),a=[48];return c(a,o.length),a=a.concat(o),i.encode(a,e)}},{"../../elliptic":109,"bn.js":53}],119:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("../../elliptic"),o=i.utils,a=o.assert,s=o.parseBytes,u=e("./key"),c=e("./signature");function f(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}t.exports=f,f.prototype.sign=function(e,t){e=s(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),u=n.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(e,t,r){e=s(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var s=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,c=t.andln(3)+i&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!=(s=e.andln(7)+n&7)&&5!==s||2!==c?u:-u,r[0].push(o),a=0==(1&c)?0:3!=(s=t.andln(7)+i&7)&&5!==s||2!==u?c:-c,r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},{"bn.js":53,"minimalistic-assert":234,"minimalistic-crypto-utils":235}],124:[function(e,t,r){t.exports={_from:"elliptic@^6.0.0",_id:"elliptic@6.4.0",_inBundle:!1,_integrity:"sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=",_location:"/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.0.0",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.0.0",saveSpec:null,fetchSpec:"^6.0.0"},_requiredBy:["/browserify-sign","/create-ecdh"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",_shasum:"cac9af8762c85836187003c8dfe193e5e2eae5df",_spec:"elliptic@^6.0.0",_where:"/Users/alexvlasov/Blockchain/web3swift_jsproxy/node_modules/browserify-sign",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.4.0"}},{}],125:[function(e,t,r){"use strict";const n=e("ethjs-util");function i(e){let t=n.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}t.exports={incrementHexNumber:function(e){return i(n.intToHex(parseInt(e,16)+1))},formatHex:i}},{"ethjs-util":155}],126:[function(e,t,r){const n=e("eth-query"),i=e("events"),o=e("pify"),a=e("./hexUtils"),s=a.incrementHexNumber,u=1e3,c=60*u;t.exports=class extends i{constructor(e={}){if(super(),!e.provider)throw new Error("RpcBlockTracker - no provider specified.");this._provider=e.provider,this._query=new n(e.provider),this._pollingInterval=e.pollingInterval||4*u,this._syncingTimeout=e.syncingTimeout||1*c,this._trackingBlock=null,this._trackingBlockTimestamp=null,this._currentBlock=null,this._isRunning=!1,this._performSync=this._performSync.bind(this),this._handleNewBlockNotification=this._handleNewBlockNotification.bind(this)}getTrackingBlock(){return this._trackingBlock}getCurrentBlock(){return this._currentBlock}async awaitCurrentBlock(){return this._currentBlock?this._currentBlock:(await new Promise(e=>this.once("latest",e)),this._currentBlock)}async start(e={}){this._isRunning||(this._isRunning=!0,e.fromBlock?await this._setTrackingBlock(await this._fetchBlockByNumber(e.fromBlock)):await this._setTrackingBlock(await this._fetchLatestBlock()),this._provider.on?await this._initSubscription():this._performSync().catch(e=>{e&&console.error(e)}))}async stop(){this._isRunning=!1,this._provider.on&&await this._removeSubscription()}async _setTrackingBlock(e){if(this._trackingBlock&&this._trackingBlock.hash===e.hash)return;const t=this._trackingBlockTimestamp,r=Date.now();t&&r-t>this._syncingTimeout?(this._trackingBlockTimestamp=null,await this._warpToLatest()):(this._trackingBlock=e,this._trackingBlockTimestamp=r,this.emit("block",e))}async _setCurrentBlock(e){if(this._currentBlock&&this._currentBlock.hash===e.hash)return;const t=this._currentBlock;this._currentBlock=e,this.emit("latest",e),this.emit("sync",{newBlock:e,oldBlock:t})}async _warpToLatest(){await this._setTrackingBlock(await this._fetchLatestBlock())}async _pollForNextBlock(){setTimeout(()=>this._performSync(),this._pollingInterval)}async _performSync(){if(!this._isRunning)return;const e=this.getTrackingBlock();if(!e)throw new Error("RpcBlockTracker - tracking block is missing");const t=s(e.number);try{const r=await this._fetchBlockByNumber(t);r?(await this._setTrackingBlock(r),this._performSync()):(await this._setCurrentBlock(e),this._pollForNextBlock())}catch(t){t.message.includes("index out of range")||t.message.includes("Couldn't find block by reference")?(await this._setCurrentBlock(e),this._pollForNextBlock()):(console.error(t),this._pollForNextBlock())}}async _handleNewBlockNotification(e,t){t.id==this._subscriptionId&&(e&&(this.emit("error",e),await this._removeSubscription()),await this._setTrackingBlock(await this._fetchBlockByNumber(t.result.number)))}async _initSubscription(){this._provider.on("data",this._handleNewBlockNotification);let e=await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_subscribe",params:["newHeads"]});this._subscriptionId=e.result}async _removeSubscription(){if(!this._subscriptionId)throw new Error("Not subscribed.");this._provider.removeListener("data",this._handleNewBlockNotification),await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_unsubscribe",params:[this._subscriptionId]}),delete this._subscriptionId}_fetchLatestBlock(){return o(this._query.getBlockByNumber).call(this._query,"latest",!0)}_fetchBlockByNumber(e){const t=a.formatHex(e);return o(this._query.getBlockByNumber).call(this._query,t,!0)}}},{"./hexUtils":125,"eth-query":135,events:157,pify:252}],127:[function(e,t,r){(function(t){var n=e("js-sha3").keccak_256,i=e("idna-uts46-hx");function o(e){return e?i.toUnicode(e,{useStd3ASCII:!0,transitional:!1}):e}r.hash=function(e){for(var r="",i=0;i<32;i++)r+="00";if(name=o(e),name){var a=name.split(".");for(i=a.length-1;i>=0;i--){var s=n(a[i]);r=n(new t(r+s,"hex"))}}return"0x"+r},r.normalize=o}).call(this,e("buffer").Buffer)},{buffer:84,"idna-uts46-hx":177,"js-sha3":128}],128:[function(e,t,r){(function(e,r){!function(){"use strict";var n="object"==typeof window?window:{};!n.JS_SHA3_NO_NODE_JS&&"object"==typeof e&&e.versions&&e.versions.node&&(n=r);for(var i=!n.JS_SHA3_NO_COMMON_JS&&"object"==typeof t&&t.exports,o="0123456789abcdef".split(""),a=[0,8,16,24],s=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],u=[224,256,384,512],c=["hex","buffer","arrayBuffer","array"],f=function(e,t,r){return function(n){return new _(e,t,e).update(n)[r]()}},h=function(e,t,r){return function(n,i){return new _(e,t,i).update(n)[r]()}},l=function(e,t){var r=f(e,t,"hex");r.create=function(){return new _(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}_.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,o=this.blocks,s=this.byteCount,u=this.blockCount,c=0,f=this.s;c>2]|=e[c]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(o[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=s){for(this.start=r-s,this.block=o[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+o[15&e]+o[e>>12&15]+o[e>>8&15]+o[e>>20&15]+o[e>>16&15]+o[e>>28&15]+o[e>>24&15];s%t==0&&(A(r),a=0)}return i&&(e=r[a],i>0&&(u+=o[e>>4&15]+o[15&e]),i>1&&(u+=o[e>>12&15]+o[e>>8&15]),i>2&&(u+=o[e>>20&15]+o[e>>16&15])),u},_.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&A(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var A=function(e){var t,r,n,i,o,a,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],a=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(a<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|a>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=a^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=s[n],e[1]^=s[n+1]};if(i)t.exports=p;else for(y=0;y{setTimeout(t,e)})}function c(e){const t=e.toString();return s.some(e=>t.includes(e))}async function f(e,t,r){const{fetchUrl:n,fetchParams:a}=h({network:e,req:t}),s=await o(n,a),u=await s.text();if(!s.ok)switch(s.status){case 405:throw new i.MethodNotFound;case 418:throw l("Request is being rate limited.");case 503:case 504:throw function(){let e="Gateway timeout. The request took too long to process. ";return e+="This can happen when querying logs over too wide a block range.",l("Gateway timeout. The request took too long to process. This can happen when querying logs over too wide a block range.")}();default:throw l(u)}if("eth_getBlockByNumber"===t.method&&"Not Found"===u)return void(r.result=null);const c=JSON.parse(u);r.result=c.result,r.error=c.error}function h({network:e,req:t}){const r=function(e){return{id:e.id,jsonrpc:e.jsonrpc,method:e.method,params:e.params}}(t),{method:n,params:i}=r,o={};let s=`https://api.infura.io/v1/jsonrpc/${e}`;if(a.includes(n))o.method="POST",o.headers={Accept:"application/json","Content-Type":"application/json"},o.body=JSON.stringify(r);else{o.method="GET",s+=`/${n}?params=${encodeURIComponent(JSON.stringify(i))}`}return{fetchUrl:s,fetchParams:o}}function l(e){const t=new Error(e);return new i.InternalError(t)}t.exports=function(e={}){const t=e.network||"mainnet",r=e.maxAttempts||5;if(!r)throw new Error(`Invalid value for 'maxAttempts': "${r}" (${typeof r})`);return n(async(e,n,i)=>{for(let i=1;i<=r;i++)try{await f(t,e,n);break}catch(e){if(!c(e))throw e;const t=r-i;if(!t){const t=`InfuraProvider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,r=new Error(t);throw r}await u(1e3)}})},t.exports.fetchConfigFromReq=h},{"cross-fetch":96,"json-rpc-engine/src/createAsyncMiddleware":187,"json-rpc-error":189}],131:[function(e,t,r){t.exports=function(e){return{sendAsync:e.handle.bind(e)}}},{}],132:[function(e,t,r){var n=function(e,t){for(var r=[],n=0;n>6|192);else{if(i>55295&&i<56320){if(++n==e.length)return null;var o=e.charCodeAt(n);if(o<56320||o>57343)return null;r+=t((i=65536+((1023&i)<<10)+(1023&o))>>18|240),r+=t(i>>12&63|128)}else r+=t(i>>12|224);r+=t(i>>6&63|128)}r+=t(63&i|128)}}return r},toString:function(e){for(var t="",r=0,o=i(e);r127){if(a>191&&a<224){if(r>=o)return null;a=(31&a)<<6|63&n(e,r)}else if(a>223&&a<240){if(r+1>=o)return null;a=(15&a)<<12|(63&n(e,r))<<6|63&n(e,++r)}else{if(!(a>239&&a<248))return null;if(r+2>=o)return null;a=(7&a)<<18|(63&n(e,r))<<12|(63&n(e,++r))<<6|63&n(e,++r)}++r}if(a<=65535)t+=String.fromCharCode(a);else{if(!(a<=1114111))return null;a-=65536,t+=String.fromCharCode(a>>10|55296),t+=String.fromCharCode(1023&a|56320)}}return t},fromNumber:function(e){var t=e.toString(16);return t.length%2==0?"0x"+t:"0x0"+t},toNumber:function(e){return parseInt(e.slice(2),16)},fromNat:function(e){return"0x0"===e?"0x":e.length%2==0?e:"0x0"+e.slice(2)},toNat:function(e){return"0"===e[2]?"0x"+e.slice(3):e},fromArray:a,toArray:o,fromUint8Array:function(e){return a([].slice.call(e,0))},toUint8Array:function(e){return new Uint8Array(o(e))}}},{"./array.js":132}],134:[function(e,t,r){var n="0123456789abcdef".split(""),i=[1,256,65536,16777216],o=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],s=function(e){var t,r,n,i,o,s,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=a[n],e[1]^=a[n+1]},u=function(e){return function(t){var r;if("0x"===t.slice(0,2)){r=[];for(var a=2,u=t.length;a>2]|=t[d]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|63&r)<=57344?(u[y>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<=c){for(e.start=y-c,e.block=u[f],y=0;y>2]|=i[3&y],e.lastByteIndex===c)for(u[0]=u[f],y=1;y>4&15]+n[15&p]+n[p>>12&15]+n[p>>8&15]+n[p>>20&15]+n[p>>16&15]+n[p>>28&15]+n[p>>24&15];m%f==0&&(s(l),y=0)}return"0x"+b}(function(e){return{blocks:[],reset:!0,block:0,start:0,blockCount:1600-(e<<1)>>5,outputBlocks:e>>5,s:(t=[0,0,0,0,0,0,0,0,0,0],[].concat(t,t,t,t,t))};var t}(e),r)}};t.exports={keccak256:u(256),keccak512:u(512),keccak256s:u(256),keccak512s:u(512)}},{}],135:[function(e,t,r){const n=e("xtend"),i=e("json-rpc-random-id")();function o(e){this.currentProvider=e}function a(e){return function(){var t=[].slice.call(arguments),r=t.pop();this.sendAsync({method:e,params:t},r)}}function s(e,t){return function(){var r=[].slice.call(arguments),n=r.pop();r.lengtho)throw new Error("Elements exceed array size: "+o);for(d in h=[],e=e.slice(0,e.lastIndexOf("[")),"string"==typeof t&&(t=JSON.parse(t)),t)h.push(l(e,t[d]));if("dynamic"===o){var p=l("uint256",t.length);h.unshift(p)}return r.concat(h)}if("bytes"===e)return t=new r(t),h=r.concat([l("uint256",t.length),t]),t.length%32!=0&&(h=r.concat([h,n.zeros(32-t.length%32)])),h;if(e.startsWith("bytes")){if((o=s(e))<1||o>32)throw new Error("Invalid bytes width: "+o);return n.setLengthRight(t,32)}if(e.startsWith("uint")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid uint width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied uint exceeds width: "+o+" vs "+a.bitLength());if(a<0)throw new Error("Supplied uint is negative");return a.toArrayLike(r,"be",32)}if(e.startsWith("int")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid int width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied int exceeds width: "+o+" vs "+a.bitLength());return a.toTwos(256).toArrayLike(r,"be",32)}if(e.startsWith("ufixed")){if(o=u(e),(a=f(t))<0)throw new Error("Supplied ufixed is negative");return l("uint256",a.mul(new i(2).pow(new i(o[1]))))}if(e.startsWith("fixed"))return o=u(e),l("int256",f(t).mul(new i(2).pow(new i(o[1]))));throw new Error("Unsupported or invalid type: "+e)}function d(e,t,n){var o,a,s,u;if("string"==typeof e&&(e=p(e)),"address"===e.name)return d(e.rawType,t,n).toArrayLike(r,"be",20).toString("hex");if("bool"===e.name)return d(e.rawType,t,n).toString()===new i(1).toString();if("string"===e.name){var c=d(e.rawType,t,n);return new r(c,"utf8").toString()}if(e.isArray){for(s=[],o=e.size,"dynamic"===e.size&&(o=d("uint256",t,n=d("uint256",t,n).toNumber()).toNumber(),n+=32),u=0;ue.size)throw new Error("Decoded int exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("int")){if((a=new i(t.slice(n,n+32),16,"be").fromTwos(256)).bitLength()>e.size)throw new Error("Decoded uint exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("ufixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("uint256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}if(e.name.startsWith("fixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("int256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}throw new Error("Unsupported or invalid type: "+e.name)}function p(e){var t,r,n;if(y(e)){t=c(e);var i=e.slice(0,e.lastIndexOf("["));return i=p(i),r={isArray:!0,name:e,size:t,memoryUsage:"dynamic"===t?32:i.memoryUsage*t,subArray:i}}switch(e){case"address":n="uint160";break;case"bool":n="uint8";break;case"string":n="bytes"}if(r={rawType:n,name:e,memoryUsage:32},e.startsWith("bytes")&&"bytes"!==e||e.startsWith("uint")||e.startsWith("int")?r.size=s(e):(e.startsWith("ufixed")||e.startsWith("fixed"))&&(r.size=u(e)),e.startsWith("bytes")&&"bytes"!==e&&(r.size<1||r.size>32))throw new Error("Invalid bytes width: "+r.size);if((e.startsWith("uint")||e.startsWith("int"))&&(r.size%8||r.size<8||r.size>256))throw new Error("Invalid int/uint width: "+r.size);return r}function b(e){return"string"===e||"bytes"===e||"dynamic"===c(e)}function y(e){return e.lastIndexOf("]")===e.length-1}function m(e,t){return e.startsWith("address")||e.startsWith("bytes")?"0x"+t.toString("hex"):t.toString()}o.eventID=function(e,t){var i=e+"("+t.map(a).join(",")+")";return n.sha3(new r(i))},o.methodID=function(e,t){return o.eventID(e,t).slice(0,4)},o.rawEncode=function(e,t){var n=[],i=[],o=0;e.forEach(function(e){if(y(e)){var t=c(e);o+="dynamic"!==t?32*t:32}else o+=32});for(var s=0;s32)throw new Error("Invalid bytes width: "+i);u.push(n.setLengthRight(l,i))}else if(h.startsWith("uint")){if((i=s(h))%8||i<8||i>256)throw new Error("Invalid uint width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied uint exceeds width: "+i+" vs "+o.bitLength());u.push(o.toArrayLike(r,"be",i/8))}else{if(!h.startsWith("int"))throw new Error("Unsupported or invalid type: "+h);if((i=s(h))%8||i<8||i>256)throw new Error("Invalid int width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied int exceeds width: "+i+" vs "+o.bitLength());u.push(o.toTwos(i).toArrayLike(r,"be",i/8))}}return r.concat(u)},o.soliditySHA3=function(e,t){return n.sha3(o.solidityPack(e,t))},o.soliditySHA256=function(e,t){return n.sha256(o.solidityPack(e,t))},o.solidityRIPEMD160=function(e,t){return n.ripemd160(o.solidityPack(e,t),!0)},o.fromSerpent=function(e){for(var t,r=[],n=0;n="0"&&t<="9");)o+=e[a]-"0",a++;n=a-1,r.push(o)}else if("i"===i)r.push("int256");else{if("a"!==i)throw new Error("Unsupported or invalid type: "+i);r.push("int256[]")}}return r},o.toSerpent=function(e){for(var t=[],r=0;r0){var r=this.raw.slice();this.v=this._chainId,this.r=0,this.s=0,t=this.raw,this.raw=r}else t=this.raw.slice(0,6);return n.rlphash(t)},e.prototype.getChainId=function(){return this._chainId},e.prototype.getSenderAddress=function(){if(this._from)return this._from;var e=this.getSenderPublicKey();return this._from=n.publicToAddress(e),this._from},e.prototype.getSenderPublicKey=function(){if(!(this._senderPubKey&&this._senderPubKey.length||this.verifySignature()))throw new Error("Invalid Signature");return this._senderPubKey},e.prototype.verifySignature=function(){var e=this.hash(!1);if(this._homestead&&1===new o(this.s).cmp(a))return!1;try{var t=n.bufferToInt(this.v);this._chainId>0&&(t-=2*this._chainId+8),this._senderPubKey=n.ecrecover(e,t,this.r,this.s)}catch(e){return!1}return!!this._senderPubKey},e.prototype.sign=function(e){var t=this.hash(!1),r=n.ecsign(t,e);this._chainId>0&&(r.v+=2*this._chainId+8),Object.assign(this,r)},e.prototype.getDataFee=function(){for(var e=this.raw[5],t=new o(0),r=0;r0&&t.push(["gas limit is too low. Need at least "+this.getBaseFee()]),void 0===e||!1===e?0===t.length:t.join(" ")},e}();t.exports=s}).call(this,e("buffer").Buffer)},{buffer:84,"ethereum-common/params.json":137,"ethereumjs-util":141}],141:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("keccak"),o=e("secp256k1"),a=e("assert"),s=e("rlp"),u=e("bn.js"),c=e("create-hash"),f=e("safe-buffer").Buffer;Object.assign(r,e("ethjs-util")),r.MAX_INTEGER=new u("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16),r.TWO_POW256=new u("10000000000000000000000000000000000000000000000000000000000000000",16),r.KECCAK256_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",r.SHA3_NULL_S=r.KECCAK256_NULL_S,r.KECCAK256_NULL=f.from(r.KECCAK256_NULL_S,"hex"),r.SHA3_NULL=r.KECCAK256_NULL,r.KECCAK256_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",r.SHA3_RLP_ARRAY_S=r.KECCAK256_RLP_ARRAY_S,r.KECCAK256_RLP_ARRAY=f.from(r.KECCAK256_RLP_ARRAY_S,"hex"),r.SHA3_RLP_ARRAY=r.KECCAK256_RLP_ARRAY,r.KECCAK256_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",r.SHA3_RLP_S=r.KECCAK256_RLP_S,r.KECCAK256_RLP=f.from(r.KECCAK256_RLP_S,"hex"),r.SHA3_RLP=r.KECCAK256_RLP,r.BN=u,r.rlp=s,r.secp256k1=o,r.zeros=function(e){return f.allocUnsafe(e).fill(0)},r.zeroAddress=function(){var e=r.zeros(20);return r.bufferToHex(e)},r.setLengthLeft=r.setLength=function(e,t,n){var i=r.zeros(t);return e=r.toBuffer(e),n?e.length0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e},r.toBuffer=function(e){if(!f.isBuffer(e))if(Array.isArray(e))e=f.from(e);else if("string"==typeof e)e=r.isHexString(e)?f.from(r.padToEven(r.stripHexPrefix(e)),"hex"):f.from(e);else if("number"==typeof e)e=r.intToBuffer(e);else if(null==e)e=f.allocUnsafe(0);else if(u.isBN(e))e=e.toArrayLike(f);else{if(!e.toArray)throw new Error("invalid type");e=f.from(e.toArray())}return e},r.bufferToInt=function(e){return new u(r.toBuffer(e)).toNumber()},r.bufferToHex=function(e){return"0x"+(e=r.toBuffer(e)).toString("hex")},r.fromSigned=function(e){return new u(e).fromTwos(256)},r.toUnsigned=function(e){return f.from(e.toTwos(256).toArray())},r.keccak=function(e,t){return e=r.toBuffer(e),t||(t=256),i("keccak"+t).update(e).digest()},r.keccak256=function(e){return r.keccak(e)},r.sha3=r.keccak,r.sha256=function(e){return e=r.toBuffer(e),c("sha256").update(e).digest()},r.ripemd160=function(e,t){e=r.toBuffer(e);var n=c("rmd160").update(e).digest();return!0===t?r.setLength(n,32):n},r.rlphash=function(e){return r.keccak(s.encode(e))},r.isValidPrivate=function(e){return o.privateKeyVerify(e)},r.isValidPublic=function(e,t){return 64===e.length?o.publicKeyVerify(f.concat([f.from([4]),e])):!!t&&o.publicKeyVerify(e)},r.pubToAddress=r.publicToAddress=function(e,t){return e=r.toBuffer(e),t&&64!==e.length&&(e=o.publicKeyConvert(e,!1).slice(1)),a(64===e.length),r.keccak(e).slice(-20)};var h=r.privateToPublic=function(e){return e=r.toBuffer(e),o.publicKeyCreate(e,!1).slice(1)};r.importPublic=function(e){return 64!==(e=r.toBuffer(e)).length&&(e=o.publicKeyConvert(e,!1).slice(1)),e},r.ecsign=function(e,t){var r=o.sign(e,t),n={};return n.r=r.signature.slice(0,32),n.s=r.signature.slice(32,64),n.v=r.recovery+27,n},r.hashPersonalMessage=function(e){var t=r.toBuffer("Ethereum Signed Message:\n"+e.length.toString());return r.keccak(f.concat([t,e]))},r.ecrecover=function(e,t,n,i){var a=f.concat([r.setLength(n,32),r.setLength(i,32)],64),s=t-27;if(0!==s&&1!==s)throw new Error("Invalid signature v value");var u=o.recover(e,a,s);return o.publicKeyConvert(u,!1).slice(1)},r.toRpcSig=function(e,t,n){if(27!==e&&28!==e)throw new Error("Invalid recovery id");return r.bufferToHex(f.concat([r.setLengthLeft(t,32),r.setLengthLeft(n,32),r.toBuffer(e-27)]))},r.fromRpcSig=function(e){if(65!==(e=r.toBuffer(e)).length)throw new Error("Invalid signature length");var t=e[64];return t<27&&(t+=27),{v:t,r:e.slice(0,32),s:e.slice(32,64)}},r.privateToAddress=function(e){return r.publicToAddress(h(e))},r.isValidAddress=function(e){return/^0x[0-9a-fA-F]{40}$/.test(e)},r.isZeroAddress=function(e){return r.zeroAddress()===r.addHexPrefix(e)},r.toChecksumAddress=function(e){e=r.stripHexPrefix(e).toLowerCase();for(var t=r.keccak(e).toString("hex"),n="0x",i=0;i=8?n+=e[i].toUpperCase():n+=e[i];return n},r.isValidChecksumAddress=function(e){return r.isValidAddress(e)&&r.toChecksumAddress(e)===e},r.generateAddress=function(e,t){return e=r.toBuffer(e),t=(t=new u(t)).isZero()?null:f.from(t.toArray()),r.rlphash([e,t]).slice(-20)},r.isPrecompiled=function(e){var t=r.unpad(e);return 1===t.length&&t[0]>=1&&t[0]<=8},r.addHexPrefix=function(e){return"string"!=typeof e?e:r.isHexPrefixed(e)?e:"0x"+e},r.isValidSignature=function(e,t,r,n){var i=new u("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16),o=new u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16);return 32===t.length&&32===r.length&&((27===e||28===e)&&(t=new u(t),r=new u(r),!(t.isZero()||t.gt(o)||r.isZero()||r.gt(o))&&(!1!==n||1!==new u(r).cmp(i))))},r.baToJSON=function(e){if(f.isBuffer(e))return"0x"+e.toString("hex");if(e instanceof Array){for(var t=[],n=0;n=i.length,"The field "+t.name+" must not have more "+t.length+" bytes")):t.allowZero&&0===i.length||!t.length||a(t.length===i.length,"The field "+t.name+" must have byte length of "+t.length),e.raw[n]=i}e._fields.push(t.name),Object.defineProperty(e,t.name,{enumerable:!0,configurable:!0,get:i,set:o}),t.default&&(e[t.name]=t.default),t.alias&&Object.defineProperty(e,t.alias,{enumerable:!1,configurable:!0,set:o,get:i})}),i)if("string"==typeof i&&(i=f.from(r.stripHexPrefix(i),"hex")),f.isBuffer(i)&&(i=s.decode(i)),Array.isArray(i)){if(i.length>e._fields.length)throw new Error("wrong number of fields in data");i.forEach(function(t,n){e[e._fields[n]]=r.toBuffer(t)})}else{if("object"!==(void 0===i?"undefined":n(i)))throw new Error("invalid data");var o=Object.keys(i);t.forEach(function(t){-1!==o.indexOf(t.name)&&(e[t.name]=i[t.name]),-1!==o.indexOf(t.alias)&&(e[t.alias]=i[t.alias])})}}},{assert:19,"bn.js":53,"create-hash":91,"ethjs-util":155,keccak:195,rlp:289,"safe-buffer":290,secp256k1:295}],142:[function(e,t,r){arguments[4][128][0].apply(r,arguments)},{_process:257,dup:128}],143:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var a=e("./address"),s=e("./bignumber"),u=e("./bytes"),c=e("./utf8"),f=e("./properties"),h=o(e("./errors")),l=new RegExp(/^bytes([0-9]*)$/),d=new RegExp(/^(u?int)([0-9]*)$/),p=new RegExp(/^(.*)\[([0-9]*)\]$/);r.defaultCoerceFunc=function(e,t){var r=e.match(d);return r&&parseInt(r[2])<=48?t.toNumber():t};var b=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"),y=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function m(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}function v(e,t){function r(t){throw new Error('unexpected character "'+e[t]+'" at position '+t+' in "'+e+'"')}for(var n={type:"",name:"",state:{allowType:!0}},i=n,o=0;o1){var i=r[1].match(b);if(""!=i[1].trim()||""!=i[3].trim())throw new Error("unexpected tokens");L(i[2]).forEach(function(e){t.outputs.push(v(e))})}return t}(e.trim()));throw new Error("unknown signature")};var w=function(){return function(e,t,r,n,i){this.coerceFunc=e,this.name=t,this.type=r,this.localName=n,this.dynamic=i}}(),_=function(e){function t(t){var r=e.call(this,t.coerceFunc,t.name,t.type,void 0,t.dynamic)||this;return f.defineReadOnly(r,"coder",t),r}return i(t,e),t.prototype.encode=function(e){return this.coder.encode(e)},t.prototype.decode=function(e,t){return this.coder.decode(e,t)},t}(w),A=function(e){function t(t,r){return e.call(this,t,"null","",r,!1)||this}return i(t,e),t.prototype.encode=function(e){return u.arrayify([])},t.prototype.decode=function(e,t){if(t>e.length)throw new Error("invalid null");return{consumed:0,value:this.coerceFunc("null",void 0)}},t}(w),E=function(e){function t(t,r,n,i){var o=this,a=(n?"int":"uint")+8*r;return(o=e.call(this,t,a,a,i,!1)||this).size=r,o.signed=n,o}return i(t,e),t.prototype.encode=function(e){try{var t=s.bigNumberify(e);return t=t.toTwos(8*this.size).maskn(8*this.size),this.signed&&(t=t.fromTwos(8*this.size).toTwos(256)),u.padZeros(u.arrayify(t),32)}catch(t){h.throwError("invalid number value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:e})}return null},t.prototype.decode=function(e,t){e.length32)throw new Error;t.set(r)}catch(t){h.throwError("invalid "+this.name+" value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:t.value||e})}return t},t.prototype.decode=function(e,t){return e.length=0?n:"")+"]",s=-1===n||r.dynamic;return(o=e.call(this,t,"array",a,i,s)||this).coder=r,o.length=n,o}return i(t,e),t.prototype.encode=function(e){Array.isArray(e)||h.throwError("expected array value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:"array",value:e});var t=this.length,r=new Uint8Array(0);-1===t&&(t=e.length,r=x.encode(t)),h.checkArgumentCount(t,e.length,"in coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i256||i%8!=0)&&h.throwError("invalid "+r[1]+" bit length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new E(e,i/8,"int"===r[1],t.name);if(r=t.type.match(l))return(0===(i=parseInt(r[1]))||i>32)&&h.throwError("invalid bytes length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new S(e,i,t.name);if(r=t.type.match(p)){var i=parseInt(r[2]||"-1");return(t=f.jsonCopy(t)).type=r[1],new N(e,D(e,t),i,t.name)}return"tuple"===t.type.substring(0,5)?function(e,t,r){t||(t=[]);var n=[];return t.forEach(function(t){n.push(D(e,t))}),new R(e,n,r)}(e,t.components,t.name):""===t.type?new A(e,t.name):(h.throwError("invalid type",h.INVALID_ARGUMENT,{arg:"type",value:t.type}),null)}var F=function(){function e(t){h.checkNew(this,e),t||(t=r.defaultCoerceFunc),f.defineReadOnly(this,"coerceFunc",t)}return e.prototype.encode=function(e,t){e.length!==t.length&&h.throwError("types/values length mismatch",h.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):e,r.push(D(this.coerceFunc,t))},this),u.hexlify(new R(this.coerceFunc,r,"_").encode(t))},e.prototype.decode=function(e,t){var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):f.jsonCopy(e),r.push(D(this.coerceFunc,t))},this),new R(this.coerceFunc,r,"_").decode(u.arrayify(t),0).value},e}();r.AbiCoder=F,r.defaultAbiCoder=new F},{"./address":144,"./bignumber":145,"./bytes":146,"./errors":147,"./properties":149,"./utf8":152}],144:[function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var i=n(e("bn.js")),o=e("./bytes"),a=e("./keccak256"),s=e("./rlp"),u=e("./errors");function c(e){"string"==typeof e&&e.match(/^0x[0-9A-Fa-f]{40}$/)||u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=o.arrayify(a.keccak256(r));for(var i=0;i<40;i+=2)r[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(15&r[i>>1])>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}for(var f={},h=0;h<10;h++)f[String(h)]=String(h);for(h=0;h<26;h++)f[String.fromCharCode(65+h)]=String(10+h);var l,d=Math.floor((l=9007199254740991,Math.log10?Math.log10(l):Math.log(l)/Math.LN10));function p(e){e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00";var t="";for(e.split("").forEach(function(e){t+=f[e]});t.length>=d;){var r=t.substring(0,d);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function b(e){var t=null;if("string"!=typeof e&&u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e}),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=c(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&u.throwError("bad address checksum",u.INVALID_ARGUMENT,{arg:"address",value:e});else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==p(e)&&u.throwError("bad icap checksum",u.INVALID_ARGUMENT,{arg:"address",value:e}),t=new i.default.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=c("0x"+t)}else u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});return t}r.getAddress=b,r.getIcapAddress=function(e){for(var t=new i.default.BN(b(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+p("XE00"+t)+t},r.getContractAddress=function(e){if(!e.from)throw new Error("missing from address");var t=e.nonce;return b("0x"+a.keccak256(s.encode([b(e.from),o.stripZeros(o.hexlify(t))])).substring(26))}},{"./bytes":146,"./errors":147,"./keccak256":148,"./rlp":150,"bn.js":53}],145:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=o(e("bn.js")),u=e("./bytes"),c=e("./properties"),f=e("./types"),h=a(e("./errors")),l=new s.default.BN(-1);function d(e){var t=e.toString(16);return"-"===t[0]?t.length%2==0?"-0x0"+t.substring(1):"-0x"+t.substring(1):t.length%2==1?"0x0"+t:"0x"+t}function p(e){return m(e)._bn}function b(e){return new y(d(e))}var y=function(e){function t(r){var n=e.call(this)||this;if(h.checkNew(n,t),"string"==typeof r)u.isHexString(r)?("0x"==r&&(r="0x0"),c.defineReadOnly(n,"_hex",r)):"-"===r[0]&&u.isHexString(r.substring(1))?c.defineReadOnly(n,"_hex",r):r.match(/^-?[0-9]*$/)?(""==r&&(r="0"),c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))):h.throwError("invalid BigNumber string value",h.INVALID_ARGUMENT,{arg:"value",value:r});else if("number"==typeof r){parseInt(String(r))!==r&&h.throwError("underflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"underflow",value:r,outputValue:parseInt(String(r))});try{c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}}else r instanceof t?c.defineReadOnly(n,"_hex",r._hex):r.toHexString?c.defineReadOnly(n,"_hex",d(p(r.toHexString()))):u.isArrayish(r)?c.defineReadOnly(n,"_hex",d(new s.default.BN(u.hexlify(r).substring(2),16))):h.throwError("invalid BigNumber value",h.INVALID_ARGUMENT,{arg:"value",value:r});return n}return i(t,e),Object.defineProperty(t.prototype,"_bn",{get:function(){return"-"===this._hex[0]?new s.default.BN(this._hex.substring(3),16).mul(l):new s.default.BN(this._hex.substring(2),16)},enumerable:!0,configurable:!0}),t.prototype.fromTwos=function(e){return b(this._bn.fromTwos(e))},t.prototype.toTwos=function(e){return b(this._bn.toTwos(e))},t.prototype.add=function(e){return b(this._bn.add(p(e)))},t.prototype.sub=function(e){return b(this._bn.sub(p(e)))},t.prototype.div=function(e){return m(e).isZero()&&h.throwError("division by zero",h.NUMERIC_FAULT,{operation:"divide",fault:"division by zero"}),b(this._bn.div(p(e)))},t.prototype.mul=function(e){return b(this._bn.mul(p(e)))},t.prototype.mod=function(e){return b(this._bn.mod(p(e)))},t.prototype.pow=function(e){return b(this._bn.pow(p(e)))},t.prototype.maskn=function(e){return b(this._bn.maskn(e))},t.prototype.eq=function(e){return this._bn.eq(p(e))},t.prototype.lt=function(e){return this._bn.lt(p(e))},t.prototype.lte=function(e){return this._bn.lte(p(e))},t.prototype.gt=function(e){return this._bn.gt(p(e))},t.prototype.gte=function(e){return this._bn.gte(p(e))},t.prototype.isZero=function(){return this._bn.isZero()},t.prototype.toNumber=function(){try{return this._bn.toNumber()}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}return null},t.prototype.toString=function(){return this._bn.toString(10)},t.prototype.toHexString=function(){return this._hex},t}(f.BigNumber);function m(e){return e instanceof y?e:new y(e)}r.bigNumberify=m,r.ConstantNegativeOne=m(-1),r.ConstantZero=m(0),r.ConstantOne=m(1),r.ConstantTwo=m(2),r.ConstantWeiPerEther=m("1000000000000000000")},{"./bytes":146,"./errors":147,"./properties":149,"./types":151,"bn.js":53}],146:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./errors");function i(e){return!!e._bn}function o(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return new Uint8Array(Array.prototype.slice.apply(e,t))},e)}function a(e){if(!e||parseInt(String(e.length))!=e.length||"string"==typeof e)return!1;for(var t=0;t=256||parseInt(String(r))!=r)return!1}return!0}function s(e){if(null==e&&n.throwError("cannot convert null value to array",n.INVALID_ARGUMENT,{arg:"value",value:e}),i(e)&&(e=e.toHexString()),"string"==typeof e){var t=e.match(/^(0x)?[0-9a-fA-F]*$/);t||n.throwError("invalid hexidecimal string",n.INVALID_ARGUMENT,{arg:"value",value:e}),"0x"!==t[1]&&n.throwError("hex string must have 0x prefix",n.INVALID_ARGUMENT,{arg:"value",value:e}),(e=e.substring(2)).length%2&&(e="0"+e);for(var r=[],s=0;s>4]+f[15&u])}return"0x"+o.join("")}return n.throwError("invalid hexlify value",null,{arg:"value",value:e}),"never"}function l(e,t){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length<2*t+2;)e="0x0"+e.substring(2);return e}function d(e){var t,r=0,i="0x",o="0x";if((t=e)&&null!=t.r&&null!=t.s){null==e.v&&null==e.recoveryParam&&n.throwError("at least on of recoveryParam or v must be specified",n.INVALID_ARGUMENT,{argument:"signature",value:e}),i=l(e.r,32),o=l(e.s,32),"string"==typeof(r=e.v)&&(r=parseInt(r,16));var a=e.recoveryParam;null==a&&null!=e.v&&(a=1-r%2),r=27+a}else{var u=s(e);if(65!==u.length)throw new Error("invalid signature");i=h(u.slice(0,32)),o=h(u.slice(32,64)),27!==(r=u[64])&&28!==r&&(r=27+r%2)}return{r:i,s:o,recoveryParam:r-27,v:r}}r.hexlify=h,r.hexDataLength=function(e){return c(e)&&e.length%2==0?(e.length-2)/2:null},r.hexDataSlice=function(e,t,r){return c(e)||n.throwError("invalid hex data",n.INVALID_ARGUMENT,{arg:"value",value:e}),e.length%2!=0&&n.throwError("hex data length must be even",n.INVALID_ARGUMENT,{arg:"value",value:e}),t=2+2*t,null!=r?"0x"+e.substring(t,t+2*r):"0x"+e.substring(t)},r.hexStripZeros=function(e){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length>3&&"0x0"===e.substring(0,3);)e="0x"+e.substring(3);return e},r.hexZeroPad=l,r.splitSignature=d,r.joinSignature=function(e){return h(u([(e=d(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}},{"./errors":147}],147:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.MISSING_NEW="MISSING_NEW",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.NUMERIC_FAULT="NUMERIC_FAULT",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION";var n=!1,i=!1;function o(e,t,n){if(i)throw new Error("unknown error");t||(t=r.UNKNOWN_ERROR),n||(n={});var o=[];Object.keys(n).forEach(function(e){try{o.push(e+"="+JSON.stringify(n[e]))}catch(t){o.push(e+"="+JSON.stringify(n[e].toString()))}});var a=e;o.length&&(e+=" ("+o.join(", ")+")");var s=new Error(e);throw s.reason=a,s.code=t,Object.keys(n).forEach(function(e){s[e]=n[e]}),s}r.throwError=o,r.checkNew=function(e,t){e instanceof t||o("missing new",r.MISSING_NEW,{name:t.name})},r.checkArgumentCount=function(e,t,n){n||(n=""),et&&o("too many arguments"+n,r.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})},r.setCensorship=function(e,t){n&&o("error censorship permanent",r.UNSUPPORTED_OPERATION,{operation:"setCersorship"}),i=!!e,n=!!t}},{}],148:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("js-sha3"),i=e("./bytes");r.keccak256=function(e){return"0x"+n.keccak_256(i.arrayify(e))}},{"./bytes":146,"js-sha3":142}],149:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defineReadOnly=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})},r.defineFrozen=function(e,t,r){var n=JSON.stringify(r);Object.defineProperty(e,t,{enumerable:!0,get:function(){return JSON.parse(n)}})},r.resolveProperties=function(e){var t={},r=[];return Object.keys(e).forEach(function(n){var i=e[n];i instanceof Promise?r.push(i.then(function(e){return t[n]=e,null})):t[n]=i}),Promise.all(r).then(function(){return t})},r.shallowCopy=function(e){var t={};for(var r in e)t[r]=e[r];return t},r.jsonCopy=function(e){return JSON.parse(JSON.stringify(e))}},{}],150:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./bytes");function i(e){for(var t=[];e;)t.unshift(255&e),e>>=8;return t}function o(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function s(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(r=e[t]-247)>e.length)throw new Error("too short");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("to short");return a(e,t,t+1+r,r+i)}if(e[t]>=192){if(t+1+(i=e[t]-192)>e.length)throw new Error("invalid rlp data");return a(e,t,t+1,i)}if(e[t]>=184){var r;if(t+1+(r=e[t]-183)>e.length)throw new Error("invalid rlp data");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("invalid rlp data");return{consumed:1+r+i,result:n.hexlify(e.slice(t+1+r,t+1+r+i))}}if(e[t]>=128){var i;if(t+1+(i=e[t]-128)>e.length)throw new Error("invlaid rlp data");return{consumed:1+i,result:n.hexlify(e.slice(t+1,t+1+i))}}return{consumed:1,result:n.hexlify(e[t])}}r.encode=function(e){return n.hexlify(function e(t){if(Array.isArray(t)){var r=[];return t.forEach(function(t){r=r.concat(e(t))}),r.length<=55?(r.unshift(192+r.length),r):((o=i(r.length)).unshift(247+o.length),o.concat(r))}var o,a=Array.prototype.slice.call(n.arrayify(t));return 1===a.length&&a[0]<=127?a:a.length<=55?(a.unshift(128+a.length),a):((o=i(a.length)).unshift(183+o.length),o.concat(a))}(e))},r.decode=function(e){var t=n.arrayify(e),r=s(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}},{"./bytes":146}],151:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=function(){return function(){}}();r.BigNumber=n;var i=function(){return function(){}}();r.Indexed=i;var o=function(){return function(){}}();r.MinimalProvider=o;var a=function(){return function(){}}();r.Signer=a;var s=function(){return function(){}}();r.HDNode=s},{}],152:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,i=e("./bytes");!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(n=r.UnicodeNormalizationForm||(r.UnicodeNormalizationForm={})),r.toUtf8Bytes=function(e,t){void 0===t&&(t=n.current),t!=n.current&&(e=e.normalize(t));for(var r=[],o=0,a=0;a>6|192,r[o++]=63&s|128):55296==(64512&s)&&a+1>18|240,r[o++]=s>>12&63|128,r[o++]=s>>6&63|128,r[o++]=63&s|128):(r[o++]=s>>12|224,r[o++]=s>>6&63|128,r[o++]=63&s|128)}return i.arrayify(r)},r.toUtf8String=function(e){e=i.arrayify(e);for(var t="",r=0;r>7!=0){if(n>>6!=2){var o=null;if(n>>5==6)o=1;else if(n>>4==14)o=2;else if(n>>3==30)o=3;else if(n>>2==62)o=4;else{if(n>>1!=126)continue;o=5}if(r+o>e.length){for(;r>6==2;r++);if(r!=e.length)continue;return t}var a,s=n&(1<<8-o-1)-1;for(a=0;a>6!=2)break;s=s<<6|63&u}a==o?s<=65535?t+=String.fromCharCode(s):(s-=65536,t+=String.fromCharCode(55296+(s>>10&1023),56320+(1023&s))):r--}}else t+=String.fromCharCode(n)}return t}},{"./bytes":146}],153:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("number-to-bn"),o=new n(0),a=new n(-1),s={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",Gwei:"1000000000",shannon:"1000000000",nanoether:"1000000000",nano:"1000000000",szabo:"1000000000000",microether:"1000000000000",micro:"1000000000000",finney:"1000000000000000",milliether:"1000000000000000",milli:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"};function u(e){var t=e?e.toLowerCase():"ether",r=s[t];if("string"!=typeof r)throw new Error("[ethjs-unit] the unit provided "+e+" doesn't exists, please use the one of the following units "+JSON.stringify(s,null,2));return new n(r,10)}function c(e){if("string"==typeof e){if(!e.match(/^-?[0-9.]+$/))throw new Error("while converting number to string, invalid number value '"+e+"', should be a number matching (^-?[0-9.]+).");return e}if("number"==typeof e)return String(e);if("object"==typeof e&&e.toString&&(e.toTwos||e.dividedToIntegerBy))return e.toPrecision?String(e.toPrecision()):e.toString(10);throw new Error("while converting number to string, invalid number value '"+e+"' type "+typeof e+".")}t.exports={unitMap:s,numberToString:c,getValueOfUnit:u,fromWei:function(e,t,r){var n=i(e),c=n.lt(o),f=u(t),h=s[t].length-1||1,l=r||{};c&&(n=n.mul(a));for(var d=n.mod(f).toString(10);d.length2)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal points");var l=h[0],d=h[1];if(l||(l="0"),d||(d="0"),d.length>o)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal places");for(;d.length=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{}],155:[function(e,t,r){(function(r){"use strict";var n=e("is-hex-prefixed"),i=e("strip-hex-prefix");function o(e){var t=e;if("string"!=typeof t)throw new Error("[ethjs-util] while padding to even, value must be string, is currently "+typeof t+", while padToEven.");return t.length%2&&(t="0"+t),t}function a(e){return"0x"+e.toString(16)}t.exports={arrayContainsArray:function(e,t,r){if(!0!==Array.isArray(e))throw new Error("[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '"+typeof e+"'");if(!0!==Array.isArray(t))throw new Error("[ethjs-util] method arrayContainsArray requires input 'subset' to be an array got type '"+typeof t+"'");return t[Boolean(r)?"some":"every"](function(t){return e.indexOf(t)>=0})},intToBuffer:function(e){var t=a(e);return new r(o(t.slice(2)),"hex")},getBinarySize:function(e){if("string"!=typeof e)throw new Error("[ethjs-util] while getting binary size, method getBinarySize requires input 'str' to be type String, got '"+typeof e+"'.");return r.byteLength(e,"utf8")},isHexPrefixed:n,stripHexPrefix:i,padToEven:o,intToHex:a,fromAscii:function(e){for(var t="",r=0;r0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var r,n,a,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(r=this._events[e]).length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=a;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){n=s;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],158:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("md5.js");t.exports=function(e,t,r,o){if(n.isBuffer(e)||(e=n.from(e,"binary")),t&&(n.isBuffer(t)||(t=n.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var a=r/8,s=n.alloc(a),u=n.alloc(o||0),c=n.alloc(0);a>0||o>0;){var f=new i;f.update(c),f.update(e),t&&f.update(t),c=f.digest();var h=0;if(a>0){var l=s.length-a;h=Math.min(a,c.length),c.copy(s,l,0,h),a-=h}if(h0){var d=u.length-o,p=Math.min(o,c.length-h);c.copy(u,d,h,h+p),o-=p}}return c.fill(0),{key:s,iv:u}}},{"md5.js":231,"safe-buffer":290}],159:[function(e,t,r){"use strict";var n=e("is-callable"),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.exports=function(e,t,r){if(!n(t))throw new TypeError("iterator must be a function");var a;arguments.length>=3&&(a=r),"[object Array]"===i.call(e)?function(e,t,r){for(var n=0,i=e.length;n=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},i.prototype._update=function(e){throw new Error("_update is not implemented")},i.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();return void 0!==e&&(t=t.toString(e)),t},i.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=i}).call(this,e("buffer").Buffer)},{buffer:84,inherits:180,stream:311}],162:[function(e,t,r){var n=r;n.utils=e("./hash/utils"),n.common=e("./hash/common"),n.sha=e("./hash/sha"),n.ripemd=e("./hash/ripemd"),n.hmac=e("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":163,"./hash/hmac":164,"./hash/ripemd":165,"./hash/sha":166,"./hash/utils":173}],163:[function(e,t,r){"use strict";var n=e("./utils"),i=e("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},{"../utils":173}],173:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits");function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function s(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=i,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,a=255&i;o?r.push(o,a):r.push(a)}else for(n=0;n>>0}return a},r.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},r.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},r.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},r.sum64_lo=function(e,t,r,n){return t+n>>>0},r.sum64_4_hi=function(e,t,r,n,i,o,a,s){var u=0,c=t;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},r.sum64_5_hi=function(e,t,r,n,i,o,a,s,u,c){var f=0,h=t;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,n,i,o,a,s,u,c){return t+n+o+s+c>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:180,"minimalistic-assert":234}],174:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("minimalistic-crypto-utils"),o=e("minimalistic-assert");function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}t.exports=a,a.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},a.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length\\$%@ءؤة\"'^|~⦅⦆・ゥャ¢£¬¦¥₩│←↑→↓■○𐐨𐐩𐐪𐐫𐐬𐐭𐐮𐐯𐐰𐐱𐐲𐐳𐐴𐐵𐐶𐐷𐐸𐐹𐐺𐐻𐐼𐐽𐐾𐐿𐑀𐑁𐑂𐑃𐑄𐑅𐑆𐑇𐑈𐑉𐑊𐑋𐑌𐑍𐑎𐑏𐓘𐓙𐓚𐓛𐓜𐓝𐓞𐓟𐓠𐓡𐓢𐓣𐓤𐓥𐓦𐓧𐓨𐓩𐓪𐓫𐓬𐓭𐓮𐓯𐓰𐓱𐓲𐓳𐓴𐓵𐓶𐓷𐓸𐓹𐓺𐓻𐳀𐳁𐳂𐳃𐳄𐳅𐳆𐳇𐳈𐳉𐳊𐳋𐳌𐳍𐳎𐳏𐳐𐳑𐳒𐳓𐳔𐳕𐳖𐳗𐳘𐳙𐳚𐳛𐳜𐳝𐳞𐳟𐳠𐳡𐳢𐳣𐳤𐳥𐳦𐳧𐳨𐳩𐳪𐳫𐳬𐳭𐳮𐳯𐳰𐳱𐳲𑣀𑣁𑣂𑣃𑣄𑣅𑣆𑣇𑣈𑣉𑣊𑣋𑣌𑣍𑣎𑣏𑣐𑣑𑣒𑣓𑣔𑣕𑣖𑣗𑣘𑣙𑣚𑣛𑣜𑣝𑣞𑣟ıȷ∇∂𞤢𞤣𞤤𞤥𞤦𞤧𞤨𞤩𞤪𞤫𞤬𞤭𞤮𞤯𞤰𞤱𞤲𞤳𞤴𞤵𞤶𞤷𞤸𞤹𞤺𞤻𞤼𞤽𞤾𞤿𞥀𞥁𞥂𞥃ٮڡٯ字双多解交映無前後再新初終販声吹演投捕遊指禁空合満申割営配得可丽丸乁𠄢你侻倂偺備像㒞𠘺兔兤具𠔜㒹內𠕋冗冤仌冬𩇟刃㓟刻剆剷㔕包匆卉博即卽卿𠨬灰及叟𠭣叫叱吆咞吸呈周咢哶唐啓啣善喫喳嗂圖圗噑噴壮城埴堍型堲報墬𡓤売壷夆夢奢𡚨𡛪姬娛娧姘婦㛮嬈嬾𡧈寃寘寳𡬘寿将㞁屠峀岍𡷤嵃𡷦嵮嵫嵼巡巢㠯巽帨帽幩㡢𢆃㡼庰庳庶𪎒𢌱舁弢㣇𣊸𦇚形彫㣣徚忍志忹悁㤺㤜𢛔惇慈慌慺憲憤憯懞戛扝抱拔捐𢬌挽拼捨掃揤𢯱搢揅掩㨮摩摾撝摷㩬敬𣀊旣書晉㬙㬈㫤冒冕最暜肭䏙朡杞杓𣏃㭉柺枅桒𣑭梎栟椔楂榣槪檨𣚣櫛㰘次𣢧歔㱎歲殟殻𣪍𡴋𣫺汎𣲼沿泍汧洖派浩浸涅𣴞洴港湮㴳滇𣻑淹潮𣽞𣾎濆瀹瀛㶖灊災灷炭𠔥煅𤉣熜爨牐𤘈犀犕𤜵𤠔獺王㺬玥㺸瑇瑜璅瓊㼛甤𤰶甾𤲒𢆟瘐𤾡𤾸𥁄㿼䀈𥃳𥃲𥄙𥄳眞真瞋䁆䂖𥐝硎䃣𥘦𥚚𥛅秫䄯穊穏𥥼𥪧䈂𥮫篆築䈧𥲀糒䊠糨糣紀𥾆絣䌁緇縂繅䌴𦈨𦉇䍙𦋙罺𦌾羕翺𦓚𦔣聠𦖨聰𣍟䏕育脃䐋脾媵𦞧𦞵𣎓𣎜舄辞䑫芑芋芝劳花芳芽苦𦬼茝荣莭茣莽菧荓菊菌菜𦰶𦵫𦳕䔫蓱蓳蔖𧏊蕤𦼬䕝䕡𦾱𧃒䕫虐虧虩蚩蚈蜎蛢蜨蝫螆蟡蠁䗹衠𧙧裗裞䘵裺㒻𧢮𧥦䚾䛇誠𧲨貫賁贛起𧼯𠠄跋趼跰𠣞軔𨗒𨗭邔郱鄑𨜮鄛鈸鋗鋘鉼鏹鐕𨯺開䦕閷𨵷䧦雃嶲霣𩅅𩈚䩮䩶韠𩐊䪲𩒖頩𩖶飢䬳餩馧駂駾䯎𩬰鱀鳽䳎䳭鵧𪃎䳸𪄅𪈎𪊑䵖黾鼅鼏鼖𪘀",mapChar:function(r){return r>=196608?r>=917760&&r<=917999?18874368:0:e[t[r>>4]][15&r]}}},"function"==typeof define&&define.amd?define([],function(){return i()}):"object"==typeof r?t.exports=i():n.uts46_map=i()},{}],177:[function(e,t,r){var n,i;n=this,i=function(e,t){function r(r,n,i){for(var o=[],a=e.ucs2.decode(r),s=0;s>23,l=f>>21&3,d=f>>5&65535,p=31&f,b=t.mapStr.substr(d,p);if(0===l||n&&1&h)throw new Error("Illegal char "+c);1===l?o.push(b):2===l?o.push(i?b:c):3===l&&o.push(c)}return o.join("").normalize("NFC")}function n(t,n,o){void 0===o&&(o=!1);var a=r(t,o,n).split(".");return(a=a.map(function(t){return t.startsWith("xn--")?i(t=e.decode(t.substring(4)),o,!1):i(t,o,n),t})).join(".")}function i(e,n,i){if("-"===e[2]&&"-"===e[3])throw new Error("Failed to validate "+e);if(e.startsWith("-")||e.endsWith("-"))throw new Error("Failed to validate "+e);if(e.includes("."))throw new Error("Failed to validate "+e);if(r(e,n,i)!==e)throw new Error("Failed to validate "+e);var o=e.codePointAt(0);if(t.mapChar(o)&2<<23)throw new Error("Label contains illegal character: "+o)}return{toUnicode:function(e,t){return void 0===t&&(t={}),n(e,!1,"useStd3ASCII"in t&&t.useStd3ASCII)},toAscii:function(t,r){void 0===r&&(r={});var i,o=!("transitional"in r)||r.transitional,a="useStd3ASCII"in r&&r.useStd3ASCII,s="verifyDnsLength"in r&&r.verifyDnsLength,u=n(t,o,a).split(".").map(e.toASCII),c=u.join(".");if(s){if(c.length<1||c.length>253)throw new Error("DNS name has wrong length: "+c);for(i=0;i63)throw new Error("DNS label has wrong length: "+f)}}return c}}},"function"==typeof define&&define.amd?define(["punycode","./idna-map"],function(e,t){return i(e,t)}):"object"==typeof r?t.exports=i(e("punycode"),e("./idna-map")):n.uts46=i(n.punycode,n.idna_map)},{"./idna-map":176,punycode:265}],178:[function(e,t,r){r.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,f=-7,h=r?i-1:0,l=r?-1:1,d=e[t+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=s;f>0;o=256*o+e[t+h],h+=l,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+e[t+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=c}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var a,s,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(a++,u/=2),a+h>=f?(s=0,a=f):a+h>=1?(s=(t*u-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;e[r+d]=255&a,d+=p,a/=256,c-=8);e[r+d-p]|=128*b}},{}],179:[function(e,t,r){var n=[].indexOf;t.exports=function(e,t){if(n)return e.indexOf(t);for(var r=0;r-32e3)throw new Error("Invalid error code");if(!(this instanceof f))return new f(e);i.call(this,"Server error",e)};n(f,i),i.ParseError=o,i.InvalidRequest=a,i.MethodNotFound=s,i.InvalidParams=u,i.InternalError=c,i.ServerError=f,t.exports=i},{inherits:180}],191:[function(e,t,r){t.exports=function(e){var t=(e=e||{}).max||Number.MAX_SAFE_INTEGER,r=void 0!==e.start?e.start:Math.floor(Math.random()*t);return function(){return r%=t,r++}}},{}],192:[function(e,t,r){r.parse=e("./lib/parse"),r.stringify=e("./lib/stringify")},{"./lib/parse":193,"./lib/stringify":194}],193:[function(e,t,r){var n,i,o,a,s={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},u=function(e){throw{name:"SyntaxError",message:e,at:n,text:o}},c=function(e){return e&&e!==i&&u("Expected '"+e+"' instead of '"+i+"'"),i=o.charAt(n),n+=1,i},f=function(){var e,t="";for("-"===i&&(t="-",c("-"));i>="0"&&i<="9";)t+=i,c();if("."===i)for(t+=".";c()&&i>="0"&&i<="9";)t+=i;if("e"===i||"E"===i)for(t+=i,c(),"-"!==i&&"+"!==i||(t+=i,c());i>="0"&&i<="9";)t+=i,c();if(e=+t,isFinite(e))return e;u("Bad number")},h=function(){var e,t,r,n="";if('"'===i)for(;c();){if('"'===i)return c(),n;if("\\"===i)if(c(),"u"===i){for(r=0,t=0;t<4&&(e=parseInt(c(),16),isFinite(e));t+=1)r=16*r+e;n+=String.fromCharCode(r)}else{if("string"!=typeof s[i])break;n+=s[i]}else n+=i}u("Bad string")},l=function(){for(;i&&i<=" ";)c()};a=function(){switch(l(),i){case"{":return function(){var e,t={};if("{"===i){if(c("{"),l(),"}"===i)return c("}"),t;for(;i;){if(e=h(),l(),c(":"),Object.hasOwnProperty.call(t,e)&&u('Duplicate key "'+e+'"'),t[e]=a(),l(),"}"===i)return c("}"),t;c(","),l()}}u("Bad object")}();case"[":return function(){var e=[];if("["===i){if(c("["),l(),"]"===i)return c("]"),e;for(;i;){if(e.push(a()),l(),"]"===i)return c("]"),e;c(","),l()}}u("Bad array")}();case'"':return h();case"-":return f();default:return i>="0"&&i<="9"?f():function(){switch(i){case"t":return c("t"),c("r"),c("u"),c("e"),!0;case"f":return c("f"),c("a"),c("l"),c("s"),c("e"),!1;case"n":return c("n"),c("u"),c("l"),c("l"),null}u("Unexpected '"+i+"'")}()}},t.exports=function(e,t){var r;return o=e,n=0,i=" ",r=a(),l(),i&&u("Syntax error"),"function"==typeof t?function e(r,n){var i,o,a=r[n];if(a&&"object"==typeof a)for(i in a)Object.prototype.hasOwnProperty.call(a,i)&&(void 0!==(o=e(a,i))?a[i]=o:delete a[i]);return t.call(r,n,a)}({"":r},""):r}},{}],194:[function(e,t,r){var n,i,o,a=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,s={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function u(e){return a.lastIndex=0,a.test(e)?'"'+e.replace(a,function(e){var t=s[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}t.exports=function(e,t,r){var a;if(n="",i="","number"==typeof r)for(a=0;a>>31),p=l^(a<<1|o>>>31),b=e[0]^d,y=e[1]^p,m=e[10]^d,v=e[11]^p,g=e[20]^d,w=e[21]^p,_=e[30]^d,A=e[31]^p,E=e[40]^d,x=e[41]^p;d=r^(s<<1|u>>>31),p=i^(u<<1|s>>>31);var k=e[2]^d,S=e[3]^p,M=e[12]^d,I=e[13]^p,T=e[22]^d,U=e[23]^p,j=e[32]^d,B=e[33]^p,P=e[42]^d,C=e[43]^p;d=o^(c<<1|f>>>31),p=a^(f<<1|c>>>31);var N=e[4]^d,R=e[5]^p,L=e[14]^d,O=e[15]^p,D=e[24]^d,F=e[25]^p,q=e[34]^d,H=e[35]^p,z=e[44]^d,K=e[45]^p;d=s^(h<<1|l>>>31),p=u^(l<<1|h>>>31);var V=e[6]^d,G=e[7]^p,W=e[16]^d,Y=e[17]^p,X=e[26]^d,Z=e[27]^p,J=e[36]^d,$=e[37]^p,Q=e[46]^d,ee=e[47]^p;d=c^(r<<1|i>>>31),p=f^(i<<1|r>>>31);var te=e[8]^d,re=e[9]^p,ne=e[18]^d,ie=e[19]^p,oe=e[28]^d,ae=e[29]^p,se=e[38]^d,ue=e[39]^p,ce=e[48]^d,fe=e[49]^p,he=b,le=y,de=v<<4|m>>>28,pe=m<<4|v>>>28,be=g<<3|w>>>29,ye=w<<3|g>>>29,me=A<<9|_>>>23,ve=_<<9|A>>>23,ge=E<<18|x>>>14,we=x<<18|E>>>14,_e=k<<1|S>>>31,Ae=S<<1|k>>>31,Ee=I<<12|M>>>20,xe=M<<12|I>>>20,ke=T<<10|U>>>22,Se=U<<10|T>>>22,Me=B<<13|j>>>19,Ie=j<<13|B>>>19,Te=P<<2|C>>>30,Ue=C<<2|P>>>30,je=R<<30|N>>>2,Be=N<<30|R>>>2,Pe=L<<6|O>>>26,Ce=O<<6|L>>>26,Ne=F<<11|D>>>21,Re=D<<11|F>>>21,Le=q<<15|H>>>17,Oe=H<<15|q>>>17,De=K<<29|z>>>3,Fe=z<<29|K>>>3,qe=V<<28|G>>>4,He=G<<28|V>>>4,ze=Y<<23|W>>>9,Ke=W<<23|Y>>>9,Ve=X<<25|Z>>>7,Ge=Z<<25|X>>>7,We=J<<21|$>>>11,Ye=$<<21|J>>>11,Xe=ee<<24|Q>>>8,Ze=Q<<24|ee>>>8,Je=te<<27|re>>>5,$e=re<<27|te>>>5,Qe=ne<<20|ie>>>12,et=ie<<20|ne>>>12,tt=ae<<7|oe>>>25,rt=oe<<7|ae>>>25,nt=se<<8|ue>>>24,it=ue<<8|se>>>24,ot=ce<<14|fe>>>18,at=fe<<14|ce>>>18;e[0]=he^~Ee&Ne,e[1]=le^~xe&Re,e[10]=qe^~Qe&be,e[11]=He^~et&ye,e[20]=_e^~Pe&Ve,e[21]=Ae^~Ce&Ge,e[30]=Je^~de&ke,e[31]=$e^~pe&Se,e[40]=je^~ze&tt,e[41]=Be^~Ke&rt,e[2]=Ee^~Ne&We,e[3]=xe^~Re&Ye,e[12]=Qe^~be&Me,e[13]=et^~ye&Ie,e[22]=Pe^~Ve&nt,e[23]=Ce^~Ge&it,e[32]=de^~ke&Le,e[33]=pe^~Se&Oe,e[42]=ze^~tt&me,e[43]=Ke^~rt&ve,e[4]=Ne^~We&ot,e[5]=Re^~Ye&at,e[14]=be^~Me&De,e[15]=ye^~Ie&Fe,e[24]=Ve^~nt&ge,e[25]=Ge^~it&we,e[34]=ke^~Le&Xe,e[35]=Se^~Oe&Ze,e[44]=tt^~me&Te,e[45]=rt^~ve&Ue,e[6]=We^~ot&he,e[7]=Ye^~at&le,e[16]=Me^~De&qe,e[17]=Ie^~Fe&He,e[26]=nt^~ge&_e,e[27]=it^~we&Ae,e[36]=Le^~Xe&Je,e[37]=Oe^~Ze&$e,e[46]=me^~Te&je,e[47]=ve^~Ue&Be,e[8]=ot^~he&Ee,e[9]=at^~le&xe,e[18]=De^~qe&Qe,e[19]=Fe^~He&et,e[28]=ge^~_e&Pe,e[29]=we^~Ae&Ce,e[38]=Xe^~Je&de,e[39]=Ze^~$e&pe,e[48]=Te^~je&ze,e[49]=Ue^~Be&Ke,e[0]^=n[2*t],e[1]^=n[2*t+1]}}},{}],200:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("./keccak-state-unroll");function o(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}o.prototype.initialize=function(e,t){for(var r=0;r<50;++r)this.state[r]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},o.prototype.absorb=function(e){for(var t=0;t>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(i.p1600(this.state),this.count=0);return t},o.prototype.copy=function(e){for(var t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},t.exports=o},{"./keccak-state-unroll":199,"safe-buffer":290}],201:[function(e,t,r){var n=e("./_root").Symbol;t.exports=n},{"./_root":217}],202:[function(e,t,r){var n=e("./_baseTimes"),i=e("./isArguments"),o=e("./isArray"),a=e("./isBuffer"),s=e("./_isIndex"),u=e("./isTypedArray"),c=Object.prototype.hasOwnProperty;t.exports=function(e,t){var r=o(e),f=!r&&i(e),h=!r&&!f&&a(e),l=!r&&!f&&!h&&u(e),d=r||f||h||l,p=d?n(e.length,String):[],b=p.length;for(var y in e)!t&&!c.call(e,y)||d&&("length"==y||h&&("offset"==y||"parent"==y)||l&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||s(y,b))||p.push(y);return p}},{"./_baseTimes":207,"./_isIndex":211,"./isArguments":219,"./isArray":220,"./isBuffer":222,"./isTypedArray":227}],203:[function(e,t,r){var n=e("./_Symbol"),i=e("./_getRawTag"),o=e("./_objectToString"),a="[object Null]",s="[object Undefined]",u=n?n.toStringTag:void 0;t.exports=function(e){return null==e?void 0===e?s:a:u&&u in Object(e)?i(e):o(e)}},{"./_Symbol":201,"./_getRawTag":210,"./_objectToString":215}],204:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isObjectLike"),o="[object Arguments]";t.exports=function(e){return i(e)&&n(e)==o}},{"./_baseGetTag":203,"./isObjectLike":226}],205:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isLength"),o=e("./isObjectLike"),a={};a["[object Float32Array]"]=a["[object Float64Array]"]=a["[object Int8Array]"]=a["[object Int16Array]"]=a["[object Int32Array]"]=a["[object Uint8Array]"]=a["[object Uint8ClampedArray]"]=a["[object Uint16Array]"]=a["[object Uint32Array]"]=!0,a["[object Arguments]"]=a["[object Array]"]=a["[object ArrayBuffer]"]=a["[object Boolean]"]=a["[object DataView]"]=a["[object Date]"]=a["[object Error]"]=a["[object Function]"]=a["[object Map]"]=a["[object Number]"]=a["[object Object]"]=a["[object RegExp]"]=a["[object Set]"]=a["[object String]"]=a["[object WeakMap]"]=!1,t.exports=function(e){return o(e)&&i(e.length)&&!!a[n(e)]}},{"./_baseGetTag":203,"./isLength":224,"./isObjectLike":226}],206:[function(e,t,r){var n=e("./_isPrototype"),i=e("./_nativeKeys"),o=Object.prototype.hasOwnProperty;t.exports=function(e){if(!n(e))return i(e);var t=[];for(var r in Object(e))o.call(e,r)&&"constructor"!=r&&t.push(r);return t}},{"./_isPrototype":212,"./_nativeKeys":213}],207:[function(e,t,r){t.exports=function(e,t){for(var r=-1,n=Array(e);++r-1&&e%1==0&&e-1&&e%1==0&&e<=n}},{}],225:[function(e,t,r){t.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},{}],226:[function(e,t,r){t.exports=function(e){return null!=e&&"object"==typeof e}},{}],227:[function(e,t,r){var n=e("./_baseIsTypedArray"),i=e("./_baseUnary"),o=e("./_nodeUtil"),a=o&&o.isTypedArray,s=a?i(a):n;t.exports=s},{"./_baseIsTypedArray":205,"./_baseUnary":208,"./_nodeUtil":214}],228:[function(e,t,r){var n=e("./_arrayLikeKeys"),i=e("./_baseKeys"),o=e("./isArrayLike");t.exports=function(e){return o(e)?n(e):i(e)}},{"./_arrayLikeKeys":202,"./_baseKeys":206,"./isArrayLike":221}],229:[function(e,t,r){t.exports=function(){}},{}],230:[function(e,t,r){t.exports=function(){return!1}},{}],231:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base"),o=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function s(e,t){return e<>>32-t}function u(e,t,r,n,i,o,a){return s(e+(t&r|~t&n)+i+o|0,a)+t|0}function c(e,t,r,n,i,o,a){return s(e+(t&n|r&~n)+i+o|0,a)+t|0}function f(e,t,r,n,i,o,a){return s(e+(t^r^n)+i+o|0,a)+t|0}function h(e,t,r,n,i,o,a){return s(e+(r^(t|~n))+i+o|0,a)+t|0}n(a,i),a.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,a=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,a=u(a,r=u(r,n,i,a,e[0],3614090360,7),n,i,e[1],3905402710,12),r,n,e[2],606105819,17),a,r,e[3],3250441966,22),i=u(i,a=u(a,r=u(r,n,i,a,e[4],4118548399,7),n,i,e[5],1200080426,12),r,n,e[6],2821735955,17),a,r,e[7],4249261313,22),i=u(i,a=u(a,r=u(r,n,i,a,e[8],1770035416,7),n,i,e[9],2336552879,12),r,n,e[10],4294925233,17),a,r,e[11],2304563134,22),i=u(i,a=u(a,r=u(r,n,i,a,e[12],1804603682,7),n,i,e[13],4254626195,12),r,n,e[14],2792965006,17),a,r,e[15],1236535329,22),i=c(i,a=c(a,r=c(r,n,i,a,e[1],4129170786,5),n,i,e[6],3225465664,9),r,n,e[11],643717713,14),a,r,e[0],3921069994,20),i=c(i,a=c(a,r=c(r,n,i,a,e[5],3593408605,5),n,i,e[10],38016083,9),r,n,e[15],3634488961,14),a,r,e[4],3889429448,20),i=c(i,a=c(a,r=c(r,n,i,a,e[9],568446438,5),n,i,e[14],3275163606,9),r,n,e[3],4107603335,14),a,r,e[8],1163531501,20),i=c(i,a=c(a,r=c(r,n,i,a,e[13],2850285829,5),n,i,e[2],4243563512,9),r,n,e[7],1735328473,14),a,r,e[12],2368359562,20),i=f(i,a=f(a,r=f(r,n,i,a,e[5],4294588738,4),n,i,e[8],2272392833,11),r,n,e[11],1839030562,16),a,r,e[14],4259657740,23),i=f(i,a=f(a,r=f(r,n,i,a,e[1],2763975236,4),n,i,e[4],1272893353,11),r,n,e[7],4139469664,16),a,r,e[10],3200236656,23),i=f(i,a=f(a,r=f(r,n,i,a,e[13],681279174,4),n,i,e[0],3936430074,11),r,n,e[3],3572445317,16),a,r,e[6],76029189,23),i=f(i,a=f(a,r=f(r,n,i,a,e[9],3654602809,4),n,i,e[12],3873151461,11),r,n,e[15],530742520,16),a,r,e[2],3299628645,23),i=h(i,a=h(a,r=h(r,n,i,a,e[0],4096336452,6),n,i,e[7],1126891415,10),r,n,e[14],2878612391,15),a,r,e[5],4237533241,21),i=h(i,a=h(a,r=h(r,n,i,a,e[12],1700485571,6),n,i,e[3],2399980690,10),r,n,e[10],4293915773,15),a,r,e[1],2240044497,21),i=h(i,a=h(a,r=h(r,n,i,a,e[8],1873313359,6),n,i,e[15],4264355552,10),r,n,e[6],2734768916,15),a,r,e[13],1309151649,21),i=h(i,a=h(a,r=h(r,n,i,a,e[4],4149444226,6),n,i,e[11],3174756917,10),r,n,e[2],718787259,15),a,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+a|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=a}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":232,inherits:180}],232:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("stream").Transform;function o(e){i.call(this),this._block=n.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}e("inherits")(o,i),o.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},o.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},o.prototype.update=function(e,t){if(function(e,t){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");n.isBuffer(e)||(e=n.from(e,t));for(var r=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},{inherits:180,"safe-buffer":290,stream:311}],233:[function(e,t,r){var n=e("bn.js"),i=e("brorand");function o(e){this.rand=e||new i.Rand}t.exports=o,o.create=function(e){return new o(e)},o.prototype._randbelow=function(e){var t=e.bitLength(),r=Math.ceil(t/8);do{var i=new n(this.rand.generate(r))}while(i.cmp(e)>=0);return i},o.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},o.prototype.test=function(e,t,r){var i=e.bitLength(),o=n.mont(e),a=new n(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var s=e.subn(1),u=0;!s.testn(u);u++);for(var c=e.shrn(u),f=s.toRed(o);t>0;t--){var h=this._randrange(new n(2),s);r&&r(h);var l=h.toRed(o).redPow(c);if(0!==l.cmp(a)&&0!==l.cmp(f)){for(var d=1;d0;t--){var f=this._randrange(new n(2),a),h=e.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(u);if(0!==l.cmp(o)&&0!==l.cmp(c)){for(var d=1;d>8,a=255&i;o?r.push(o,a):r.push(a)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},{}],236:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],237:[function(e,t,r){var n=e("bn.js"),i=e("strip-hex-prefix");t.exports=function(e){if("string"==typeof e||"number"==typeof e){var t=new n(1),r=String(e).toLowerCase().trim(),o="0x"===r.substr(0,2)||"-0x"===r.substr(0,3),a=i(r);if("-"===a.substr(0,1)&&(a=i(a.slice(1)),t=new n(-1,10)),!(a=""===a?"0":a).match(/^-?[0-9]+$/)&&a.match(/^[0-9A-Fa-f]+$/)||a.match(/^[a-fA-F]+$/)||!0===o&&a.match(/^[0-9A-Fa-f]+$/))return new n(a,16).mul(t);if((a.match(/^-?[0-9]+$/)||""===a)&&!1===o)return new n(a,10).mul(t)}else if("object"==typeof e&&e.toString&&!e.pop&&!e.push&&e.toString(10).match(/^-?[0-9]+$/)&&(e.mul||e.dividedToIntegerBy))return new n(e.toString(10),10);throw new Error("[number-to-bn] while converting number "+JSON.stringify(e)+" to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.")}},{"bn.js":236,"strip-hex-prefix":318}],238:[function(e,t,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,a,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),u=1;u0;)if(q+=r,r=e.charAt(o++),4===H?(N+=String.fromCharCode(parseInt(q,16)),H=0,c=o-1):H++,!r)break e;if('"'===r&&!L){D=F.pop()||p,N+=e.substring(c,o-1);break}if(!("\\"!==r||L||(L=!0,N+=e.substring(c,o-1),r=e.charAt(o++))))break;if(L){if(L=!1,"n"===r?N+="\n":"r"===r?N+="\r":"t"===r?N+="\t":"f"===r?N+="\f":"b"===r?N+="\b":"u"===r?(H=1,q=""):N+=r,r=e.charAt(o++),c=o-1,r)continue;break}h.lastIndex=o;var l=h.exec(e);if(!l){o=e.length+1,N+=e.substring(c,o-1);break}if(o=l.index+1,!(r=e.charAt(l.index))){N+=e.substring(c,o-1);break}}continue;case A:if(!r)continue;if("r"!==r)return W("Invalid true started with t"+r);D=E;continue;case E:if(!r)continue;if("u"!==r)return W("Invalid true started with tr"+r);D=x;continue;case x:if(!r)continue;if("e"!==r)return W("Invalid true started with tru"+r);a(!0),u(),D=F.pop()||p;continue;case k:if(!r)continue;if("a"!==r)return W("Invalid false started with f"+r);D=S;continue;case S:if(!r)continue;if("l"!==r)return W("Invalid false started with fa"+r);D=M;continue;case M:if(!r)continue;if("s"!==r)return W("Invalid false started with fal"+r);D=I;continue;case I:if(!r)continue;if("e"!==r)return W("Invalid false started with fals"+r);a(!1),u(),D=F.pop()||p;continue;case T:if(!r)continue;if("u"!==r)return W("Invalid null started with n"+r);D=U;continue;case U:if(!r)continue;if("l"!==r)return W("Invalid null started with nu"+r);D=j;continue;case j:if(!r)continue;if("l"!==r)return W("Invalid null started with nul"+r);a(null),u(),D=F.pop()||p;continue;case B:if("."!==r)return W("Leading zero not followed by .");R+=r,D=P;continue;case P:if(-1!=="0123456789".indexOf(r))R+=r;else if("."===r){if(-1!==R.indexOf("."))return W("Invalid number has two dots");R+=r}else if("e"===r||"E"===r){if(-1!==R.indexOf("e")||-1!==R.indexOf("E"))return W("Invalid number has two exponential");R+=r}else if("+"===r||"-"===r){if("e"!==n&&"E"!==n)return W("Invalid symbol in number");R+=r}else R&&(a(parseFloat(R)),u(),R=""),o--,D=F.pop()||p;continue;default:return W("Unknown state: "+D)}K>=C&&(X=0,N!==s&&N.length>f&&(W("Max buffer length exceeded: textNode"),X=Math.max(X,N.length)),R.length>f&&(W("Max buffer length exceeded: numberNode"),X=Math.max(X,R.length)),C=f-X+K);var X}),e(ce).on(function(){if(D==d)return a({}),u(),void(O=!0);D===p&&0===z||W("Unexpected end");N!==s&&(a(N),u(),N=s);O=!0})}var C,N,R,L,O,D,F,q,H,z,K,V=(C=d(function(e){return e.unshift(/^/),(t=RegExp(e.map(f("source")).join(""))).exec.bind(t);var t}),L=C(N=/(\$?)/,/([\w-_]+|\*)/,R=/(?:{([\w ]*?)})?/),O=C(N,/\["([^"]+)"\]/,R),D=C(N,/\[(\d+|\*)\]/,R),F=C(N,/()/,/{([\w ]*?)}/),q=C(/\.\./),H=C(/\./),z=C(N,/!/),K=C(/$/),function(e){return e(h(L,O,D,F),q,H,z,K)});function G(e,t){return{key:e,node:t}}var W=f("key"),Y=f("node"),X={};function Z(e){var t=e(ee).emit,r=e(te).emit,n=e(ae).emit,o=e(oe).emit;function a(e,t,r){Y(x(e))[t]=r}function s(e,r,n){e&&a(e,r,n);var i=A(G(r,n),e);return t(i),i}var u={};return u[le]=function(e,t){if(!e)return n(t),s(e,X,t);var r=function(e,t){var r=Y(x(e));return m(i,r)?s(e,v(r),t):e}(e,t),o=k(r),u=W(x(r));return a(o,u,t),A(G(u,t),o)},u[de]=function(e){return r(e),k(e)||o(Y(x(e)))},u[he]=s,u}var J=V(function(e,t,r,n,i){var a=1,s=2,f=3,l=c(W,x),d=c(Y,x);function b(e,t){return!!t[a]?p(e,x):e}function m(e){if(e==y)return y;return p(function(e){return l(e)!=X},c(e,k))}function g(){return function(e){return l(e)==X}}function w(e,t,r,n,i){var o=e(r);if(o){var a=function(e,t,r){return U(function(e,t){return t(e,r)},t,e)}(t,n,o);return i(r.substr(v(o[0])),a)}}function A(e,t){return u(w,e,t)}var E=h(A(e,M(b,function(e,t){var r=t[f];return r?p(c(u(_,S(r.split(/\W+/))),d),e):e},function(e,t){var r=t[s];return p(r&&"*"!=r?function(e){return l(e)==r}:y,e)},m)),A(t,M(function(e){if(e==y)return y;var t=g(),r=e,n=m(function(e){return i(e)}),i=h(t,r,n);return i})),A(r,M()),A(n,M(b,g)),A(i,M(function(e){return function(t){var r=e(t);return!0===r?x(t):r}})),function(e){throw o('"'+e+'" could not be tokenised')});function I(e,t){return t}function T(e,t){return E(e,t,e?T:I)}return function(e){try{return T(e,y)}catch(t){throw o('Could not compile "'+e+'" because '+t.message)}}});function $(e,t,r){var n,i;function o(e){return function(t){return t.id==e}}return{on:function(r,o){var a={listener:r,id:o||r};return t&&t.emit(e,r,a.id),n=A(a,n),i=A(r,i),this},emit:function(){!function e(t,r){t&&(x(t).apply(null,r),e(k(t),r))}(i,arguments)},un:function(t){var a;n=j(n,o(t),function(e){a=e}),a&&(i=j(i,function(e){return e==a.listener}),r&&r.emit(e,a.listener,a.id))},listeners:function(){return i},hasListener:function(e){return w(function e(t,r){return r&&(t(x(r))?x(r):e(t,k(r)))}(e?o(e):y,n))}}}var Q=1,ee=Q++,te=Q++,re=Q++,ne=Q++,ie="fail",oe=Q++,ae=Q++,se="start",ue="data",ce="end",fe=Q++,he=Q++,le=Q++,de=Q++;function pe(e,t,r){try{var n=a.parse(t)}catch(e){}return{statusCode:e,body:t,jsonBody:n,thrown:r}}function be(e,t){var r={node:e(te),path:e(ee)};function n(t,r,n){var i=e(t).emit;r.on(function(e){var t=n(e);!1!==t&&function(e,t,r){var n=B(r);e(t,I(k(T(W,n))),I(T(Y,n)))}(i,Y(t),e)},t),e("removeListener").on(function(n){n==t&&(e(n).listeners()||r.un(t))})}e("newListener").on(function(e){var i=/(node|path):(.*)/.exec(e);if(i){var o=r[i[1]];o.hasListener(e)||n(e,o,t(i[2]))}})}function ye(e,t){var r,n=/^(node|path):./,i=e(oe),o=e(ne).emit,a=e(re).emit,s=d(function(t,i){if(r[t])l(i,r[t]);else{var o=e(t),a=i[0];n.test(t)?c(o,a):o.on(a)}return r});function c(e,t,n){n=n||t;var i=f(t);return e.on(function(){var t=!1;r.forget=function(){t=!0},l(arguments,i),delete r.forget,t&&e.un(n)},n),r}function f(e){return function(){try{return e.apply(r,arguments)}catch(e){setTimeout(function(){throw e})}}}function h(t,r,n){var i;i="node"==t?function(e){return function(){var t=e.apply(this,arguments);w(t)&&(t==ge.drop?o():a(t))}}(n):n,c(function(t,r){return e(t+":"+r)}(t,r),i,n)}function p(e,t,n){return g(t)?h(e,t,n):function(e,t){for(var r in t)h(e,r,t[r])}(e,t),r}return e(ae).on(function(e){var t;r.root=(t=e,function(){return t})}),e(se).on(function(e,t){r.header=function(e){return e?t[e]:t}}),r={on:s,addListener:s,removeListener:function(t,n,o){if("done"==t)i.un(n);else if("node"==t||"path"==t)e.un(t+":"+n,o);else{var a=n;e(t).un(a)}return r},emit:e.emit,node:u(p,"node"),path:u(p,"path"),done:u(c,i),start:u(function(t,n){return e(t).on(f(n),n),r},se),fail:e(ie).on,abort:e(fe).emit,header:b,root:b,source:t}}function me(t,r,n,i,o){var a=function(){var e={},t=n("newListener"),r=n("removeListener");function n(n){return e[n]=$(n,t,r)}function i(t){return e[t]||n(t)}return["emit","on","un"].forEach(function(e){i[e]=d(function(t,r){l(r,i(t)[e])})}),i}();return r&&function(t,r,n,i,o,a,c){"use strict";var f=t(ue).emit,h=t(ie).emit,l=0,d=!0;function p(){var e=r.responseText,t=e.substr(l);t&&f(t),l=v(e)}t(fe).on(function(){r.onreadystatechange=null,r.abort()}),"onprogress"in r&&(r.onprogress=p),r.onreadystatechange=function(){function e(){try{d&&t(se).emit(r.status,(e=r.getAllResponseHeaders(),n={},e&&e.split("\r\n").forEach(function(e){var t=e.indexOf(": ");n[e.substring(0,t)]=e.substring(t+2)}),n)),d=!1}catch(e){}var e,n}switch(r.readyState){case 2:case 3:return e();case 4:e(),2==String(r.status)[0]?(p(),t(ce).emit()):h(pe(r.status,r.responseText))}};try{for(var b in r.open(n,i,!0),a)r.setRequestHeader(b,a[b]);(function(e,t){function r(t){return t.port||{"http:":80,"https:":443}[t.protocol||e.protocol]}return!!(t.protocol&&t.protocol!=e.protocol||t.host&&t.host!=e.host||t.host&&r(t)!=r(e))})(e.location,function(e){var t=/(\w+:)?(?:\/\/)([\w.-]+)?(?::(\d+))?\/?/.exec(e)||[];return{protocol:t[1]||"",host:t[2]||"",port:t[3]||""}}(i))||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.withCredentials=c,r.send(o)}catch(t){e.setTimeout(u(h,pe(s,s,t)),0)}}(a,new XMLHttpRequest,t,r,n,i,o),P(a),function(e,t){"use strict";var r,n={};function i(e){return function(t){r=e(r,t)}}for(var o in t)e(o).on(i(t[o]),n);e(re).on(function(e){var t=x(r),n=W(t),i=k(r);i&&(Y(x(i))[n]=e)}),e(ne).on(function(){var e=x(r),t=W(e),n=k(r);n&&delete Y(x(n))[t]}),e(fe).on(function(){for(var r in t)e(r).un(n)})}(a,Z(a)),be(a,J),ye(a,r)}function ve(e,t,r,n,i,o,s){return i=i?a.parse(a.stringify(i)):{},n?g(n)||(n=a.stringify(n),i["Content-Type"]=i["Content-Type"]||"application/json"):n=null,e(r||"GET",function(e,t){return!1===t&&(-1==e.indexOf("?")?e+="?":e+="&",e+="_="+(new Date).getTime()),e}(t,s),n,i,o||!1)}function ge(e){var t=M("resume","pause","pipe"),r=u(_,t);return e?r(e)||g(e)?ve(me,e):ve(me,e.url,e.method,e.body,e.headers,e.withCredentials,e.cached):me()}ge.drop=function(){return ge.drop},"function"==typeof define&&define.amd?define("oboe",[],function(){return ge}):"object"==typeof r?t.exports=ge:e.oboe=ge}(function(){try{return window}catch(e){return self}}(),Object,Array,Error,JSON)},{}],240:[function(e,t,r){r.endianness=function(){return"LE"},r.hostname=function(){return"undefined"!=typeof location?location.hostname:""},r.loadavg=function(){return[]},r.uptime=function(){return 0},r.freemem=function(){return Number.MAX_VALUE},r.totalmem=function(){return Number.MAX_VALUE},r.cpus=function(){return[]},r.type=function(){return"Browser"},r.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},r.networkInterfaces=r.getNetworkInterfaces=function(){return{}},r.arch=function(){return"javascript"},r.platform=function(){return"browser"},r.tmpdir=r.tmpDir=function(){return"/tmp"},r.EOL="\n",r.homedir=function(){return"/"}},{}],241:[function(e,t,r){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],242:[function(e,t,r){"use strict";var n=e("asn1.js");r.certificate=e("./certificate");var i=n.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});r.RSAPrivateKey=i;var o=n.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});r.RSAPublicKey=o;var a=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())});r.PublicKey=a;var s=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),u=n.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(s),this.key("subjectPrivateKey").octstr())});r.PrivateKey=u;var c=n.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});r.EncryptedPrivateKey=c;var f=n.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});r.DSAPrivateKey=f,r.DSAparam=n.define("DSAparam",function(){this.int()});var h=n.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(l),this.key("publicKey").optional().explicit(1).bitstr())});r.ECPrivateKey=h;var l=n.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});r.signature=n.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},{"./certificate":243,"asn1.js":5}],243:[function(e,t,r){"use strict";var n=e("asn1.js"),i=n.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),o=n.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),a=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional())}),s=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())}),u=n.define("RelativeDistinguishedName",function(){this.setof(o)}),c=n.define("RDNSequence",function(){this.seqof(u)}),f=n.define("Name",function(){this.choice({rdnSequence:this.use(c)})}),h=n.define("Validity",function(){this.seq().obj(this.key("notBefore").use(i),this.key("notAfter").use(i))}),l=n.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),d=n.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int(),this.key("serialNumber").int(),this.key("signature").use(a),this.key("issuer").use(f),this.key("validity").use(h),this.key("subject").use(f),this.key("subjectPublicKeyInfo").use(s),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(l).optional())}),p=n.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(a),this.key("signatureValue").bitstr())});t.exports=p},{"asn1.js":5}],244:[function(e,t,r){(function(r){var n=/Proc-Type: 4,ENCRYPTED\n\r?DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\n\r?\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?/m,i=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n/m,o=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?-----END \1-----$/m,a=e("evp_bytestokey"),s=e("browserify-aes");t.exports=function(e,t){var u,c=e.toString(),f=c.match(n);if(f){var h="aes"+f[1],l=new r(f[2],"hex"),d=new r(f[3].replace(/\r?\n/g,""),"base64"),p=a(t,l.slice(0,8),parseInt(f[1],10)).key,b=[],y=s.createDecipheriv(h,p,l);b.push(y.update(d)),b.push(y.final()),u=r.concat(b)}else{var m=c.match(o);u=new r(m[2].replace(/\r?\n/g,""),"base64")}return{tag:c.match(i)[1],data:u}}}).call(this,e("buffer").Buffer)},{"browserify-aes":58,buffer:84,evp_bytestokey:158}],245:[function(e,t,r){(function(r){var n=e("./asn1"),i=e("./aesid.json"),o=e("./fixProc"),a=e("browserify-aes"),s=e("pbkdf2");function u(e){var t;"object"!=typeof e||r.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=new r(e));var u,c,f=o(e,t),h=f.tag,l=f.data;switch(h){case"CERTIFICATE":c=n.certificate.decode(l,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(c||(c=n.PublicKey.decode(l,"der")),u=c.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPublicKey.decode(c.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return c.subjectPrivateKey=c.subjectPublicKey,{type:"ec",data:c};case"1.2.840.10040.4.1":return c.algorithm.params.pub_key=n.DSAparam.decode(c.subjectPublicKey.data,"der"),{type:"dsa",data:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"ENCRYPTED PRIVATE KEY":l=function(e,t){var n=e.algorithm.decrypt.kde.kdeparams.salt,o=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),u=i[e.algorithm.decrypt.cipher.algo.join(".")],c=e.algorithm.decrypt.cipher.iv,f=e.subjectPrivateKey,h=parseInt(u.split("-")[1],10)/8,l=s.pbkdf2Sync(t,n,o,h),d=a.createDecipheriv(u,l,c),p=[];return p.push(d.update(f)),p.push(d.final()),r.concat(p)}(l=n.EncryptedPrivateKey.decode(l,"der"),t);case"PRIVATE KEY":switch(u=(c=n.PrivateKey.decode(l,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPrivateKey.decode(c.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:c.algorithm.curve,privateKey:n.ECPrivateKey.decode(c.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return c.algorithm.params.priv_key=n.DSAparam.decode(c.subjectPrivateKey,"der"),{type:"dsa",params:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"RSA PUBLIC KEY":return n.RSAPublicKey.decode(l,"der");case"RSA PRIVATE KEY":return n.RSAPrivateKey.decode(l,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:n.DSAPrivateKey.decode(l,"der")};case"EC PRIVATE KEY":return{curve:(l=n.ECPrivateKey.decode(l,"der")).parameters.value,privateKey:l.privateKey};default:throw new Error("unknown key type "+h)}}t.exports=u,u.signature=n.signature}).call(this,e("buffer").Buffer)},{"./aesid.json":241,"./asn1":242,"./fixProc":244,"browserify-aes":58,buffer:84,pbkdf2:247}],246:[function(e,t,r){var n=e("trim"),i=e("for-each");t.exports=function(e){if(!e)return{};var t={};return i(n(e).split("\n"),function(e){var r,i=e.indexOf(":"),o=n(e.slice(0,i)).toLowerCase(),a=n(e.slice(i+1));void 0===t[o]?t[o]=a:(r=t[o],"[object Array]"===Object.prototype.toString.call(r)?t[o].push(a):t[o]=[t[o],a])}),t}},{"for-each":159,trim:324}],247:[function(e,t,r){r.pbkdf2=e("./lib/async"),r.pbkdf2Sync=e("./lib/sync")},{"./lib/async":248,"./lib/sync":251}],248:[function(e,t,r){(function(r,n){var i,o=e("./precondition"),a=e("./default-encoding"),s=e("./sync"),u=e("safe-buffer").Buffer,c=n.crypto&&n.crypto.subtle,f={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},h=[];function l(e,t,r,n,i){return c.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then(function(e){return c.deriveBits({name:"PBKDF2",salt:t,iterations:r,hash:{name:i}},e,n<<3)}).then(function(e){return u.from(e)})}t.exports=function(e,t,d,p,b,y){if(u.isBuffer(e)||(e=u.from(e,a)),u.isBuffer(t)||(t=u.from(t,a)),o(d,p),"function"==typeof b&&(y=b,b=void 0),"function"!=typeof y)throw new Error("No callback provided to pbkdf2");var m=f[(b=b||"sha1").toLowerCase()];if(!m||"function"!=typeof n.Promise)return r.nextTick(function(){var r;try{r=s(e,t,d,p,b)}catch(e){return y(e)}y(null,r)});!function(e,t){e.then(function(e){r.nextTick(function(){t(null,e)})},function(e){r.nextTick(function(){t(e)})})}(function(e){if(n.process&&!n.process.browser)return Promise.resolve(!1);if(!c||!c.importKey||!c.deriveBits)return Promise.resolve(!1);if(void 0!==h[e])return h[e];var t=l(i=i||u.alloc(8),i,10,128,e).then(function(){return!0}).catch(function(){return!1});return h[e]=t,t}(m).then(function(r){return r?l(e,t,d,p,m):s(e,t,d,p,b)}),y)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-encoding":249,"./precondition":250,"./sync":251,_process:257,"safe-buffer":290}],249:[function(e,t,r){(function(e){var r;e.browser?r="utf-8":r=parseInt(e.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary";t.exports=r}).call(this,e("_process"))},{_process:257}],250:[function(e,t,r){var n=Math.pow(2,30)-1;t.exports=function(e,t){if("number"!=typeof e)throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if("number"!=typeof t)throw new TypeError("Key length not a number");if(t<0||t>n||t!=t)throw new TypeError("Bad key length")}},{}],251:[function(e,t,r){var n=e("create-hash/md5"),i=e("ripemd160"),o=e("sha.js"),a=e("./precondition"),s=e("./default-encoding"),u=e("safe-buffer").Buffer,c=u.alloc(128),f={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function h(e,t,r){var a=function(e){return"rmd160"===e||"ripemd160"===e?i:"md5"===e?n:function(t){return o(e).update(t).digest()}}(e),s="sha512"===e||"sha384"===e?128:64;t.length>s?t=a(t):t.length1)for(var r=1;rp||new a(t).cmp(d.modulus)>=0)throw new Error("decryption error");l=f?c(new a(t),d):s(t,d);var b=new r(p-l.length);if(b.fill(0),l=r.concat([b,l],p),4===h)return function(e,t){e.modulus;var n=e.modulus.byteLength(),a=(t.length,u("sha1").update(new r("")).digest()),s=a.length;if(0!==t[0])throw new Error("decryption error");var c=t.slice(1,s+1),f=t.slice(s+1),h=o(c,i(f,s)),l=o(f,i(h,n-s-1));if(function(e,t){e=new r(e),t=new r(t);var n=0,i=e.length;e.length!==t.length&&(n++,i=Math.min(e.length,t.length));var o=-1;for(;++o=t.length){o++;break}var a=t.slice(2,i-1);t.slice(i-1,i);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;a.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,l,f);if(3===h)return l;throw new Error("unknown padding")}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245}],262:[function(e,t,r){(function(r){var n=e("parse-asn1"),i=e("randombytes"),o=e("create-hash"),a=e("./mgf"),s=e("./xor"),u=e("bn.js"),c=e("./withPublic"),f=e("browserify-rsa");t.exports=function(e,t,h){var l;l=e.padding?e.padding:h?1:4;var d,p=n(e);if(4===l)d=function(e,t){var n=e.modulus.byteLength(),c=t.length,f=o("sha1").update(new r("")).digest(),h=f.length,l=2*h;if(c>n-l-2)throw new Error("message too long");var d=new r(n-c-l-2);d.fill(0);var p=n-h-1,b=i(h),y=s(r.concat([f,d,new r([1]),t],p),a(b,p)),m=s(b,a(y,h));return new u(r.concat([new r([0]),m,y],n))}(p,t);else if(1===l)d=function(e,t,n){var o,a=t.length,s=e.modulus.byteLength();if(a>s-11)throw new Error("message too long");n?(o=new r(s-a-3)).fill(255):o=function(e,t){var n,o=new r(e),a=0,s=i(2*e),u=0;for(;a=0)throw new Error("data too long for modulus")}return h?f(d,p):c(d,p)}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245,randombytes:270}],263:[function(e,t,r){(function(r){var n=e("bn.js");t.exports=function(e,t){return new r(e.toRed(n.mont(t.modulus)).redPow(new n(t.publicExponent)).fromRed().toArray())}}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84}],264:[function(e,t,r){t.exports=function(e,t){for(var r=e.length,n=-1;++n= 0x80 (not a basic code point)","invalid-input":"Invalid input"},A=f-h,E=Math.floor,x=String.fromCharCode;function k(e){throw new RangeError(_[e])}function S(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function M(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+S((e=e.replace(w,".")).split("."),t).join(".")}function I(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=x((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=x(e)}).join("")}function U(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function j(e,t,r){var n=0;for(e=r?E(e/p):e>>1,e+=E(e/t);e>A*l>>1;n+=f)e=E(e/A);return E(n+(A+1)*e/(e+d))}function B(e){var t,r,n,i,o,a,s,u,d,p,v,g=[],w=e.length,_=0,A=y,x=b;for((r=e.lastIndexOf(m))<0&&(r=0),n=0;n=128&&k("not-basic"),g.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=w&&k("invalid-input"),((u=(v=e.charCodeAt(i++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:f)>=f||u>E((c-_)/a))&&k("overflow"),_+=u*a,!(u<(d=s<=x?h:s>=x+l?l:s-x));s+=f)a>E(c/(p=f-d))&&k("overflow"),a*=p;x=j(_-o,t=g.length+1,0==o),E(_/t)>c-A&&k("overflow"),A+=E(_/t),_%=t,g.splice(_++,0,A)}return T(g)}function P(e){var t,r,n,i,o,a,s,u,d,p,v,g,w,_,A,S=[];for(g=(e=I(e)).length,t=y,r=0,o=b,a=0;a=t&&vE((c-r)/(w=n+1))&&k("overflow"),r+=(s-t)*w,t=s,a=0;ac&&k("overflow"),v==t){for(u=r,d=f;!(u<(p=d<=o?h:d>=o+l?l:d-o));d+=f)A=u-p,_=f-p,S.push(x(U(p+A%_,0))),u=E(A/_);S.push(x(U(u,0))),o=j(r,w,n==i),r=0,++n}++r,++t}return S.join("")}if(s={version:"1.4.1",ucs2:{decode:I,encode:T},decode:B,encode:P,toASCII:function(e){return M(e,function(e){return g.test(e)?"xn--"+P(e):e})},toUnicode:function(e){return M(e,function(e){return v.test(e)?B(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return s});else if(i&&o)if(t.exports==i)o.exports=s;else for(u in s)s.hasOwnProperty(u)&&(i[u]=s[u]);else n.punycode=s}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],266:[function(e,t,r){"use strict";var n=e("strict-uri-encode"),i=e("object-assign"),o=e("decode-uri-component");function a(e,t){return t.encode?t.strict?n(e):encodeURIComponent(e):e}function s(e){var t=e.indexOf("?");return-1===t?"":e.slice(t+1)}function u(e,t){var r=function(e){var t;switch(e.arrayFormat){case"index":return function(e,r,n){t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return function(e,r,n){t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};default:return function(e,t,r){void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t=i({arrayFormat:"none"},t)),n=Object.create(null);return"string"!=typeof e?n:(e=e.trim().replace(/^[?#&]/,""))?(e.split("&").forEach(function(e){var t=e.replace(/\+/g," ").split("="),i=t.shift(),a=t.length>0?t.join("="):void 0;a=void 0===a?null:o(a),r(o(i),a,n)}),Object.keys(n).sort().reduce(function(e,t){var r=n[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=function e(t){return Array.isArray(t)?t.sort():"object"==typeof t?e(Object.keys(t)).sort(function(e,t){return Number(e)-Number(t)}).map(function(e){return t[e]}):t}(r):e[t]=r,e},Object.create(null))):n}r.extract=s,r.parse=u,r.stringify=function(e,t){!1===(t=i({encode:!0,strict:!0,arrayFormat:"none"},t)).sort&&(t.sort=function(){});var r=function(e){switch(e.arrayFormat){case"index":return function(t,r,n){return null===r?[a(t,e),"[",n,"]"].join(""):[a(t,e),"[",a(n,e),"]=",a(r,e)].join("")};case"bracket":return function(t,r){return null===r?a(t,e):[a(t,e),"[]=",a(r,e)].join("")};default:return function(t,r){return null===r?a(t,e):[a(t,e),"=",a(r,e)].join("")}}}(t);return e?Object.keys(e).sort(t.sort).map(function(n){var i=e[n];if(void 0===i)return"";if(null===i)return a(n,t);if(Array.isArray(i)){var o=[];return i.slice().forEach(function(e){void 0!==e&&o.push(r(n,e,o.length))}),o.join("&")}return a(n,t)+"="+a(i,t)}).filter(function(e){return e.length>0}).join("&"):""},r.parseUrl=function(e,t){return{url:e.split("?")[0]||"",query:u(s(e),t)}}},{"decode-uri-component":98,"object-assign":238,"strict-uri-encode":316}],267:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&",r=r||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(a,d)?i(a[d])?a[d].push(p):a[d]=[a[d],p]:a[d]=p}return a};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],268:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,s){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),function(a){var s=encodeURIComponent(n(a))+r;return i(e[a])?o(e[a],function(e){return s+encodeURIComponent(n(e))}).join(t):s+encodeURIComponent(n(e[a]))}).join(t):s?encodeURIComponent(n(s))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n65536)throw new Error("requested too many random bytes");var a=new n.Uint8Array(e);e>0&&o.getRandomValues(a);var s=i.from(a.buffer);if("function"==typeof t)return r.nextTick(function(){t(null,s)});return s}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,"safe-buffer":290}],271:[function(e,t,r){(function(t,n){"use strict";function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=e("safe-buffer"),a=e("randombytes"),s=o.Buffer,u=o.kMaxLength,c=n.crypto||n.msCrypto,f=Math.pow(2,32)-1;function h(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>f||e<0)throw new TypeError("offset must be a uint32");if(e>u||e>t)throw new RangeError("offset out of range")}function l(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>f||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>u)throw new RangeError("buffer too small")}function d(e,r,n,i){if(t.browser){var o=e.buffer,s=new Uint8Array(o,r,n);return c.getRandomValues(s),i?void t.nextTick(function(){i(null,e)}):e}if(!i)return a(n).copy(e,r),e;a(n,function(t,n){if(t)return i(t);n.copy(e,r),i(null,e)})}c&&c.getRandomValues||!t.browser?(r.randomFill=function(e,t,r,i){if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)i=t,t=0,r=e.length;else if("function"==typeof r)i=r,r=e.length-t;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return h(t,e.length),l(r,t,e.length),d(e,t,r,i)},r.randomFillSync=function(e,t,r){void 0===t&&(t=0);if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');h(t,e.length),void 0===r&&(r=e.length-t);return l(r,t,e.length),d(e,t,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,randombytes:270,"safe-buffer":290}],272:[function(e,t,r){t.exports=window.crypto},{}],273:[function(e,t,r){t.exports=e("crypto")},{crypto:272}],274:[function(e,t,r){t.exports=function(t,r){var n=e("./crypto.js"),i="function"==typeof r;if(t>65536){if(!i)throw new Error("Requested too many random bytes.");r(new Error("Requested too many random bytes."))}if(void 0!==n&&n.randomBytes){if(!i)return"0x"+n.randomBytes(t).toString("hex");n.randomBytes(t,function(e,t){e?r(u):r(null,"0x"+t.toString("hex"))})}else{var o;if(void 0!==n?o=n:"undefined"!=typeof msCrypto&&(o=msCrypto),o&&o.getRandomValues){var a=o.getRandomValues(new Uint8Array(t)),s="0x"+Array.from(a).map(function(e){return e.toString(16)}).join("");if(!i)return s;r(null,s)}else{var u=new Error('No "crypto" object available. This Browser doesn\'t support generating secure random bytes.');if(!i)throw u;r(u)}}}},{"./crypto.js":273}],275:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":276}],276:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick,i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=h;var o=e("core-util-is");o.inherits=e("inherits");var a=e("./_stream_readable"),s=e("./_stream_writable");o.inherits(h,a);for(var u=i(s.prototype),c=0;c0?("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),n?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):_(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?_(e,a,t,!1):S(e,a)):_(e,a,t,!1))):n||(a.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=A?e=A:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(d("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i(k,e):k(e))}function k(e){d("emit readable"),e.emit("readable"),U(e)}function S(e,t){t.readingMore||(t.readingMore=!0,i(M,e,t))}function M(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=c.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,a),0===(e-=a)){a===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function B(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i(P,t,e))}function P(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function C(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return d("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?B(this):x(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&B(this),null;var n,i=t.needReadable;return d("need readable",i),(0===t.length||t.length-e0?j(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&B(this)),null!==n&&this.emit("data",n),n},g.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},g.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,d("pipe count=%d opts=%j",o.pipesCount,t);var u=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?f:g;function c(t,r){d("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,d("cleanup"),e.removeListener("close",m),e.removeListener("finish",v),e.removeListener("drain",h),e.removeListener("error",y),e.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",g),n.removeListener("data",b),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||h())}function f(){d("onend"),e.end()}o.endEmitted?i(u):n.once("end",u),e.on("unpipe",c);var h=function(e){return function(){var t=e._readableState;d("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,U(e))}}(n);e.on("drain",h);var l=!1;var p=!1;function b(t){d("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==C(o.pipes,e))&&!l&&(d("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(t){d("onerror",t),g(),e.removeListener("error",y),0===s(e,"error")&&e.emit("error",t)}function m(){e.removeListener("finish",v),g()}function v(){d("onfinish"),e.removeListener("close",m),g()}function g(){d("unpipe"),n.unpipe(e)}return n.on("data",b),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?a(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",y),e.once("close",m),e.once("finish",v),e.emit("pipe",n),o.flowing||(d("pipe resume"),n.resume()),e},g.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:i;m.WritableState=y;var u=e("core-util-is");u.inherits=e("inherits");var c={deprecate:e("util-deprecate")},f=e("./internal/streams/stream"),h=e("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=e("./internal/streams/destroy");function b(){}function y(t,r){a=a||e("./_stream_duplex"),t=t||{};var n=r instanceof a;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var u=t.highWaterMark,c=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=u||0===u?u:n&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===t.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,o=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,o){--t.pendingcb,r?(i(o,n),i(E,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(o(n),e._writableState.errorEmitted=!0,e.emit("error",n),E(e,t))}(e,r,n,t,o);else{var a=_(r);a||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),n?s(g,e,r,a,o):g(e,r,a,o)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function m(t){if(a=a||e("./_stream_duplex"),!(d.call(m,this)||this instanceof a))return new m(t);this._writableState=new y(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),f.call(this)}function v(e,t,r,n,i,o,a){t.writelen=n,t.writecb=a,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function g(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),E(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),a=t.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,v(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,h=r.callback;if(v(e,t,!1,t.objectMode?1:c.length,c,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function A(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),E(e,t)})}function E(e,t){var r=_(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,i(A,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}u.inherits(m,f),y.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(y.prototype,"buffer",{get:c.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===m&&(e&&e._writableState instanceof y)}})):d=function(e){return e instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(e,t,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=e,h.isBuffer(n)||n instanceof l);return s&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof r&&(r=b),o.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),i(t,r)}(this,r):(s||function(e,t,r,n){var o=!0,a=!1;return null===r?a=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),i(n,a),o=!1),o}(this,o,e,r))&&(o.pendingcb++,a=function(e,t,r,n,i,o){if(!r){var a=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,r));return t}(t,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=t.objectMode?1:n.length;t.length+=s;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},m.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,E(e,t),r&&(t.finished?i(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),m.prototype.destroy=p.destroy,m.prototype._undestroy=p.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":276,"./internal/streams/destroy":282,"./internal/streams/stream":283,_process:257,"core-util-is":89,inherits:180,"process-nextick-args":256,"safe-buffer":290,"util-deprecate":330}],281:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,i,o=n.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,r=o,i=s,t.copy(r,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":290,util:55}],282:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick;function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var r=this,o=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return o||a?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||n(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n(i,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":256}],283:[function(e,t,r){t.exports=e("events").EventEmitter},{events:157}],284:[function(e,t,r){t.exports=e("./readable").PassThrough},{"./readable":285}],285:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":276,"./lib/_stream_passthrough.js":277,"./lib/_stream_readable.js":278,"./lib/_stream_transform.js":279,"./lib/_stream_writable.js":280}],286:[function(e,t,r){t.exports=e("./readable").Transform},{"./readable":285}],287:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":280}],288:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base");function o(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function a(e,t){return e<>>32-t}function s(e,t,r,n,i,o,s,u){return a(e+(t^r^n)+o+s|0,u)+i|0}function u(e,t,r,n,i,o,s,u){return a(e+(t&r|~t&n)+o+s|0,u)+i|0}function c(e,t,r,n,i,o,s,u){return a(e+((t|~r)^n)+o+s|0,u)+i|0}function f(e,t,r,n,i,o,s,u){return a(e+(t&n|r&~n)+o+s|0,u)+i|0}function h(e,t,r,n,i,o,s,u){return a(e+(t^(r|~n))+o+s|0,u)+i|0}n(o,i),o.prototype._update=function(){for(var e=new Array(16),t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,o=this._d,l=this._e;l=s(l,r=s(r,n,i,o,l,e[0],0,11),n,i=a(i,10),o,e[1],0,14),n=s(n=a(n,10),i=s(i,o=s(o,l,r,n,i,e[2],0,15),l,r=a(r,10),n,e[3],0,12),o,l=a(l,10),r,e[4],0,5),o=s(o=a(o,10),l=s(l,r=s(r,n,i,o,l,e[5],0,8),n,i=a(i,10),o,e[6],0,7),r,n=a(n,10),i,e[7],0,9),r=s(r=a(r,10),n=s(n,i=s(i,o,l,r,n,e[8],0,11),o,l=a(l,10),r,e[9],0,13),i,o=a(o,10),l,e[10],0,14),i=s(i=a(i,10),o=s(o,l=s(l,r,n,i,o,e[11],0,15),r,n=a(n,10),i,e[12],0,6),l,r=a(r,10),n,e[13],0,7),l=u(l=a(l,10),r=s(r,n=s(n,i,o,l,r,e[14],0,9),i,o=a(o,10),l,e[15],0,8),n,i=a(i,10),o,e[7],1518500249,7),n=u(n=a(n,10),i=u(i,o=u(o,l,r,n,i,e[4],1518500249,6),l,r=a(r,10),n,e[13],1518500249,8),o,l=a(l,10),r,e[1],1518500249,13),o=u(o=a(o,10),l=u(l,r=u(r,n,i,o,l,e[10],1518500249,11),n,i=a(i,10),o,e[6],1518500249,9),r,n=a(n,10),i,e[15],1518500249,7),r=u(r=a(r,10),n=u(n,i=u(i,o,l,r,n,e[3],1518500249,15),o,l=a(l,10),r,e[12],1518500249,7),i,o=a(o,10),l,e[0],1518500249,12),i=u(i=a(i,10),o=u(o,l=u(l,r,n,i,o,e[9],1518500249,15),r,n=a(n,10),i,e[5],1518500249,9),l,r=a(r,10),n,e[2],1518500249,11),l=u(l=a(l,10),r=u(r,n=u(n,i,o,l,r,e[14],1518500249,7),i,o=a(o,10),l,e[11],1518500249,13),n,i=a(i,10),o,e[8],1518500249,12),n=c(n=a(n,10),i=c(i,o=c(o,l,r,n,i,e[3],1859775393,11),l,r=a(r,10),n,e[10],1859775393,13),o,l=a(l,10),r,e[14],1859775393,6),o=c(o=a(o,10),l=c(l,r=c(r,n,i,o,l,e[4],1859775393,7),n,i=a(i,10),o,e[9],1859775393,14),r,n=a(n,10),i,e[15],1859775393,9),r=c(r=a(r,10),n=c(n,i=c(i,o,l,r,n,e[8],1859775393,13),o,l=a(l,10),r,e[1],1859775393,15),i,o=a(o,10),l,e[2],1859775393,14),i=c(i=a(i,10),o=c(o,l=c(l,r,n,i,o,e[7],1859775393,8),r,n=a(n,10),i,e[0],1859775393,13),l,r=a(r,10),n,e[6],1859775393,6),l=c(l=a(l,10),r=c(r,n=c(n,i,o,l,r,e[13],1859775393,5),i,o=a(o,10),l,e[11],1859775393,12),n,i=a(i,10),o,e[5],1859775393,7),n=f(n=a(n,10),i=f(i,o=c(o,l,r,n,i,e[12],1859775393,5),l,r=a(r,10),n,e[1],2400959708,11),o,l=a(l,10),r,e[9],2400959708,12),o=f(o=a(o,10),l=f(l,r=f(r,n,i,o,l,e[11],2400959708,14),n,i=a(i,10),o,e[10],2400959708,15),r,n=a(n,10),i,e[0],2400959708,14),r=f(r=a(r,10),n=f(n,i=f(i,o,l,r,n,e[8],2400959708,15),o,l=a(l,10),r,e[12],2400959708,9),i,o=a(o,10),l,e[4],2400959708,8),i=f(i=a(i,10),o=f(o,l=f(l,r,n,i,o,e[13],2400959708,9),r,n=a(n,10),i,e[3],2400959708,14),l,r=a(r,10),n,e[7],2400959708,5),l=f(l=a(l,10),r=f(r,n=f(n,i,o,l,r,e[15],2400959708,6),i,o=a(o,10),l,e[14],2400959708,8),n,i=a(i,10),o,e[5],2400959708,6),n=h(n=a(n,10),i=f(i,o=f(o,l,r,n,i,e[6],2400959708,5),l,r=a(r,10),n,e[2],2400959708,12),o,l=a(l,10),r,e[4],2840853838,9),o=h(o=a(o,10),l=h(l,r=h(r,n,i,o,l,e[0],2840853838,15),n,i=a(i,10),o,e[5],2840853838,5),r,n=a(n,10),i,e[9],2840853838,11),r=h(r=a(r,10),n=h(n,i=h(i,o,l,r,n,e[7],2840853838,6),o,l=a(l,10),r,e[12],2840853838,8),i,o=a(o,10),l,e[2],2840853838,13),i=h(i=a(i,10),o=h(o,l=h(l,r,n,i,o,e[10],2840853838,12),r,n=a(n,10),i,e[14],2840853838,5),l,r=a(r,10),n,e[1],2840853838,12),l=h(l=a(l,10),r=h(r,n=h(n,i,o,l,r,e[3],2840853838,13),i,o=a(o,10),l,e[8],2840853838,14),n,i=a(i,10),o,e[11],2840853838,11),n=h(n=a(n,10),i=h(i,o=h(o,l,r,n,i,e[6],2840853838,8),l,r=a(r,10),n,e[15],2840853838,5),o,l=a(l,10),r,e[13],2840853838,6),o=a(o,10);var d=this._a,p=this._b,b=this._c,y=this._d,m=this._e;m=h(m,d=h(d,p,b,y,m,e[5],1352829926,8),p,b=a(b,10),y,e[14],1352829926,9),p=h(p=a(p,10),b=h(b,y=h(y,m,d,p,b,e[7],1352829926,9),m,d=a(d,10),p,e[0],1352829926,11),y,m=a(m,10),d,e[9],1352829926,13),y=h(y=a(y,10),m=h(m,d=h(d,p,b,y,m,e[2],1352829926,15),p,b=a(b,10),y,e[11],1352829926,15),d,p=a(p,10),b,e[4],1352829926,5),d=h(d=a(d,10),p=h(p,b=h(b,y,m,d,p,e[13],1352829926,7),y,m=a(m,10),d,e[6],1352829926,7),b,y=a(y,10),m,e[15],1352829926,8),b=h(b=a(b,10),y=h(y,m=h(m,d,p,b,y,e[8],1352829926,11),d,p=a(p,10),b,e[1],1352829926,14),m,d=a(d,10),p,e[10],1352829926,14),m=f(m=a(m,10),d=h(d,p=h(p,b,y,m,d,e[3],1352829926,12),b,y=a(y,10),m,e[12],1352829926,6),p,b=a(b,10),y,e[6],1548603684,9),p=f(p=a(p,10),b=f(b,y=f(y,m,d,p,b,e[11],1548603684,13),m,d=a(d,10),p,e[3],1548603684,15),y,m=a(m,10),d,e[7],1548603684,7),y=f(y=a(y,10),m=f(m,d=f(d,p,b,y,m,e[0],1548603684,12),p,b=a(b,10),y,e[13],1548603684,8),d,p=a(p,10),b,e[5],1548603684,9),d=f(d=a(d,10),p=f(p,b=f(b,y,m,d,p,e[10],1548603684,11),y,m=a(m,10),d,e[14],1548603684,7),b,y=a(y,10),m,e[15],1548603684,7),b=f(b=a(b,10),y=f(y,m=f(m,d,p,b,y,e[8],1548603684,12),d,p=a(p,10),b,e[12],1548603684,7),m,d=a(d,10),p,e[4],1548603684,6),m=f(m=a(m,10),d=f(d,p=f(p,b,y,m,d,e[9],1548603684,15),b,y=a(y,10),m,e[1],1548603684,13),p,b=a(b,10),y,e[2],1548603684,11),p=c(p=a(p,10),b=c(b,y=c(y,m,d,p,b,e[15],1836072691,9),m,d=a(d,10),p,e[5],1836072691,7),y,m=a(m,10),d,e[1],1836072691,15),y=c(y=a(y,10),m=c(m,d=c(d,p,b,y,m,e[3],1836072691,11),p,b=a(b,10),y,e[7],1836072691,8),d,p=a(p,10),b,e[14],1836072691,6),d=c(d=a(d,10),p=c(p,b=c(b,y,m,d,p,e[6],1836072691,6),y,m=a(m,10),d,e[9],1836072691,14),b,y=a(y,10),m,e[11],1836072691,12),b=c(b=a(b,10),y=c(y,m=c(m,d,p,b,y,e[8],1836072691,13),d,p=a(p,10),b,e[12],1836072691,5),m,d=a(d,10),p,e[2],1836072691,14),m=c(m=a(m,10),d=c(d,p=c(p,b,y,m,d,e[10],1836072691,13),b,y=a(y,10),m,e[0],1836072691,13),p,b=a(b,10),y,e[4],1836072691,7),p=u(p=a(p,10),b=u(b,y=c(y,m,d,p,b,e[13],1836072691,5),m,d=a(d,10),p,e[8],2053994217,15),y,m=a(m,10),d,e[6],2053994217,5),y=u(y=a(y,10),m=u(m,d=u(d,p,b,y,m,e[4],2053994217,8),p,b=a(b,10),y,e[1],2053994217,11),d,p=a(p,10),b,e[3],2053994217,14),d=u(d=a(d,10),p=u(p,b=u(b,y,m,d,p,e[11],2053994217,14),y,m=a(m,10),d,e[15],2053994217,6),b,y=a(y,10),m,e[0],2053994217,14),b=u(b=a(b,10),y=u(y,m=u(m,d,p,b,y,e[5],2053994217,6),d,p=a(p,10),b,e[12],2053994217,9),m,d=a(d,10),p,e[2],2053994217,12),m=u(m=a(m,10),d=u(d,p=u(p,b,y,m,d,e[13],2053994217,9),b,y=a(y,10),m,e[9],2053994217,12),p,b=a(b,10),y,e[7],2053994217,5),p=s(p=a(p,10),b=u(b,y=u(y,m,d,p,b,e[10],2053994217,15),m,d=a(d,10),p,e[14],2053994217,8),y,m=a(m,10),d,e[12],0,8),y=s(y=a(y,10),m=s(m,d=s(d,p,b,y,m,e[15],0,5),p,b=a(b,10),y,e[10],0,12),d,p=a(p,10),b,e[4],0,9),d=s(d=a(d,10),p=s(p,b=s(b,y,m,d,p,e[1],0,12),y,m=a(m,10),d,e[5],0,5),b,y=a(y,10),m,e[8],0,14),b=s(b=a(b,10),y=s(y,m=s(m,d,p,b,y,e[7],0,6),d,p=a(p,10),b,e[6],0,8),m,d=a(d,10),p,e[2],0,13),m=s(m=a(m,10),d=s(d,p=s(p,b,y,m,d,e[13],0,6),b,y=a(y,10),m,e[14],0,5),p,b=a(b,10),y,e[0],0,15),p=s(p=a(p,10),b=s(b,y=s(y,m,d,p,b,e[3],0,13),m,d=a(d,10),p,e[9],0,11),y,m=a(m,10),d,e[11],0,11),y=a(y,10);var v=this._b+i+y|0;this._b=this._c+o+m|0,this._c=this._d+l+d|0,this._d=this._e+r+p|0,this._e=this._a+n+b|0,this._a=v},o.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=o}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":161,inherits:180}],289:[function(e,t,r){const n=e("assert"),i=e("safe-buffer").Buffer;function o(e,t){if("00"===e.slice(0,2))throw new Error("invalid RLP: extra zeros");return parseInt(e,t)}function a(e,t){if(e<56)return i.from([e+t]);var r=u(e),n=u(t+55+r.length/2);return i.from(n+r,"hex")}function s(e){return"0x"===e.slice(0,2)}function u(e){var t=e.toString(16);return t.length%2&&(t="0"+t),t}function c(e){if(!i.isBuffer(e))if("string"==typeof e)e=s(e)?i.from(((r="string"!=typeof(n=e)?n:s(n)?n.slice(2):n).length%2&&(r="0"+r),r),"hex"):i.from(e);else if("number"==typeof e)e?(t=u(e),e=i.from(t,"hex")):e=i.from([]);else if(null==e)e=i.from([]);else{if(!e.toArray)throw new Error("invalid type");e=i.from(e.toArray())}var t,r,n;return e}r.encode=function(e){if(e instanceof Array){for(var t=[],n=0;nt.length)throw new Error("invalid rlp: total length is larger than the data");if(0===(s=t.slice(n,h)).length)throw new Error("invalid rlp, List has a invalid length");for(;s.length;)u=e(s),c.push(u.data),s=u.remainder;return{data:c,remainder:t.slice(h)}}(e=c(e));return t?r:(n.equal(r.remainder.length,0,"invalid remainder"),r.data)},r.getLength=function(e){if(!e||0===e.length)return i.from([]);var t=(e=c(e))[0];if(t<=127)return e.length;if(t<=183)return t-127;if(t<=191)return t-182;if(t<=247)return t-191;var r=t-246;return r+o(e.slice(1,r).toString("hex"),16)}},{assert:19,"safe-buffer":290}],290:[function(e,t,r){var n=e("buffer"),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function a(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,r),r.Buffer=a),o(i,a),a.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:84}],291:[function(e,t,r){const n=e("util"),i=e("events/");var o="object"==typeof Reflect?Reflect:null,a=o&&"function"==typeof o.apply?o.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};function s(){i.call(this)}function u(e,t,r){try{a(e,t,r)}catch(e){setTimeout(()=>{throw e})}}t.exports=s,n.inherits(s,i),s.prototype.emit=function(e){for(var t=[],r=1;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var s=i[e];if(void 0===s)return!1;if("function"==typeof s)u(s,this,t);else{var c=s.length,f=function(e,t){for(var r=new Array(t),n=0;n0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=function(){for(var e=[],t=0;t0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var c=u.length,f=p(u,c);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return l(this,e,!0)},s.prototype.rawListeners=function(e){return l(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},{}],293:[function(e,t,r){t.exports=e("scryptsy")},{scryptsy:294}],294:[function(e,t,r){(function(r){var n=e("pbkdf2").pbkdf2Sync,i=2147483647;function o(e,t,n,i,o){if(r.isBuffer(e)&&r.isBuffer(n))e.copy(n,i,t,t+o);else for(;o--;)n[i++]=e[t++]}t.exports=function(e,t,a,s,u,c,f){if(0===a||0!=(a&a-1))throw Error("N must be > 0 and a power of 2");if(a>i/128/s)throw Error("Parameter N is too large");if(s>i/128/u)throw Error("Parameter r is too large");var h,l=new r(256*s),d=new r(128*s*a),p=new Int32Array(16),b=new Int32Array(16),y=new r(64),m=n(e,t,1,128*u*s,"sha256");if(f){var v=u*a*2,g=0;h=function(){++g%1e3==0&&f({current:g,total:v,percent:g/v*100})}}for(var w=0;w>>32-t}function x(e){var t;for(t=0;t<16;t++)p[t]=(255&e[4*t+0])<<0,p[t]|=(255&e[4*t+1])<<8,p[t]|=(255&e[4*t+2])<<16,p[t]|=(255&e[4*t+3])<<24;for(o(p,0,b,0,16),t=8;t>0;t-=2)b[4]^=E(b[0]+b[12],7),b[8]^=E(b[4]+b[0],9),b[12]^=E(b[8]+b[4],13),b[0]^=E(b[12]+b[8],18),b[9]^=E(b[5]+b[1],7),b[13]^=E(b[9]+b[5],9),b[1]^=E(b[13]+b[9],13),b[5]^=E(b[1]+b[13],18),b[14]^=E(b[10]+b[6],7),b[2]^=E(b[14]+b[10],9),b[6]^=E(b[2]+b[14],13),b[10]^=E(b[6]+b[2],18),b[3]^=E(b[15]+b[11],7),b[7]^=E(b[3]+b[15],9),b[11]^=E(b[7]+b[3],13),b[15]^=E(b[11]+b[7],18),b[1]^=E(b[0]+b[3],7),b[2]^=E(b[1]+b[0],9),b[3]^=E(b[2]+b[1],13),b[0]^=E(b[3]+b[2],18),b[6]^=E(b[5]+b[4],7),b[7]^=E(b[6]+b[5],9),b[4]^=E(b[7]+b[6],13),b[5]^=E(b[4]+b[7],18),b[11]^=E(b[10]+b[9],7),b[8]^=E(b[11]+b[10],9),b[9]^=E(b[8]+b[11],13),b[10]^=E(b[9]+b[8],18),b[12]^=E(b[15]+b[14],7),b[13]^=E(b[12]+b[15],9),b[14]^=E(b[13]+b[12],13),b[15]^=E(b[14]+b[13],18);for(t=0;t<16;++t)p[t]=b[t]+p[t];for(t=0;t<16;t++){var r=4*t;e[r+0]=p[t]>>0&255,e[r+1]=p[t]>>8&255,e[r+2]=p[t]>>16&255,e[r+3]=p[t]>>24&255}}function k(e,t,r,n,i){for(var o=0;o=r)throw RangeError(n)}}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":181}],297:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("bip66"),o=n.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),a=n.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(e,t,r){var i=n.from(r?o:a);return e.copy(i,r?8:9),t.copy(i,r?181:214),i},r.privateKeyImport=function(e){var t=e.length,r=0;if(!(t2||t1?e[r+n-2]<<8:0);if(!(t<(r+=n)+i||t32||t1&&0===t[o]&&!(128&t[o+1]);--r,++o);for(var a=n.concat([n.from([0]),e.s]),s=33,u=0;s>1&&0===a[u]&&!(128&a[u+1]);--s,++u);return i.encode(t.slice(o),a.slice(u))},r.signatureImport=function(e){var t=n.alloc(32,0),r=n.alloc(32,0);try{var o=i.decode(e);if(33===o.r.length&&0===o.r[0]&&(o.r=o.r.slice(1)),o.r.length>32)throw new Error("R length is too long");if(33===o.s.length&&0===o.s[0]&&(o.s=o.s.slice(1)),o.s.length>32)throw new Error("S length is too long")}catch(e){return}return o.r.copy(t,32-o.r.length),o.s.copy(r,32-o.s.length),{r:t,s:r}},r.signatureImportLax=function(e){var t=n.alloc(32,0),r=n.alloc(32,0),i=e.length,o=0;if(48===e[o++]){var a=e[o++];if(!(128&a&&(o+=a-128)>i)&&2===e[o++]){var s=e[o++];if(128&s){if(o+(a=s-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(s=0;a>0;o+=1,a-=1)s=(s<<8)+e[o]}if(!(s>i-o)){var u=o;if(o+=s,2===e[o++]){var c=e[o++];if(128&c){if(o+(a=c-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(c=0;a>0;o+=1,a-=1)c=(c<<8)+e[o]}if(!(c>i-o)){var f=o;for(o+=c;s>0&&0===e[u];s-=1,u+=1);if(!(s>32)){var h=e.slice(u,u+s);for(h.copy(t,32-h.length);c>0&&0===e[f];c-=1,f+=1);if(!(c>32)){var l=e.slice(f,f+c);return l.copy(r,32-l.length),{r:t,s:r}}}}}}}}}},{bip66:52,"safe-buffer":290}],298:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("create-hash"),o=e("bn.js"),a=e("elliptic").ec,s=e("../messages.json"),u=new a("secp256k1"),c=u.curve;function f(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new o(t);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),u.keyPair({pub:{x:r,y:n}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new o(t),i=new o(r);if(n.cmp(c.p)>=0||i.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),i=i.toRed(c.red),(6===e||7===e)&&i.isOdd()!==(7===e))return null;var a=n.redSqr().redIMul(n);return i.redSqr().redISub(a.redIAdd(c.b)).isZero()?u.keyPair({pub:{x:n,y:i}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}r.privateKeyVerify=function(e){var t=new o(e);return t.cmp(c.n)<0&&!t.isZero()},r.privateKeyExport=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.privateKeyNegate=function(e){var t=new o(e);return t.isZero()?n.alloc(32):c.n.sub(t).umod(c.n).toArrayLike(n,"be",32)},r.privateKeyModInverse=function(e){var t=new o(e);if(t.cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(c.n).toArrayLike(n,"be",32)},r.privateKeyTweakAdd=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new o(e)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(n,"be",32)},r.privateKeyTweakMul=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new o(e)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(n,"be",32)},r.publicKeyCreate=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.publicKeyConvert=function(e,t){var r=f(e);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return n.from(r.getPublic(t,!0))},r.publicKeyVerify=function(e){return null!==f(e)},r.publicKeyTweakAdd=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return n.from(c.g.mul(t).add(i.pub).encode(!0,r))},r.publicKeyTweakMul=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return n.from(i.pub.mul(t).encode(!0,r))},r.publicKeyCombine=function(e,t){for(var r=new Array(e.length),i=0;i=0||r.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var i=n.from(e);return 1===r.cmp(u.nh)&&c.n.sub(r).toArrayLike(n,"be",32).copy(i,32),i},r.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new o(t).cmp(c.n)>=0||new o(r).cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},r.signatureImport=function(e){var t=new o(e.r);t.cmp(c.n)>=0&&(t=new o(0));var r=new o(e.s);return r.cmp(c.n)>=0&&(r=new o(0)),n.concat([t.toArrayLike(n,"be",32),r.toArrayLike(n,"be",32)])},r.sign=function(e,t,r,i){if("function"==typeof r){var a=r;r=function(r){var u=a(e,t,null,i,r);if(!n.isBuffer(u)||32!==u.length)throw new Error(s.ECDSA_SIGN_FAIL);return new o(u)}}var f=new o(t);if(f.cmp(c.n)>=0||f.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var h=u.sign(e,t,{canonical:!0,k:r,pers:i});return{signature:n.concat([h.r.toArrayLike(n,"be",32),h.s.toArrayLike(n,"be",32)]),recovery:h.recoveryParam}},r.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},i=new o(n.r),a=new o(n.s);if(i.cmp(c.n)>=0||a.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===a.cmp(u.nh)||i.isZero()||a.isZero())return!1;var h=f(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return u.verify(e,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(e,t,r,i){var a={r:t.slice(0,32),s:t.slice(32,64)},f=new o(a.r),h=new o(a.s);if(f.cmp(c.n)>=0||h.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(f.isZero()||h.isZero())throw new Error;var l=u.recoverPubKey(e,a,r);return n.from(l.encode(!0,i))}catch(e){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(e,t){var n=r.ecdhUnsafe(e,t,!0);return i("sha256").update(n).digest()},r.ecdhUnsafe=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var a=new o(t);if(a.cmp(c.n)>=0||a.isZero())throw new Error(s.ECDH_FAIL);return n.from(i.pub.mul(a).encode(!0,r))}},{"../messages.json":300,"bn.js":53,"create-hash":91,elliptic:109,"safe-buffer":290}],299:[function(e,t,r){"use strict";var n=e("./assert"),i=e("./der"),o=e("./messages.json");function a(e,t){return void 0===e?t:(n.isBoolean(e,o.COMPRESSED_TYPE_INVALID),e)}t.exports=function(e){return{privateKeyVerify:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0);var s=e.privateKeyExport(t,r);return i.privateKeyExport(t,s,r)},privateKeyImport:function(t){if(n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),(t=i.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakAdd(t,r,i)},publicKeyTweakMul:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakMul(t,r,i)},publicKeyCombine:function(t,r){n.isArray(t,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(t,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=2&&("function"==typeof arguments[1]?r.task=arguments[1]:r.n=arguments[1]);var n=r.task;if(r.task=function(){n(t.leave)},t.current+r.n-e>t.capacity)return 1===e&&(t.current--,t.firstHere=!1),t.queue.push(r);t.current+=r.n-e,r.task(t.leave),1===e&&(t.firstHere=!1)},leave:function(e){if(e=e||1,t.current-=e,t.queue.length){var r=t.queue[0];r.n+t.current>t.capacity||(t.queue.shift(),t.current+=r.n,i(r.task))}else if(t.current<0)throw new Error("leave called too many times.")},available:function(e){return e=e||1,t.current+e<=t.capacity}};return t}void 0!==e&&e&&"function"==typeof e.nextTick&&(i=e.nextTick),"object"==typeof r?t.exports=o:"function"==typeof define&&define.amd?define(function(){return o}):n.semaphore=o}(this)}).call(this,e("_process"))},{_process:257}],302:[function(e,t,r){"use strict";t.exports="function"==typeof setImmediate?setImmediate:function(){var e=[].slice.apply(arguments);e.splice(1,0,0),setTimeout.apply(null,e)}},{}],303:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t){this._block=n.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}i.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=n.from(e,t));for(var r=this._block,i=this._blockSize,o=e.length,a=this._len,s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},{"safe-buffer":290}],304:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":305,"./sha1":306,"./sha224":307,"./sha256":308,"./sha384":309,"./sha512":310}],305:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((t=n)<<5|t>>>27)+f(d,i,o,s)+u+r[l]+a[d];u=s,s=o,o=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],306:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function h(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=(t=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=c(n)+h(p,i,o,s)+u+r[d]+a[p]|0;u=s,s=o,o=f(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],307:[function(e,t,r){var n=e("inherits"),i=e("./sha256"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}n(u,i),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=u},{"./hash":303,"./sha256":308,inherits:180,"safe-buffer":290}],308:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function l(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(u,i),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,m=0;m<16;++m)r[m]=e.readInt32BE(4*m);for(;m<64;++m)r[m]=0|(((t=r[m-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[m-7]+d(r[m-15])+r[m-16];for(var v=0;v<64;++v){var g=y+l(u)+c(u,p,b)+a[v]+r[v]|0,w=h(n)+f(n,i,o)|0;y=b,b=p,p=u,u=s+g|0,s=o,o=i,i=n,n=g+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},u.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],309:[function(e,t,r){var n=e("inherits"),i=e("./sha512"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}n(u,i),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=u},{"./hash":303,"./sha512":310,inherits:180,"safe-buffer":290}],310:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function l(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function y(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function m(e,t){return e>>>0>>0?1:0}n(u,i),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,s=0|this._eh,u=0|this._fh,v=0|this._gh,g=0|this._hh,w=0|this._al,_=0|this._bl,A=0|this._cl,E=0|this._dl,x=0|this._el,k=0|this._fl,S=0|this._gl,M=0|this._hl,I=0;I<32;I+=2)t[I]=e.readInt32BE(4*I),t[I+1]=e.readInt32BE(4*I+4);for(;I<160;I+=2){var T=t[I-30],U=t[I-30+1],j=d(T,U),B=p(U,T),P=b(T=t[I-4],U=t[I-4+1]),C=y(U,T),N=t[I-14],R=t[I-14+1],L=t[I-32],O=t[I-32+1],D=B+R|0,F=j+N+m(D,B)|0;F=(F=F+P+m(D=D+C|0,C)|0)+L+m(D=D+O|0,O)|0,t[I]=F,t[I+1]=D}for(var q=0;q<160;q+=2){F=t[q],D=t[q+1];var H=f(r,n,i),z=f(w,_,A),K=h(r,w),V=h(w,r),G=l(s,x),W=l(x,s),Y=a[q],X=a[q+1],Z=c(s,u,v),J=c(x,k,S),$=M+W|0,Q=g+G+m($,M)|0;Q=(Q=(Q=Q+Z+m($=$+J|0,J)|0)+Y+m($=$+X|0,X)|0)+F+m($=$+D|0,D)|0;var ee=V+z|0,te=K+H+m(ee,V)|0;g=v,M=S,v=u,S=k,u=s,k=x,s=o+Q+m(x=E+$|0,E)|0,o=i,E=A,i=n,A=_,n=r,_=w,r=Q+te+m(w=$+ee|0,$)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+A|0,this._dl=this._dl+E|0,this._el=this._el+x|0,this._fl=this._fl+k|0,this._gl=this._gl+S|0,this._hl=this._hl+M|0,this._ah=this._ah+r+m(this._al,w)|0,this._bh=this._bh+n+m(this._bl,_)|0,this._ch=this._ch+i+m(this._cl,A)|0,this._dh=this._dh+o+m(this._dl,E)|0,this._eh=this._eh+s+m(this._el,x)|0,this._fh=this._fh+u+m(this._fl,k)|0,this._gh=this._gh+v+m(this._gl,S)|0,this._hh=this._hh+g+m(this._hl,M)|0},u.prototype._hash=function(){var e=o.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],311:[function(e,t,r){t.exports=i;var n=e("events").EventEmitter;function i(){n.call(this)}e("inherits")(i,n),i.Readable=e("readable-stream/readable.js"),i.Writable=e("readable-stream/writable.js"),i.Duplex=e("readable-stream/duplex.js"),i.Transform=e("readable-stream/transform.js"),i.PassThrough=e("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,e.end())}function u(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(f(),0===n.listenerCount(this,"error"))throw e}function f(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),e.removeListener("close",f)}return r.on("error",c),e.on("error",c),r.on("end",f),r.on("close",f),e.on("close",f),e.emit("pipe",r),e}},{events:157,inherits:180,"readable-stream/duplex.js":275,"readable-stream/passthrough.js":284,"readable-stream/readable.js":285,"readable-stream/transform.js":286,"readable-stream/writable.js":287}],312:[function(e,t,r){(function(t){var n=e("./lib/request"),i=e("./lib/response"),o=e("xtend"),a=e("builtin-status-codes"),s=e("url"),u=r;u.request=function(e,r){e="string"==typeof e?s.parse(e):o(e);var i=-1===t.location.protocol.search(/^https?:$/)?"http:":"",a=e.protocol||i,u=e.hostname||e.host,c=e.port,f=e.path||"/";u&&-1!==u.indexOf(":")&&(u="["+u+"]"),e.url=(u?a+"//"+u:"")+(c?":"+c:"")+f,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var h=new n(e);return r&&h.on("response",r),h},u.get=function(e,t){var r=u.request(e,t);return r.end(),r},u.ClientRequest=n,u.IncomingMessage=i,u.Agent=function(){},u.Agent.defaultMaxSockets=4,u.STATUS_CODES=a,u.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/request":314,"./lib/response":315,"builtin-status-codes":85,url:327,xtend:423}],313:[function(e,t,r){(function(e){r.fetch=s(e.fetch)&&s(e.ReadableStream),r.writableStream=s(e.WritableStream),r.abortController=s(e.AbortController),r.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),r.blobConstructor=!0}catch(e){}var t;function n(){if(void 0!==t)return t;if(e.XMLHttpRequest){t=new e.XMLHttpRequest;try{t.open("GET",e.XDomainRequest?"/":"https://example.com")}catch(e){t=null}}else t=null;return t}function i(e){var t=n();if(!t)return!1;try{return t.responseType=e,t.responseType===e}catch(e){}return!1}var o=void 0!==e.ArrayBuffer,a=o&&s(e.ArrayBuffer.prototype.slice);function s(e){return"function"==typeof e}r.arraybuffer=r.fetch||o&&i("arraybuffer"),r.msstream=!r.fetch&&a&&i("ms-stream"),r.mozchunkedarraybuffer=!r.fetch&&o&&i("moz-chunked-arraybuffer"),r.overrideMimeType=r.fetch||!!n()&&s(n().overrideMimeType),r.vbArray=s(e.VBArray),t=null}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],314:[function(e,t,r){(function(r,n,i){var o=e("./capability"),a=e("inherits"),s=e("./response"),u=e("readable-stream"),c=e("to-arraybuffer"),f=s.IncomingMessage,h=s.readyStates;var l=t.exports=function(e){var t,r=this;u.Writable.call(r),r._opts=e,r._body=[],r._headers={},e.auth&&r.setHeader("Authorization","Basic "+new i(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){r.setHeader(t,e.headers[t])});var n=!0;if("disable-fetch"===e.mode||"requestTimeout"in e&&!o.abortController)n=!1,t=!0;else if("prefer-streaming"===e.mode)t=!1;else if("allow-wrong-content-type"===e.mode)t=!o.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");t=!0}r._mode=function(e,t){return o.fetch&&t?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&e?"arraybuffer":o.vbArray&&e?"text:vbarray":"text"}(t,n),r.on("finish",function(){r._onFinish()})};a(l,u.Writable),l.prototype.setHeader=function(e,t){var r=e.toLowerCase();-1===d.indexOf(r)&&(this._headers[r]={name:e,value:t})},l.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},l.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},l.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,a=e._headers,s=null;"GET"!==t.method&&"HEAD"!==t.method&&(s=o.arraybuffer?c(i.concat(e._body)):o.blobConstructor?new n.Blob(e._body.map(function(e){return c(e)}),{type:(a["content-type"]||{}).value||""}):i.concat(e._body).toString());var u=[];if(Object.keys(a).forEach(function(e){var t=a[e].name,r=a[e].value;Array.isArray(r)?r.forEach(function(e){u.push([t,e])}):u.push([t,r])}),"fetch"===e._mode){var f=null;if(o.abortController){var l=new AbortController;f=l.signal,e._fetchAbortController=l,"requestTimeout"in t&&0!==t.requestTimeout&&n.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},t.requestTimeout)}n.fetch(e._opts.url,{method:e._opts.method,headers:u,body:s||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin",signal:f}).then(function(t){e._fetchResponse=t,e._connect()},function(t){e.emit("error",t)})}else{var d=e._xhr=new n.XMLHttpRequest;try{d.open(e._opts.method,e._opts.url,!0)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}"responseType"in d&&(d.responseType=e._mode.split(":")[0]),"withCredentials"in d&&(d.withCredentials=!!t.withCredentials),"text"===e._mode&&"overrideMimeType"in d&&d.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in t&&(d.timeout=t.requestTimeout,d.ontimeout=function(){e.emit("requestTimeout")}),u.forEach(function(e){d.setRequestHeader(e[0],e[1])}),e._response=null,d.onreadystatechange=function(){switch(d.readyState){case h.LOADING:case h.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(d.onprogress=function(){e._onXHRProgress()}),d.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{d.send(s)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}}}},l.prototype._onXHRProgress=function(){(function(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}})(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},l.prototype._connect=function(){var e=this;e._destroyed||(e._response=new f(e._xhr,e._fetchResponse,e._mode),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},l.prototype._write=function(e,t,r){this._body.push(e),r()},l.prototype.abort=l.prototype.destroy=function(){this._destroyed=!0,this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},l.prototype.end=function(e,t,r){"function"==typeof e&&(r=e,e=void 0),u.Writable.prototype.end.call(this,e,t,r)},l.prototype.flushHeaders=function(){},l.prototype.setTimeout=function(){},l.prototype.setNoDelay=function(){},l.prototype.setSocketKeepAlive=function(){};var d=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,"./response":315,_process:257,buffer:84,inherits:180,"readable-stream":285,"to-arraybuffer":323}],315:[function(e,t,r){(function(t,n,i){var o=e("./capability"),a=e("inherits"),s=e("readable-stream"),u=r.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},c=r.IncomingMessage=function(e,r,n){var a=this;if(s.Readable.call(a),a._mode=n,a.headers={},a.rawHeaders=[],a.trailers={},a.rawTrailers=[],a.on("end",function(){t.nextTick(function(){a.emit("close")})}),"fetch"===n){if(a._fetchResponse=r,a.url=r.url,a.statusCode=r.status,a.statusMessage=r.statusText,r.headers.forEach(function(e,t){a.headers[t.toLowerCase()]=e,a.rawHeaders.push(t,e)}),o.writableStream){var u=new WritableStream({write:function(e){return new Promise(function(t,r){a._destroyed||(a.push(new i(e))?t():a._resumeFetch=t)})},close:function(){a._destroyed||a.push(null)},abort:function(e){a._destroyed||a.emit("error",e)}});try{return void r.body.pipeTo(u)}catch(e){}}var c=r.body.getReader();!function e(){c.read().then(function(t){a._destroyed||(t.done?a.push(null):(a.push(new i(t.value)),e()))}).catch(function(e){a._destroyed||a.emit("error",e)})}()}else{if(a._xhr=e,a._pos=0,a.url=e.responseURL,a.statusCode=e.status,a.statusMessage=e.statusText,e.getAllResponseHeaders().split(/\r?\n/).forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var r=t[1].toLowerCase();"set-cookie"===r?(void 0===a.headers[r]&&(a.headers[r]=[]),a.headers[r].push(t[2])):void 0!==a.headers[r]?a.headers[r]+=", "+t[2]:a.headers[r]=t[2],a.rawHeaders.push(t[1],t[2])}}),a._charset="x-user-defined",!o.overrideMimeType){var f=a.rawHeaders["mime-type"];if(f){var h=f.match(/;\s*charset=([^;])(;|$)/);h&&(a._charset=h[1].toLowerCase())}a._charset||(a._charset="utf-8")}}};a(c,s.Readable),c.prototype._read=function(){var e=this._resumeFetch;e&&(this._resumeFetch=null,e())},c.prototype._onXHRProgress=function(){var e=this,t=e._xhr,r=null;switch(e._mode){case"text:vbarray":if(t.readyState!==u.DONE)break;try{r=new n.VBArray(t.responseBody).toArray()}catch(e){}if(null!==r){e.push(new i(r));break}case"text":try{r=t.responseText}catch(t){e._mode="text:vbarray";break}if(r.length>e._pos){var o=r.substr(e._pos);if("x-user-defined"===e._charset){for(var a=new i(o.length),s=0;se._pos&&(e.push(new i(new Uint8Array(c.result.slice(e._pos)))),e._pos=c.result.byteLength)},c.onload=function(){e.push(null)},c.readAsArrayBuffer(r)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,_process:257,buffer:84,inherits:180,"readable-stream":285}],316:[function(e,t,r){"use strict";t.exports=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}},{}],317:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=f,this.end=h,t=3;break;default:return this.write=l,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:-1}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�".repeat(r);if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�".repeat(r+1);if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�".repeat(r+2)}}(this,e,t);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function l(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}r.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":290}],318:[function(e,t,r){var n=e("is-hex-prefixed");t.exports=function(e){return"string"!=typeof e?e:n(e)?e.slice(2):e}},{"is-hex-prefixed":185}],319:[function(e,t,r){var n=function(){throw"This swarm.js function isn't available on the browser."},i={readFile:n},o={download:n,safeDownloadArchived:n,directoryTree:n},a={platform:n,arch:n},s={join:n,slice:n},u={spawn:n},c={lookup:n},f=e("xhr-request-promise"),h=e("eth-lib/lib/bytes"),l=e("./swarm-hash.js"),d=e("./pick.js"),p=e("./swarm");t.exports=p({fsp:i,files:o,os:a,path:s,child_process:u,defaultArchives:{},mimetype:c,request:f,downloadUrl:null,bytes:h,hash:l,pick:d})},{"./pick.js":320,"./swarm":322,"./swarm-hash.js":321,"eth-lib/lib/bytes":133,"xhr-request-promise":411}],320:[function(e,t,r){var n=function(e){return function(){return new Promise(function(t,r){var n=function(r){var n={},i=r.target.files.length,o=0;[].map.call(r.target.files,function(r){var a=new FileReader;a.onload=function(a){var s=new Uint8Array(a.target.result);if("directory"===e){var u=r.webkitRelativePath;n[u.slice(u.indexOf("/")+1)]={type:"text/plain",data:s},++o===i&&t(n)}else if("file"===e){var c=r.webkitRelativePath;t({type:mimetype.lookup(c),data:s})}else t(s)},a.readAsArrayBuffer(r)})},i=void 0;"directory"===e?((i=document.createElement("input")).addEventListener("change",n),i.type="file",i.webkitdirectory=!0,i.mozdirectory=!0,i.msdirectory=!0,i.odirectory=!0,i.directory=!0):((i=document.createElement("input")).addEventListener("change",n),i.type="file");var o=document.createEvent("MouseEvents");o.initEvent("click",!0,!1),i.dispatchEvent(o)})}};t.exports={data:n("data"),file:n("file"),directory:n("directory")}},{}],321:[function(e,t,r){var n=e("eth-lib/lib/hash").keccak256,i=e("eth-lib/lib/bytes"),o=function(e,t){var r=i.reverse(i.pad(6,i.fromNumber(e))),o=i.flatten([r,"0x0000",t]);return n(o).slice(2)};t.exports=function e(t){"string"==typeof t&&"0x"!==t.slice(0,2)?t=i.fromString(t):"string"!=typeof t&&void 0!==t.length&&(t=i.fromUint8Array(t));var r=i.length(t);if(r<=4096)return o(r,t);for(var n=4096;128*n0){var a=i.join(r,o);n.push(g(e)(t[o])(a))}return Promise.all(n).then(function(){return r})})}}},_=function(e){return function(t){return u(e+"/bzzr:/",{body:"string"==typeof t?L(t):t,method:"POST"})}},A=function(e){return function(t){return function(r){return function(n){return function i(o){var a="/"===r[0]?r:"/"+r,s=e+"/bzz:/"+t+a,c={method:"PUT",headers:{"Content-Type":n.type},body:n.data};return u(s,c).then(function(e){if(-1!==e.indexOf("error"))throw e;return e}).catch(function(e){return o>0&&i(o-1)})}(3)}}}},E=function(e){return function(t){return k(e)({"":t})}},x=function(e){return function(r){return t.readFile(r).then(function(t){return E(e)({type:a.lookup(r),data:t})})}},k=function(e){return function(t){return _(e)("{}").then(function(r){return Object.keys(t).reduce(function(r,n){return r.then(function(r){return function(n){return A(e)(n)(r)(t[r])}}(n))},Promise.resolve(r))})}},S=function(e){return function(r){return t.readFile(r).then(_(e))}},M=function(e){return function(n){return function(i){return r.directoryTree(i).then(function(e){return Promise.all(e.map(function(e){return t.readFile(e)})).then(function(t){var r=e.map(function(e){return e.slice(i.length)}),n=e.map(function(e){return a.lookup(e)||"text/plain"});return d(r)(t.map(function(e,t){return{type:n[t],data:e}}))})}).then(function(e){return(t=n?{"":e[n]}:{},function(e){var r={};for(var n in t)r[n]=t[n];for(var i in e)r[i]=e[i];return r})(e);var t}).then(k(e))}}},I=function(e){return function(t){if("data"===t.pick)return l.data().then(_(e));if("file"===t.pick)return l.file().then(E(e));if("directory"===t.pick)return l.directory().then(k(e));if(t.path)switch(t.kind){case"data":return S(e)(t.path);case"file":return x(e)(t.path);case"directory":return M(e)(t.defaultFile)(t.path)}else{if(t.length||"string"==typeof t)return _(e)(t);if(t instanceof Object)return k(e)(t)}return Promise.reject(new Error("Bad arguments"))}},T=function(e){return function(t){return function(r){return C(e)(t).then(function(n){return n?r?w(e)(t)(r):v(e)(t):r?g(e)(t)(r):b(e)(t)})}}},U=function(e,t){var i=n.platform().replace("win32","windows")+"-"+("x64"===n.arch()?"amd64":"386"),o=(t||s)[i],a=c+o.archive+".tar.gz",u=o.archiveMD5,f=o.binaryMD5;return r.safeDownloadArchived(a)(u)(f)(e)},j=function(e){return new Promise(function(t,r){var n=o.spawn,i=function(e){return function(t){return-1!==(""+t).indexOf(e)}},a=e.account,s=e.password,u=e.dataDir,c=e.ensApi,f=e.privateKey,h=0,l=n(e.binPath,["--bzzaccount",a||f,"--datadir",u,"--ens-api",c]),d=function(e){0===h&&i("Passphrase")(e)?setTimeout(function(){h=1,l.stdin.write(s+"\n")},500):i("Swarm http proxy started")(e)&&(h=2,clearTimeout(p),t(l))};l.stdout.on("data",d),l.stderr.on("data",d);var p=setTimeout(function(){return r(new Error("Couldn't start swarm process."))},2e4)})},B=function(e){return new Promise(function(t,r){e.stderr.removeAllListeners("data"),e.stdout.removeAllListeners("data"),e.stdin.removeAllListeners("error"),e.removeAllListeners("error"),e.removeAllListeners("exit"),e.kill("SIGINT");var n=setTimeout(function(){return e.kill("SIGKILL")},8e3);e.once("close",function(){clearTimeout(n),t()})})},P=function(e){return _(e)("test").then(function(e){return"c9a99c7d326dcc6316f32fe2625b311f6dc49a175e6877681ded93137d3569e7"===e}).catch(function(){return!1})},C=function(e){return function(t){return b(e)(t).then(function(e){try{return!!JSON.parse(R(e)).entries}catch(e){return!1}})}},N=function(e){return function(t,r,n,i,o){var a;return void 0!==t&&(a=e(t)),void 0!==r&&(a=e(r)),void 0!==n&&(a=e(n)),void 0!==i&&(a=e(i)),void 0!==o&&(a=e(o)),a}},R=function(e){return f.toString(f.fromUint8Array(e))},L=function(e){return f.toUint8Array(f.fromString(e))},O=function(e){return{download:function(t,r){return T(e)(t)(r)},downloadData:N(b(e)),downloadDataToDisk:N(g(e)),downloadDirectory:N(v(e)),downloadDirectoryToDisk:N(w(e)),downloadEntries:N(y(e)),downloadRoutes:N(m(e)),isAvailable:function(){return P(e)},upload:function(t){return I(e)(t)},uploadData:N(_(e)),uploadFile:N(E(e)),uploadFileFromDisk:N(E(e)),uploadDataFromDisk:N(S(e)),uploadDirectory:N(k(e)),uploadDirectoryFromDisk:N(M(e)),uploadToManifest:N(A(e)),pick:l,hash:h,fromString:L,toString:R}};return{at:O,local:function(e){return function(t){return P("http://localhost:8500").then(function(r){return r?t(O("http://localhost:8500")).then(function(){}):U(e.binPath,e.archives).onData(function(t){return(e.onProgress||function(){})(t.length)}).then(function(){return j(e)}).then(function(e){return t(O("http://localhost:8500")).then(function(){return e})}).then(B)})}},download:T,downloadBinary:U,downloadData:b,downloadDataToDisk:g,downloadDirectory:v,downloadDirectoryToDisk:w,downloadEntries:y,downloadRoutes:m,isAvailable:P,startProcess:j,stopProcess:B,upload:I,uploadData:_,uploadDataFromDisk:S,uploadFile:E,uploadFileFromDisk:x,uploadDirectory:k,uploadDirectoryFromDisk:M,uploadToManifest:A,pick:l,hash:h,fromString:L,toString:R}}},{}],323:[function(e,t,r){var n=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(n.isBuffer(e)){for(var t=new Uint8Array(e.length),r=e.length,i=0;i=0&&t<=A};function k(e){return function(t,r,n,i){r=m(r,i,4);var o=!x(t)&&y.keys(t),a=(o||t).length,s=e>0?0:a-1;return arguments.length<3&&(n=t[o?o[s]:s],s+=e),function(t,r,n,i,o,a){for(;o>=0&&o=0},y.invoke=function(e,t){var r=u.call(arguments,2),n=y.isFunction(t);return y.map(e,function(e){var i=n?t:e[t];return null==i?i:i.apply(e,r)})},y.pluck=function(e,t){return y.map(e,y.property(t))},y.where=function(e,t){return y.filter(e,y.matcher(t))},y.findWhere=function(e,t){return y.find(e,y.matcher(t))},y.max=function(e,t,r){var n,i,o=-1/0,a=-1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;so&&(o=n);else t=v(t,r),y.each(e,function(e,r,n){((i=t(e,r,n))>a||i===-1/0&&o===-1/0)&&(o=e,a=i)});return o},y.min=function(e,t,r){var n,i,o=1/0,a=1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;sn||void 0===r)return 1;if(r0?0:i-1;o>=0&&o0?a=o>=0?o:Math.max(o+s,a):s=o>=0?Math.min(o+1,s):o+s+1;else if(r&&o&&s)return n[o=r(n,i)]===i?o:-1;if(i!=i)return(o=t(u.call(n,a,s),y.isNaN))>=0?o+a:-1;for(o=e>0?a:s-1;o>=0&&ot?(a&&(clearTimeout(a),a=null),s=c,o=e.apply(n,i),a||(n=i=null)):a||!1===r.trailing||(a=setTimeout(u,f)),o}},y.debounce=function(e,t,r){var n,i,o,a,s,u=function(){var c=y.now()-a;c=0?n=setTimeout(u,t-c):(n=null,r||(s=e.apply(o,i),n||(o=i=null)))};return function(){o=this,i=arguments,a=y.now();var c=r&&!n;return n||(n=setTimeout(u,t)),c&&(s=e.apply(o,i),o=i=null),s}},y.wrap=function(e,t){return y.partial(t,e)},y.negate=function(e){return function(){return!e.apply(this,arguments)}},y.compose=function(){var e=arguments,t=e.length-1;return function(){for(var r=t,n=e[t].apply(this,arguments);r--;)n=e[r].call(this,n);return n}},y.after=function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},y.before=function(e,t){var r;return function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=null),r}},y.once=y.partial(y.before,2);var j=!{toString:null}.propertyIsEnumerable("toString"),B=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];function P(e,t){var r=B.length,n=e.constructor,i=y.isFunction(n)&&n.prototype||o,a="constructor";for(y.has(e,a)&&!y.contains(t,a)&&t.push(a);r--;)(a=B[r])in e&&e[a]!==i[a]&&!y.contains(t,a)&&t.push(a)}y.keys=function(e){if(!y.isObject(e))return[];if(l)return l(e);var t=[];for(var r in e)y.has(e,r)&&t.push(r);return j&&P(e,t),t},y.allKeys=function(e){if(!y.isObject(e))return[];var t=[];for(var r in e)t.push(r);return j&&P(e,t),t},y.values=function(e){for(var t=y.keys(e),r=t.length,n=Array(r),i=0;i":">",'"':""","'":"'","`":"`"},R=y.invert(N),L=function(e){var t=function(t){return e[t]},r="(?:"+y.keys(e).join("|")+")",n=RegExp(r),i=RegExp(r,"g");return function(e){return e=null==e?"":""+e,n.test(e)?e.replace(i,t):e}};y.escape=L(N),y.unescape=L(R),y.result=function(e,t,r){var n=null==e?void 0:e[t];return void 0===n&&(n=r),y.isFunction(n)?n.call(e):n};var O=0;y.uniqueId=function(e){var t=++O+"";return e?e+t:t},y.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var D=/(.)^/,F={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},q=/\\|'|\r|\n|\u2028|\u2029/g,H=function(e){return"\\"+F[e]};y.template=function(e,t,r){!t&&r&&(t=r),t=y.defaults({},t,y.templateSettings);var n=RegExp([(t.escape||D).source,(t.interpolate||D).source,(t.evaluate||D).source].join("|")+"|$","g"),i=0,o="__p+='";e.replace(n,function(t,r,n,a,s){return o+=e.slice(i,s).replace(q,H),i=s+t.length,r?o+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":n?o+="'+\n((__t=("+n+"))==null?'':__t)+\n'":a&&(o+="';\n"+a+"\n__p+='"),t}),o+="';\n",t.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{var a=new Function(t.variable||"obj","_",o)}catch(e){throw e.source=o,e}var s=function(e){return a.call(this,e,y)},u=t.variable||"obj";return s.source="function("+u+"){\n"+o+"}",s},y.chain=function(e){var t=y(e);return t._chain=!0,t};var z=function(e,t){return e._chain?y(t).chain():t};y.mixin=function(e){y.each(y.functions(e),function(t){var r=y[t]=e[t];y.prototype[t]=function(){var e=[this._wrapped];return s.apply(e,arguments),z(this,r.apply(y,e))}})},y.mixin(y),y.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=i[e];y.prototype[e]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==e&&"splice"!==e||0!==r.length||delete r[0],z(this,r)}}),y.each(["concat","join","slice"],function(e){var t=i[e];y.prototype[e]=function(){return z(this,t.apply(this._wrapped,arguments))}}),y.prototype.value=function(){return this._wrapped},y.prototype.valueOf=y.prototype.toJSON=y.prototype.value,y.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return y})}).call(this)},{}],326:[function(e,t,r){t.exports=function(e,t){if(t){t=(t=t.trim().replace(/^(\?|#|&)/,""))?"?"+t:t;var r=e.split(/[\?\#]/),n=r[0];t&&/\:\/\/[^\/]*$/.test(n)&&(n+="/");var i=e.match(/(\#.*)$/);e=n+t,i&&(e+=i[0])}return e}},{}],327:[function(e,t,r){"use strict";var n=e("punycode"),i=e("./util");function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}r.parse=g,r.resolve=function(e,t){return g(e,!1,!0).resolve(t)},r.resolveObject=function(e,t){return e?g(e,!1,!0).resolveObject(t):t},r.format=function(e){i.isString(e)&&(e=g(e));return e instanceof o?e.format():o.prototype.format.call(e)},r.Url=o;var a=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=e("querystring");function g(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o127?P+="x":P+=B[C];if(!P.match(d)){var R=U.slice(0,M),L=U.slice(M+1),O=B.match(p);O&&(R.push(O[1]),L.unshift(O[2])),L.length&&(g="/"+L.join(".")+g),this.hostname=R.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),T||(this.hostname=n.toASCII(this.hostname));var D=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+D,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==g[0]&&(g="/"+g))}if(!b[A])for(M=0,j=f.length;M0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift());return r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!E.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var k=E.slice(-1)[0],S=(r.host||e.host||E.length>1)&&("."===k||".."===k)||""===k,M=0,I=E.length;I>=0;I--)"."===(k=E[I])?E.splice(I,1):".."===k?(E.splice(I,1),M++):M&&(E.splice(I,1),M--);if(!_&&!A)for(;M--;M)E.unshift("..");!_||""===E[0]||E[0]&&"/"===E[0].charAt(0)||E.unshift(""),S&&"/"!==E.join("/").substr(-1)&&E.push("");var T,U=""===E[0]||E[0]&&"/"===E[0].charAt(0);x&&(r.hostname=r.host=U?"":E.length?E.shift():"",(T=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift()));return(_=_||r.host&&E.length)&&!U&&E.unshift(""),E.length?r.pathname=E.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":328,punycode:265,querystring:269}],328:[function(e,t,r){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],329:[function(e,t,r){(function(e){!function(n){var i="object"==typeof r&&r,o="object"==typeof t&&t&&t.exports==i&&t,a="object"==typeof e&&e;a.global!==a&&a.window!==a||(n=a);var s,u,c,f=String.fromCharCode;function h(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i=55296&&e<=57343)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value")}function d(e,t){return f(e>>t&63|128)}function p(e){if(0==(4294967168&e))return f(e);var t="";return 0==(4294965248&e)?t=f(e>>6&31|192):0==(4294901760&e)?(l(e),t=f(e>>12&15|224),t+=d(e,6)):0==(4292870144&e)&&(t=f(e>>18&7|240),t+=d(e,12),t+=d(e,6)),t+=f(63&e|128)}function b(){if(c>=u)throw Error("Invalid byte index");var e=255&s[c];if(c++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function y(){var e,t;if(c>u)throw Error("Invalid byte index");if(c==u)return!1;if(e=255&s[c],c++,0==(128&e))return e;if(192==(224&e)){if((t=(31&e)<<6|b())>=128)return t;throw Error("Invalid continuation byte")}if(224==(240&e)){if((t=(15&e)<<12|b()<<6|b())>=2048)return l(t),t;throw Error("Invalid continuation byte")}if(240==(248&e)&&(t=(15&e)<<18|b()<<12|b()<<6|b())>=65536&&t<=1114111)return t;throw Error("Invalid UTF-8 detected")}var m={version:"2.0.0",encode:function(e){for(var t=h(e),r=t.length,n=-1,i="";++n65535&&(i+=f((t-=65536)>>>10&1023|55296),t=56320|1023&t),i+=f(t);return i}(r)}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return m});else if(i&&!i.nodeType)if(o)o.exports=m;else{var v={}.hasOwnProperty;for(var g in m)v.call(m,g)&&(i[g]=m[g])}else n.utf8=m}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],330:[function(e,t,r){(function(e){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],331:[function(e,t,r){arguments[4][180][0].apply(r,arguments)},{dup:180}],332:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],333:[function(e,t,r){(function(t,n){var i=/%[sdj%]/g;r.format=function(e){if(!m(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(t)?n.showHidden=t:t&&r._extend(n,t),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,e,n.depth)}function u(e,t){var r=s.styles[t];return r?"["+s.colors[r][0]+"m"+e+"["+s.colors[r][1]+"m":e}function c(e,t){return e}function f(e,t,n){if(e.customInspect&&t&&E(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return m(i)||(i=f(e,i,n)),i}var o=function(e,t){if(v(t))return e.stylize("undefined","undefined");if(m(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(y(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(b(t))return e.stylize("null","null")}(e,t);if(o)return o;var a=Object.keys(t),s=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),A(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return h(t);if(0===a.length){if(E(t)){var u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","special")}if(g(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(_(t))return e.stylize(Date.prototype.toString.call(t),"date");if(A(t))return h(t)}var c,w="",x=!1,k=["{","}"];(d(t)&&(x=!0,k=["[","]"]),E(t))&&(w=" [Function"+(t.name?": "+t.name:"")+"]");return g(t)&&(w=" "+RegExp.prototype.toString.call(t)),_(t)&&(w=" "+Date.prototype.toUTCString.call(t)),A(t)&&(w=" "+h(t)),0!==a.length||x&&0!=t.length?n<0?g(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=x?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(c,w,k)):k[0]+w+k[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),M(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=b(r)?f(e,u.value,null):f(e,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n")):s=e.stylize("[Circular]","special")),v(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function b(e){return null===e}function y(e){return"number"==typeof e}function m(e){return"string"==typeof e}function v(e){return void 0===e}function g(e){return w(e)&&"[object RegExp]"===x(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===x(e)}function A(e){return w(e)&&("[object Error]"===x(e)||e instanceof Error)}function E(e){return"function"==typeof e}function x(e){return Object.prototype.toString.call(e)}function k(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(v(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=t.pid;a[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else a[e]=function(){};return a[e]},r.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(e){return null==e},r.isNumber=y,r.isString=m,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=v,r.isRegExp=g,r.isObject=w,r.isDate=_,r.isError=A,r.isFunction=E,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[k(e.getHours()),k(e.getMinutes()),k(e.getSeconds())].join(":"),[e.getDate(),S[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":332,_process:257,inherits:331}],334:[function(require,module,exports){var indexOf=require("indexof"),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},c.prototype.getCall=function(e){return n.isFunction(this.call)?this.call(e):this.call},c.prototype.extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},c.prototype.validateArgs=function(e){if(e.length!==this.params)throw i.InvalidNumberOfParams(e.length,this.params,this.name)},c.prototype.formatInput=function(e){var t=this;return this.inputFormatter?this.inputFormatter.map(function(r,n){return r?r.call(t,e[n]):e[n]}):e},c.prototype.formatOutput=function(e){var t=this;return n.isArray(e)?e.map(function(e){return t.outputFormatter&&e?t.outputFormatter(e):e}):this.outputFormatter&&e?this.outputFormatter(e):e},c.prototype.toPayload=function(e){var t=this.getCall(e),r=this.extractCallback(e),n=this.formatInput(e);this.validateArgs(n);var i={method:t,params:n,callback:r};return this.transformPayload&&(i=this.transformPayload(i)),i},c.prototype._confirmTransaction=function(e,t,r){var i=this,f=!1,h=!0,l=0,d=0,p=null,b="",y=n.isObject(r.params[0])&&r.params[0].gas?r.params[0].gas:null,m=n.isObject(r.params[0])&&r.params[0].data&&r.params[0].from&&!r.params[0].to,v=[new c({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:o.outputTransactionReceiptFormatter}),new c({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[o.inputAddressFormatter,o.inputDefaultBlockNumberFormatter]}),new u({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:o.outputBlockFormatter}}})],g={};n.each(v,function(e){e.attachToObject(g),e.requestManager=i.requestManager});var w=function(r,n,o,u,c){if(!o)return c||(c={unsubscribe:function(){clearInterval(p)}}),(r?s.resolve(r):g.getTransactionReceipt(t)).catch(function(t){c.unsubscribe(),f=!0,a._fireError({message:"Failed to check for transaction receipt:",data:t},e.eventEmitter,e.reject)}).then(function(t){if(!t||!t.blockHash)throw new Error("Receipt missing or blockHash null");return i.extraFormatters&&i.extraFormatters.receiptFormatter&&(t=i.extraFormatters.receiptFormatter(t)),e.eventEmitter.listeners("confirmation").length>0&&(void 0!==r&&0===d||e.eventEmitter.emit("confirmation",d,t),h=!1,25===++d&&(c.unsubscribe(),e.eventEmitter.removeAllListeners())),t}).then(function(t){if(m&&!f){if(!t.contractAddress)return h&&(c.unsubscribe(),f=!0),void a._fireError(new Error("The transaction receipt didn't contain a contract address."),e.eventEmitter,e.reject);g.getCode(t.contractAddress,function(r,n){n&&(n.length>2?(e.eventEmitter.emit("receipt",t),i.extraFormatters&&i.extraFormatters.contractDeployFormatter?e.resolve(i.extraFormatters.contractDeployFormatter(t)):e.resolve(t),h&&e.eventEmitter.removeAllListeners()):a._fireError(new Error("The contract code couldn't be stored, please check your gas limit."),e.eventEmitter,e.reject),h&&c.unsubscribe(),f=!0)})}return t}).then(function(t){m||f||(t.outOfGas||y&&y===t.gasUsed||!0!==t.status&&"0x1"!==t.status&&void 0!==t.status?(b=JSON.stringify(t,null,2),!1===t.status||"0x0"===t.status?a._fireError(new Error("Transaction has been reverted by the EVM:\n"+b),e.eventEmitter,e.reject):a._fireError(new Error("Transaction ran out of gas. Please provide more gas:\n"+b),e.eventEmitter,e.reject)):(e.eventEmitter.emit("receipt",t),e.resolve(t),h&&e.eventEmitter.removeAllListeners()),h&&c.unsubscribe(),f=!0)}).catch(function(){l++,n?l-1>=750&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject)):l-1>=50&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject))});c.unsubscribe(),f=!0,a._fireError({message:"Failed to subscribe to new newBlockHeaders to confirm the transaction receipts.",data:o},e.eventEmitter,e.reject)},_=function(e){n.isFunction(this.requestManager.provider.on)?g.subscribe("newBlockHeaders",w.bind(null,e,!1)):p=setInterval(w.bind(null,e,!0),1e3)}.bind(this);g.getTransactionReceipt(t).then(function(t){t&&t.blockHash?(e.eventEmitter.listeners("confirmation").length>0&&_(t),w(t,!1)):f||_()}).catch(function(){f||_()})};var f=function(e,t){return n.isNumber(e)?t.wallet[e]:n.isObject(e)&&e.address&&e.privateKey?e:t.wallet[e.toLowerCase()]};c.prototype.buildCall=function(){var e=this,t="eth_sendTransaction"===e.call||"eth_sendRawTransaction"===e.call,r=function(){var r=s(!t),i=e.toPayload(Array.prototype.slice.call(arguments)),o=function(n,o){try{o=e.formatOutput(o)}catch(e){n=e}if(o instanceof Error&&(n=o),n)return n.error&&(n=n.error),a._fireError(n,r.eventEmitter,r.reject,i.callback);i.callback&&i.callback(null,o),t?(r.eventEmitter.emit("transactionHash",o),e._confirmTransaction(r,o,i)):n||r.resolve(o)},u=function(t){var r=n.extend({},i,{method:"eth_sendRawTransaction",params:[t.rawTransaction]});e.requestManager.send(r,o)},h=function(e,t){var i;if(t&&t.accounts&&t.accounts.wallet&&t.accounts.wallet.length)if("eth_sendTransaction"===e.method){var a=e.params[0];if((i=f(n.isObject(a)?a.from:null,t.accounts))&&i.privateKey)return t.accounts.signTransaction(n.omit(a,"from"),i.privateKey).then(u)}else if("eth_sign"===e.method){var s=e.params[1];if((i=f(e.params[0],t.accounts))&&i.privateKey){var c=t.accounts.sign(s,i.privateKey);return e.callback&&e.callback(null,c.signature),void r.resolve(c.signature)}}return t.requestManager.send(e,o)};t&&n.isObject(i.params[0])&&void 0===i.params[0].gasPrice?new c({name:"getGasPrice",call:"eth_gasPrice",params:0}).createFunction(e.requestManager)(function(t,r){r&&(i.params[0].gasPrice=r),h(i,e)}):h(i,e);return r.eventEmitter};return r.method=e,r.request=this.request.bind(this),r},c.prototype.request=function(){var e=this.toPayload(Array.prototype.slice.call(arguments));return e.format=this.formatOutput.bind(this),e},t.exports=c},{underscore:325,"web3-core-helpers":338,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-utils":403}],340:[function(e,t,r){"use strict";var n=e("eventemitter3"),i=e("any-promise"),o=function(e){var t,r,o=new i(function(){t=arguments[0],r=arguments[1]});if(e)return{resolve:t,reject:r,eventEmitter:o};var a=new n;return o._events=a._events,o.emit=a.emit,o.on=a.on,o.once=a.once,o.off=a.off,o.listeners=a.listeners,o.addListener=a.addListener,o.removeListener=a.removeListener,o.removeAllListeners=a.removeAllListeners,{resolve:t,reject:r,eventEmitter:o}};o.resolve=function(e){var t=o(!0);return t.resolve(e),t.eventEmitter},t.exports=o},{"any-promise":2,eventemitter3:156}],341:[function(e,t,r){"use strict";var n=e("./jsonrpc"),i=e("web3-core-helpers").errors,o=function(e){this.requestManager=e,this.requests=[]};o.prototype.add=function(e){this.requests.push(e)},o.prototype.execute=function(){var e=this.requests;this.requestManager.sendBatch(e,function(t,r){r=r||[],e.map(function(e,t){return r[t]||{}}).forEach(function(t,r){if(e[r].callback){if(t&&t.error)return e[r].callback(i.ErrorResponse(t));if(!n.isValidResponse(t))return e[r].callback(i.InvalidResponse(t));try{e[r].callback(null,e[r].format?e[r].format(t.result):t.result)}catch(t){e[r].callback(t)}}})})},t.exports=o},{"./jsonrpc":344,"web3-core-helpers":338}],342:[function(e,t,r){"use strict";var n=null,i=window;void 0!==i.ethereumProvider?n=i.ethereumProvider:void 0!==i.web3&&i.web3.currentProvider&&(i.web3.currentProvider.sendAsync&&(i.web3.currentProvider.send=i.web3.currentProvider.sendAsync,delete i.web3.currentProvider.sendAsync),!i.web3.currentProvider.on&&i.web3.currentProvider.connection&&"ipcProviderWrapper"===i.web3.currentProvider.connection.constructor.name&&(i.web3.currentProvider.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.connection.on("data",function(e){var r="";e=e.toString();try{r=JSON.parse(e)}catch(r){return t(new Error("Couldn't parse response data"+e))}r.id||-1===r.method.indexOf("_subscription")||t(null,r)});break;default:this.connection.on(e,t)}}),n=i.web3.currentProvider),t.exports=n},{}],343:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("./jsonrpc.js"),a=e("./batch.js"),s=e("./givenProvider.js"),u=function e(t){this.provider=null,this.providers=e.providers,this.setProvider(t),this.subscriptions={}};u.givenProvider=s,u.providers={WebsocketProvider:e("web3-providers-ws"),HttpProvider:e("web3-providers-http"),IpcProvider:e("web3-providers-ipc")},u.prototype.setProvider=function(e,t){var r=this;if(e&&"string"==typeof e&&this.providers)if(/^http(s)?:\/\//i.test(e))e=new this.providers.HttpProvider(e);else if(/^ws(s)?:\/\//i.test(e))e=new this.providers.WebsocketProvider(e);else if(e&&"object"==typeof t&&"function"==typeof t.connect)e=new this.providers.IpcProvider(e,t);else if(e)throw new Error("Can't autodetect provider for \""+e+'"');this.provider&&this.provider.connected&&this.clearSubscriptions(),this.provider=e||null,this.provider&&this.provider.on&&this.provider.on("data",function(e,t){(e=e||t).method&&r.subscriptions[e.params.subscription]&&r.subscriptions[e.params.subscription].callback&&r.subscriptions[e.params.subscription].callback(null,e.params.result)})},u.prototype.send=function(e,t){if(t=t||function(){},!this.provider)return t(i.InvalidProvider());var r=o.toPayload(e.method,e.params);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,n){return n&&n.id&&r.id!==n.id?t(new Error('Wrong response id "'+n.id+'" (expected: "'+r.id+'") in '+JSON.stringify(r))):e?t(e):n&&n.error?t(i.ErrorResponse(n)):o.isValidResponse(n)?void t(null,n.result):t(i.InvalidResponse(n))})},u.prototype.sendBatch=function(e,t){if(!this.provider)return t(i.InvalidProvider());var r=o.toBatchPayload(e);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,r){return e?t(e):n.isArray(r)?void t(null,r):t(i.InvalidResponse(r))})},u.prototype.addSubscription=function(e,t,r,n){if(!this.provider.on)throw new Error("The provider doesn't support subscriptions: "+this.provider.constructor.name);this.subscriptions[e]={callback:n,type:r,name:t}},u.prototype.removeSubscription=function(e,t){this.subscriptions[e]&&(this.send({method:this.subscriptions[e].type+"_unsubscribe",params:[e]},t),delete this.subscriptions[e])},u.prototype.clearSubscriptions=function(e){var t=this;Object.keys(this.subscriptions).forEach(function(r){e&&"syncing"===t.subscriptions[r].name||t.removeSubscription(r)}),this.provider.reset&&this.provider.reset()},t.exports={Manager:u,BatchManager:a}},{"./batch.js":341,"./givenProvider.js":342,"./jsonrpc.js":344,underscore:325,"web3-core-helpers":338,"web3-providers-http":398,"web3-providers-ipc":399,"web3-providers-ws":400}],344:[function(e,t,r){"use strict";var n={messageId:0,toPayload:function(e,t){if(!e)throw new Error('JSONRPC method should be specified for params: "'+JSON.stringify(t)+'"!');return n.messageId++,{jsonrpc:"2.0",id:n.messageId,method:e,params:t||[]}},isValidResponse:function(e){return Array.isArray(e)?e.every(t):t(e);function t(e){return!(!e||e.error||"2.0"!==e.jsonrpc||"number"!=typeof e.id&&"string"!=typeof e.id||void 0===e.result)}},toBatchPayload:function(e){return e.map(function(e){return n.toPayload(e.method,e.params)})}};t.exports=n},{}],345:[function(e,t,r){"use strict";var n=e("./subscription.js"),i=function(e){this.name=e.name,this.type=e.type,this.subscriptions=e.subscriptions||{},this.requestManager=null};i.prototype.setRequestManager=function(e){this.requestManager=e},i.prototype.attachToObject=function(e){var t=this.buildCall(),r=this.name.split(".");r.length>1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},i.prototype.buildCall=function(){var e=this;return function(){e.subscriptions[arguments[0]]||console.warn("Subscription "+JSON.stringify(arguments[0])+" doesn't exist. Subscribing anyway.");var t=new n({subscription:e.subscriptions[arguments[0]],requestManager:e.requestManager,type:e.type});return t.subscribe.apply(t,arguments)}},t.exports={subscriptions:i,subscription:n}},{"./subscription.js":346}],346:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("eventemitter3");function a(e){o.call(this),this.id=null,this.callback=n.identity,this.arguments=null,this._reconnectIntervalId=null,this.options={subscription:e.subscription,type:e.type,requestManager:e.requestManager}}a.prototype=Object.create(o.prototype),a.prototype.constructor=a,a.prototype._extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},a.prototype._validateArgs=function(e){var t=this.options.subscription;if(t||(t={}),t.params||(t.params=0),e.length!==t.params)throw i.InvalidNumberOfParams(e.length,t.params+1,e[0])},a.prototype._formatInput=function(e){var t=this.options.subscription;return t&&t.inputFormatter?t.inputFormatter.map(function(t,r){return t?t(e[r]):e[r]}):e},a.prototype._formatOutput=function(e){var t=this.options.subscription;return t&&t.outputFormatter&&e?t.outputFormatter(e):e},a.prototype._toPayload=function(e){var t=[];if(this.callback=this._extractCallback(e)||n.identity,this.subscriptionMethod||(this.subscriptionMethod=e.shift(),this.options.subscription.subscriptionName&&(this.subscriptionMethod=this.options.subscription.subscriptionName)),this.arguments||(this.arguments=this._formatInput(e),this._validateArgs(this.arguments),e=[]),t.push(this.subscriptionMethod),t=t.concat(this.arguments),e.length)throw new Error("Only a callback is allowed as parameter on an already instantiated subscription.");return{method:this.options.type+"_subscribe",params:t}},a.prototype.unsubscribe=function(e){this.options.requestManager.removeSubscription(this.id,e),this.id=null,this.removeAllListeners(),clearInterval(this._reconnectIntervalId)},a.prototype.subscribe=function(){var e=this,t=Array.prototype.slice.call(arguments),r=this._toPayload(t);if(!r)return this;if(!this.options.requestManager.provider){var i=new Error("No provider set.");return this.callback(i,null,this),this.emit("error",i),this}if(!this.options.requestManager.provider.on){var o=new Error("The current provider doesn't support subscriptions: "+this.options.requestManager.provider.constructor.name);return this.callback(o,null,this),this.emit("error",o),this}return this.id&&this.unsubscribe(),this.options.params=r.params[1],"logs"===r.params[0]&&n.isObject(r.params[1])&&r.params[1].hasOwnProperty("fromBlock")&&isFinite(r.params[1].fromBlock)&&this.options.requestManager.send({method:"eth_getLogs",params:[r.params[1]]},function(t,r){t?(e.callback(t,null,e),e.emit("error",t)):r.forEach(function(t){var r=e._formatOutput(t);e.callback(null,r,e),e.emit("data",r)})}),"object"==typeof r.params[1]&&delete r.params[1].fromBlock,this.options.requestManager.send(r,function(t,i){!t&&i?(e.id=i,e.options.requestManager.addSubscription(e.id,r.params[0],e.options.type,function(t,r){t?(e.options.requestManager.removeSubscription(e.id),e.options.requestManager.provider.once&&(e._reconnectIntervalId=setInterval(function(){e.options.requestManager.provider.reconnect&&e.options.requestManager.provider.reconnect()},500),e.options.requestManager.provider.once("connect",function(){clearInterval(e._reconnectIntervalId),e.subscribe(e.callback)})),e.emit("error",t),e.callback(t,null,e)):(n.isArray(r)||(r=[r]),r.forEach(function(t){var r=e._formatOutput(t);if(n.isFunction(e.options.subscription.subscriptionHandler))return e.options.subscription.subscriptionHandler.call(e,r);e.emit("data",r),e.callback(null,r,e)}))})):(e.callback(t,null,e),e.emit("error",t))}),this},t.exports=a},{eventemitter3:156,underscore:325,"web3-core-helpers":338}],347:[function(e,t,r){"use strict";var n=e("web3-core-helpers").formatters,i=e("web3-core-method"),o=e("web3-utils");t.exports=function(e){var t=function(t){var r;return t.property?(e[t.property]||(e[t.property]={}),r=e[t.property]):r=e,t.methods&&t.methods.forEach(function(t){t instanceof i||(t=new i(t)),t.attachToObject(r),t.setRequestManager(e._requestManager)}),e};return t.formatters=n,t.utils=o,t.Method=i,t}},{"web3-core-helpers":338,"web3-core-method":339,"web3-utils":403}],348:[function(e,t,r){"use strict";var n=e("web3-core-requestmanager"),i=e("./extend.js");t.exports={packageInit:function(e,t){if(t=Array.prototype.slice.call(t),!e)throw new Error('You need to instantiate using the "new" keyword.');Object.defineProperty(e,"currentProvider",{get:function(){return e._provider},set:function(t){return e.setProvider(t)},enumerable:!0,configurable:!0}),t[0]&&t[0]._requestManager?e._requestManager=new n.Manager(t[0].currentProvider):(e._requestManager=new n.Manager,e._requestManager.setProvider(t[0],t[1])),e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers,e._provider=e._requestManager.provider,e.setProvider||(e.setProvider=function(t,r){return e._requestManager.setProvider(t,r),e._provider=e._requestManager.provider,!0}),e.BatchRequest=n.BatchManager.bind(null,e._requestManager),e.extend=i(e)},addProviders:function(e){e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers}}},{"./extend.js":347,"web3-core-requestmanager":343}],349:[function(e,t,r){var n=e("underscore"),i=e("web3-utils"),o=new(0,e("ethers/utils/abi-coder").AbiCoder)(function(e,t){return!e.match(/^u?int/)||n.isArray(t)||n.isObject(t)&&"BN"===t.constructor.name?t:t.toString()});function a(){}var s=function(){};s.prototype.encodeFunctionSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e).slice(0,10)},s.prototype.encodeEventSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e)},s.prototype.encodeParameter=function(e,t){return this.encodeParameters([e],[t])},s.prototype.encodeParameters=function(e,t){return o.encode(this.mapTypes(e),t)},s.prototype.mapTypes=function(e){var t=this,r=[];return e.forEach(function(e){if(t.isSimplifiedStructFormat(e)){var n=Object.keys(e)[0];r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}else r.push(e)}),r},s.prototype.isSimplifiedStructFormat=function(e){return"object"==typeof e&&void 0===e.components&&void 0===e.name},s.prototype.mapStructNameAndType=function(e){var t="tuple";return e.indexOf("[]")>-1&&(t="tuple[]",e=e.slice(0,-2)),{type:t,name:e}},s.prototype.mapStructToCoderFormat=function(e){var t=this,r=[];return Object.keys(e).forEach(function(n){"object"!=typeof e[n]?r.push({name:n,type:e[n]}):r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}),r},s.prototype.encodeFunctionCall=function(e,t){return this.encodeFunctionSignature(e)+this.encodeParameters(e.inputs,t).replace("0x","")},s.prototype.decodeParameter=function(e,t){return this.decodeParameters([e],t)[0]},s.prototype.decodeParameters=function(e,t){if(!t||"0x"===t||"0X"===t)throw new Error("Returned values aren't valid, did it run Out of Gas?");var r=o.decode(this.mapTypes(e),"0x"+t.replace(/0x/i,"")),i=new a;return i.__length__=0,e.forEach(function(e,t){var o=r[i.__length__];o="0x"===o?null:o,i[t]=o,n.isObject(e)&&e.name&&(i[e.name]=o),i.__length__++}),i},s.prototype.decodeLog=function(e,t,r){var i=this;r=n.isArray(r)?r:[r],t=t||"";var o=[],s=[],u=0;e.forEach(function(e,t){e.indexed?(s[t]=["bool","int","uint","address","fixed","ufixed"].find(function(t){return-1!==e.type.indexOf(t)})?i.decodeParameter(e.type,r[u]):r[u],u++):o[t]=e});var c=t,f=c?this.decodeParameters(o,c):[],h=new a;return h.__length__=0,e.forEach(function(e,t){h[t]="string"===e.type?"":null,void 0!==f[t]&&(h[t]=f[t]),void 0!==s[t]&&(h[t]=s[t]),e.name&&(h[e.name]=h[t]),h.__length__++}),h};var u=new s;t.exports=u},{"ethers/utils/abi-coder":143,underscore:325,"web3-utils":403}],350:[function(e,t,r){(function(r){var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=e("./bytes"),o=e("./nat"),a=e("elliptic"),s=(e("./rlp"),new a.ec("secp256k1")),u=e("./hash"),c=u.keccak256,f=u.keccak256s,h=function(e){for(var t=f(e.slice(2)),r="0x",n=0;n<40;n++)r+=parseInt(t[n+2],16)>7?e[n+2].toUpperCase():e[n+2];return r},l=function(e){var t=new r(e.slice(2),"hex"),n="0x"+s.keyFromPrivate(t).getPublic(!1,"hex").slice(2),i=c(n);return{address:h("0x"+i.slice(-40)),privateKey:e}},d=function(e){var t=n(e,3),r=t[0],o=i.pad(32,t[1]),a=i.pad(32,t[2]);return i.flatten([o,a,r])},p=function(e){return[i.slice(64,i.length(e),e),i.slice(0,32,e),i.slice(32,64,e)]},b=function(e){return function(t,n){var a=s.keyFromPrivate(new r(n.slice(2),"hex")).sign(new r(t.slice(2),"hex"),{canonical:!0});return d([o.fromString(i.fromNumber(e+a.recoveryParam)),i.pad(32,i.fromNat("0x"+a.r.toString(16))),i.pad(32,i.fromNat("0x"+a.s.toString(16)))])}},y=b(27);t.exports={create:function(e){var t=c(i.concat(i.random(32),e||i.random(32))),r=i.concat(i.concat(i.random(32),t),i.random(32)),n=c(r);return l(n)},toChecksum:h,fromPrivate:l,sign:y,makeSigner:b,recover:function(e,t){var n=p(t),o={v:i.toNumber(n[0]),r:n[1].slice(2),s:n[2].slice(2)},a="0x"+s.recoverPubKey(new r(e.slice(2),"hex"),o,o.v<2?o.v:1-o.v%2).encode("hex",!1).slice(2),u=c(a);return h("0x"+u.slice(-40))},encodeSignature:d,decodeSignature:p}}).call(this,e("buffer").Buffer)},{"./bytes":352,"./hash":353,"./nat":354,"./rlp":355,buffer:84,elliptic:109}],351:[function(e,t,r){arguments[4][132][0].apply(r,arguments)},{dup:132}],352:[function(e,t,r){arguments[4][133][0].apply(r,arguments)},{"./array.js":351,dup:133}],353:[function(e,t,r){arguments[4][134][0].apply(r,arguments)},{dup:134}],354:[function(e,t,r){var n=e("bn.js"),i=e("./bytes"),o=function(e){return new n(e.slice(2),16)},a=function(e){var t="0x"+("0x"===e.slice(0,2)?new n(e.slice(2),16):new n(e,10)).toString("hex");return"0x0"===t?"0x":t},s=function(e){return"string"==typeof e?/^0x/.test(e)?e:"0x"+e:"0x"+new n(e).toString("hex")},u=function(e){return o(e).toNumber()},c=function(e){return function(t,r){return"0x"+o(t)[e](o(r)).toString("hex")}},f=c("add"),h=c("mul"),l=c("div"),d=c("sub");t.exports={toString:function(e){return o(e).toString(10)},fromString:a,toNumber:u,fromNumber:s,toEther:function(e){return u(l(e,a("10000000000")))/1e8},fromEther:function(e){return h(s(Math.floor(1e8*e)),a("10000000000"))},toUint256:function(e){return i.pad(32,e)},add:f,mul:h,div:l,sub:d}},{"./bytes":352,"bn.js":53}],355:[function(e,t,r){t.exports={encode:function(e){var t=function(e){return(t=e.toString(16)).length%2==0?t:"0"+t;var t},r=function(e,r){return e<56?t(r+e):t(r+t(e).length/2+55)+t(e)};return"0x"+function e(t){if("string"==typeof t){var n=t.slice(2);return(2!=n.length||n>="80"?r(n.length/2,128):"")+n}var i=t.map(e).join("");return r(i.length/2,192)+i}(e)},decode:function(e){var t=2,r=function(){if(t>=e.length)throw"";var r=e.slice(t,t+2);return r<"80"?(t+=2,"0x"+r):r<"c0"?i():o()},n=function(){var r=parseInt(e.slice(t,t+=2),16)%64;return r<56?r:parseInt(e.slice(t,t+=2*(r-55)),16)},i=function(){var r=n();return"0x"+e.slice(t,t+=2*r)},o=function(){for(var e=2*n()+t,i=[];t>>((3&t)<<3)&255;return i}}t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],357:[function(e,t,r){for(var n=e("./rng"),i=[],o={},a=0;a<256;a++)i[a]=(a+256).toString(16).substr(1),o[i[a]]=a;function s(e,t){var r=t||0,n=i;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var u=n(),c=[1|u[0],u[1],u[2],u[3],u[4],u[5]],f=16383&(u[6]<<8|u[7]),h=0,l=0;function d(e,t,r){var i=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||n)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var a=0;a<16;a++)t[i+a]=o[a];return t||s(o)}var p=d;p.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:f,a=void 0!==e.msecs?e.msecs:(new Date).getTime(),u=void 0!==e.nsecs?e.nsecs:l+1,d=a-h+(u-l)/1e4;if(d<0&&void 0===e.clockseq&&(o=o+1&16383),(d<0||a>h)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");h=a,l=u,f=o;var p=(1e4*(268435455&(a+=122192928e5))+u)%4294967296;i[n++]=p>>>24&255,i[n++]=p>>>16&255,i[n++]=p>>>8&255,i[n++]=255&p;var b=a/4294967296*1e4&268435455;i[n++]=b>>>8&255,i[n++]=255&b,i[n++]=b>>>24&15|16,i[n++]=b>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var y=e.node||c,m=0;m<6;m++)i[n+m]=y[m];return t||s(i)},p.v4=d,p.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=o[e])});i<16;)t[n+i++]=0;return t},p.unparse=s,t.exports=p},{"./rng":356}],358:[function(e,t,r){(function(r,n){"use strict";var i=e("underscore"),o=e("web3-core"),a=e("web3-core-method"),s=e("any-promise"),u=e("eth-lib/lib/account"),c=e("eth-lib/lib/hash"),f=e("eth-lib/lib/rlp"),h=e("eth-lib/lib/nat"),l=e("eth-lib/lib/bytes"),d=e(void 0===r?"crypto-browserify":"crypto"),p=e("scrypt.js"),b=e("uuid"),y=e("web3-utils"),m=e("web3-core-helpers"),v=function(e){return i.isUndefined(e)||i.isNull(e)},g=function(e){for(;e&&e.startsWith("0x0");)e="0x"+e.slice(3);return e},w=function(e){return e.length%2==1&&(e=e.replace("0x","0x0")),e},_=function(){var e=this;o.packageInit(this,arguments),delete this.BatchRequest,delete this.extend;var t=[new a({name:"getId",call:"net_version",params:0,outputFormatter:y.hexToNumber}),new a({name:"getGasPrice",call:"eth_gasPrice",params:0}),new a({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[function(e){if(y.isAddress(e))return e;throw new Error("Address "+e+' is not a valid address to get the "transactionCount".')},function(){return"latest"}]})];this._ethereumCall={},i.each(t,function(t){t.attachToObject(e._ethereumCall),t.setRequestManager(e._requestManager)}),this.wallet=new A(this)};function A(e){this._accounts=e,this.length=0,this.defaultKeyName="web3js_wallet"}_.prototype._addAccountFunctions=function(e){var t=this;return e.signTransaction=function(r,n){return t.signTransaction(r,e.privateKey,n)},e.sign=function(r){return t.sign(r,e.privateKey)},e.encrypt=function(r,n){return t.encrypt(e.privateKey,r,n)},e},_.prototype.create=function(e){return this._addAccountFunctions(u.create(e||y.randomHex(32)))},_.prototype.privateKeyToAccount=function(e){return this._addAccountFunctions(u.fromPrivate(e))},_.prototype.signTransaction=function(e,t,r){var n,o=!1;if(r=r||function(){},!e)return o=new Error("No transaction object given!"),r(o),s.reject(o);function a(e){if(e.gas||e.gasLimit||(o=new Error('"gas" is missing')),(e.nonce<0||e.gas<0||e.gasPrice<0||e.chainId<0)&&(o=new Error("Gas, gasPrice, nonce or chainId is lower than 0")),o)return r(o),s.reject(o);try{var i=e=m.formatters.inputCallFormatter(e);i.to=e.to||"0x",i.data=e.data||"0x",i.value=e.value||"0x",i.chainId=y.numberToHex(e.chainId);var a=f.encode([l.fromNat(i.nonce),l.fromNat(i.gasPrice),l.fromNat(i.gas),i.to.toLowerCase(),l.fromNat(i.value),i.data,l.fromNat(i.chainId||"0x1"),"0x","0x"]),d=c.keccak256(a),p=u.makeSigner(2*h.toNumber(i.chainId||"0x1")+35)(c.keccak256(a),t),b=f.decode(a).slice(0,6).concat(u.decodeSignature(p));b[6]=w(g(b[6])),b[7]=w(g(b[7])),b[8]=w(g(b[8]));var v=f.encode(b),_=f.decode(v);n={messageHash:d,v:g(_[6]),r:g(_[7]),s:g(_[8]),rawTransaction:v}}catch(e){return r(e),s.reject(e)}return r(null,n),n}return void 0!==e.nonce&&void 0!==e.chainId&&void 0!==e.gasPrice?s.resolve(a(e)):s.all([v(e.chainId)?this._ethereumCall.getId():e.chainId,v(e.gasPrice)?this._ethereumCall.getGasPrice():e.gasPrice,v(e.nonce)?this._ethereumCall.getTransactionCount(this.privateKeyToAccount(t).address):e.nonce]).then(function(t){if(v(t[0])||v(t[1])||v(t[2]))throw new Error('One of the values "chainId", "gasPrice", or "nonce" couldn\'t be fetched: '+JSON.stringify(t));return a(i.extend(e,{chainId:t[0],gasPrice:t[1],nonce:t[2]}))})},_.prototype.recoverTransaction=function(e){var t=f.decode(e),r=u.encodeSignature(t.slice(6,9)),n=l.toNumber(t[6]),i=n<35?[]:[l.fromNumber(n-35>>1),"0x","0x"],o=t.slice(0,6).concat(i),a=f.encode(o);return u.recover(c.keccak256(a),r)},_.prototype.hashMessage=function(e){var t=y.isHexStrict(e)?y.hexToBytes(e):e,r=n.from(t),i="Ethereum Signed Message:\n"+t.length,o=n.from(i),a=n.concat([o,r]);return c.keccak256s(a)},_.prototype.sign=function(e,t){var r=this.hashMessage(e),n=u.sign(r,t),i=u.decodeSignature(n);return{message:e,messageHash:r,v:i[0],r:i[1],s:i[2],signature:n}},_.prototype.recover=function(e,t,r){var n=[].slice.apply(arguments);return i.isObject(e)?this.recover(e.messageHash,u.encodeSignature([e.v,e.r,e.s]),!0):(r||(e=this.hashMessage(e)),n.length>=4?(r=n.slice(-1)[0],r=!!i.isBoolean(r)&&!!r,this.recover(e,u.encodeSignature(n.slice(1,4)),r)):u.recover(e,t))},_.prototype.decrypt=function(e,t,r){if(!i.isString(t))throw new Error("No password given.");var o,a,s=i.isObject(e)?e:JSON.parse(r?e.toLowerCase():e);if(3!==s.version)throw new Error("Not a valid V3 wallet");if("scrypt"===s.crypto.kdf)a=s.crypto.kdfparams,o=p(new n(t),new n(a.salt,"hex"),a.n,a.r,a.p,a.dklen);else{if("pbkdf2"!==s.crypto.kdf)throw new Error("Unsupported key derivation scheme");if("hmac-sha256"!==(a=s.crypto.kdfparams).prf)throw new Error("Unsupported parameters to PBKDF2");o=d.pbkdf2Sync(new n(t),new n(a.salt,"hex"),a.c,a.dklen,"sha256")}var u=new n(s.crypto.ciphertext,"hex");if(y.sha3(n.concat([o.slice(16,32),u])).replace("0x","")!==s.crypto.mac)throw new Error("Key derivation failed - possibly wrong password");var c=d.createDecipheriv(s.crypto.cipher,o.slice(0,16),new n(s.crypto.cipherparams.iv,"hex")),f="0x"+n.concat([c.update(u),c.final()]).toString("hex");return this.privateKeyToAccount(f)},_.prototype.encrypt=function(e,t,r){var i,o=this.privateKeyToAccount(e),a=(r=r||{}).salt||d.randomBytes(32),s=r.iv||d.randomBytes(16),u=r.kdf||"scrypt",c={dklen:r.dklen||32,salt:a.toString("hex")};if("pbkdf2"===u)c.c=r.c||262144,c.prf="hmac-sha256",i=d.pbkdf2Sync(new n(t),a,c.c,c.dklen,"sha256");else{if("scrypt"!==u)throw new Error("Unsupported kdf");c.n=r.n||8192,c.r=r.r||8,c.p=r.p||1,i=p(new n(t),a,c.n,c.r,c.p,c.dklen)}var f=d.createCipheriv(r.cipher||"aes-128-ctr",i.slice(0,16),s);if(!f)throw new Error("Unsupported cipher");var h=n.concat([f.update(new n(o.privateKey.replace("0x",""),"hex")),f.final()]),l=y.sha3(n.concat([i.slice(16,32),new n(h,"hex")])).replace("0x","");return{version:3,id:b.v4({random:r.uuid||d.randomBytes(16)}),address:o.address.toLowerCase().replace("0x",""),crypto:{ciphertext:h.toString("hex"),cipherparams:{iv:s.toString("hex")},cipher:r.cipher||"aes-128-ctr",kdf:u,kdfparams:c,mac:l.toString("hex")}}},A.prototype._findSafeIndex=function(e){return e=e||0,i.has(this,e)?this._findSafeIndex(e+1):e},A.prototype._currentIndexes=function(){return Object.keys(this).map(function(e){return parseInt(e)}).filter(function(e){return e<9e20})},A.prototype.create=function(e,t){for(var r=0;r=2?t.slice(2):t;var r=h.decodeParameters(e,t);return 1===r.__length__?r[0]:(delete r.__length__,r)},l.prototype.deploy=function(e,t){if((e=e||{}).arguments=e.arguments||[],!(e=this._getOrSetDefaultOptions(e)).data)return a._fireError(new Error('No "data" specified in neither the given options, nor the default options.'),null,null,t);var r=n.find(this.options.jsonInterface,function(e){return"constructor"===e.type})||{};return r.signature="constructor",this._createTxObject.apply({method:r,parent:this,deployData:e.data,_ethAccounts:this.constructor._ethAccounts},e.arguments)},l.prototype._generateEventOptions=function(){var e=Array.prototype.slice.call(arguments),t=this._getCallback(e),r=n.isObject(e[e.length-1])?e.pop():{},i=n.isString(e[0])?e[0]:"allevents";if(!(i="allevents"===i.toLowerCase()?{name:"ALLEVENTS",jsonInterface:this.options.jsonInterface}:this.options.jsonInterface.find(function(e){return"event"===e.type&&(e.name===i||e.signature==="0x"+i.replace("0x",""))})))throw new Error('Event "'+i.name+"\" doesn't exist in this contract.");if(!a.isAddress(this.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return{params:this._encodeEventABI(i,r),event:i,callback:t}},l.prototype.clone=function(){return new this.constructor(this.options.jsonInterface,this.options.address,this.options)},l.prototype.once=function(e,t,r){var i=Array.prototype.slice.call(arguments);if(!(r=this._getCallback(i)))throw new Error("Once requires a callback as the second parameter.");t&&delete t.fromBlock,this._on(e,t,function(e,t,i){i.unsubscribe(),n.isFunction(r)&&r(e,t,i)})},l.prototype._on=function(){var e=this._generateEventOptions.apply(this,arguments);this._checkListener("newListener",e.event.name,e.callback),this._checkListener("removeListener",e.event.name,e.callback);var t=new s({subscription:{params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event),subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},type:"eth",requestManager:this._requestManager});return t.subscribe("logs",e.params,e.callback||function(){}),t},l.prototype.getPastEvents=function(){var e=this._generateEventOptions.apply(this,arguments),t=new o({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event)});t.setRequestManager(this._requestManager);var r=t.buildCall();return t=null,r(e.params,e.callback)},l.prototype._createTxObject=function(){var e=Array.prototype.slice.call(arguments),t={};if("function"===this.method.type&&(t.call=this.parent._executeMethod.bind(t,"call"),t.call.request=this.parent._executeMethod.bind(t,"call",!0)),t.send=this.parent._executeMethod.bind(t,"send"),t.send.request=this.parent._executeMethod.bind(t,"send",!0),t.encodeABI=this.parent._encodeMethodABI.bind(t),t.estimateGas=this.parent._executeMethod.bind(t,"estimate"),e&&this.method.inputs&&e.length!==this.method.inputs.length){if(this.nextMethod)return this.nextMethod.apply(null,e);throw c.InvalidNumberOfParams(e.length,this.method.inputs.length,this.method.name)}return t.arguments=e||[],t._method=this.method,t._parent=this.parent,t._ethAccounts=this.parent.constructor._ethAccounts||this._ethAccounts,this.deployData&&(t._deployData=this.deployData),t},l.prototype._processExecuteArguments=function(e,t){var r={};if(r.type=e.shift(),r.callback=this._parent._getCallback(e),"call"===r.type&&!0!==e[e.length-1]&&(n.isString(e[e.length-1])||isFinite(e[e.length-1]))&&(r.defaultBlock=e.pop()),r.options=n.isObject(e[e.length-1])?e.pop():{},r.generateRequest=!0===e[e.length-1]&&e.pop(),r.options=this._parent._getOrSetDefaultOptions(r.options),r.options.data=this.encodeABI(),!this._deployData&&!a.isAddress(this._parent.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return this._deployData||(r.options.to=this._parent.options.address),r.options.data?r:a._fireError(new Error("Couldn't find a matching contract method, or the number of parameters is wrong."),t.eventEmitter,t.reject,r.callback)},l.prototype._executeMethod=function(){var e=this,t=this._parent._processExecuteArguments.call(this,Array.prototype.slice.call(arguments),r),r=f("send"!==t.type),i=e.constructor._ethAccounts||e._ethAccounts;if(t.generateRequest){var s={params:[u.inputCallFormatter.call(this._parent,t.options)],callback:t.callback};return"call"===t.type?(s.params.push(u.inputDefaultBlockNumberFormatter.call(this._parent,t.defaultBlock)),s.method="eth_call",s.format=this._parent._decodeMethodReturn.bind(null,this._method.outputs)):s.method="eth_sendTransaction",s}switch(t.type){case"estimate":return new o({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[u.inputCallFormatter],outputFormatter:a.hexToNumber,requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.callback);case"call":return new o({name:"call",call:"eth_call",params:2,inputFormatter:[u.inputCallFormatter,u.inputDefaultBlockNumberFormatter],outputFormatter:function(t){return e._parent._decodeMethodReturn(e._method.outputs,t)},requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.defaultBlock,t.callback);case"send":if(!a.isAddress(t.options.from))return a._fireError(new Error('No "from" address specified in neither the given options, nor the default options.'),r.eventEmitter,r.reject,t.callback);if(n.isBoolean(this._method.payable)&&!this._method.payable&&t.options.value&&t.options.value>0)return a._fireError(new Error("Can not send value to non-payable contract method or constructor"),r.eventEmitter,r.reject,t.callback);var c={receiptFormatter:function(t){if(n.isArray(t.logs)){var r=n.map(t.logs,function(t){return e._parent._decodeEventABI.call({name:"ALLEVENTS",jsonInterface:e._parent.options.jsonInterface},t)});t.events={};var i=0;r.forEach(function(e){e.event?t.events[e.event]?Array.isArray(t.events[e.event])?t.events[e.event].push(e):t.events[e.event]=[t.events[e.event],e]:t.events[e.event]=e:(t.events[i]=e,i++)}),delete t.logs}return t},contractDeployFormatter:function(t){var r=e._parent.clone();return r.options.address=t.contractAddress,r}};return new o({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[u.inputTransactionFormatter],requestManager:e._parent._requestManager,accounts:e.constructor._ethAccounts||e._ethAccounts,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock,extraFormatters:c}).createFunction()(t.options,t.callback)}},t.exports=l},{underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-utils":403}],360:[function(e,t,r){"use strict";var n=e("./config"),i=e("./contracts/Registry"),o=e("./lib/ResolverMethodHandler");function a(e){this.eth=e}Object.defineProperty(a.prototype,"registry",{get:function(){return new i(this)},enumerable:!0}),Object.defineProperty(a.prototype,"resolverMethodHandler",{get:function(){return new o(this.registry)},enumerable:!0}),a.prototype.resolver=function(e){return this.registry.resolver(e)},a.prototype.getAddress=function(e,t){return this.resolverMethodHandler.method(e,"addr",[]).call(t)},a.prototype.setAddress=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setAddr",[t]).send(r,n)},a.prototype.getPubkey=function(e,t){return this.resolverMethodHandler.method(e,"pubkey",[],t).call(t)},a.prototype.setPubkey=function(e,t,r,n,i){return this.resolverMethodHandler.method(e,"setPubkey",[t,r]).send(n,i)},a.prototype.getContent=function(e,t){return this.resolverMethodHandler.method(e,"content",[]).call(t)},a.prototype.setContent=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setContent",[t]).send(r,n)},a.prototype.getMultihash=function(e,t){return this.resolverMethodHandler.method(e,"multihash",[]).call(t)},a.prototype.setMultihash=function(e,t,r,n){return this.resolverMethodHandler.method(e,"multihash",[t]).send(r,n)},a.prototype.checkNetwork=function(){var e=this;return e.eth.getBlock("latest").then(function(t){var r=new Date/1e3-t.timestamp;if(r>3600)throw new Error("Network not synced; last block was "+r+" seconds ago");return e.eth.net.getNetworkType()}).then(function(e){var t=n.addresses[e];if(void 0===t)throw new Error("ENS is not supported on network "+e);return t})},t.exports=a},{"./config":361,"./contracts/Registry":362,"./lib/ResolverMethodHandler":364}],361:[function(e,t,r){"use strict";t.exports={addresses:{main:"0x314159265dD8dbb310642f98f50C066173C1259b",ropsten:"0x112234455c3a32fd11230c42e7bccd4a84e02010",rinkeby:"0xe7410170f87102df0055eb195163a03b7f2bff4a"}}},{}],362:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-eth-contract"),o=e("eth-ens-namehash"),a=e("web3-core-promievent"),s=e("../ressources/ABI/Registry"),u=e("../ressources/ABI/Resolver");function c(e){var t=this;this.ens=e,this.contract=e.checkNetwork().then(function(e){var r=new i(s,e);return r.setProvider(t.ens.eth.currentProvider),r})}c.prototype.owner=function(e,t){var r=new a(!0);return this.contract.then(function(i){i.methods.owner(o.hash(e)).call().then(function(e){r.resolve(e),n.isFunction(t)&&t(e)}).catch(function(e){r.reject(e),n.isFunction(t)&&t(e)})}),r.eventEmitter},c.prototype.resolver=function(e){var t=this;return this.contract.then(function(t){return t.methods.resolver(o.hash(e)).call()}).then(function(e){var r=new i(u,e);return r.setProvider(t.ens.eth.currentProvider),r})},t.exports=c},{"../ressources/ABI/Registry":365,"../ressources/ABI/Resolver":366,"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340,"web3-eth-contract":359}],363:[function(e,t,r){"use strict";var n=e("./ENS");t.exports=n},{"./ENS":360}],364:[function(e,t,r){"use strict";var n=e("web3-core-promievent"),i=e("eth-ens-namehash"),o=e("underscore");function a(e){this.registry=e}a.prototype.method=function(e,t,r,n){return{call:this.call.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this}),send:this.send.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this})}},a.prototype.call=function(e){var t=this,r=new n,i=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){t.parent.handleCall(r,n.methods[t.methodName],i,e)}).catch(function(e){r.reject(e)}),r.eventEmitter},a.prototype.send=function(e,t){var r=this,i=new n,o=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){r.parent.handleSend(i,n.methods[r.methodName],o,e,t)}).catch(function(e){i.reject(e)}),i.eventEmitter},a.prototype.handleCall=function(e,t,r,n){return t.apply(this,r).call().then(function(t){e.resolve(t),o.isFunction(n)&&n(t)}).catch(function(t){e.reject(t),o.isFunction(n)&&n(t)}),e},a.prototype.handleSend=function(e,t,r,n,i){return t.apply(this,r).send(n).on("transactionHash",function(t){e.eventEmitter.emit("transactionHash",t)}).on("confirmation",function(t,r){e.eventEmitter.emit("confirmation",t,r)}).on("receipt",function(t){e.eventEmitter.emit("receipt",t),e.resolve(t),o.isFunction(i)&&i(t)}).on("error",function(t){e.eventEmitter.emit("error",t),e.reject(t),o.isFunction(i)&&i(t)}),e},a.prototype.prepareArguments=function(e,t){var r=i.hash(e);return t.length>0?(t.unshift(r),t):[r]},t.exports=a},{"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340}],365:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"resolver",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"owner",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"label",type:"bytes32"},{name:"owner",type:"address"}],name:"setSubnodeOwner",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"ttl",type:"uint64"}],name:"setTTL",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"ttl",outputs:[{name:"",type:"uint64"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"resolver",type:"address"}],name:"setResolver",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"owner",type:"address"}],name:"setOwner",outputs:[],payable:!1,type:"function"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"label",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"NewOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"resolver",type:"address"}],name:"NewResolver",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"ttl",type:"uint64"}],name:"NewTTL",type:"event"}]},{}],366:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"interfaceID",type:"bytes4"}],name:"supportsInterface",outputs:[{name:"",type:"bool"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"},{name:"contentTypes",type:"uint256"}],name:"ABI",outputs:[{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes"}],name:"setMultihash",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"multihash",outputs:[{name:"",type:"bytes"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"setPubkey",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"content",outputs:[{name:"ret",type:"bytes32"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"addr",outputs:[{name:"ret",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],name:"setABI",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"name",outputs:[{name:"ret",type:"string"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"name",type:"string"}],name:"setName",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes32"}],name:"setContent",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"pubkey",outputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"addr",type:"address"}],name:"setAddr",outputs:[],payable:!1,type:"function"},{inputs:[{name:"ensAddr",type:"address"}],payable:!1,type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"a",type:"address"}],name:"AddrChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"hash",type:"bytes32"}],name:"ContentChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"name",type:"string"}],name:"NameChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"contentType",type:"uint256"}],name:"ABIChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"x",type:"bytes32"},{indexed:!1,name:"y",type:"bytes32"}],name:"PubkeyChanged",type:"event"}]},{}],367:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],368:[function(e,t,r){"use strict";var n=e("web3-utils"),i=e("bn.js"),o=function(e){var t="A".charCodeAt(0),r="Z".charCodeAt(0);return(e=(e=e.toUpperCase()).substr(4)+e.substr(0,4)).split("").map(function(e){var n=e.charCodeAt(0);return n>=t&&n<=r?n-t+10:e}).join("")},a=function(e){for(var t,r=e;r.length>2;)t=r.slice(0,9),r=parseInt(t,10)%97+r.slice(t.length);return parseInt(r,10)%97},s=function(e){this._iban=e};s.toAddress=function(e){if(!(e=new s(e)).isDirect())throw new Error("IBAN is indirect and can't be converted");return e.toAddress()},s.toIban=function(e){return s.fromAddress(e).toString()},s.fromAddress=function(e){if(!n.isAddress(e))throw new Error("Provided address is not a valid address: "+e);e=e.replace("0x","").replace("0X","");var t=function(e,t){for(var r=e;r.length<2*t;)r="0"+r;return r}(new i(e,16).toString(36),15);return s.fromBban(t.toUpperCase())},s.fromBban=function(e){var t=("0"+(98-a(o("XE00"+e)))).slice(-2);return new s("XE"+t+e)},s.createIndirect=function(e){return s.fromBban("ETH"+e.institution+e.identifier)},s.isValid=function(e){return new s(e).isValid()},s.prototype.isValid=function(){return/^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban)&&1===a(o(this._iban))},s.prototype.isDirect=function(){return 34===this._iban.length||35===this._iban.length},s.prototype.isIndirect=function(){return 20===this._iban.length},s.prototype.checksum=function(){return this._iban.substr(2,2)},s.prototype.institution=function(){return this.isIndirect()?this._iban.substr(7,4):""},s.prototype.client=function(){return this.isIndirect()?this._iban.substr(11):""},s.prototype.toAddress=function(){if(this.isDirect()){var e=this._iban.substr(4),t=new i(e,36);return n.toChecksumAddress(t.toString(16,20))}return""},s.prototype.toString=function(){return this._iban},t.exports=s},{"bn.js":367,"web3-utils":403}],369:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=e("web3-net"),s=e("web3-core-helpers").formatters,u=function(){var e=this;n.packageInit(this,arguments),this.net=new a(this.currentProvider);var t=null,r="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return t},set:function(e){return e&&(t=o.toChecksumAddress(s.inputAddressFormatter(e))),u.forEach(function(e){e.defaultAccount=t}),e},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return r},set:function(e){return r=e,u.forEach(function(e){e.defaultBlock=r}),e},enumerable:!0});var u=[new i({name:"getAccounts",call:"personal_listAccounts",params:0,outputFormatter:o.toChecksumAddress}),new i({name:"newAccount",call:"personal_newAccount",params:1,inputFormatter:[null],outputFormatter:o.toChecksumAddress}),new i({name:"unlockAccount",call:"personal_unlockAccount",params:3,inputFormatter:[s.inputAddressFormatter,null,null]}),new i({name:"lockAccount",call:"personal_lockAccount",params:1,inputFormatter:[s.inputAddressFormatter]}),new i({name:"importRawKey",call:"personal_importRawKey",params:2}),new i({name:"sendTransaction",call:"personal_sendTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"signTransaction",call:"personal_signTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"sign",call:"personal_sign",params:3,inputFormatter:[s.inputSignFormatter,s.inputAddressFormatter,null]}),new i({name:"ecRecover",call:"personal_ecRecover",params:2,inputFormatter:[s.inputSignFormatter,null]})];u.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};n.addProviders(u),t.exports=u},{"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-net":372,"web3-utils":403}],370:[function(e,t,r){"use strict";var n=e("underscore");t.exports=function(e){var t,r=this;return this.net.getId().then(function(e){return t=e,r.getBlock(0)}).then(function(r){var i="private";return"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"===r.hash&&1===t&&(i="main"),"0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303"===r.hash&&2===t&&(i="morden"),"0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"===r.hash&&3===t&&(i="ropsten"),"0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177"===r.hash&&4===t&&(i="rinkeby"),"0xa3c565fc15c7478862d50ccd6561e3c06b24cc509bf388941c25ea985ce32cb9"===r.hash&&42===t&&(i="kovan"),n.isFunction(e)&&e(null,i),i}).catch(function(t){if(!n.isFunction(e))throw t;e(t)})}},{underscore:325}],371:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core"),o=e("web3-core-helpers"),a=e("web3-core-subscriptions").subscriptions,s=e("web3-core-method"),u=e("web3-utils"),c=e("web3-net"),f=e("web3-eth-ens"),h=e("web3-eth-personal"),l=e("web3-eth-contract"),d=e("web3-eth-iban"),p=e("web3-eth-accounts"),b=e("web3-eth-abi"),y=e("./getNetworkType.js"),m=o.formatters,v=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},g=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},w=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},_=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},A=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"},E=function(){var e=this;i.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments),e.personal.setProvider.apply(e,arguments),e.accounts.setProvider.apply(e,arguments),e.Contract.setProvider(e.currentProvider,e.accounts)};var r=null,o="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return r},set:function(t){return t&&(r=u.toChecksumAddress(m.inputAddressFormatter(t))),e.Contract.defaultAccount=r,e.personal.defaultAccount=r,k.forEach(function(e){e.defaultAccount=r}),t},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return o},set:function(t){return o=t,e.Contract.defaultBlock=o,e.personal.defaultBlock=o,k.forEach(function(e){e.defaultBlock=o}),t},enumerable:!0}),this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new c(this.currentProvider),this.net.getNetworkType=y.bind(this),this.accounts=new p(this.currentProvider),this.personal=new h(this.currentProvider),this.personal.defaultAccount=this.defaultAccount;var E=this,x=function(){l.apply(this,arguments);var e=this,t=E.setProvider;E.setProvider=function(){t.apply(E,arguments),i.packageInit(e,[E.currentProvider])}};x.setProvider=function(){l.setProvider.apply(this,arguments)},(x.prototype=Object.create(l.prototype)).constructor=x,this.Contract=x,this.Contract.defaultAccount=this.defaultAccount,this.Contract.defaultBlock=this.defaultBlock,this.Contract.setProvider(this.currentProvider,this.accounts),this.Iban=d,this.abi=b,this.ens=new f(this);var k=[new s({name:"getNodeInfo",call:"web3_clientVersion"}),new s({name:"getProtocolVersion",call:"eth_protocolVersion",params:0}),new s({name:"getCoinbase",call:"eth_coinbase",params:0}),new s({name:"isMining",call:"eth_mining",params:0}),new s({name:"getHashrate",call:"eth_hashrate",params:0,outputFormatter:u.hexToNumber}),new s({name:"isSyncing",call:"eth_syncing",params:0,outputFormatter:m.outputSyncingFormatter}),new s({name:"getGasPrice",call:"eth_gasPrice",params:0,outputFormatter:m.outputBigNumberFormatter}),new s({name:"getAccounts",call:"eth_accounts",params:0,outputFormatter:u.toChecksumAddress}),new s({name:"getBlockNumber",call:"eth_blockNumber",params:0,outputFormatter:u.hexToNumber}),new s({name:"getBalance",call:"eth_getBalance",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:m.outputBigNumberFormatter}),new s({name:"getStorageAt",call:"eth_getStorageAt",params:3,inputFormatter:[m.inputAddressFormatter,u.numberToHex,m.inputDefaultBlockNumberFormatter]}),new s({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"getBlock",call:v,params:2,inputFormatter:[m.inputBlockNumberFormatter,function(e){return!!e}],outputFormatter:m.outputBlockFormatter}),new s({name:"getUncle",call:w,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputBlockFormatter}),new s({name:"getBlockTransactionCount",call:_,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getBlockUncleCount",call:A,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getTransaction",call:"eth_getTransactionByHash",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionFromBlock",call:g,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionReceiptFormatter}),new s({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"sendSignedTransaction",call:"eth_sendRawTransaction",params:1,inputFormatter:[null]}),new s({name:"signTransaction",call:"eth_signTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sign",call:"eth_sign",params:2,inputFormatter:[m.inputSignFormatter,m.inputAddressFormatter],transformPayload:function(e){return e.params.reverse(),e}}),new s({name:"call",call:"eth_call",params:2,inputFormatter:[m.inputCallFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[m.inputCallFormatter],outputFormatter:u.hexToNumber}),new s({name:"submitWork",call:"eth_submitWork",params:3}),new s({name:"getWork",call:"eth_getWork",params:0}),new s({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter}),new a({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:m.outputBlockFormatter},pendingTransactions:{subscriptionName:"newPendingTransactions",params:0},logs:{params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter,subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},syncing:{params:0,outputFormatter:m.outputSyncingFormatter,subscriptionHandler:function(e){var t=this;!0!==this._isSyncing?(this._isSyncing=!0,this.emit("changed",t._isSyncing),n.isFunction(this.callback)&&this.callback(null,t._isSyncing,this),setTimeout(function(){t.emit("data",e),n.isFunction(t.callback)&&t.callback(null,e,t)},0)):(this.emit("data",e),n.isFunction(t.callback)&&this.callback(null,e,this),clearTimeout(this._isSyncingTimeout),this._isSyncingTimeout=setTimeout(function(){e.currentBlock>e.highestBlock-200&&(t._isSyncing=!1,t.emit("changed",t._isSyncing),n.isFunction(t.callback)&&t.callback(null,t._isSyncing,t))},500))}}}})];k.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager,e.accounts),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};i.addProviders(E),t.exports=E},{"./getNetworkType.js":370,underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-eth-accounts":358,"web3-eth-contract":359,"web3-eth-ens":363,"web3-eth-iban":368,"web3-eth-personal":369,"web3-net":372,"web3-utils":403}],372:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=function(){var e=this;n.packageInit(this,arguments),[new i({name:"getId",call:"net_version",params:0,outputFormatter:o.hexToNumber}),new i({name:"isListening",call:"net_listening",params:0}),new i({name:"getPeerCount",call:"net_peerCount",params:0,outputFormatter:o.hexToNumber})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(a),t.exports=a},{"web3-core":348,"web3-core-method":339,"web3-utils":403}],373:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits,o=e("ethereumjs-util"),a=e("eth-block-tracker"),s=e("async/map"),u=e("async/eachSeries"),c=e("./util/stoplight.js");e("./util/rpc-cache-utils.js"),e("./util/create-payload.js");function f(e){const t=this;n.call(t),t.setMaxListeners(30),e=e||{};const r={sendAsync:t._handleAsync.bind(t)},i=e.blockTrackerProvider||r;t._blockTracker=e.blockTracker||new a({provider:i,pollingInterval:e.pollingInterval||4e3}),t._blockTracker.on("block",e=>{const r=function(e){return{number:o.toBuffer(e.number),hash:o.toBuffer(e.hash),parentHash:o.toBuffer(e.parentHash),nonce:o.toBuffer(e.nonce),mixHash:o.toBuffer(e.mixHash),sha3Uncles:o.toBuffer(e.sha3Uncles),logsBloom:o.toBuffer(e.logsBloom),transactionsRoot:o.toBuffer(e.transactionsRoot),stateRoot:o.toBuffer(e.stateRoot),receiptsRoot:o.toBuffer(e.receiptRoot||e.receiptsRoot),miner:o.toBuffer(e.miner),difficulty:o.toBuffer(e.difficulty),totalDifficulty:o.toBuffer(e.totalDifficulty),size:o.toBuffer(e.size),extraData:o.toBuffer(e.extraData),gasLimit:o.toBuffer(e.gasLimit),gasUsed:o.toBuffer(e.gasUsed),timestamp:o.toBuffer(e.timestamp),transactions:e.transactions}}(e);t._setCurrentBlock(r)}),t._blockTracker.on("block",t.emit.bind(t,"rawBlock")),t._blockTracker.on("sync",t.emit.bind(t,"sync")),t._blockTracker.on("latest",t.emit.bind(t,"latest")),t._ready=new c,t._blockTracker.once("block",()=>{t._ready.go()}),t.currentBlock=null,t._providers=[]}t.exports=f,i(f,n),f.prototype.start=function(e=function(){}){this._blockTracker.start().then(e).catch(e)},f.prototype.stop=function(){this._blockTracker.stop()},f.prototype.addProvider=function(e){this._providers.push(e),e.setEngine(this)},f.prototype.send=function(e){throw new Error("Web3ProviderEngine does not support synchronous requests.")},f.prototype.sendAsync=function(e,t){const r=this;r._ready.await(function(){Array.isArray(e)?s(e,r._handleAsync.bind(r),t):r._handleAsync(e,t)})},f.prototype._handleAsync=function(e,t){var r=this,n=-1,i=null,o=null,a=[];function s(r,n){o=r,i=n,u(a,function(e,t){e?e(o,i,t):t()},function(){var r={id:e.id,jsonrpc:e.jsonrpc,result:i};null!=o?(r.error={message:o.stack||o.message||o,code:-32e3},t(o,r)):t(null,r)})}!function t(i){n+=1;a.unshift(i);if(n>=r._providers.length)s(new Error('Request for method "'+e.method+'" not handled by any subprovider. Please check your subprovider configuration to ensure this method is handled.'));else try{var o=r._providers[n];o.handleRequest(e,t,s)}catch(e){s(e)}}()},f.prototype._setCurrentBlock=function(e){this.currentBlock=e,this.emit("block",e)}},{"./util/create-payload.js":391,"./util/rpc-cache-utils.js":394,"./util/stoplight.js":396,"async/eachSeries":25,"async/map":41,"eth-block-tracker":126,"ethereumjs-util":141,events:157,util:333}],374:[function(e,t,r){var n="undefined"!=typeof JSON?JSON:e("jsonify");t.exports=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var r=t.space||"";"number"==typeof r&&(r=Array(r+1).join(" "));var a,s="boolean"==typeof t.cycles&&t.cycles,u=t.replacer||function(e,t){return t},c=t.cmp&&(a=t.cmp,function(e){return function(t,r){var n={key:t,value:e[t]},i={key:r,value:e[r]};return a(n,i)}}),f=[];return function e(t,a,h,l){var d=r?"\n"+new Array(l+1).join(r):"",p=r?": ":":";if(h&&h.toJSON&&"function"==typeof h.toJSON&&(h=h.toJSON()),void 0!==(h=u.call(t,a,h))){if("object"!=typeof h||null===h)return n.stringify(h);if(i(h)){for(var b=[],y=0;y dist/ProviderEngine.js","bundle-zero":"browserify -s ZeroClientProvider -e zero.js -t [ babelify --presets [ es2015 ] ] > dist/ZeroClientProvider.js",prepublish:"npm run build && npm run bundle",test:"node test/index.js"},version:"14.1.0"}},{}],376:[function(e,t,r){const n=e("util").inherits,i=e("ethereumjs-util"),o=i.BN,a=e("clone"),s=e("../util/rpc-cache-utils.js"),u=e("../util/stoplight.js"),c=e("./subprovider.js");function f(e){e=e||{},this._ready=new u,this.strategies={perma:new l({eth_getTransactionByHash:p,eth_getTransactionReceipt:p}),block:new d(this),fork:new d(this)}}function h(){var e=this;e.cache={};var t=setInterval(function(){e.cache={}},6e5);t.unref&&t.unref()}function l(e){this.strategy=new h,this.conditionals=e}function d(){this.cache={}}function p(e){if(!e)return!1;if(!e.blockHash)return!1;var t;return(t=e.blockHash,new o(i.toBuffer(t))).gt(new o(0))}t.exports=f,n(f,c),f.prototype.setEngine=function(e){const t=this;function r(e){var r=t.currentBlock;t.currentBlock=e,r&&(t.strategies.block.cacheRollOff(r),t.strategies.fork.cacheRollOff(r))}t.engine=e,e.once("block",function(n){t.currentBlock=n,t._ready.go(),e.on("block",r)})},f.prototype.handleRequest=function(e,t,r){const n=this;return e.skipCache?t():"eth_getBlockByNumber"===e.method&&"latest"===e.params[0]?t():void n._ready.await(function(){n._handleRequest(e,t,r)})},f.prototype._handleRequest=function(e,t,r){const n=this;var o=s.cacheTypeForPayload(e),a=this.strategies[o];if(!a)return t();if(!a.canCache(e))return t();var u,c=s.blockTagForPayload(e);c||(c="latest"),u="earliest"===c?"0x00":"latest"===c?i.bufferToHex(n.currentBlock.number):c,a.hitCheck(e,u,r,function(){t(function(t,r,n){if(t)return n();a.cacheResult(e,r,u,n)})})},h.prototype.hitCheck=function(e,t,r,n){var i,o,u,c,f=s.cacheIdentifierForPayload(e),h=this.cache[f];return h&&(i=t,o=h.blockNumber,u=parseInt(i,16),c=parseInt(o,16),(u===c?0:u>c?1:-1)>=0)?r(null,a(h.result)):n()},h.prototype.cacheResult=function(e,t,r,n){var i=s.cacheIdentifierForPayload(e);if(t){var o=a(t);this.cache[i]={blockNumber:r,result:o}}n()},h.prototype.canCache=function(e){return s.canCache(e)},l.prototype.hitCheck=function(e,t,r,n){return this.strategy.hitCheck(e,t,r,n)},l.prototype.cacheResult=function(e,t,r,n){var i=this.conditionals[e.method];i?i(t)?this.strategy.cacheResult(e,t,r,n):n():this.strategy.cacheResult(e,t,r,n)},l.prototype.canCache=function(e){return this.strategy.canCache(e)},d.prototype.getBlockCacheForPayload=function(e,t){const r=Number.parseInt(t,16);let n=this.cache[r];if(!n){const e={};this.cache[r]=e,n=e}return n},d.prototype.hitCheck=function(e,t,r,n){var i=this.getBlockCacheForPayload(e,t);if(!i)return n();var o=i[s.cacheIdentifierForPayload(e)];return o?r(null,o):n()},d.prototype.cacheResult=function(e,t,r,n){t&&(this.getBlockCacheForPayload(e,r)[s.cacheIdentifierForPayload(e)]=t);n()},d.prototype.canCache=function(e){return!!s.canCache(e)&&"pending"!==s.blockTagForPayload(e)},d.prototype.cacheRollOff=function(e){const t=this,r=i.bufferToHex(e.number),n=Number.parseInt(r,16);Object.keys(t.cache).map(Number).filter(e=>e<=n).forEach(e=>delete t.cache[e])}},{"../util/rpc-cache-utils.js":394,"../util/stoplight.js":396,"./subprovider.js":387,clone:87,"ethereumjs-util":141,util:333}],377:[function(e,t,r){const n=e("util").inherits,i=e("xtend"),o=e("./fixture.js"),a=e("../package.json").version;function s(e){var t=i({web3_clientVersion:"ProviderEngine/v"+a+"/javascript",net_listening:!0,eth_hashrate:"0x00",eth_mining:!1},e=e||{});o.call(this,t)}t.exports=s,n(s,o)},{"../package.json":375,"./fixture.js":380,util:333,xtend:423}],378:[function(e,t,r){const n=e("cross-fetch"),i=e("util").inherits,o=e("async/retry"),a=e("async/waterfall"),s=e("async/asyncify"),u=e("json-rpc-error"),c=e("promise-to-callback"),f=e("../util/create-payload.js"),h=e("./subprovider.js"),l=["Gateway timeout","ETIMEDOUT","SyntaxError"];function d(e){this.rpcUrl=e.rpcUrl,this.originHttpHeaderKey=e.originHttpHeaderKey}function p(e){const t=e.toString();return l.some(e=>t.includes(e))}t.exports=d,i(d,h),d.prototype.handleRequest=function(e,t,r){const n=this,i=e.origin,a=f(e);delete a.origin;const s={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(a)};n.originHttpHeaderKey&&i&&(s.headers[n.originHttpHeaderKey]=i),o({times:5,interval:1e3,errorFilter:p},e=>n._submitRequest(s,e),(e,t)=>{if(e&&p(e)){const t=`FetchSubprovider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,n=new Error(t);return r(n)}return r(e,t)})},d.prototype._submitRequest=function(e,t){const r=this.rpcUrl;c(n(r,e))((e,r)=>{if(e)return t(e);a([function(e){switch(r.status){case 405:return e(new u.MethodNotFound);case 418:return e(function(){const e=new Error("Request is being rate limited.");return new u.InternalError(e)}());case 503:case 504:return e(function(){let e="Gateway timeout. The request took too long to process. ";const t=new Error(e+="This can happen when querying logs over too wide a block range.");return new u.InternalError(t)}());default:return e()}},e=>c(r.text())(e),s(e=>JSON.parse(e)),function(e,t){if(200!==r.status)return t(new u.InternalError(e));if(e.error)return t(new u.InternalError(e.error));t(null,e.result)}],t)})}},{"../util/create-payload.js":391,"./subprovider.js":387,"async/asyncify":20,"async/retry":43,"async/waterfall":44,"cross-fetch":96,"json-rpc-error":189,"promise-to-callback":258,util:333}],379:[function(e,t,r){const n=e("async"),i=e("util").inherits,o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/stoplight.js"),u=e("events").EventEmitter;function c(e){e=e||{};const t=this;t.filterIndex=0,t.filters={},t.filterDestroyHandlers={},t.asyncBlockHandlers={},t.asyncPendingBlockHandlers={},t._ready=new s,t._ready.setMaxListeners(e.maxFilters||25),t._ready.go(),t.pendingBlockTimeout=e.pendingBlockTimeout||4e3,t.checkForPendingBlocksActive=!1,setTimeout(function(){t.engine.on("block",function(e){t._ready.stop();var r=v(t.asyncBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,function(e){e&&console.error(e),t._ready.go()})})})}function f(e){u.apply(this),this.type="block",this.engine=e.engine,this.blockNumber=e.blockNumber,this.updates=[]}function h(e){u.apply(this),this.type="log",this.fromBlock=void 0!==e.fromBlock?e.fromBlock:"latest",this.toBlock=void 0!==e.toBlock?e.toBlock:"latest";var t=e.address&&(Array.isArray(e.address)?e.address:[e.address]);this.address=t&&t.map(d),this.topics=e.topics||[],this.updates=[],this.allResults=[]}function l(){u.apply(this),this.type="pendingTx",this.updates=[],this.allResults=[]}function d(e){return"0x"===e.slice(0,2)?e:"0x"+e}function p(e){return o.intToHex(e)}function b(e){return Number(e)}function y(e){return function(e){let t=o.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}(e.toString("hex"))}function m(e){return e&&-1===["earliest","latest","pending"].indexOf(e)}function v(e){return Object.keys(e).map(function(t){return e[t]})}t.exports=c,i(c,a),c.prototype.handleRequest=function(e,t,r){const n=this;switch(e.method){case"eth_newBlockFilter":return void n.newBlockFilter(r);case"eth_newPendingTransactionFilter":return n.newPendingTransactionFilter(r),void n.checkForPendingBlocks();case"eth_newFilter":return void n.newLogFilter(e.params[0],r);case"eth_getFilterChanges":return void n._ready.await(function(){n.getFilterChanges(e.params[0],r)});case"eth_getFilterLogs":return void n._ready.await(function(){n.getFilterLogs(e.params[0],r)});case"eth_uninstallFilter":return void n._ready.await(function(){n.uninstallFilter(e.params[0],r)});default:return void t()}},c.prototype.newBlockFilter=function(e){const t=this;t._getBlockNumber(function(r,n){if(r)return e(r);var i=new f({blockNumber:n}),o=i.update.bind(i);t.engine.on("block",o);t.filterIndex++,t.filters[t.filterIndex]=i,t.filterDestroyHandlers[t.filterIndex]=function(){t.engine.removeListener("block",o)};var a=p(t.filterIndex);e(null,a)})},c.prototype.newLogFilter=function(e,t){const r=this;r._getBlockNumber(function(n,i){if(n)return t(n);var o=new h(e),a=o.update.bind(o);r.filterIndex++,r.asyncBlockHandlers[r.filterIndex]=function(e,t){r._logsForBlock(e,function(e,r){if(e)return t(e);a(r),t()})},r.filters[r.filterIndex]=o;var s=p(r.filterIndex);t(null,s)})},c.prototype.newPendingTransactionFilter=function(e){const t=this;var r=new l,n=r.update.bind(r);t.filterIndex++,t.asyncPendingBlockHandlers[t.filterIndex]=function(e,r){t._txHashesForBlock(e,function(e,t){if(e)return r(e);n(t),r()})},t.filters[t.filterIndex]=r,e(null,p(t.filterIndex))},c.prototype.getFilterChanges=function(e,t){var r=Number.parseInt(e,16),n=this.filters[r];if(n||console.warn("FilterSubprovider - no filter with that id:",e),!n)return t(null,[]);var i=n.getChanges();n.clearChanges(),t(null,i)},c.prototype.getFilterLogs=function(e,t){const r=this;var n=Number.parseInt(e,16),i=r.filters[n];if(i||console.warn("FilterSubprovider - no filter with that id:",e),!i)return t(null,[]);if("log"===i.type)r.emitPayload({method:"eth_getLogs",params:[{fromBlock:i.fromBlock,toBlock:i.toBlock,address:i.address,topics:i.topics}]},function(e,r){if(e)return t(e);t(null,r.result)});else{t(null,[])}},c.prototype.uninstallFilter=function(e,t){var r=Number.parseInt(e,16);if(this.filters[r]){this.filters[r].removeAllListeners();var n=this.filterDestroyHandlers[r];delete this.filters[r],delete this.asyncBlockHandlers[r],delete this.asyncPendingBlockHandlers[r],delete this.filterDestroyHandlers[r],n&&n(),t(null,!0)}else t(null,!1)},c.prototype.checkForPendingBlocks=function(){const e=this;e.checkForPendingBlocksActive||!!Object.keys(e.asyncPendingBlockHandlers).length&&(e.checkForPendingBlocksActive=!0,e.emitPayload({method:"eth_getBlockByNumber",params:["pending",!0]},function(t,r){if(t)return e.checkForPendingBlocksActive=!1,void console.error(t);e.onNewPendingBlock(r.result,function(t){t&&console.error(t),e.checkForPendingBlocksActive=!1,setTimeout(e.checkForPendingBlocks.bind(e),e.pendingBlockTimeout)})}))},c.prototype.onNewPendingBlock=function(e,t){var r=v(this.asyncPendingBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,t)},c.prototype._getBlockNumber=function(e){e(null,y(this.engine.currentBlock.number))},c.prototype._logsForBlock=function(e,t){var r=y(e.number);this.emitPayload({method:"eth_getLogs",params:[{fromBlock:r,toBlock:r}]},function(e,r){return e?t(e):r.error?t(r.error):void t(null,r.result)})},c.prototype._txHashesForBlock=function(e,t){var r=e.transactions;if(0===r.length)return t(null,[]);"string"==typeof r[0]?t(null,r):t(null,r.map(e=>e.hash))},i(f,u),f.prototype.update=function(e){var t="0x"+e.hash.toString("hex");this.updates.push(t),this.emit("data",e)},f.prototype.getChanges=function(){return this.updates},f.prototype.clearChanges=function(){this.updates=[]},i(h,u),h.prototype.validateLog=function(e){return!(m(this.fromBlock)&&b(this.fromBlock)>=b(e.blockNumber))&&(!(m(this.toBlock)&&b(this.toBlock)<=b(e.blockNumber))&&(!(this.address&&!this.address.map(e=>e.toLowerCase()).includes(e.address.toLowerCase()))&&this.topics.reduce(function(t,r,n){if(!t)return!1;if(!r)return!0;var i=e.topics[n];return!!i&&(Array.isArray(r)?r:[r]).filter(function(e){return i.toLowerCase()===e.toLowerCase()}).length>0},!0)))},h.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateLog(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},h.prototype.getChanges=function(){return this.updates},h.prototype.getAllResults=function(){return this.allResults},h.prototype.clearChanges=function(){this.updates=[]},i(l,u),l.prototype.validateUnique=function(e){return-1===this.allResults.indexOf(e)},l.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateUnique(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},l.prototype.getChanges=function(){return this.updates},l.prototype.getAllResults=function(){return this.allResults},l.prototype.clearChanges=function(){this.updates=[]}},{"../util/stoplight.js":396,"./subprovider.js":387,async:21,"ethereumjs-util":141,events:157,util:333}],380:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){e=e||{},this.staticResponses=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){var n=this.staticResponses[e.method];"function"==typeof n?n(e,t,r):void 0!==n?setTimeout(()=>r(null,n)):t()}},{"./subprovider.js":387,util:333}],381:[function(e,t,r){const n=e("async/waterfall"),i=e("async/parallel"),o=e("util").inherits,a=e("ethereumjs-util"),s=e("eth-sig-util"),u=e("xtend"),c=e("semaphore"),f=e("./subprovider.js"),h=e("../util/estimate-gas.js"),l=/^[0-9A-Fa-f]+$/g;function d(e){this.nonceLock=c(1),e.getAccounts&&(this.getAccounts=e.getAccounts),e.processTransaction&&(this.processTransaction=e.processTransaction),e.processMessage&&(this.processMessage=e.processMessage),e.processPersonalMessage&&(this.processPersonalMessage=e.processPersonalMessage),e.processTypedMessage&&(this.processTypedMessage=e.processTypedMessage),this.approveTransaction=e.approveTransaction||this.autoApprove,this.approveMessage=e.approveMessage||this.autoApprove,this.approvePersonalMessage=e.approvePersonalMessage||this.autoApprove,this.approveTypedMessage=e.approveTypedMessage||this.autoApprove,e.signTransaction&&(this.signTransaction=e.signTransaction||y("signTransaction")),e.signMessage&&(this.signMessage=e.signMessage||y("signMessage")),e.signPersonalMessage&&(this.signPersonalMessage=e.signPersonalMessage||y("signPersonalMessage")),e.signTypedMessage&&(this.signTypedMessage=e.signTypedMessage||y("signTypedMessage")),e.recoverPersonalSignature&&(this.recoverPersonalSignature=e.recoverPersonalSignature),e.publishTransaction&&(this.publishTransaction=e.publishTransaction)}function p(e){return e.toLowerCase()}function b(e){return"string"==typeof e&&("0x"===e.slice(0,2)&&e.slice(2).match(l))}function y(e){return function(t,r){r(new Error('ProviderEngine - HookedWalletSubprovider - Must provide "'+e+'" fn in constructor options'))}}t.exports=d,o(d,f),d.prototype.handleRequest=function(e,t,r){const i=this;let o,s,c,f,h;switch(i._parityRequests={},i._parityRequestCount=0,e.method){case"eth_coinbase":return void i.getAccounts(function(e,t){if(e)return r(e);let n=t[0]||null;r(null,n)});case"eth_accounts":return void i.getAccounts(function(e,t){if(e)return r(e);r(null,t)});case"eth_sendTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processTransaction(o,e)],r);case"eth_signTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processSignTransaction(o,e)],r);case"eth_sign":return h=e.params[0],f=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateMessage(s,e),e=>i.processMessage(s,e)],r);case"personal_sign":const l=e.params[0];if(function(e){const t=a.addHexPrefix(e);return!a.isValidAddress(t)&&b(e)}(e.params[1])&&function(e){const t=a.addHexPrefix(e);return a.isValidAddress(t)}(l)){let t="The eth_personalSign method requires params ordered ";t+="[message, address]. This was previously handled incorrectly, ",t+="and has been corrected automatically. ",t+="Please switch this param order for smooth behavior in the future.",console.warn(t),h=e.params[0],f=e.params[1]}else f=e.params[0],h=e.params[1];return c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validatePersonalMessage(s,e),e=>i.processPersonalMessage(s,e)],r);case"personal_ecRecover":f=e.params[0];let d=e.params[1];return c=e.params[2]||{},s=u(c,{sig:d,data:f}),void i.recoverPersonalSignature(s,r);case"eth_signTypedData":return f=e.params[0],h=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateTypedMessage(s,e),e=>i.processTypedMessage(s,e)],r);case"parity_postTransaction":return o=e.params[0],void i.parityPostTransaction(o,r);case"parity_postSign":return h=e.params[0],f=e.params[1],void i.parityPostSign(h,f,r);case"parity_checkRequest":const p=e.params[0];return void i.parityCheckRequest(p,r);case"parity_defaultAccount":return void i.getAccounts(function(e,t){if(e)return r(e);const n=t[0]||null;r(null,n)});default:return void t()}},d.prototype.getAccounts=function(e){e(null,[])},d.prototype.processTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeAndSubmitTx(e,t)],t)},d.prototype.processSignTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeTx(e,t)],t)},d.prototype.processMessage=function(e,t){const r=this;n([t=>r.approveMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signMessage(e,t)],t)},d.prototype.processPersonalMessage=function(e,t){const r=this;n([t=>r.approvePersonalMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signPersonalMessage(e,t)],t)},d.prototype.processTypedMessage=function(e,t){const r=this;n([t=>r.approveTypedMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signTypedMessage(e,t)],t)},d.prototype.autoApprove=function(e,t){t(null,!0)},d.prototype.checkApproval=function(e,t,r){r(t?null:new Error("User denied "+e+" signature."))},d.prototype.parityPostTransaction=function(e,t){const r=this,n=`0x${r._parityRequestCount.toString(16)}`;r._parityRequestCount++,r.emitPayload({method:"eth_sendTransaction",params:[e]},function(e,t){if(e)return void(r._parityRequests[n]={error:e});const i=t.result;r._parityRequests[n]=i}),t(null,n)},d.prototype.parityPostSign=function(e,t,r){const n=this,i=`0x${n._parityRequestCount.toString(16)}`;n._parityRequestCount++,n.emitPayload({method:"eth_sign",params:[e,t]},function(e,t){if(e)return void(n._parityRequests[i]={error:e});const r=t.result;n._parityRequests[i]=r}),r(null,i)},d.prototype.parityCheckRequest=function(e,t){const r=this._parityRequests[e]||null;return r?r.error?t(r.error):void t(null,r):t(null,null)},d.prototype.recoverPersonalSignature=function(e,t){let r;try{r=s.recoverPersonalSignature(e)}catch(e){return t(e)}t(null,r)},d.prototype.validateTransaction=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign transaction."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign transaction for this address: "${e.from}"`))})},d.prototype.validateMessage=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign message."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validatePersonalMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign personal message.")):void 0===e.data?t(new Error("Undefined message - message required to sign personal message.")):b(e.data)?void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))}):t(new Error("HookedWalletSubprovider - validateMessage - message was not encoded as hex."))},d.prototype.validateTypedMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign typed data.")):void 0===e.data?t(new Error("Undefined data - message required to sign typed data.")):void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validateSender=function(e,t){if(!e)return t(null,!1);this.getAccounts(function(r,n){if(r)return t(r);const i=-1!==n.map(p).indexOf(e.toLowerCase());t(null,i)})},d.prototype.finalizeAndSubmitTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r),r.publishTransaction.bind(r)],function(e,n){if(r.nonceLock.leave(),e)return t(e);t(null,n)})})},d.prototype.finalizeTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r)],function(n,i){if(r.nonceLock.leave(),n)return t(n);t(null,{raw:i,tx:e})})})},d.prototype.publishTransaction=function(e,t){this.emitPayload({method:"eth_sendRawTransaction",params:[e]},function(e,r){if(e)return t(e);t(null,r.result)})},d.prototype.fillInTxExtras=function(e,t){const r=this,n=e.from,o={};void 0===e.gasPrice&&(o.gasPrice=r.emitPayload.bind(r,{method:"eth_gasPrice",params:[]})),void 0===e.nonce&&(o.nonce=r.emitPayload.bind(r,{method:"eth_getTransactionCount",params:[n,"pending"]})),void 0===e.gas&&(o.gas=h.bind(null,r.engine,function(e){return{from:e.from,to:e.to,value:e.value,data:e.data,gas:e.gas,gasPrice:e.gasPrice,nonce:e.nonce}}(e))),i(o,function(r,n){if(r)return t(r);const i={};n.gasPrice&&(i.gasPrice=n.gasPrice.result),n.nonce&&(i.nonce=n.nonce.result),n.gas&&(i.gas=n.gas),t(null,u(e,i))})}},{"../util/estimate-gas.js":392,"./subprovider.js":387,"async/parallel":42,"async/waterfall":44,"eth-sig-util":136,"ethereumjs-util":141,semaphore:301,util:333,xtend:423}],382:[function(e,t,r){const n=e("../util/rpc-cache-utils.js").cacheIdentifierForPayload,i=e("./subprovider.js");t.exports=class extends i{constructor(e){super(),this.inflightRequests={}}addEngine(e){this.engine=e}handleRequest(e,t,r){const i=n(e,{includeBlockRef:!0});if(!i)return t();let o=this.inflightRequests[i];o?o.push(r):(o=[],this.inflightRequests[i]=o,t((e,t,r)=>{delete this.inflightRequests[i],o.forEach(r=>r(e,t)),r(e,t)}))}}},{"../util/rpc-cache-utils.js":394,"./subprovider.js":387}],383:[function(e,t,r){const n=e("eth-json-rpc-infura/src/createProvider"),i=e("./provider.js");t.exports=class extends i{constructor(e={}){super(n(e))}}},{"./provider.js":385,"eth-json-rpc-infura/src/createProvider":129}],384:[function(e,t,r){(function(r){const n=e("util").inherits,i=e("ethereumjs-tx"),o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/rpc-cache-utils").blockTagForPayload;function u(e){this.nonceCache={}}t.exports=u,n(u,a),u.prototype.handleRequest=function(e,t,n){const a=this;switch(e.method){case"eth_getTransactionCount":var u=s(e),c=e.params[0].toLowerCase(),f=a.nonceCache[c];return void("pending"===u?f?n(null,f):t(function(e,t,r){if(e)return r();void 0===a.nonceCache[c]&&(a.nonceCache[c]=t),r()}):t());case"eth_sendRawTransaction":return void t(function(t,n,s){if(t)return s();var u=e.params[0],c=(o.stripHexPrefix(u),new r(o.stripHexPrefix(u),"hex"),new i(new r(o.stripHexPrefix(u),"hex"))),f="0x"+c.getSenderAddress().toString("hex").toLowerCase(),h=o.bufferToInt(c.nonce),l=(++h).toString(16);l.length%2&&(l="0"+l),l="0x"+l,a.nonceCache[f]=l,s()});default:return void t()}}}).call(this,e("buffer").Buffer)},{"../util/rpc-cache-utils":394,"./subprovider.js":387,buffer:84,"ethereumjs-tx":140,"ethereumjs-util":141,util:333}],385:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){if(!e)throw new Error("ProviderSubprovider - no provider specified");if(!e.sendAsync)throw new Error("ProviderSubprovider - specified provider does not have a sendAsync method");this.provider=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){this.provider.sendAsync(e,function(e,t){return e?r(e):t.error?r(new Error(t.error.message)):void r(null,t.result)})}},{"./subprovider.js":387,util:333}],386:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js"),o=(e("xtend"),e("ethereumjs-util"));function a(e){}t.exports=a,n(a,i),a.prototype.handleRequest=function(e,t,r){var n=e.params[0];if("object"==typeof n&&!Array.isArray(n)){var i=function(e){return s.reduce(function(t,r){return r in e&&(Array.isArray(e[r])?t[r]=e[r].map(function(e){return u(e)}):t[r]=u(e[r])),t},{})}(n);e.params[0]=i}t()};var s=["from","to","value","data","gas","gasPrice","nonce","fromBlock","toBlock","address","topics"];function u(e){switch(e){case"latest":case"pending":case"earliest":return e;default:return"string"==typeof e?o.addHexPrefix(e.toLowerCase()):e}}},{"./subprovider.js":387,"ethereumjs-util":141,util:333,xtend:423}],387:[function(e,t,r){const n=e("../util/create-payload.js");function i(){}t.exports=i,i.prototype.setEngine=function(e){const t=this;t.engine=e,e.on("block",function(e){t.currentBlock=e})},i.prototype.handleRequest=function(e,t,r){throw new Error("Subproviders should override `handleRequest`.")},i.prototype.emitPayload=function(e,t){this.engine.sendAsync(n(e),t)}},{"../util/create-payload.js":391}],388:[function(e,t,r){const n=e("events").EventEmitter,i=e("./filters.js"),o=e("../util/rpc-hex-encoding.js"),a=e("util").inherits,s=e("ethereumjs-util");function u(e){e=e||{},n.apply(this,Array.prototype.slice.call(arguments)),i.apply(this,[e]),this.subscriptions={}}a(u,i),Object.assign(u.prototype,n.prototype),u.prototype.constructor=u,u.prototype.eth_subscribe=function(e,t){const r=this;let n=()=>{},i=e.params[0];switch(i){case"logs":let o=e.params[1];n=r.newLogFilter.bind(r,o);break;case"newPendingTransactions":n=r.newPendingTransactionFilter.bind(r);break;case"newHeads":n=r.newBlockFilter.bind(r);break;case"syncing":default:return void t(new Error("unsupported subscription type"))}n(function(e,n){if(e)return t(e);const o=Number.parseInt(n,16);r.subscriptions[o]=i,r.filters[o].on("data",function(e){Array.isArray(e)||(e=[e]);var t=r._notificationHandler.bind(r,n,i);e.forEach(t),r.filters[o].clearChanges()}),"newPendingTransactions"===i&&r.checkForPendingBlocks(),t(null,n)})},u.prototype.eth_unsubscribe=function(e,t){const r=this;let n=e.params[0];const i=Number.parseInt(n,16);if(r.subscriptions[i]){r.subscriptions[i];r.uninstallFilter(n,function(e,n){delete r.subscriptions[i],t(e,n)})}else t(new Error(`Subscription ID ${n} not found.`))},u.prototype._notificationHandler=function(e,t,r){const n=this;"newHeads"===t&&(r=n._notificationResultFromBlock(r)),n.emit("data",null,{jsonrpc:"2.0",method:"eth_subscription",params:{subscription:e,result:r}})},u.prototype._notificationResultFromBlock=function(e){return{hash:s.bufferToHex(e.hash),parentHash:s.bufferToHex(e.parentHash),sha3Uncles:s.bufferToHex(e.sha3Uncles),miner:s.bufferToHex(e.miner),stateRoot:s.bufferToHex(e.stateRoot),transactionsRoot:s.bufferToHex(e.transactionsRoot),receiptsRoot:s.bufferToHex(e.receiptsRoot),logsBloom:s.bufferToHex(e.logsBloom),difficulty:o.intToQuantityHex(s.bufferToInt(e.difficulty)),number:o.intToQuantityHex(s.bufferToInt(e.number)),gasLimit:o.intToQuantityHex(s.bufferToInt(e.gasLimit)),gasUsed:o.intToQuantityHex(s.bufferToInt(e.gasUsed)),nonce:e.nonce?s.bufferToHex(e.nonce):null,mixHash:s.bufferToHex(e.mixHash),timestamp:o.intToQuantityHex(s.bufferToInt(e.timestamp)),extraData:s.bufferToHex(e.extraData)}},u.prototype.handleRequest=function(e,t,r){switch(e.method){case"eth_subscribe":this.eth_subscribe(e,r);break;case"eth_unsubscribe":this.eth_unsubscribe(e,r);break;default:i.prototype.handleRequest.apply(this,Array.prototype.slice.call(arguments))}},t.exports=u},{"../util/rpc-hex-encoding.js":395,"./filters.js":379,"ethereumjs-util":141,events:157,util:333}],389:[function(e,t,r){(function(r){const n=e("backoff"),i=e("events"),o=(e("util").inherits,r.WebSocket||e("ws")),a=e("./subprovider"),s=e("../util/create-payload");class u extends a{constructor({rpcUrl:e,debug:t,origin:r}){super(),i.call(this),Object.defineProperties(this,{_backoff:{value:n.exponential({randomisationFactor:.2,maxDelay:5e3})},_connectTime:{value:null,writable:!0},_log:{value:t?(...e)=>console.info.apply(console,["[WSProvider]",...e]):()=>{}},_origin:{value:r},_pendingRequests:{value:new Map},_socket:{value:null,writable:!0},_unhandledRequests:{value:[]},_url:{value:e}}),this._handleSocketClose=this._handleSocketClose.bind(this),this._handleSocketMessage=this._handleSocketMessage.bind(this),this._handleSocketOpen=this._handleSocketOpen.bind(this),this._backoff.on("ready",()=>{this._openSocket()}),this._openSocket()}handleRequest(e,t,r){if(!this._socket||this._socket.readyState!==o.OPEN)return this._unhandledRequests.push(Array.from(arguments)),void this._log("Socket not open. Request queued.");this._pendingRequests.set(e.id,[e,r]);const n=s(e);delete n.origin,this._socket.send(JSON.stringify(n)),this._log(`Sent: ${n.method} #${n.id}`)}_handleSocketClose({reason:e,code:t}){this._log(`Socket closed, code ${t} (${e||"no reason"})`),this._connectTime&&Date.now()-this._connectTime>5e3&&this._backoff.reset(),this._socket.removeEventListener("close",this._handleSocketClose),this._socket.removeEventListener("message",this._handleSocketMessage),this._socket.removeEventListener("open",this._handleSocketOpen),this._socket=null,this._backoff.backoff()}_handleSocketMessage(e){let t;try{t=JSON.parse(e.data)}catch(e){return void this._log("Received a message that is not valid JSON:",t)}if(void 0===t.id)return this.emit("data",null,t);if(!this._pendingRequests.has(t.id))return;const[r,n]=this._pendingRequests.get(t.id);if(this._pendingRequests.delete(t.id),this._log(`Received: ${r.method} #${t.id}`),t.error)return n(new Error(t.error.message));n(null,t.result)}_handleSocketOpen(){this._log("Socket open."),this._connectTime=Date.now(),this._pendingRequests.forEach(([e,t])=>{this._unhandledRequests.push([e,null,t])}),this._pendingRequests.clear(),this._unhandledRequests.splice(0,this._unhandledRequests.length).forEach(e=>{this.handleRequest.apply(this,e)})}_openSocket(){this._log("Opening socket..."),this._socket=new o(this._url,null,{origin:this._origin}),this._socket.addEventListener("close",this._handleSocketClose),this._socket.addEventListener("message",this._handleSocketMessage),this._socket.addEventListener("open",this._handleSocketOpen)}}Object.assign(u.prototype,i.prototype),t.exports=u}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util/create-payload":391,"./subprovider":387,backoff:45,events:157,util:333,ws:55}],390:[function(e,t,r){t.exports=function(e,t){if(!e)throw t||"Assertion failed"}},{}],391:[function(e,t,r){const n=e("./random-id.js"),i=e("xtend");t.exports=function(e){return i({id:n(),jsonrpc:"2.0",params:[]},e)}},{"./random-id.js":393,xtend:423}],392:[function(e,t,r){const n=e("./create-payload.js");t.exports=function(e,t,r){e.sendAsync(n({method:"eth_estimateGas",params:[t]}),function(e,t){if(e)return"no contract code at given address"===e.message?r(null,"0xcf08"):r(e);r(null,t.result)})}},{"./create-payload.js":391}],393:[function(e,t,r){const n=3;t.exports=function(){var e=(new Date).getTime()*Math.pow(10,n),t=Math.floor(Math.random()*Math.pow(10,n));return e+t}},{}],394:[function(e,t,r){const n=e("json-stable-stringify");function i(e){return"never"!==s(e)}function o(e){var t=a(e);return t>=e.params.length?e.params:"eth_getBlockByNumber"===e.method?e.params.slice(1):e.params.slice(0,t)}function a(e){switch(e.method){case"eth_getStorageAt":return 2;case"eth_getBalance":case"eth_getCode":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":return 1;case"eth_getBlockByNumber":return 0;default:return}}function s(e){switch(e.method){case"web3_clientVersion":case"web3_sha3":case"eth_protocolVersion":case"eth_getBlockTransactionCountByHash":case"eth_getUncleCountByBlockHash":case"eth_getCode":case"eth_getBlockByHash":case"eth_getTransactionByHash":case"eth_getTransactionByBlockHashAndIndex":case"eth_getTransactionReceipt":case"eth_getUncleByBlockHashAndIndex":case"eth_getCompilers":case"eth_compileLLL":case"eth_compileSolidity":case"eth_compileSerpent":case"shh_version":return"perma";case"eth_getBlockByNumber":case"eth_getBlockTransactionCountByNumber":case"eth_getUncleCountByBlockNumber":case"eth_getTransactionByBlockNumberAndIndex":case"eth_getUncleByBlockNumberAndIndex":return"fork";case"eth_gasPrice":case"eth_blockNumber":case"eth_getBalance":case"eth_getStorageAt":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":case"eth_getFilterLogs":case"eth_getLogs":case"net_peerCount":return"block";case"net_version":case"net_peerCount":case"net_listening":case"eth_syncing":case"eth_sign":case"eth_coinbase":case"eth_mining":case"eth_hashrate":case"eth_accounts":case"eth_sendTransaction":case"eth_sendRawTransaction":case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_getFilterChanges":case"eth_getWork":case"eth_submitWork":case"eth_submitHashrate":case"db_putString":case"db_getString":case"db_putHex":case"db_getHex":case"shh_post":case"shh_newIdentity":case"shh_hasIdentity":case"shh_newGroup":case"shh_addToGroup":case"shh_newFilter":case"shh_uninstallFilter":case"shh_getFilterChanges":case"shh_getMessages":return"never"}}t.exports={cacheIdentifierForPayload:function(e,t={}){if(!i(e))return null;const{includeBlockRef:r}=t,a=r?e.params:o(e);return e.method+":"+n(a)},canCache:i,blockTagForPayload:function(e){var t=a(e);if(t>=e.params.length)return null;return e.params[t]},paramsWithoutBlockTag:o,blockTagParamIndex:a,cacheTypeForPayload:s}},{"json-stable-stringify":374}],395:[function(e,t,r){(function(r){const n=e("ethereumjs-util"),i=e("./assert.js");t.exports={intToQuantityHex:function(e){i("number"==typeof e&&e===Math.floor(e),"intToQuantityHex arg must be an integer");var t=n.toBuffer(e).toString("hex");"0"===t[0]&&(t=t.substring(1));return n.addHexPrefix(t)},quantityHexToInt:function(e){i("string"==typeof e,"arg to quantityHexToInt must be a string");var t=n.stripHexPrefix(e);t.length%2!=0&&(t="0"+t);var o=new r(t,"hex");return n.bufferToInt(o)}}}).call(this,e("buffer").Buffer)},{"./assert.js":390,buffer:84,"ethereumjs-util":141}],396:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits;function o(){n.call(this),this.isLocked=!0}t.exports=o,i(o,n),o.prototype.go=function(){this.isLocked=!1,this.emit("unlock")},o.prototype.stop=function(){this.isLocked=!0,this.emit("lock")},o.prototype.await=function(e){const t=this;t.isLocked?t.once("unlock",e):setTimeout(e)}},{events:157,util:333}],397:[function(e,t,r){const n=e("./index.js"),i=e("./subproviders/default-fixture.js"),o=e("./subproviders/nonce-tracker.js"),a=e("./subproviders/cache.js"),s=e("./subproviders/filters.js"),u=e("./subproviders/subscriptions"),c=e("./subproviders/inflight-cache"),f=e("./subproviders/hooked-wallet.js"),h=e("./subproviders/sanitizer.js"),l=e("./subproviders/infura.js"),d=e("./subproviders/fetch.js"),p=e("./subproviders/websocket.js");t.exports=function(e={}){const t=function({rpcUrl:e}){if(!e)return;switch(e.split(":")[0].toLowerCase()){case"http":case"https":return"http";case"ws":case"wss":return"ws";default:throw new Error(`ProviderEngine - unrecognized protocol in "${e}"`)}}(e),r=new n(e.engineParams),b=new i(e.static);r.addProvider(b),r.addProvider(new o);const y=new h;r.addProvider(y);const m=new a;if(r.addProvider(m),"ws"===t){const e=new s;r.addProvider(e)}else{const e=new u;e.on("data",(e,t)=>{r.emit("data",e,t)}),r.addProvider(e)}const v=new c;r.addProvider(v);const g=new f({getAccounts:e.getAccounts,processTransaction:e.processTransaction,approveTransaction:e.approveTransaction,signTransaction:e.signTransaction,publishTransaction:e.publishTransaction,processMessage:e.processMessage,approveMessage:e.approveMessage,signMessage:e.signMessage,processPersonalMessage:e.processPersonalMessage,processTypedMessage:e.processTypedMessage,approvePersonalMessage:e.approvePersonalMessage,approveTypedMessage:e.approveTypedMessage,signPersonalMessage:e.signPersonalMessage,signTypedMessage:e.signTypedMessage,personalRecoverSigner:e.personalRecoverSigner});r.addProvider(g);const w=e.dataSubprovider||function(e,t){const{rpcUrl:r,debug:n}=t;if(!e)return new l;if("http"===e)return new d({rpcUrl:r,debug:n});if("ws"===e)return new p({rpcUrl:r,debug:n});throw new Error(`ProviderEngine - unrecognized connectionType "${e}"`)}(t,e);"ws"===t&&w.on("data",(e,t)=>{r.emit("data",e,t)});r.addProvider(w),e.stopped||r.start();return r}},{"./index.js":373,"./subproviders/cache.js":376,"./subproviders/default-fixture.js":377,"./subproviders/fetch.js":378,"./subproviders/filters.js":379,"./subproviders/hooked-wallet.js":381,"./subproviders/inflight-cache":382,"./subproviders/infura.js":383,"./subproviders/nonce-tracker.js":384,"./subproviders/sanitizer.js":386,"./subproviders/subscriptions":388,"./subproviders/websocket.js":389}],398:[function(e,t,r){var n=e("web3-core-helpers").errors,i=e("xhr2-cookies").XMLHttpRequest,o=e("http"),a=e("https"),s=function(e,t){t=t||{},this.host=e||"http://localhost:8545","https"===this.host.substring(0,5)?this.httpsAgent=new a.Agent({keepAlive:!0}):this.httpAgent=new o.Agent({keepAlive:!0}),this.timeout=t.timeout||0,this.headers=t.headers,this.connected=!1};s.prototype._prepareRequest=function(){var e=new i;return e.nodejsSet({httpsAgent:this.httpsAgent,httpAgent:this.httpAgent}),e.open("POST",this.host,!0),e.setRequestHeader("Content-Type","application/json"),e.timeout=this.timeout&&1!==this.timeout?this.timeout:0,e.withCredentials=!0,this.headers&&this.headers.forEach(function(t){e.setRequestHeader(t.name,t.value)}),e},s.prototype.send=function(e,t){var r=this,i=this._prepareRequest();i.onreadystatechange=function(){if(4===i.readyState&&1!==i.timeout){var e=i.responseText,o=null;try{e=JSON.parse(e)}catch(e){o=n.InvalidResponse(i.responseText)}r.connected=!0,t(o,e)}},i.ontimeout=function(){r.connected=!1,t(n.ConnectionTimeout(this.timeout))};try{i.send(JSON.stringify(e))}catch(e){this.connected=!1,t(n.InvalidConnection(this.host))}},s.prototype.disconnect=function(){},t.exports=s},{http:312,https:175,"web3-core-helpers":338,"xhr2-cookies":418}],399:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("oboe"),a=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],this.path=e,this.connected=!1,this.connection=t.connect({path:this.path}),this.addDefaultEvents();var i=function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,t||-1===e.method.indexOf("_subscription")?r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t]):r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)})};"Socket"===t.constructor.name?o(this.connection).done(i):this.connection.on("data",function(e){r._parseResponse(e.toString()).forEach(i)})};a.prototype.addDefaultEvents=function(){var e=this;this.connection.on("connect",function(){e.connected=!0}),this.connection.on("close",function(){e.connected=!1}),this.connection.on("error",function(){e._timeout()}),this.connection.on("end",function(){e._timeout()}),this.connection.on("timeout",function(){e._timeout()})},a.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},a.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n},a.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on IPC")),delete this.responseCallbacks[e])},a.prototype.reconnect=function(){this.connection.connect({path:this.path})},a.prototype.send=function(e,t){this.connection.writable||this.connection.connect({path:this.path}),this.connection.write(JSON.stringify(e)),this._addResponseCallback(e,t)},a.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;default:this.connection.on(e,t)}},a.prototype.once=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");this.connection.once(e,t)},a.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)});break;default:this.connection.removeListener(e,t)}},a.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;default:this.connection.removeAllListeners(e)}},a.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.connection.removeAllListeners("error"),this.connection.removeAllListeners("end"),this.connection.removeAllListeners("timeout"),this.addDefaultEvents()},t.exports=a},{oboe:239,underscore:325,"web3-core-helpers":338}],400:[function(e,t,r){(function(r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=null,a=null,s=null;if("undefined"!=typeof window&&void 0!==window.WebSocket)o=function(e,t){return new window.WebSocket(e,t)},a=btoa,s=function(e){return new URL(e)};else{o=e("websocket").w3cwebsocket,a=function(e){return r(e).toString("base64")};var u=e("url");if(u.URL){var c=u.URL;s=function(e){return new c(e)}}else s=e("url").parse}var f=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],t=t||{},this._customTimeout=t.timeout;var i=s(e),u=t.headers||{},c=t.protocol||void 0;i.username&&i.password&&(u.authorization="Basic "+a(i.username+":"+i.password));var f=t.clientConfig||void 0;i.auth&&(u.authorization="Basic "+a(i.auth)),this.connection=new o(e,c,void 0,u,void 0,f),this.addDefaultEvents(),this.connection.onmessage=function(e){var t="string"==typeof e.data?e.data:"";r._parseResponse(t).forEach(function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,!t&&e&&e.method&&-1!==e.method.indexOf("_subscription")?r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)}):r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t])})},Object.defineProperty(this,"connected",{get:function(){return this.connection&&this.connection.readyState===this.connection.OPEN},enumerable:!0})};f.prototype.addDefaultEvents=function(){var e=this;this.connection.onerror=function(){e._timeout()},this.connection.onclose=function(){e._timeout(),e.reset()}},f.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},f.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n;var o=this;this._customTimeout&&setTimeout(function(){o.responseCallbacks[r]&&(o.responseCallbacks[r](i.ConnectionTimeout(o._customTimeout)),delete o.responseCallbacks[r])},this._customTimeout)},f.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on WS")),delete this.responseCallbacks[e])},f.prototype.send=function(e,t){var r=this;if(this.connection.readyState!==this.connection.CONNECTING){if(this.connection.readyState!==this.connection.OPEN)return console.error("connection not open on send()"),"function"==typeof this.connection.onerror?this.connection.onerror(new Error("connection not open")):console.error("no error callback"),void t(new Error("connection not open"));this.connection.send(JSON.stringify(e)),this._addResponseCallback(e,t)}else setTimeout(function(){r.send(e,t)},10)},f.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;case"connect":this.connection.onopen=t;break;case"end":this.connection.onclose=t;break;case"error":this.connection.onerror=t}},f.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)})}},f.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;case"connect":this.connection.onopen=null;break;case"end":this.connection.onclose=null;break;case"error":this.connection.onerror=null}},f.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.addDefaultEvents()},f.prototype.disconnect=function(){this.connection&&this.connection.close()},t.exports=f}).call(this,e("buffer").Buffer)},{buffer:84,underscore:325,url:327,"web3-core-helpers":338,websocket:408}],401:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-subscriptions").subscriptions,o=e("web3-core-method"),a=e("web3-net"),s=function(){var e=this;n.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments)},this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new a(this.currentProvider),[new i({name:"subscribe",type:"shh",subscriptions:{messages:{params:1}}}),new o({name:"getVersion",call:"shh_version",params:0}),new o({name:"getInfo",call:"shh_info",params:0}),new o({name:"setMaxMessageSize",call:"shh_setMaxMessageSize",params:1}),new o({name:"setMinPoW",call:"shh_setMinPoW",params:1}),new o({name:"markTrustedPeer",call:"shh_markTrustedPeer",params:1}),new o({name:"newKeyPair",call:"shh_newKeyPair",params:0}),new o({name:"addPrivateKey",call:"shh_addPrivateKey",params:1}),new o({name:"deleteKeyPair",call:"shh_deleteKeyPair",params:1}),new o({name:"hasKeyPair",call:"shh_hasKeyPair",params:1}),new o({name:"getPublicKey",call:"shh_getPublicKey",params:1}),new o({name:"getPrivateKey",call:"shh_getPrivateKey",params:1}),new o({name:"newSymKey",call:"shh_newSymKey",params:0}),new o({name:"addSymKey",call:"shh_addSymKey",params:1}),new o({name:"generateSymKeyFromPassword",call:"shh_generateSymKeyFromPassword",params:1}),new o({name:"hasSymKey",call:"shh_hasSymKey",params:1}),new o({name:"getSymKey",call:"shh_getSymKey",params:1}),new o({name:"deleteSymKey",call:"shh_deleteSymKey",params:1}),new o({name:"newMessageFilter",call:"shh_newMessageFilter",params:1}),new o({name:"getFilterMessages",call:"shh_getFilterMessages",params:1}),new o({name:"deleteMessageFilter",call:"shh_deleteMessageFilter",params:1}),new o({name:"post",call:"shh_post",params:1,inputFormatter:[null]}),new o({name:"unsubscribe",call:"shh_unsubscribe",params:1})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(s),t.exports=s},{"web3-core":348,"web3-core-method":339,"web3-core-subscriptions":345,"web3-net":372}],402:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],403:[function(e,t,r){var n=e("underscore"),i=e("ethjs-unit"),o=e("./utils.js"),a=e("./soliditySha3.js"),s=e("randomhex"),u=function(e,t){var r=[];return t.forEach(function(t){if("object"==typeof t.components){if("tuple"!==t.type.substring(0,5))throw new Error("components found but type is not tuple; report on GitHub");var i="",o=t.type.indexOf("[");o>=0&&(i=t.type.substring(o));var a=u(e,t.components);n.isArray(a)&&e?r.push("tuple("+a.join(",")+")"+i):e?r.push("("+a+")"):r.push("("+a.join(",")+")"+i)}else r.push(t.type)}),r},c=function(e){if(!o.isHexStrict(e))throw new Error("The parameter must be a valid HEX string.");var t="",r=0,n=e.length;for("0x"===e.substring(0,2)&&(r=2);r7?r+=e[n].toUpperCase():r+=e[n];return r},toHex:o.toHex,toBN:o.toBN,bytesToHex:o.bytesToHex,hexToBytes:o.hexToBytes,hexToNumberString:o.hexToNumberString,hexToNumber:o.hexToNumber,toDecimal:o.hexToNumber,numberToHex:o.numberToHex,fromDecimal:o.numberToHex,hexToUtf8:o.hexToUtf8,hexToString:o.hexToUtf8,toUtf8:o.hexToUtf8,utf8ToHex:o.utf8ToHex,stringToHex:o.utf8ToHex,fromUtf8:o.utf8ToHex,hexToAscii:c,toAscii:c,asciiToHex:f,fromAscii:f,unitMap:i.unitMap,toWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.toWei(e,t):i.toWei(e,t).toString(10)},fromWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.fromWei(e,t):i.fromWei(e,t).toString(10)},padLeft:o.leftPad,leftPad:o.leftPad,padRight:o.rightPad,rightPad:o.rightPad,toTwosComplement:o.toTwosComplement}},{"./soliditySha3.js":404,"./utils.js":405,"ethjs-unit":153,randomhex:274,underscore:325}],404:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("./utils.js"),a=function(e){var t=typeof e;if("string"===t)return o.isHexStrict(e)?new i(e.replace(/0x/i,""),16):new i(e,10);if("number"===t)return new i(e);if(o.isBigNumber(e))return new i(e.toString(10));if(o.isBN(e))return e;throw new Error(e+" is not a number")},s=function(e,t,r){var n,s,u;if("bytes"===(e=(u=e).startsWith("int[")?"int256"+u.slice(3):"int"===u?"int256":u.startsWith("uint[")?"uint256"+u.slice(4):"uint"===u?"uint256":u.startsWith("fixed[")?"fixed128x128"+u.slice(5):"fixed"===u?"fixed128x128":u.startsWith("ufixed[")?"ufixed128x128"+u.slice(6):"ufixed"===u?"ufixed128x128":u)){if(t.replace(/^0x/i,"").length%2!=0)throw new Error("Invalid bytes characters "+t.length);return t}if("string"===e)return o.utf8ToHex(t);if("bool"===e)return t?"01":"00";if(e.startsWith("address")){if(n=r?64:40,!o.isAddress(t))throw new Error(t+" is not a valid address, or the checksum is invalid.");return o.leftPad(t.toLowerCase(),n)}if(n=function(e){var t=/^\D+(\d+).*$/.exec(e);return t?parseInt(t[1],10):null}(e),e.startsWith("bytes")){if(!n)throw new Error("bytes[] not yet supported in solidity");if(r&&(n=32),n<1||n>32||n256)throw new Error("Invalid uint"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied uint exceeds width: "+n+" vs "+s.bitLength());if(s.lt(new i(0)))throw new Error("Supplied uint "+s.toString()+" is negative");return n?o.leftPad(s.toString("hex"),n/8*2):s}if(e.startsWith("int")){if(n%8||n<8||n>256)throw new Error("Invalid int"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied int exceeds width: "+n+" vs "+s.bitLength());return s.lt(new i(0))?s.toTwos(n).toString("hex"):n?o.leftPad(s.toString("hex"),n/8*2):s}throw new Error("Unsupported or invalid type: "+e)},u=function(e){if(n.isArray(e))throw new Error("Autodetection of array types is not supported.");var t,r,a="";if(n.isObject(e)&&(e.hasOwnProperty("v")||e.hasOwnProperty("t")||e.hasOwnProperty("value")||e.hasOwnProperty("type"))?(t=e.hasOwnProperty("t")?e.t:e.type,a=e.hasOwnProperty("v")?e.v:e.value):(t=o.toHex(e,!0),a=o.toHex(e),t.startsWith("int")||t.startsWith("uint")||(t="bytes")),!t.startsWith("int")&&!t.startsWith("uint")||"string"!=typeof a||/^(-)?0x/i.test(a)||(a=new i(a)),n.isArray(a)){if((r=function(e){var t=/^\D+\d*\[(\d+)\]$/.exec(e);return t?parseInt(t[1],10):null}(t))&&a.length!==r)throw new Error(t+" is not matching the given array "+JSON.stringify(a));r=a.length}return n.isArray(a)?a.map(function(e){return s(t,e,r).toString("hex").replace("0x","")}).join(""):s(t,a,r).toString("hex").replace("0x","")};t.exports=function(){var e=Array.prototype.slice.call(arguments),t=n.map(e,u);return o.sha3("0x"+t.join(""))}},{"./utils.js":405,"bn.js":402,underscore:325}],405:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("number-to-bn"),a=e("utf8"),s=e("eth-lib/lib/hash"),u=function(e){return e instanceof i||e&&e.constructor&&"BN"===e.constructor.name},c=function(e){return e&&e.constructor&&"BigNumber"===e.constructor.name},f=function(e){try{return o.apply(null,arguments)}catch(t){throw new Error(t+' Given value: "'+e+'"')}},h=function(e){return!!/^(0x)?[0-9a-f]{40}$/i.test(e)&&(!(!/^(0x|0X)?[0-9a-f]{40}$/.test(e)&&!/^(0x|0X)?[0-9A-F]{40}$/.test(e))||l(e))},l=function(e){e=e.replace(/^0x/i,"");for(var t=m(e.toLowerCase()).replace(/^0x/i,""),r=0;r<40;r++)if(parseInt(t[r],16)>7&&e[r].toUpperCase()!==e[r]||parseInt(t[r],16)<=7&&e[r].toLowerCase()!==e[r])return!1;return!0},d=function(e){var t="";e=(e=(e=(e=(e=a.encode(e)).replace(/^(?:\u0000)*/,"")).split("").reverse().join("")).replace(/^(?:\u0000)*/,"")).split("").reverse().join("");for(var r=0;r>>4).toString(16)),t.push((15&e[r]).toString(16));return"0x"+t.join("")},isHex:function(e){return(n.isString(e)||n.isNumber(e))&&/^(-0x|0x)?[0-9a-f]*$/i.test(e)},isHexStrict:y,leftPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+new Array(i).join(r||"0")+e},rightPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+e+new Array(i).join(r||"0")},toTwosComplement:function(e){return"0x"+f(e).toTwos(256).toString(16,64)},sha3:m}},{"bn.js":402,"eth-lib/lib/hash":134,"number-to-bn":237,underscore:325,utf8:329}],406:[function(e,t,r){t.exports={_from:"web3@1.0.0-beta.36",_id:"web3@1.0.0-beta.36",_inBundle:!1,_integrity:"sha512-fZDunw1V0AQS27r5pUN3eOVP7u8YAvyo6vOapdgVRolAu5LgaweP7jncYyLINqIX9ZgWdS5A090bt+ymgaYHsw==",_location:"/web3",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"web3@1.0.0-beta.36",name:"web3",escapedName:"web3",rawSpec:"1.0.0-beta.36",saveSpec:null,fetchSpec:"1.0.0-beta.36"},_requiredBy:["#USER","/"],_resolved:"https://registry.npmjs.org/web3/-/web3-1.0.0-beta.36.tgz",_shasum:"2954da9e431124c88396025510d840ba731c8373",_spec:"web3@1.0.0-beta.36",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy",author:{name:"ethereum.org"},authors:[{name:"Fabian Vogelsteller",email:"fabian@ethereum.org",homepage:"http://frozeman.de"},{name:"Marek Kotewicz",email:"marek@parity.io",url:"https://github.com/debris"},{name:"Marian Oancea",url:"https://github.com/cubedro"},{name:"Gav Wood",email:"g@parity.io",homepage:"http://gavwood.com"},{name:"Jeffery Wilcke",email:"jeffrey.wilcke@ethereum.org",url:"https://github.com/obscuren"}],bugs:{url:"https://github.com/ethereum/web3.js/issues"},bundleDependencies:!1,dependencies:{"web3-bzz":"1.0.0-beta.36","web3-core":"1.0.0-beta.36","web3-eth":"1.0.0-beta.36","web3-eth-personal":"1.0.0-beta.36","web3-net":"1.0.0-beta.36","web3-shh":"1.0.0-beta.36","web3-utils":"1.0.0-beta.36"},deprecated:!1,description:"Ethereum JavaScript API",keywords:["Ethereum","JavaScript","API"],license:"LGPL-3.0",main:"src/index.js",name:"web3",namespace:"ethereum",repository:{type:"git",url:"https://github.com/ethereum/web3.js/tree/master/packages/web3"},version:"1.0.0-beta.36"}},{}],407:[function(e,t,r){"use strict";var n=e("../package.json").version,i=e("web3-core"),o=e("web3-eth"),a=e("web3-net"),s=e("web3-eth-personal"),u=e("web3-shh"),c=e("web3-bzz"),f=e("web3-utils"),h=function(){var e=this;i.packageInit(this,arguments),this.version=n,this.utils=f,this.eth=new o(this),this.shh=new u(this),this.bzz=new c(this);var t=this.setProvider;this.setProvider=function(r,n){return t.apply(e,arguments),this.eth.setProvider(r,n),this.shh.setProvider(r,n),this.bzz.setProvider(r),!0}};h.version=n,h.utils=f,h.modules={Eth:o,Net:a,Personal:s,Shh:u,Bzz:c},i.addProviders(h),t.exports=h},{"../package.json":406,"web3-bzz":335,"web3-core":348,"web3-eth":371,"web3-eth-personal":369,"web3-net":372,"web3-shh":401,"web3-utils":403}],408:[function(e,t,r){var n=function(){return this||{}}(),i=n.WebSocket||n.MozWebSocket,o=e("./version");function a(e,t){return t?new i(e,t):new i(e)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(e){Object.defineProperty(a,e,{get:function(){return i[e]}})}),t.exports={w3cwebsocket:i?a:null,version:o}},{"./version":409}],409:[function(e,t,r){t.exports=e("../package.json").version},{"../package.json":410}],410:[function(e,t,r){t.exports={_from:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_id:"websocket@1.0.26",_inBundle:!1,_integrity:"",_location:"/websocket",_phantomChildren:{},_requested:{type:"git",raw:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",name:"websocket",escapedName:"websocket",rawSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",saveSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",fetchSpec:"git://github.com/frozeman/WebSocket-Node.git",gitCommittish:"browserifyCompatible"},_requiredBy:["/web3-providers-ws"],_resolved:"git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",_spec:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy/node_modules/web3-providers-ws",author:{name:"Brian McKelvey",email:"brian@worlize.com",url:"https://www.worlize.com/"},browser:"lib/browser.js",bugs:{url:"https://github.com/theturtle32/WebSocket-Node/issues"},bundleDependencies:!1,config:{verbose:!1},contributors:[{name:"Iñaki Baz Castillo",email:"ibc@aliax.net",url:"http://dev.sipdoc.net"}],dependencies:{debug:"^2.2.0",nan:"^2.3.3","typedarray-to-buffer":"^3.1.2",yaeti:"^0.0.6"},deprecated:!1,description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",devDependencies:{"buffer-equal":"^1.0.0",faucet:"^0.0.1",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-jshint":"^2.0.4",jshint:"^2.0.0","jshint-stylish":"^2.2.1",tape:"^4.0.1"},directories:{lib:"./lib"},engines:{node:">=0.10.0"},homepage:"https://github.com/theturtle32/WebSocket-Node",keywords:["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],license:"Apache-2.0",main:"index",name:"websocket",repository:{type:"git",url:"git+https://github.com/theturtle32/WebSocket-Node.git"},scripts:{gulp:"gulp",install:"(node-gyp rebuild 2> builderror.log) || (exit 0)",test:"faucet test/unit"},version:"1.0.26"}},{}],411:[function(e,t,r){var n=e("xhr-request");t.exports=function(e,t){return new Promise(function(r,i){n(e,t,function(e,t){e?i(e):r(t)})})}},{"xhr-request":412}],412:[function(e,t,r){var n=e("query-string"),i=e("url-set-query"),o=e("object-assign"),a=e("./lib/ensure-header.js"),s=e("./lib/request.js"),u="application/json",c=function(){};t.exports=function(e,t,r){if(!e||"string"!=typeof e)throw new TypeError("must specify a URL");"function"==typeof t&&(r=t,t={});if(r&&"function"!=typeof r)throw new TypeError("expected cb to be undefined or a function");r=r||c;var f=(t=t||{}).json?"json":"text",h=(t=o({responseType:f},t)).headers||{},l=(t.method||"GET").toUpperCase(),d=t.query;d&&("string"!=typeof d&&(d=n.stringify(d)),e=i(e,d));"json"===t.responseType&&a(h,"Accept",u);t.json&&"GET"!==l&&"HEAD"!==l&&(a(h,"Content-Type",u),t.body=JSON.stringify(t.body));return t.method=l,t.url=e,t.headers=h,delete t.query,delete t.json,s(t,r)}},{"./lib/ensure-header.js":413,"./lib/request.js":415,"object-assign":238,"query-string":266,"url-set-query":326}],413:[function(e,t,r){t.exports=function(e,t,r){var n=t.toLowerCase();e[t]||e[n]||(e[t]=r)}},{}],414:[function(e,t,r){t.exports=function(e,t){return t?{statusCode:t.statusCode,headers:t.headers,method:e.method,url:e.url,rawRequest:t.rawRequest?t.rawRequest:t}:null}},{}],415:[function(e,t,r){var n=e("xhr"),i=e("./normalize-response"),o=function(){};t.exports=function(e,t){delete e.uri;var r=!1;"json"===e.responseType&&(e.responseType="text",r=!0);var a=n(e,function(n,a,s){if(r&&!n)try{var u=a.rawRequest.responseText;s=JSON.parse(u)}catch(e){n=e}a=i(e,a),t(n,n?null:s,a),t=o}),s=a.onabort;return a.onabort=function(){var e=s.apply(a,Array.prototype.slice.call(arguments));return t(new Error("XHR Aborted")),t=o,e},a}},{"./normalize-response":414,xhr:416}],416:[function(e,t,r){"use strict";var n=e("global/window"),i=e("is-function"),o=e("parse-headers"),a=e("xtend");function s(e,t,r){var n=e;return i(t)?(r=t,"string"==typeof e&&(n={uri:e})):n=a(t,{uri:e}),n.callback=r,n}function u(e,t,r){return c(t=s(e,t,r))}function c(e){if(void 0===e.callback)throw new Error("callback argument missing");var t=!1,r=function(r,n,i){t||(t=!0,e.callback(r,n,i))};function n(e){return clearTimeout(f),e instanceof Error||(e=new Error(""+(e||"Unknown XMLHttpRequest Error"))),e.statusCode=0,r(e,m)}function i(){if(!s){var t;clearTimeout(f),t=e.useXDR&&void 0===c.status?200:1223===c.status?204:c.status;var n=m,i=null;return 0!==t?(n={body:function(){var e=void 0;if(e=c.response?c.response:c.responseText||function(e){try{if("document"===e.responseType)return e.responseXML;var t=e.responseXML&&"parsererror"===e.responseXML.documentElement.nodeName;if(""===e.responseType&&!t)return e.responseXML}catch(e){}return null}(c),y)try{e=JSON.parse(e)}catch(e){}return e}(),statusCode:t,method:l,headers:{},url:h,rawRequest:c},c.getAllResponseHeaders&&(n.headers=o(c.getAllResponseHeaders()))):i=new Error("Internal XMLHttpRequest Error"),r(i,n,n.body)}}var a,s,c=e.xhr||null;c||(c=e.cors||e.useXDR?new u.XDomainRequest:new u.XMLHttpRequest);var f,h=c.url=e.uri||e.url,l=c.method=e.method||"GET",d=e.body||e.data,p=c.headers=e.headers||{},b=!!e.sync,y=!1,m={body:void 0,headers:{},statusCode:0,method:l,url:h,rawRequest:c};if("json"in e&&!1!==e.json&&(y=!0,p.accept||p.Accept||(p.Accept="application/json"),"GET"!==l&&"HEAD"!==l&&(p["content-type"]||p["Content-Type"]||(p["Content-Type"]="application/json"),d=JSON.stringify(!0===e.json?d:e.json))),c.onreadystatechange=function(){4===c.readyState&&setTimeout(i,0)},c.onload=i,c.onerror=n,c.onprogress=function(){},c.onabort=function(){s=!0},c.ontimeout=n,c.open(l,h,!b,e.username,e.password),b||(c.withCredentials=!!e.withCredentials),!b&&e.timeout>0&&(f=setTimeout(function(){if(!s){s=!0,c.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT",n(e)}},e.timeout)),c.setRequestHeader)for(a in p)p.hasOwnProperty(a)&&c.setRequestHeader(a,p[a]);else if(e.headers&&!function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}(e.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in e&&(c.responseType=e.responseType),"beforeSend"in e&&"function"==typeof e.beforeSend&&e.beforeSend(c),c.send(d||null),c}t.exports=u,t.exports.default=u,u.XMLHttpRequest=n.XMLHttpRequest||function(){},u.XDomainRequest="withCredentials"in new u.XMLHttpRequest?u.XMLHttpRequest:n.XDomainRequest,function(e,t){for(var r=0;r=0)return this._url=this._parseUrl(t.headers.location),this._method="GET",this._loweredHeaders["content-type"]&&(delete this._headers[this._loweredHeaders["content-type"]],delete this._loweredHeaders["content-type"]),null!=this._headers["Content-Type"]&&delete this._headers["Content-Type"],delete this._headers["Content-Length"],this.upload._reset(),this._finalizeHeaders(),void this._sendHxxpRequest();this._response=t,this._response.on("data",function(e){return n._onHttpResponseData(t,e)}),this._response.on("end",function(){return n._onHttpResponseEnd(t)}),this._response.on("close",function(){return n._onHttpResponseClose(t)}),this.responseUrl=this._url.href.split("#")[0],this.status=t.statusCode,this.statusText=s.STATUS_CODES[this.status],this._parseResponseHeaders(t);var i=this._responseHeaders["content-length"]||"";this._totalBytes=+i,this._lengthComputable=!!i,this._setReadyState(r.HEADERS_RECEIVED)}},r.prototype._onHttpResponseData=function(e,t){this._response===e&&(this._responseParts.push(new n(t)),this._loadedBytes+=t.length,this.readyState!==r.LOADING&&this._setReadyState(r.LOADING),this._dispatchProgress("progress"))},r.prototype._onHttpResponseEnd=function(e){this._response===e&&(this._parseResponse(),this._request=null,this._response=null,this._setReadyState(r.DONE),this._dispatchProgress("load"),this._dispatchProgress("loadend"))},r.prototype._onHttpResponseClose=function(e){if(this._response===e){var t=this._request;this._setError(),t.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend")}},r.prototype._onHttpTimeout=function(e){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("timeout"),this._dispatchProgress("loadend"))},r.prototype._onHttpRequestError=function(e,t){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend"))},r.prototype._dispatchProgress=function(e){var t=new r.ProgressEvent(e);t.lengthComputable=this._lengthComputable,t.loaded=this._loadedBytes,t.total=this._totalBytes,this.dispatchEvent(t)},r.prototype._setError=function(){this._request=null,this._response=null,this._responseHeaders=null,this._responseParts=null},r.prototype._parseUrl=function(e,t,r){var n=null==this.nodejsBaseUrl?e:f.resolve(this.nodejsBaseUrl,e),i=f.parse(n,!1,!0);i.hash=null;var o=(i.auth||"").split(":"),a=o[0],s=o[1];return(a||s||t||r)&&(i.auth=(t||a||"")+":"+(r||s||"")),i},r.prototype._parseResponseHeaders=function(e){for(var t in this._responseHeaders={},e.headers){var r=t.toLowerCase();this._privateHeaders[r]||(this._responseHeaders[r]=e.headers[t])}null!=this._mimeOverride&&(this._responseHeaders["content-type"]=this._mimeOverride)},r.prototype._parseResponse=function(){var e=n.concat(this._responseParts);switch(this._responseParts=null,this.responseType){case"json":this.responseText=null;try{this.response=JSON.parse(e.toString("utf-8"))}catch(e){this.response=null}return;case"buffer":return this.responseText=null,void(this.response=e);case"arraybuffer":this.responseText=null;for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),i=0;i0&&(window.web3.eth.defaultAccount=t[0])})}window.ethereum=s}}},console.log("JS bridging rpc url access"),"undefined"!=typeof window&&window.bridge?window.bridge.post("getRPCurl",{},function(e,r){r&&t(r.description,null),t(null,e.rpcURL)}):(console.log("No bridge to native code is found"),t(!0,null))}()},{"./wk.bridge":424,web3:407,"web3-provider-engine/zero.js":397}],2:[function(e,t,r){t.exports=e("./register")().Promise},{"./register":4}],3:[function(e,t,r){"use strict";var n=null;t.exports=function(e,t){return function(r,i){r=r||null;var o=!1!==(i=i||{}).global;if(null===n&&o&&(n=e["@@any-promise/REGISTRATION"]||null),null!==n&&null!==r&&n.implementation!==r)throw new Error('any-promise already defined as "'+n.implementation+'". You can only register an implementation before the first call to require("any-promise") and an implementation cannot be changed');return null===n&&(n=null!==r&&void 0!==i.Promise?{Promise:i.Promise,implementation:r}:t(r),o&&(e["@@any-promise/REGISTRATION"]=n)),n}}},{}],4:[function(e,t,r){"use strict";t.exports=e("./loader")(window,function(){if(void 0===window.Promise)throw new Error("any-promise browser requires a polyfill or explicit registration e.g: require('any-promise/register/bluebird')");return{Promise:window.Promise,implementation:"window.Promise"}})},{"./loader":3}],5:[function(e,t,r){var n=r;n.bignum=e("bn.js"),n.define=e("./asn1/api").define,n.base=e("./asn1/base"),n.constants=e("./asn1/constants"),n.decoders=e("./asn1/decoders"),n.encoders=e("./asn1/encoders")},{"./asn1/api":6,"./asn1/base":8,"./asn1/constants":12,"./asn1/decoders":14,"./asn1/encoders":17,"bn.js":53}],6:[function(e,t,r){var n=e("../asn1"),i=e("inherits");function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}r.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(t){var r;try{r=e("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){r=function(e){this._initNamed(e)}}return i(r,t),r.prototype._initNamed=function(e){t.call(this,e)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(n.decoders[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(n.encoders[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},{"../asn1":5,inherits:180,vm:334}],7:[function(e,t,r){var n=e("inherits"),i=e("../base").Reporter,o=e("buffer").Buffer;function a(e,t){i.call(this,t),o.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function s(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return e instanceof s||(e=new s(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=o.byteLength(e);else{if(!o.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}n(a,i),r.DecoderBuffer=a,a.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},a.prototype.restore=function(e){var t=new a(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,i.prototype.restore.call(this,e.reporter),t},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},a.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new a(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},a.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},r.EncoderBuffer=s,s.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length?e:(Array.isArray(this.value)?this.value.forEach(function(r){r.join(e,t),t+=r.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):o.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},{"../base":8,buffer:84,inherits:180}],8:[function(e,t,r){var n=r;n.Reporter=e("./reporter").Reporter,n.DecoderBuffer=e("./buffer").DecoderBuffer,n.EncoderBuffer=e("./buffer").EncoderBuffer,n.Node=e("./node")},{"./buffer":7,"./node":9,"./reporter":10}],9:[function(e,t,r){var n=e("../base").Reporter,i=e("../base").EncoderBuffer,o=e("../base").DecoderBuffer,a=e("minimalistic-assert"),s=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],u=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function c(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}t.exports=c;var f=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){var e=this._baseState,t={};f.forEach(function(r){t[r]=e[r]});var r=new this.constructor(t.parent);return r._baseState=t,r},c.prototype._wrap=function(){var e=this._baseState;u.forEach(function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}},this)},c.prototype._init=function(e){var t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter(function(e){return e._baseState.parent===this},this),a.equal(t.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(e){var t=this._baseState,r=e.filter(function(e){return e instanceof this.constructor},this);e=e.filter(function(e){return!(e instanceof this.constructor)},this),0!==r.length&&(a(null===t.children),t.children=r,r.forEach(function(e){e._baseState.parent=this},this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map(function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach(function(r){r==(0|r)&&(r|=0);var n=e[r];t[n]=r}),t}))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(e){c.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}}),s.forEach(function(e){c.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(r),this}}),c.prototype.use=function(e){a(e);var t=this._baseState;return a(null===t.use),t.use=e,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(e){var t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},c.prototype.explicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},c.prototype.implicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},c.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},c.prototype.key=function(e){var t=this._baseState;return a(null===t.key),t.key=e,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(e){var t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map(function(t){return e[t]})),this},c.prototype.contains=function(e){var t=this._baseState;return a(null===t.use),t.contains=e,this},c.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var n,i=r.default,a=!0,s=null;if(null!==r.key&&(s=e.enterKey(r.key)),r.optional){var u=null;if(null!==r.explicit?u=r.explicit:null!==r.implicit?u=r.implicit:null!==r.tag&&(u=r.tag),null!==u||r.any){if(a=this._peekTag(e,u,r.any),e.isError(a))return a}else{var c=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(c)}}if(r.obj&&a&&(n=e.enterObject()),a){if(null!==r.explicit){var f=this._decodeTag(e,r.explicit);if(e.isError(f))return f;e=f}var h=e.offset;if(null===r.use&&null===r.choice){if(r.any)c=e.save();var l=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(l))return l;r.any?i=e.raw(c):e=l}if(t&&t.track&&null!==r.tag&&t.track(e.path(),h,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),i=r.any?i:null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),e.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach(function(r){r._decode(e,t)}),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var d=new o(i);i=this._getUse(r.contains,e._reporterState.obj)._decode(d,t)}}return r.obj&&a&&(i=e.leaveObject(n)),null===r.key||null===i&&!0!==a?null!==s&&e.exitKey(s):e.leaveKey(s,r.key,i),i},c.prototype._decodeGeneric=function(e,t,r){var n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},c.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},c.prototype._decodeChoice=function(e,t){var r=this._baseState,n=null,i=!1;return Object.keys(r.choice).some(function(o){var a=e.save(),s=r.choice[o];try{var u=s._decode(e,t);if(e.isError(u))return!1;n={type:o,value:u},i=!0}catch(t){return e.restore(a),!1}return!0},this),i?n:e.error("Choice not matched")},c.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},c.prototype._encode=function(e,t,r){var n=this._baseState;if(null===n.default||n.default!==e){var i=this._encodeValue(e,t,r);if(void 0!==i&&!this._skipDefault(i,t,r))return i}},c.prototype._encodeValue=function(e,t,r){var i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);var o=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}var a=null,s=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)a=this._getUse(i.contains,r)._encode(e,t),s=!0;else if(i.children)a=i.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i},this).filter(function(e){return e}),a=this._createEncoderBuffer(a);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var u=this.clone();u._baseState.implicit=null,a=this._createEncoderBuffer(e.map(function(r){var n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)},u))}else null!==i.use?o=this._getUse(i.use,r)._encode(e,t):(a=this._encodePrimitive(i.tag,e),s=!0);if(!i.any&&null===i.choice){var c=null!==i.implicit?i.implicit:i.tag,f=null===i.implicit?"universal":"context";null===c?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(c,s,f,a))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},c.prototype._encodeChoice=function(e,t){var r=this._baseState,n=r.choice[e.type];return n||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},c.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},c.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},c.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},{"../base":8,"minimalistic-assert":234}],10:[function(e,t,r){var n=e("inherits");function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}r.Reporter=i,i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,r){var n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){var t,r=this._reporterState,n=e instanceof o;if(t=n?e:new o(r.path.map(function(e){return"["+JSON.stringify(e)+"]"}).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},i.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},n(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{inherits:180}],11:[function(e,t,r){var n=e("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=n._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=n._reverse(r.tag)},{"../constants":12}],12:[function(e,t,r){var n=r;n._reverse=function(e){var t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r|=0);var n=e[r];t[n]=r}),t},n.der=e("./der")},{"./der":11}],13:[function(e,t,r){var n=e("inherits"),i=e("../../asn1"),o=i.base,a=i.bignum,s=i.constants.der;function u(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){o.Node.call(this,"der",e)}function f(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var n=s.tagClass[r>>6],i=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:s.tag[r]}}function h(e,t,r){var n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;var i=127&n;if(i>4)return e.error("length octet is too long");n=0;for(var o=0;o=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=s.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(n.length<128)return(o=new i(2))[0]=a,o[1]=n.length,this._createEncoderBuffer([o,n]);for(var u=1,c=n.length;c>=256;c>>=8)u++;(o=new i(2+u))[0]=a,o[1]=128|u;c=1+u;for(var f=n.length;f>0;c--,f>>=8)o[c]=255&f;return this._createEncoderBuffer([o,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new i(2*e.length),n=0;n=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var o=0;for(n=0;n=128;a>>=7)o++}var s=new i(o),u=s.length-1;for(n=e.length-1;n>=0;n--){a=e[n];for(s[u--]=127&a;(a>>=7)>0;)s[u--]=128|127&a}return this._createEncoderBuffer(s)},c.prototype._encodeTime=function(e,t){var r,n=new Date(e);return"gentime"===t?r=[f(n.getFullYear()),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[f(n.getFullYear()%100),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!i.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new i(r)}if(i.isBuffer(e)){var n=e.length;0===e.length&&n++;var o=new i(n);return e.copy(o),0===e.length&&(o[0]=0),this._createEncoderBuffer(o)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);n=1;for(var a=e;a>=256;a>>=8)n++;for(a=(o=new Array(n)).length-1;a>=0;a--)o[a]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new i(o))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){var n,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,r).join()),o.length!==i.defaultBuffer.length)return!1;for(n=0;n=0;c--)if(f[c]!==h[c])return!1;for(c=f.length-1;c>=0;c--)if(u=f[c],!v(e[u],t[u],r,n))return!1;return!0}(e,t,r,a))}return r?e===t:e==t}function g(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function w(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function _(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&y(i,r,"Missing expected exception"+n);var a="string"==typeof n,s=!e&&i&&!r;if((!e&&o.isError(i)&&a&&w(i,r)||s)&&y(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(i,r)||!e&&i)throw i}h.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=p(b((t=this).actual),128)+" "+t.operator+" "+p(b(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=d(r),a=i.indexOf("\n"+o);if(a>=0){var s=i.indexOf("\n",a+1);i=i.substring(s+1)}this.stack=i}}},o.inherits(h.AssertionError,Error),h.fail=y,h.ok=m,h.equal=function(e,t,r){e!=t&&y(e,t,r,"==",h.equal)},h.notEqual=function(e,t,r){e==t&&y(e,t,r,"!=",h.notEqual)},h.deepEqual=function(e,t,r){v(e,t,!1)||y(e,t,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(e,t,r){v(e,t,!0)||y(e,t,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(e,t,r){v(e,t,!1)&&y(e,t,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function e(t,r,n){v(t,r,!0)&&y(t,r,n,"notDeepStrictEqual",e)},h.strictEqual=function(e,t,r){e!==t&&y(e,t,r,"===",h.strictEqual)},h.notStrictEqual=function(e,t,r){e===t&&y(e,t,r,"!==",h.notStrictEqual)},h.throws=function(e,t,r){_(!0,e,t,r)},h.doesNotThrow=function(e,t,r){_(!1,e,t,r)},h.ifError=function(e){if(e)throw e};var A=Object.keys||function(e){var t=[];for(var r in e)a.call(e,r)&&t.push(r);return t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":333}],20:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){return(0,i.default)(function(t,r){var i;try{i=e.apply(this,t)}catch(e){return r(e)}(0,n.default)(i)&&"function"==typeof i.then?i.then(function(e){s(r,null,e)},function(e){s(r,e.message?e:new Error(e))}):r(null,i)})};var n=a(e("lodash/isObject")),i=a(e("./internal/initialParams")),o=a(e("./internal/setImmediate"));function a(e){return e&&e.__esModule?e:{default:e}}function s(e,t,r){try{e(t,r)}catch(e){(0,o.default)(u,e)}}function u(e){throw e}t.exports=r.default},{"./internal/initialParams":31,"./internal/setImmediate":37,"lodash/isObject":225}],21:[function(e,t,r){(function(e,n){!function(e,n){"object"==typeof r&&void 0!==t?n(r):"function"==typeof define&&define.amd?define(["exports"],n):n(e.async=e.async||{})}(this,function(r){"use strict";function i(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i-1&&e%1==0&&e<=L}function D(e){return null!=e&&O(e.length)&&!function(e){if(!s(e))return!1;var t=B(e);return t==C||t==N||t==P||t==R}(e)}var F={};function q(){}function H(e){return function(){if(null!==e){var t=e;e=null,t.apply(this,arguments)}}}var z="function"==typeof Symbol&&Symbol.iterator,K=function(e){return z&&e[z]&&e[z]()};function V(e){return null!=e&&"object"==typeof e}var G="[object Arguments]";function W(e){return V(e)&&B(e)==G}var Y=Object.prototype,X=Y.hasOwnProperty,Z=Y.propertyIsEnumerable,J=W(function(){return arguments}())?W:function(e){return V(e)&&X.call(e,"callee")&&!Z.call(e,"callee")},$=Array.isArray;var Q="object"==typeof r&&r&&!r.nodeType&&r,ee=Q&&"object"==typeof t&&t&&!t.nodeType&&t,te=ee&&ee.exports===Q?A.Buffer:void 0,re=(te?te.isBuffer:void 0)||function(){return!1},ne=9007199254740991,ie=/^(?:0|[1-9]\d*)$/;function oe(e,t){return!!(t=null==t?ne:t)&&("number"==typeof e||ie.test(e))&&e>-1&&e%1==0&&e2&&(n=i(arguments,1)),t){var c={};Fe(o,function(e,t){c[t]=e}),c[e]=n,s=!0,u=Object.create(null),r(t,c)}else o[e]=n,Le(u[e]||[],function(e){e()}),d()});a++;var c=v(t[t.length-1]);t.length>1?c(o,n):c(n)}(e,t)})}function d(){if(0===c.length&&0===a)return r(null,o);for(;c.length&&a=0&&r.push(n)}),r}Fe(e,function(t,r){if(!$(t))return l(r,[t]),void f.push(r);var n=t.slice(0,t.length-1),i=n.length;if(0===i)return l(r,t),void f.push(r);h[r]=i,Le(n,function(o){if(!e[o])throw new Error("async.auto task `"+r+"` has a non-existent dependency `"+o+"` in "+n.join(", "));!function(e,t){var r=u[e];r||(r=u[e]=[]);r.push(t)}(o,function(){0===--i&&l(r,t)})})}),function(){var e,t=0;for(;f.length;)e=f.pop(),t++,Le(p(e),function(e){0==--h[e]&&f.push(e)});if(t!==n)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),d()};function Ke(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r=n?e:function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n-1;);return r}(i,o),function(e,t){for(var r=e.length;r--&&He(t,e[r],0)>-1;);return r}(i,o)+1).join("")}var ht=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,lt=/,/,dt=/(=.+)?(\s*)$/,pt=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;function bt(e,t){var r={};Fe(e,function(e,t){var n,i,o=m(e),a=!o&&1===e.length||o&&0===e.length;if($(e))n=e.slice(0,-1),e=e[e.length-1],r[t]=n.concat(n.length>0?s:e);else if(a)r[t]=e;else{if(n=i=(i=(i=(i=(i=e).toString().replace(pt,"")).match(ht)[2].replace(" ",""))?i.split(lt):[]).map(function(e){return ft(e.replace(dt,""))}),0===e.length&&!o&&0===n.length)throw new Error("autoInject task functions require explicit parameters.");o||n.pop(),r[t]=n.concat(s)}function s(t,r){var i=Ke(n,function(e){return t[e]});i.push(r),v(e).apply(null,i)}}),ze(r,t)}function yt(){this.head=this.tail=null,this.length=0}function mt(e,t){e.length=1,e.head=e.tail=t}function vt(e,t,r){if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var n=v(e),i=0,o=[],a=!1;function s(e,t,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(f.started=!0,$(e)||(e=[e]),0===e.length&&f.idle())return l(function(){f.drain()});for(var n=0,i=e.length;n0&&o.splice(s,1),a.callback.apply(a,arguments),null!=t&&f.error(t,a.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()}}var c=!1,f={_tasks:new yt,concurrency:t,payload:r,saturated:q,unsaturated:q,buffer:t/4,empty:q,drain:q,error:q,started:!1,paused:!1,push:function(e,t){s(e,!1,t)},kill:function(){f.drain=q,f._tasks.empty()},unshift:function(e,t){s(e,!0,t)},remove:function(e){f._tasks.remove(e)},process:function(){if(!c){for(c=!0;!f.paused&&i2&&(o=i(arguments,1)),n[t]=o,r(e)})},function(e){r(e,n)})}function br(e,t){pr(Ie,e,t)}function yr(e,t,r){pr(Ee(t),e,r)}var mr=function(e,t){var r=v(e);return vt(function(e,t){r(e[0],t)},t,1)},vr=function(e,t){var r=mr(e,t);return r.push=function(e,t,n){if(null==n&&(n=q),"function"!=typeof n)throw new Error("task callback must be a function");if(r.started=!0,$(e)||(e=[e]),0===e.length)return l(function(){r.drain()});t=t||0;for(var i=r._tasks.head;i&&t>=i.priority;)i=i.next;for(var o=0,a=e.length;on?1:0}je(e,function(e,t){n(e,function(r,n){if(r)return t(r);t(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);r(null,Ke(t.sort(i),Zt("value")))})}function Nr(e,t,r){var n=v(e);return a(function(i,o){var a,s=!1;i.push(function(){s||(o.apply(null,arguments),clearTimeout(a))}),a=setTimeout(function(){var t=e.name||"anonymous",n=new Error('Callback function "'+t+'" timed out.');n.code="ETIMEDOUT",r&&(n.info=r),s=!0,o(n)},t),n.apply(null,i)})}var Rr=Math.ceil,Lr=Math.max;function Or(e,t,r,n){var i=v(r);Ce(function(e,t,r,n){for(var i=-1,o=Lr(Rr((t-e)/(r||1)),0),a=Array(o);o--;)a[n?o:++i]=e,e+=r;return a}(0,e,1),t,i,n)}var Dr=ke(Or,1/0),Fr=ke(Or,1);function qr(e,t,r,n){arguments.length<=3&&(n=r,r=t,t=$(e)?[]:{}),n=H(n||q);var i=v(r);Ie(e,function(e,r,n){i(t,e,r,n)},function(e){n(e,t)})}function Hr(e,t){var r,n=null;t=t||q,Kt(e,function(e,t){v(e)(function(e,o){r=arguments.length>2?i(arguments,1):o,n=e,t(!e)})},function(){t(n,r)})}function zr(e){return function(){return(e.unmemoized||e).apply(null,arguments)}}function Kr(e,t,r){r=Ae(r||q);var n=v(t);if(!e())return r(null);var o=function(t){if(t)return r(t);if(e())return n(o);var a=i(arguments,1);r.apply(null,[null].concat(a))};n(o)}function Vr(e,t,r){Kr(function(){return!e.apply(this,arguments)},t,r)}var Gr=function(e,t){if(t=H(t||q),!$(e))return t(new Error("First argument to waterfall must be an array of functions"));if(!e.length)return t();var r=0;function n(t){var n=v(e[r++]);t.push(Ae(o)),n.apply(null,t)}function o(o){if(o||r===e.length)return t.apply(null,arguments);n(i(arguments,1))}n([])},Wr={apply:o,applyEach:Be,applyEachSeries:Re,asyncify:d,auto:ze,autoInject:bt,cargo:gt,compose:Et,concat:St,concatLimit:kt,concatSeries:Mt,constant:It,detect:Bt,detectLimit:Pt,detectSeries:Ct,dir:Rt,doDuring:Lt,doUntil:Dt,doWhilst:Ot,during:Ft,each:Ht,eachLimit:zt,eachOf:Ie,eachOfLimit:xe,eachOfSeries:wt,eachSeries:Kt,ensureAsync:Vt,every:Wt,everyLimit:Yt,everySeries:Xt,filter:er,filterLimit:tr,filterSeries:rr,forever:nr,groupBy:or,groupByLimit:ir,groupBySeries:ar,log:sr,map:je,mapLimit:Ce,mapSeries:Ne,mapValues:cr,mapValuesLimit:ur,mapValuesSeries:fr,memoize:lr,nextTick:dr,parallel:br,parallelLimit:yr,priorityQueue:vr,queue:mr,race:gr,reduce:_t,reduceRight:wr,reflect:_r,reflectAll:Ar,reject:xr,rejectLimit:kr,rejectSeries:Sr,retry:Ir,retryable:Tr,seq:At,series:Ur,setImmediate:l,some:jr,someLimit:Br,someSeries:Pr,sortBy:Cr,timeout:Nr,times:Dr,timesLimit:Or,timesSeries:Fr,transform:qr,tryEach:Hr,unmemoize:zr,until:Vr,waterfall:Gr,whilst:Kr,all:Wt,allLimit:Yt,allSeries:Xt,any:jr,anyLimit:Br,anySeries:Pr,find:Bt,findLimit:Pt,findSeries:Ct,forEach:Ht,forEachSeries:Kt,forEachLimit:zt,forEachOf:Ie,forEachOfSeries:wt,forEachOfLimit:xe,inject:_t,foldl:_t,foldr:wr,select:er,selectLimit:tr,selectSeries:rr,wrapSync:d};r.default=Wr,r.apply=o,r.applyEach=Be,r.applyEachSeries=Re,r.asyncify=d,r.auto=ze,r.autoInject=bt,r.cargo=gt,r.compose=Et,r.concat=St,r.concatLimit=kt,r.concatSeries=Mt,r.constant=It,r.detect=Bt,r.detectLimit=Pt,r.detectSeries=Ct,r.dir=Rt,r.doDuring=Lt,r.doUntil=Dt,r.doWhilst=Ot,r.during=Ft,r.each=Ht,r.eachLimit=zt,r.eachOf=Ie,r.eachOfLimit=xe,r.eachOfSeries=wt,r.eachSeries=Kt,r.ensureAsync=Vt,r.every=Wt,r.everyLimit=Yt,r.everySeries=Xt,r.filter=er,r.filterLimit=tr,r.filterSeries=rr,r.forever=nr,r.groupBy=or,r.groupByLimit=ir,r.groupBySeries=ar,r.log=sr,r.map=je,r.mapLimit=Ce,r.mapSeries=Ne,r.mapValues=cr,r.mapValuesLimit=ur,r.mapValuesSeries=fr,r.memoize=lr,r.nextTick=dr,r.parallel=br,r.parallelLimit=yr,r.priorityQueue=vr,r.queue=mr,r.race=gr,r.reduce=_t,r.reduceRight=wr,r.reflect=_r,r.reflectAll=Ar,r.reject=xr,r.rejectLimit=kr,r.rejectSeries=Sr,r.retry=Ir,r.retryable=Tr,r.seq=At,r.series=Ur,r.setImmediate=l,r.some=jr,r.someLimit=Br,r.someSeries=Pr,r.sortBy=Cr,r.timeout=Nr,r.times=Dr,r.timesLimit=Or,r.timesSeries=Fr,r.transform=qr,r.tryEach=Hr,r.unmemoize=zr,r.until=Vr,r.waterfall=Gr,r.whilst=Kr,r.all=Wt,r.allLimit=Yt,r.allSeries=Xt,r.any=jr,r.anyLimit=Br,r.anySeries=Pr,r.find=Bt,r.findLimit=Pt,r.findSeries=Ct,r.forEach=Ht,r.forEachSeries=Kt,r.forEachLimit=zt,r.forEachOf=Ie,r.forEachOfSeries=wt,r.forEachOfLimit=xe,r.inject=_t,r.foldl=_t,r.foldr=wr,r.select=er,r.selectLimit=tr,r.selectSeries=rr,r.wrapSync=d,Object.defineProperty(r,"__esModule",{value:!0})})}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257}],22:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r,a){(0,n.default)(t)(e,(0,i.default)((0,o.default)(r)),a)};var n=a(e("./internal/eachOfLimit")),i=a(e("./internal/withoutIndex")),o=a(e("./internal/wrapAsync"));function a(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./internal/eachOfLimit":29,"./internal/withoutIndex":39,"./internal/wrapAsync":40}],23:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r){((0,n.default)(e)?l:d)(e,(0,f.default)(t),r)};var n=h(e("lodash/isArrayLike")),i=h(e("./internal/breakLoop")),o=h(e("./eachOfLimit")),a=h(e("./internal/doLimit")),s=h(e("lodash/noop")),u=h(e("./internal/once")),c=h(e("./internal/onlyOnce")),f=h(e("./internal/wrapAsync"));function h(e){return e&&e.__esModule?e:{default:e}}function l(e,t,r){r=(0,u.default)(r||s.default);var n=0,o=0,a=e.length;function f(e,t){e?r(e):++o!==a&&t!==i.default||r(null)}for(0===a&&r(null);n2&&(n=(0,o.default)(arguments,1)),s[t]=n,r(e)})},function(e){r(e,s)})};var n=s(e("lodash/noop")),i=s(e("lodash/isArrayLike")),o=s(e("./slice")),a=s(e("./wrapAsync"));function s(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./slice":38,"./wrapAsync":40,"lodash/isArrayLike":221,"lodash/noop":229}],37:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.hasNextTick=r.hasSetImmediate=void 0,r.fallback=c,r.wrap=f;var n,i=e("./slice"),o=(n=i)&&n.__esModule?n:{default:n};var a,s=r.hasSetImmediate="function"==typeof setImmediate&&setImmediate,u=r.hasNextTick="object"==typeof t&&"function"==typeof t.nextTick;function c(e){setTimeout(e,0)}function f(e){return function(t){var r=(0,o.default)(arguments,1);e(function(){t.apply(null,r)})}}a=s?setImmediate:u?t.nextTick:c,r.default=f(a)}).call(this,e("_process"))},{"./slice":38,_process:257}],38:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i0,"Expected a maximum number of retry greater than 0 but got %s.",e),this.maxNumberOfRetry_=e},o.prototype.backoff=function(e){i.checkState(-1===this.timeoutID_,"Backoff in progress."),this.backoffNumber_===this.maxNumberOfRetry_?(this.emit("fail",e),this.reset()):(this.backoffDelay_=this.backoffStrategy_.next(),this.timeoutID_=setTimeout(this.handlers.backoff,this.backoffDelay_),this.emit("backoff",this.backoffNumber_,this.backoffDelay_,e))},o.prototype.onBackoff_=function(){this.timeoutID_=-1,this.emit("ready",this.backoffNumber_,this.backoffDelay_),this.backoffNumber_++},o.prototype.reset=function(){this.backoffNumber_=0,this.backoffStrategy_.reset(),clearTimeout(this.timeoutID_),this.timeoutID_=-1},t.exports=o},{events:157,precond:253,util:333}],47:[function(e,t,r){var n=e("events"),i=e("precond"),o=e("util"),a=e("./backoff"),s=e("./strategy/fibonacci");function u(e,t,r){n.EventEmitter.call(this),i.checkIsFunction(e,"Expected fn to be a function."),i.checkIsArray(t,"Expected args to be an array."),i.checkIsFunction(r,"Expected callback to be a function."),this.function_=e,this.arguments_=t,this.callback_=r,this.lastResult_=[],this.numRetries_=0,this.backoff_=null,this.strategy_=null,this.failAfter_=-1,this.retryPredicate_=u.DEFAULT_RETRY_PREDICATE_,this.state_=u.State_.PENDING}o.inherits(u,n.EventEmitter),u.State_={PENDING:0,RUNNING:1,COMPLETED:2,ABORTED:3},u.DEFAULT_RETRY_PREDICATE_=function(e){return!0},u.prototype.isPending=function(){return this.state_==u.State_.PENDING},u.prototype.isRunning=function(){return this.state_==u.State_.RUNNING},u.prototype.isCompleted=function(){return this.state_==u.State_.COMPLETED},u.prototype.isAborted=function(){return this.state_==u.State_.ABORTED},u.prototype.setStrategy=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.strategy_=e,this},u.prototype.retryIf=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.retryPredicate_=e,this},u.prototype.getLastResult=function(){return this.lastResult_.concat()},u.prototype.getNumRetries=function(){return this.numRetries_},u.prototype.failAfter=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.failAfter_=e,this},u.prototype.abort=function(){this.isCompleted()||this.isAborted()||(this.isRunning()&&this.backoff_.reset(),this.state_=u.State_.ABORTED,this.lastResult_=[new Error("Backoff aborted.")],this.emit("abort"),this.doCallback_())},u.prototype.start=function(e){i.checkState(!this.isAborted(),"FunctionCall is aborted."),i.checkState(this.isPending(),"FunctionCall already started.");var t=this.strategy_||new s;this.backoff_=e?e(t):new a(t),this.backoff_.on("ready",this.doCall_.bind(this,!0)),this.backoff_.on("fail",this.doCallback_.bind(this)),this.backoff_.on("backoff",this.handleBackoff_.bind(this)),this.failAfter_>0&&this.backoff_.failAfter(this.failAfter_),this.state_=u.State_.RUNNING,this.doCall_(!1)},u.prototype.doCall_=function(e){e&&this.numRetries_++;var t=["call"].concat(this.arguments_);n.EventEmitter.prototype.emit.apply(this,t);var r=this.handleFunctionCallback_.bind(this);this.function_.apply(null,this.arguments_.concat(r))},u.prototype.doCallback_=function(){this.callback_.apply(null,this.lastResult_)},u.prototype.handleFunctionCallback_=function(){if(!this.isAborted()){var e=Array.prototype.slice.call(arguments);this.lastResult_=e,n.EventEmitter.prototype.emit.apply(this,["callback"].concat(e));var t=e[0];t&&this.retryPredicate_(t)?this.backoff_.backoff(t):(this.state_=u.State_.COMPLETED,this.doCallback_())}},u.prototype.handleBackoff_=function(e,t,r){this.emit("backoff",e,t,r)},t.exports=u},{"./backoff":46,"./strategy/fibonacci":49,events:157,precond:253,util:333}],48:[function(e,t,r){var n=e("util"),i=e("precond"),o=e("./strategy");function a(e){o.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay(),this.factor_=a.DEFAULT_FACTOR,e&&void 0!==e.factor&&(i.checkArgument(e.factor>1,"Exponential factor should be greater than 1 but got %s.",e.factor),this.factor_=e.factor)}n.inherits(a,o),a.DEFAULT_FACTOR=2,a.prototype.next_=function(){return this.backoffDelay_=Math.min(this.nextBackoffDelay_,this.getMaxDelay()),this.nextBackoffDelay_=this.backoffDelay_*this.factor_,this.backoffDelay_},a.prototype.reset_=function(){this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()},t.exports=a},{"./strategy":50,precond:253,util:333}],49:[function(e,t,r){var n=e("util"),i=e("./strategy");function o(e){i.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}n.inherits(o,i),o.prototype.next_=function(){var e=Math.min(this.nextBackoffDelay_,this.getMaxDelay());return this.nextBackoffDelay_+=this.backoffDelay_,this.backoffDelay_=e,e},o.prototype.reset_=function(){this.nextBackoffDelay_=this.getInitialDelay(),this.backoffDelay_=0},t.exports=o},{"./strategy":50,util:333}],50:[function(e,t,r){e("events"),e("util");function n(e){return null!=e}function i(e){if(n((e=e||{}).initialDelay)&&e.initialDelay<1)throw new Error("The initial timeout must be greater than 0.");if(n(e.maxDelay)&&e.maxDelay<1)throw new Error("The maximal timeout must be greater than 0.");if(this.initialDelay_=e.initialDelay||100,this.maxDelay_=e.maxDelay||1e4,this.maxDelay_<=this.initialDelay_)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");if(n(e.randomisationFactor)&&(e.randomisationFactor<0||e.randomisationFactor>1))throw new Error("The randomisation factor must be between 0 and 1.");this.randomisationFactor_=e.randomisationFactor||0}i.prototype.getMaxDelay=function(){return this.maxDelay_},i.prototype.getInitialDelay=function(){return this.initialDelay_},i.prototype.next=function(){var e=this.next_(),t=1+Math.random()*this.randomisationFactor_;return Math.round(e*t)},i.prototype.next_=function(){throw new Error("BackoffStrategy.next_() unimplemented.")},i.prototype.reset=function(){this.reset_()},i.prototype.reset_=function(){throw new Error("BackoffStrategy.reset_() unimplemented.")},t.exports=i},{events:157,util:333}],51:[function(e,t,r){"use strict";r.byteLength=function(e){return 3*e.length/4-c(e)},r.toByteArray=function(e){var t,r,n,a,s,u=e.length;a=c(e),s=new o(3*u/4-a),r=a>0?u-4:u;var f=0;for(t=0;t>16&255,s[f++]=n>>8&255,s[f++]=255&n;2===a?(n=i[e.charCodeAt(t)]<<2|i[e.charCodeAt(t+1)]>>4,s[f++]=255&n):1===a&&(n=i[e.charCodeAt(t)]<<10|i[e.charCodeAt(t+1)]<<4|i[e.charCodeAt(t+2)]>>2,s[f++]=n>>8&255,s[f++]=255&n);return s},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o="",a=[],s=0,u=r-i;su?u:s+16383));1===i?(t=e[r-1],o+=n[t>>2],o+=n[t<<4&63],o+="=="):2===i&&(t=(e[r-2]<<8)+e[r-1],o+=n[t>>10],o+=n[t>>4&63],o+=n[t<<2&63],o+="=");return a.push(o),a.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function f(e,t,r){for(var i,o,a=[],s=t;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],52:[function(e,t,r){var n=e("safe-buffer").Buffer;t.exports={check:function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))},decode:function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");var r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},encode:function(e,t){var r=e.length,i=t.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(i>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+r]=2,o[5+r]=t.length,t.copy(o,6+r),o}}},{"safe-buffer":290}],53:[function(e,t,r){!function(t,r){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var a;"object"==typeof t?t.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{a=e("buffer").Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:55}],54:[function(e,t,r){var n;function i(e){this.rand=e}if(t.exports=function(e){return n||(n=new i(null)),n.generate(e)},t.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^t[m++],a=c[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^t[m++],s=c[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^t[m++],u=c[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^t[m++],d=o,p=a,b=s,y=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^t[m++],a=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^t[m++],s=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[m++],u=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^t[m++],[o>>>=0,a>>>=0,s>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],u=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,u=0;u<256;++u){var c=s^s<<1^s<<2^s<<3^s<<4;c=c>>>8^255&c^99,r[a]=c,n[c]=a;var f=e[a],h=e[f],l=e[h],d=257*e[c]^16843008*c;i[0][a]=d<<24|d>>>8,i[1][a]=d<<16|d>>>16,i[2][a]=d<<8|d>>>24,i[3][a]=d,d=16843009*l^65537*h^257*f^16843008*a,o[0][c]=d<<24|d>>>8,o[1][c]=d<<16|d>>>16,o[2][c]=d<<8|d>>>24,o[3][c]=d,0===a?a=s=1:(a=f^e[e[e[l^f]]],s^=e[e[s]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(e){this._key=i(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a],a^=s[o/t|0]<<24):t>6&&o%t==4&&(a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a]),i[o]=i[o-t]^a}for(var c=[],f=0;f>>24]]^u.INV_SUB_MIX[1][u.SBOX[l>>>16&255]]^u.INV_SUB_MIX[2][u.SBOX[l>>>8&255]]^u.INV_SUB_MIX[3][u.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},c.prototype.encryptBlockRaw=function(e){return a(e=i(e),this._keySchedule,u.SUB_MIX,u.SBOX,this._nRounds)},c.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=n.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},c.prototype.decryptBlock=function(e){var t=(e=i(e))[1];e[1]=e[3],e[3]=t;var r=a(e,this._invKeySchedule,u.INV_SUB_MIX,u.INV_SBOX,this._nRounds),o=n.allocUnsafe(16);return o.writeUInt32BE(r[0],0),o.writeUInt32BE(r[3],4),o.writeUInt32BE(r[2],8),o.writeUInt32BE(r[1],12),o},c.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},t.exports.AES=c},{"safe-buffer":290}],57:[function(e,t,r){var n=e("./aes"),i=e("safe-buffer").Buffer,o=e("cipher-base"),a=e("inherits"),s=e("./ghash"),u=e("buffer-xor"),c=e("./incr32");function f(e,t,r,a){o.call(this);var u=i.alloc(4,0);this._cipher=new n.AES(t);var f=this._cipher.encryptBlock(u);this._ghash=new s(f),r=function(e,t,r){if(12===t.length)return e._finID=i.concat([t,i.from([0,0,0,1])]),i.concat([t,i.from([0,0,0,2])]);var n=new s(r),o=t.length,a=o%16;n.update(t),a&&(a=16-a,n.update(i.alloc(a,0))),n.update(i.alloc(8,0));var u=8*o,f=i.alloc(8);f.writeUIntBE(u,0,8),n.update(f),e._finID=n.state;var h=i.from(e._finID);return c(h),h}(this,r,f),this._prev=i.from(r),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=a,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}a(f,o),f.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=i.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},f.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=u(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var n=Math.min(e.length,t.length),i=0;i16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},h.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(e,t){var r=o[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(t,!1,r.key,r.iv);return l(e,n.key,n.iv)},r.createDecipheriv=l},{"./aes":56,"./authCipher":57,"./modes":69,"./streamCipher":72,"cipher-base":86,evp_bytestokey:158,inherits:180,"safe-buffer":290}],60:[function(e,t,r){var n=e("./modes"),i=e("./authCipher"),o=e("safe-buffer").Buffer,a=e("./streamCipher"),s=e("cipher-base"),u=e("./aes"),c=e("evp_bytestokey");function f(e,t,r){s.call(this),this._cache=new l,this._cipher=new u.AES(t),this._prev=o.from(r),this._mode=e,this._autopadding=!0}e("inherits")(f,s),f.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get();)r=this._mode.encrypt(this,t),n.push(r);return o.concat(n)};var h=o.alloc(16,16);function l(){this.cache=o.allocUnsafe(0)}function d(e,t,r){var s=n[e.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=o.from(t)),t.length!==s.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=o.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new a(s.module,t,r):"auth"===s.type?new i(s.module,t,r):new f(s.module,t,r)}f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(h))throw this._cipher.scrub(),new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},l.prototype.add=function(e){this.cache=o.concat([this.cache,e])},l.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},l.prototype.flush=function(){for(var e=16-this.cache.length,t=o.allocUnsafe(e),r=-1;++r>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function a(e){this.h=e,this.state=n.alloc(16,0),this.cache=n.allocUnsafe(0)}a.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=o(i)},a.prototype.update=function(e){var t;for(this.cache=n.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},a.prototype.final=function(e,t){return this.cache.length&&this.ghash(n.concat([this.cache,i],16)),this.ghash(o([0,e,0,t])),this.state},t.exports=a},{"safe-buffer":290}],62:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],63:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":83}],64:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("buffer-xor");function o(e,t,r){var o=t.length,a=i(t,e._cache);return e._cache=e._cache.slice(o),e._prev=n.concat([e._prev,r?t:a]),a}r.encrypt=function(e,t,r){for(var i,a=n.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=n.allocUnsafe(0)),!(e._cache.length<=t.length)){a=n.concat([a,o(e,t,r)]);break}i=e._cache.length,a=n.concat([a,o(e,t.slice(0,i),r)]),t=t.slice(i)}return a}},{"buffer-xor":83,"safe-buffer":290}],65:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t,r){for(var n,i,a=-1,s=0;++a<8;)n=t&1<<7-a?128:0,s+=(128&(i=e._cipher.encryptBlock(e._prev)[0]^n))>>a%8,e._prev=o(e._prev,r?n:i);return s}function o(e,t){var r=e.length,i=-1,o=n.allocUnsafe(e.length);for(e=n.concat([e,n.from([t])]);++i>7;return o}r.encrypt=function(e,t,r){for(var o=t.length,a=n.allocUnsafe(o),s=-1;++s=0||!r.umod(e.prime1)||!r.umod(e.prime2);)r=new n(i(t));return r}t.exports=o,o.getr=a}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84,randombytes:270}],77:[function(e,t,r){t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":78}],78:[function(e,t,r){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],79:[function(e,t,r){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],80:[function(e,t,r){(function(r){var n=e("create-hash"),i=e("stream"),o=e("inherits"),a=e("./sign"),s=e("./verify"),u=e("./algorithms.json");function c(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function f(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function h(e){return new c(e)}function l(e){return new f(e)}Object.keys(u).forEach(function(e){u[e].id=new r(u[e].id,"hex"),u[e.toLowerCase()]=u[e]}),o(c,i.Writable),c.prototype._write=function(e,t,r){this._hash.update(e),r()},c.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},c.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),n=a(r,e,this._hashType,this._signType,this._tag);return t?n.toString(t):n},o(f,i.Writable),f.prototype._write=function(e,t,r){this._hash.update(e),r()},f.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},f.prototype.verify=function(e,t,n){"string"==typeof t&&(t=new r(t,n)),this.end();var i=this._hash.digest();return s(t,i,e,this._signType,this._tag)},t.exports={Sign:h,Verify:l,createSign:h,createVerify:l}}).call(this,e("buffer").Buffer)},{"./algorithms.json":78,"./sign":81,"./verify":82,buffer:84,"create-hash":91,inherits:180,stream:311}],81:[function(e,t,r){(function(r){var n=e("create-hmac"),i=e("browserify-rsa"),o=e("elliptic").ec,a=e("bn.js"),s=e("parse-asn1"),u=e("./curves.json");function c(e,t,i,o){if((e=new r(e.toArray())).length0&&r.ishrn(n),r}function h(e,t,i){var o,a;do{for(o=new r(0);8*o.length=t)throw new Error("invalid sig")}t.exports=function(e,t,u,c,f){var h=o(u);if("ec"===h.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var n=a[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),s=r.data.subjectPrivateKey.data;return o.verify(t,e,s)}(e,t,h)}if("dsa"===h.type){if("dsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var i=r.data.p,a=r.data.q,u=r.data.g,c=r.data.pub_key,f=o.signature.decode(e,"der"),h=f.s,l=f.r;s(h,a),s(l,a);var d=n.mont(i),p=h.invm(a);return 0===u.toRed(d).redPow(new n(t).mul(p).mod(a)).fromRed().mul(c.toRed(d).redPow(l.mul(p).mod(a)).fromRed()).mod(i).mod(a).cmp(l)}(e,t,h)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");t=r.concat([f,t]);for(var l=h.modulus.byteLength(),d=[1],p=0;t.length+d.length+2o)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=s.prototype,t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(e)}return u(e,t,r)}function u(e,t,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return F(e)?function(e,t,r){if(t<0||e.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function d(e,t){if(s.isBuffer(e))return e.length;if(q(e)||F(e))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return O(e).length;default:if(n)return L(e).length;t=(""+t).toLowerCase(),n=!0}}function p(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var o,a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var f=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function x(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return x(this,t,r);case"ascii":return S(this,t,r);case"latin1":case"binary":return M(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},s.prototype.compare=function(e,t,r,n,i){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),u=Math.min(o,a),c=this.slice(n,i),f=e.slice(t,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return m(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return g(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function S(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,r,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function B(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function C(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,8),i.write(e,t,r,n,52,8),r+8}s.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},s.prototype.readUInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeFloatLE=function(e,t,r){return P(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return P(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return C(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return C(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(e){return n.toByteArray(function(e){if((e=e.trim().replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function F(e){return e instanceof ArrayBuffer||null!=e&&null!=e.constructor&&"ArrayBuffer"===e.constructor.name&&"number"==typeof e.byteLength}function q(e){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(e)}function H(e){return e!=e}},{"base64-js":51,ieee754:178}],85:[function(e,t,r){t.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],86:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("stream").Transform,o=e("string_decoder").StringDecoder;function a(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(a,i),a.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},a.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},a.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},a.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},t.exports=a},{inherits:180,"safe-buffer":290,stream:311,string_decoder:317}],87:[function(e,t,r){(function(e){var r=function(){"use strict";function t(e,t){return null!=t&&e instanceof t}var r,n,i;try{r=Map}catch(e){r=function(){}}try{n=Set}catch(e){n=function(){}}try{i=Promise}catch(e){i=function(){}}function o(a,u,c,f,h){"object"==typeof u&&(c=u.depth,f=u.prototype,h=u.includeNonEnumerable,u=u.circular);var l=[],d=[],p=void 0!==e;return void 0===u&&(u=!0),void 0===c&&(c=1/0),function a(c,b){if(null===c)return null;if(0===b)return c;var y,m;if("object"!=typeof c)return c;if(t(c,r))y=new r;else if(t(c,n))y=new n;else if(t(c,i))y=new i(function(e,t){c.then(function(t){e(a(t,b-1))},function(e){t(a(e,b-1))})});else if(o.__isArray(c))y=[];else if(o.__isRegExp(c))y=new RegExp(c.source,s(c)),c.lastIndex&&(y.lastIndex=c.lastIndex);else if(o.__isDate(c))y=new Date(c.getTime());else{if(p&&e.isBuffer(c))return y=e.allocUnsafe?e.allocUnsafe(c.length):new e(c.length),c.copy(y),y;t(c,Error)?y=Object.create(c):void 0===f?(m=Object.getPrototypeOf(c),y=Object.create(m)):(y=Object.create(f),m=f)}if(u){var v=l.indexOf(c);if(-1!=v)return d[v];l.push(c),d.push(y)}for(var g in t(c,r)&&c.forEach(function(e,t){var r=a(t,b-1),n=a(e,b-1);y.set(r,n)}),t(c,n)&&c.forEach(function(e){var t=a(e,b-1);y.add(t)}),c){var w;m&&(w=Object.getOwnPropertyDescriptor(m,g)),w&&null==w.set||(y[g]=a(c[g],b-1))}if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(c);for(g=0;g<_.length;g++){var A=_[g];(!(x=Object.getOwnPropertyDescriptor(c,A))||x.enumerable||h)&&(y[A]=a(c[A],b-1),x.enumerable||Object.defineProperty(y,A,{enumerable:!1}))}}if(h){var E=Object.getOwnPropertyNames(c);for(g=0;g>>2),a=0,s=0;a>5]|=128<>>9<<4)]=t;for(var r=1732584193,n=-271733879,i=-1732584194,o=271733878,h=0;h>>32-s,r);var a,s}function a(e,t,r,n,i,a,s){return o(t&r|~t&n,e,t,i,a,s)}function s(e,t,r,n,i,a,s){return o(t&n|r&~n,e,t,i,a,s)}function u(e,t,r,n,i,a,s){return o(t^r^n,e,t,i,a,s)}function c(e,t,r,n,i,a,s){return o(r^(t|~n),e,t,i,a,s)}function f(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}t.exports=function(e){return n(e,i)}},{"./make-hash":92}],94:[function(e,t,r){"use strict";var n=e("inherits"),i=e("./legacy"),o=e("cipher-base"),a=e("safe-buffer").Buffer,s=e("create-hash/md5"),u=e("ripemd160"),c=e("sha.js"),f=a.alloc(128);function h(e,t){o.call(this,"digest"),"string"==typeof t&&(t=a.from(t));var r="sha512"===e||"sha384"===e?128:64;(this._alg=e,this._key=t,t.length>r)?t=("rmd160"===e?new u:c(e)).update(t).digest():t.lengths?t=e(t):t.length-1};f.prototype.append=function(e,t){e=s(e),t=u(t);var r=this.map[e];this.map[e]=r?r+","+t:t},f.prototype.delete=function(e){delete this.map[s(e)]},f.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},f.prototype.set=function(e,t){this.map[s(e)]=u(t)},f.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},f.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),c(e)},f.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),c(e)},f.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),c(e)},t.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);var o=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},b.call(y.prototype),b.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:0,statusText:""});return e.type="error",e};var a=[301,302,303,307,308];v.redirect=function(e,t){if(-1===a.indexOf(t))throw new RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},e.Headers=f,e.Request=y,e.Response=v,e.fetch=function(e,r){return new Promise(function(n,i){var o=new y(e,r),a=new XMLHttpRequest;a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new v(i,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&t.blob&&(a.responseType="blob"),o.headers.forEach(function(e,t){a.setRequestHeader(t,e)}),a.send(void 0===o._bodyInit?null:o._bodyInit)})},e.fetch.polyfill=!0}function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function u(e){return"string"!=typeof e&&(e=String(e)),e}function c(e){var r={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t.iterable&&(r[Symbol.iterator]=function(){return r}),r}function f(e){this.map={},e instanceof f?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function h(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function l(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function d(e){var t=new FileReader,r=l(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(t.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(t.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(t.arrayBuffer&&t.blob&&n(e))this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!t.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(e)&&!i(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=p(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},t.blob&&(this.blob=function(){var e=h(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var e,t,r,n=h(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=l(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function v(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}}(void 0!==e?e:this)}).call(n,void 0);var i=n.fetch;i.Response=n.Response,i.Request=n.Request,i.Headers=n.Headers;"object"==typeof t&&t.exports&&(t.exports=i,t.exports.default=i)},{}],97:[function(e,t,r){"use strict";r.randomBytes=r.rng=r.pseudoRandomBytes=r.prng=e("randombytes"),r.createHash=r.Hash=e("create-hash"),r.createHmac=r.Hmac=e("create-hmac");var n=e("browserify-sign/algos"),i=Object.keys(n),o=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(i);r.getHashes=function(){return o};var a=e("pbkdf2");r.pbkdf2=a.pbkdf2,r.pbkdf2Sync=a.pbkdf2Sync;var s=e("browserify-cipher");r.Cipher=s.Cipher,r.createCipher=s.createCipher,r.Cipheriv=s.Cipheriv,r.createCipheriv=s.createCipheriv,r.Decipher=s.Decipher,r.createDecipher=s.createDecipher,r.Decipheriv=s.Decipheriv,r.createDecipheriv=s.createDecipheriv,r.getCiphers=s.getCiphers,r.listCiphers=s.listCiphers;var u=e("diffie-hellman");r.DiffieHellmanGroup=u.DiffieHellmanGroup,r.createDiffieHellmanGroup=u.createDiffieHellmanGroup,r.getDiffieHellman=u.getDiffieHellman,r.createDiffieHellman=u.createDiffieHellman,r.DiffieHellman=u.DiffieHellman;var c=e("browserify-sign");r.createSign=c.createSign,r.Sign=c.Sign,r.createVerify=c.createVerify,r.Verify=c.Verify,r.createECDH=e("create-ecdh");var f=e("public-encrypt");r.publicEncrypt=f.publicEncrypt,r.privateEncrypt=f.privateEncrypt,r.publicDecrypt=f.publicDecrypt,r.privateDecrypt=f.privateDecrypt;var h=e("randomfill");r.randomFill=h.randomFill,r.randomFillSync=h.randomFillSync,r.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))},r.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},{"browserify-cipher":73,"browserify-sign":80,"browserify-sign/algos":77,"create-ecdh":90,"create-hash":91,"create-hmac":94,"diffie-hellman":105,pbkdf2:247,"public-encrypt":259,randombytes:270,randomfill:271}],98:[function(e,t,r){"use strict";var n=new RegExp("%[a-f0-9]{2}","gi"),i=new RegExp("(%[a-f0-9]{2})+","gi");function o(e,t){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],o(r),o(n))}function a(e){try{return decodeURIComponent(e)}catch(i){for(var t=e.match(n),r=1;r0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];r=a.r28shl(r,s),i=a.r28shl(i,s),a.pc2(r,i,e.keys,o)}},u.prototype._update=function(e,t,r,n){var i=this._desState,o=a.readUInt32BE(e,t),s=a.readUInt32BE(e,t+4);a.ip(o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,s,i.tmp,0):this._decrypt(i,o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],a.writeUInt32BE(r,o,n),a.writeUInt32BE(r,s,n+4)},u.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,o=l}a.rip(s,o,n,i)},u.prototype._decrypt=function(e,t,r,n,i){for(var o=r,s=t,u=e.keys.length-2;u>=0;u-=2){var c=e.keys[u],f=e.keys[u+1];a.expand(o,e.tmp,0),c^=e.tmp[0],f^=e.tmp[1];var h=a.substitute(c,f),l=o;o=(s^a.permute(h))>>>0,s=l}a.rip(o,s,n,i)}},{"../des":99,inherits:180,"minimalistic-assert":234}],103:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits"),o=e("../des"),a=o.Cipher,s=o.DES;function u(e){a.call(this,e);var t=new function(e,t){n.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),i=t.slice(8,16),o=t.slice(16,24);this.ciphers="encrypt"===e?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edgeState=t}i(u,a),t.exports=u,u.create=function(e){return new u(e)},u.prototype._update=function(e,t,r,n){var i=this._edgeState;i.ciphers[0]._update(e,t,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},u.prototype._pad=s.prototype._pad,u.prototype._unpad=s.prototype._unpad},{"../des":99,inherits:180,"minimalistic-assert":234}],104:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,n){for(var i=0,o=0,a=6;a>=0;a-=2){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>>s+a&1}for(a=6;a>=0;a-=2){for(s=1;s<=25;s+=8)o<<=1,o|=t>>>s+a&1;for(s=1;s<=25;s+=8)o<<=1,o|=e>>>s+a&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(e,t,r,n){for(var i=0,o=0,a=0;a<4;a++)for(var s=24;s>=0;s-=8)i<<=1,i|=t>>>s+a&1,i<<=1,i|=e>>>s+a&1;for(a=4;a<8;a++)for(s=24;s>=0;s-=8)o<<=1,o|=t>>>s+a&1,o<<=1,o|=e>>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(e,t,r,n){for(var i=0,o=0,a=7;a>=5;a--){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+a&1}for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(a=1;a<=3;a++){for(s=0;s<=24;s+=8)o<<=1,o|=t>>s+a&1;for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1}for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,i){for(var o=0,a=0,s=n.length>>>1,u=0;u>>n[u]&1;for(u=s;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=a>>>0},r.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var n=e.toString(2);n.lengthe;)r.ishrn(1);if(r.isEven()&&r.iadd(s),r.testn(1)||r.iadd(u),t.cmp(u)){if(!t.cmp(c))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&m(p)&&m(r)&&a.test(p)&&a.test(r))return r}}},{"bn.js":53,"miller-rabin":233,randombytes:270}],108:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],109:[function(e,t,r){"use strict";var n=r;n.version=e("../package.json").version,n.utils=e("./elliptic/utils"),n.rand=e("brorand"),n.curve=e("./elliptic/curve"),n.curves=e("./elliptic/curves"),n.ec=e("./elliptic/ec"),n.eddsa=e("./elliptic/eddsa")},{"../package.json":124,"./elliptic/curve":112,"./elliptic/curves":115,"./elliptic/ec":116,"./elliptic/eddsa":119,"./elliptic/utils":123,brorand:54}],110:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.getNAF,a=i.getJSF,s=i.assert;function u(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){s(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=u;t--)c=(c<<1)+n[t];a.push(c)}for(var f=this.jpoint(null,null,null),h=this.jpoint(null,null,null),l=i;l>0;l--){for(u=0;u=0;c--){for(t=0;c>=0&&0===a[c];c--)t++;if(c>=0&&t++,u=u.dblp(t),c<0)break;var f=a[c];s(0!==f),u="affine"===e.type?f>0?u.mixedAdd(i[f-1>>1]):u.mixedAdd(i[-f-1>>1].neg()):f>0?u.add(i[f-1>>1]):u.add(i[-f-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){for(var s=this._wnafT1,u=this._wnafT2,c=this._wnafT3,f=0,h=0;h=1;h-=2){var d=h-1,p=h;if(1===s[d]&&1===s[p]){var b=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(b[1]=t[d].add(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].add(t[p].neg())):(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],m=a(r[d],r[p]);f=Math.max(m[0].length,f),c[d]=new Array(f),c[p]=new Array(f);for(var v=0;v=0;h--){for(var E=0;h>=0;){var x=!0;for(v=0;v=0&&E++,_=_.dblp(E),h<0)break;for(v=0;v0?k=u[v][S-1>>1]:S<0&&(k=u[v][-S-1>>1].neg()),_="affine"===k.type?_.mixedAdd(k):_.add(k))}}for(h=0;h=Math.ceil((e.bitLength()+1)/t.step)},c.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},f.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},f.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(r),s=n.redSub(t),u=i.redMul(a),c=o.redMul(s),f=i.redMul(s),h=a.redMul(o);return this.curve.point(u,c,h,f)},f.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var a=(c=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(a.redSub(this.curve.two)),t=a.redMul(c.redSub(o)),r=a.redSqr().redSub(a).redSub(a);else{var s=this.z.redSqr(),u=a.redSub(s).redISub(s);e=n.redSub(i).redISub(o).redMul(u),t=a.redMul(c.redSub(o)),r=a.redMul(u)}}else{var c=i.redAdd(o);s=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=c.redSub(s).redSub(s);e=this.curve._mulC(n.redISub(c)).redMul(u),t=this.curve._mulC(c).redMul(i.redISub(o)),r=c.redMul(u)}return this.curve.point(e,t,r)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},f.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=i.redSub(n),s=i.redAdd(n),u=r.redAdd(t),c=o.redMul(a),f=s.redMul(u),h=o.redMul(u),l=a.redMul(s);return this.curve.point(c,f,l,h)},f.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),c=i.redAdd(s),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),h=n.redMul(u).redMul(f);return this.curve.twisted?(t=n.redMul(c).redMul(a.redSub(this.curve._mulA(o))),r=u.redMul(c)):(t=n.redMul(c).redMul(a.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(h,t,r)},f.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},f.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},f.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},f.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},f.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()},f.prototype.getY=function(){return this.normalize(),this.y.fromRed()},f.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},f.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}return!1},f.prototype.toP=f.prototype.normalize,f.prototype.mixedAdd=f.prototype.add},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],112:[function(e,t,r){"use strict";var n=r;n.base=e("./base"),n.short=e("./short"),n.mont=e("./mont"),n.edwards=e("./edwards")},{"./base":110,"./edwards":111,"./mont":113,"./short":114}],113:[function(e,t,r){"use strict";var n=e("../curve"),i=e("bn.js"),o=e("inherits"),a=n.base,s=e("../../elliptic").utils;function u(e){a.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,r){a.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(u,a),t.exports=u,u.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},o(c,a.BasePoint),u.prototype.decodePoint=function(e,t){return this.point(s.toArray(e,t),1)},u.prototype.point=function(e,t){return new c(this,e,t)},u.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=i.redMul(n),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},c.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],114:[function(e,t,r){"use strict";var n=e("../curve"),i=e("../../elliptic"),o=e("bn.js"),a=e("inherits"),s=n.base,u=i.utils.assert;function c(e){s.call(this,"short",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function f(e,t,r,n){s.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new o(t,16),this.y=new o(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function h(e,t,r,n){s.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new o(0)):(this.x=new o(t,16),this.y=new o(r,16),this.z=new o(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}a(c,s),t.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new o(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new o(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?r=i[0]:(r=i[1],u(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new o(e.a,16),b:new o(e.b,16)}}):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:o.mont(e),r=new o(2).toRed(t).redInvm(),n=r.redNeg(),i=new o(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,r,n,i,a,s,u,c,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=e,d=this.n.clone(),p=new o(1),b=new o(0),y=new o(0),m=new o(1),v=0;0!==l.cmpn(0);){var g=d.div(l);c=d.sub(g.mul(l)),f=y.sub(g.mul(p));var w=m.sub(g.mul(b));if(!n&&c.cmp(h)<0)t=u.neg(),r=p,n=c.neg(),i=f;else if(n&&2==++v)break;u=c,d=l,l=c,y=p,p=f,m=b,b=w}a=c.neg(),s=f;var _=n.sqr().add(i.sqr());return a.sqr().add(s.sqr()).cmp(_)>=0&&(a=t,s=r),n.negative&&(n=n.neg(),i=i.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:n,b:i},{a:a,b:s}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(c).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},f.prototype.isInfinity=function(){return this.inf},f.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},f.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},f.prototype.getX=function(){return this.x.fromRed()},f.prototype.getY=function(){return this.y.fromRed()},f.prototype.mul=function(e){return e=new o(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},f.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},f.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},f.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},f.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},a(h,s.BasePoint),c.prototype.jpoint=function(e,t,r){return new h(this,e,t,r)},h.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},h.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},h.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),f=c.redMul(s),h=n.redMul(c),l=u.redSqr().redIAdd(f).redISub(h).redISub(h),d=u.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(l,d,p)},h.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),f=r.redMul(u),h=s.redSqr().redIAdd(c).redISub(f).redISub(f),l=s.redMul(f.redISub(h)).redISub(i.redMul(c)),d=this.z.redMul(a);return this.curve.jpoint(h,l,d)},h.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}return!1},h.prototype.inspect=function(){return this.isInfinity()?"":""},h.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],115:[function(e,t,r){"use strict";var n,i=r,o=e("hash.js"),a=e("../elliptic"),s=a.utils.assert;function u(e){"short"===e.type?this.curve=new a.curve.short(e):"edwards"===e.type?this.curve=new a.curve.edwards(e):this.curve=new a.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=e("./precomputed/secp256k1")}catch(e){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"../elliptic":109,"./precomputed/secp256k1":122,"hash.js":162}],116:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("hmac-drbg"),o=e("../../elliptic"),a=o.utils.assert,s=e("./key"),u=e("./signature");function c(e){if(!(this instanceof c))return new c(e);"string"==typeof e&&(a(o.curves.hasOwnProperty(e),"Unknown curve "+e),e=o.curves[e]),e instanceof o.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=c,c.prototype.keyPair=function(e){return new s(this,e)},c.prototype.keyFromPrivate=function(e,t){return s.fromPrivate(this,e,t)},c.prototype.keyFromPublic=function(e,t){return s.fromPublic(this,e,t)},c.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||o.rand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),a=this.n.sub(new n(2));;){var s=new n(t.generate(r));if(!(s.cmp(a)>0))return s.iaddn(1),this.keyFromPrivate(s)}},c.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},c.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),c=e.toArray("be",a),f=new i({hash:this.hash,entropy:s,nonce:c,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(f.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var m=d.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),v^=1),new u({r:y,s:m,recoveryParam:v})}}}}}},c.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new u(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,c=a.invm(this.n),f=c.mul(e).umod(this.n),h=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(f,r.getPublic(),h)).isInfinity()&&s.eqXToP(o):!(s=this.g.mulAdd(f,r.getPublic(),h)).isInfinity()&&0===s.getX().umod(this.n).cmp(o)},c.prototype.recoverPubKey=function(e,t,r,i){a((3&r)===r,"The recovery param is more than two bits"),t=new u(t,i);var o=this.n,s=new n(e),c=t.r,f=t.s,h=1&r,l=r>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find second key candidate");c=l?this.curve.pointFromX(c.add(this.curve.n),h):this.curve.pointFromX(c,h);var d=t.r.invm(o),p=o.sub(s).mul(d).umod(o),b=f.mul(d).umod(o);return this.g.mulAdd(p,c,b)},c.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new u(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":109,"./key":117,"./signature":118,"bn.js":53,"hmac-drbg":174}],117:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils.assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../../elliptic":109,"bn.js":53}],118:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new function(){this.place=0};if(48!==e[r.place++])return!1;if(s(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=s(e,r),a=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var u=s(e,r);if(e.length!==u+r.place)return!1;var c=e.slice(r.place,u+r.place);return 0===a[0]&&128&a[1]&&(a=a.slice(1)),0===c[0]&&128&c[1]&&(c=c.slice(1)),this.r=new n(a),this.s=new n(c),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=u(t),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),a=[48];return c(a,o.length),a=a.concat(o),i.encode(a,e)}},{"../../elliptic":109,"bn.js":53}],119:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("../../elliptic"),o=i.utils,a=o.assert,s=o.parseBytes,u=e("./key"),c=e("./signature");function f(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}t.exports=f,f.prototype.sign=function(e,t){e=s(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),u=n.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(e,t,r){e=s(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var s=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,c=t.andln(3)+i&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!=(s=e.andln(7)+n&7)&&5!==s||2!==c?u:-u,r[0].push(o),a=0==(1&c)?0:3!=(s=t.andln(7)+i&7)&&5!==s||2!==u?c:-c,r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},{"bn.js":53,"minimalistic-assert":234,"minimalistic-crypto-utils":235}],124:[function(e,t,r){t.exports={_from:"elliptic@^6.0.0",_id:"elliptic@6.4.0",_inBundle:!1,_integrity:"sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=",_location:"/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.0.0",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.0.0",saveSpec:null,fetchSpec:"^6.0.0"},_requiredBy:["/browserify-sign","/create-ecdh"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",_shasum:"cac9af8762c85836187003c8dfe193e5e2eae5df",_spec:"elliptic@^6.0.0",_where:"/Users/alexvlasov/Blockchain/web3swift_jsproxy/node_modules/browserify-sign",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.4.0"}},{}],125:[function(e,t,r){"use strict";const n=e("ethjs-util");function i(e){let t=n.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}t.exports={incrementHexNumber:function(e){return i(n.intToHex(parseInt(e,16)+1))},formatHex:i}},{"ethjs-util":155}],126:[function(e,t,r){const n=e("eth-query"),i=e("events"),o=e("pify"),a=e("./hexUtils"),s=a.incrementHexNumber,u=1e3,c=60*u;t.exports=class extends i{constructor(e={}){if(super(),!e.provider)throw new Error("RpcBlockTracker - no provider specified.");this._provider=e.provider,this._query=new n(e.provider),this._pollingInterval=e.pollingInterval||4*u,this._syncingTimeout=e.syncingTimeout||1*c,this._trackingBlock=null,this._trackingBlockTimestamp=null,this._currentBlock=null,this._isRunning=!1,this._performSync=this._performSync.bind(this),this._handleNewBlockNotification=this._handleNewBlockNotification.bind(this)}getTrackingBlock(){return this._trackingBlock}getCurrentBlock(){return this._currentBlock}async awaitCurrentBlock(){return this._currentBlock?this._currentBlock:(await new Promise(e=>this.once("latest",e)),this._currentBlock)}async start(e={}){this._isRunning||(this._isRunning=!0,e.fromBlock?await this._setTrackingBlock(await this._fetchBlockByNumber(e.fromBlock)):await this._setTrackingBlock(await this._fetchLatestBlock()),this._provider.on?await this._initSubscription():this._performSync().catch(e=>{e&&console.error(e)}))}async stop(){this._isRunning=!1,this._provider.on&&await this._removeSubscription()}async _setTrackingBlock(e){if(this._trackingBlock&&this._trackingBlock.hash===e.hash)return;const t=this._trackingBlockTimestamp,r=Date.now();t&&r-t>this._syncingTimeout?(this._trackingBlockTimestamp=null,await this._warpToLatest()):(this._trackingBlock=e,this._trackingBlockTimestamp=r,this.emit("block",e))}async _setCurrentBlock(e){if(this._currentBlock&&this._currentBlock.hash===e.hash)return;const t=this._currentBlock;this._currentBlock=e,this.emit("latest",e),this.emit("sync",{newBlock:e,oldBlock:t})}async _warpToLatest(){await this._setTrackingBlock(await this._fetchLatestBlock())}async _pollForNextBlock(){setTimeout(()=>this._performSync(),this._pollingInterval)}async _performSync(){if(!this._isRunning)return;const e=this.getTrackingBlock();if(!e)throw new Error("RpcBlockTracker - tracking block is missing");const t=s(e.number);try{const r=await this._fetchBlockByNumber(t);r?(await this._setTrackingBlock(r),this._performSync()):(await this._setCurrentBlock(e),this._pollForNextBlock())}catch(t){t.message.includes("index out of range")||t.message.includes("Couldn't find block by reference")?(await this._setCurrentBlock(e),this._pollForNextBlock()):(console.error(t),this._pollForNextBlock())}}async _handleNewBlockNotification(e,t){t.id==this._subscriptionId&&(e&&(this.emit("error",e),await this._removeSubscription()),await this._setTrackingBlock(await this._fetchBlockByNumber(t.result.number)))}async _initSubscription(){this._provider.on("data",this._handleNewBlockNotification);let e=await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_subscribe",params:["newHeads"]});this._subscriptionId=e.result}async _removeSubscription(){if(!this._subscriptionId)throw new Error("Not subscribed.");this._provider.removeListener("data",this._handleNewBlockNotification),await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_unsubscribe",params:[this._subscriptionId]}),delete this._subscriptionId}_fetchLatestBlock(){return o(this._query.getBlockByNumber).call(this._query,"latest",!0)}_fetchBlockByNumber(e){const t=a.formatHex(e);return o(this._query.getBlockByNumber).call(this._query,t,!0)}}},{"./hexUtils":125,"eth-query":135,events:157,pify:252}],127:[function(e,t,r){(function(t){var n=e("js-sha3").keccak_256,i=e("idna-uts46-hx");function o(e){return e?i.toUnicode(e,{useStd3ASCII:!0,transitional:!1}):e}r.hash=function(e){for(var r="",i=0;i<32;i++)r+="00";if(name=o(e),name){var a=name.split(".");for(i=a.length-1;i>=0;i--){var s=n(a[i]);r=n(new t(r+s,"hex"))}}return"0x"+r},r.normalize=o}).call(this,e("buffer").Buffer)},{buffer:84,"idna-uts46-hx":177,"js-sha3":128}],128:[function(e,t,r){(function(e,r){!function(){"use strict";var n="object"==typeof window?window:{};!n.JS_SHA3_NO_NODE_JS&&"object"==typeof e&&e.versions&&e.versions.node&&(n=r);for(var i=!n.JS_SHA3_NO_COMMON_JS&&"object"==typeof t&&t.exports,o="0123456789abcdef".split(""),a=[0,8,16,24],s=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],u=[224,256,384,512],c=["hex","buffer","arrayBuffer","array"],f=function(e,t,r){return function(n){return new _(e,t,e).update(n)[r]()}},h=function(e,t,r){return function(n,i){return new _(e,t,i).update(n)[r]()}},l=function(e,t){var r=f(e,t,"hex");r.create=function(){return new _(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}_.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,o=this.blocks,s=this.byteCount,u=this.blockCount,c=0,f=this.s;c>2]|=e[c]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(o[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=s){for(this.start=r-s,this.block=o[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+o[15&e]+o[e>>12&15]+o[e>>8&15]+o[e>>20&15]+o[e>>16&15]+o[e>>28&15]+o[e>>24&15];s%t==0&&(A(r),a=0)}return i&&(e=r[a],i>0&&(u+=o[e>>4&15]+o[15&e]),i>1&&(u+=o[e>>12&15]+o[e>>8&15]),i>2&&(u+=o[e>>20&15]+o[e>>16&15])),u},_.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&A(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var A=function(e){var t,r,n,i,o,a,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],a=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(a<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|a>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=a^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=s[n],e[1]^=s[n+1]};if(i)t.exports=p;else for(y=0;y{setTimeout(t,e)})}function c(e){const t=e.toString();return s.some(e=>t.includes(e))}async function f(e,t,r){const{fetchUrl:n,fetchParams:a}=h({network:e,req:t}),s=await o(n,a),u=await s.text();if(!s.ok)switch(s.status){case 405:throw new i.MethodNotFound;case 418:throw l("Request is being rate limited.");case 503:case 504:throw function(){let e="Gateway timeout. The request took too long to process. ";return e+="This can happen when querying logs over too wide a block range.",l("Gateway timeout. The request took too long to process. This can happen when querying logs over too wide a block range.")}();default:throw l(u)}if("eth_getBlockByNumber"===t.method&&"Not Found"===u)return void(r.result=null);const c=JSON.parse(u);r.result=c.result,r.error=c.error}function h({network:e,req:t}){const r=function(e){return{id:e.id,jsonrpc:e.jsonrpc,method:e.method,params:e.params}}(t),{method:n,params:i}=r,o={};let s=`https://api.infura.io/v1/jsonrpc/${e}`;if(a.includes(n))o.method="POST",o.headers={Accept:"application/json","Content-Type":"application/json"},o.body=JSON.stringify(r);else{o.method="GET",s+=`/${n}?params=${encodeURIComponent(JSON.stringify(i))}`}return{fetchUrl:s,fetchParams:o}}function l(e){const t=new Error(e);return new i.InternalError(t)}t.exports=function(e={}){const t=e.network||"mainnet",r=e.maxAttempts||5;if(!r)throw new Error(`Invalid value for 'maxAttempts': "${r}" (${typeof r})`);return n(async(e,n,i)=>{for(let i=1;i<=r;i++)try{await f(t,e,n);break}catch(e){if(!c(e))throw e;const t=r-i;if(!t){const t=`InfuraProvider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,r=new Error(t);throw r}await u(1e3)}})},t.exports.fetchConfigFromReq=h},{"cross-fetch":96,"json-rpc-engine/src/createAsyncMiddleware":187,"json-rpc-error":189}],131:[function(e,t,r){t.exports=function(e){return{sendAsync:e.handle.bind(e)}}},{}],132:[function(e,t,r){var n=function(e,t){for(var r=[],n=0;n>6|192);else{if(i>55295&&i<56320){if(++n==e.length)return null;var o=e.charCodeAt(n);if(o<56320||o>57343)return null;r+=t((i=65536+((1023&i)<<10)+(1023&o))>>18|240),r+=t(i>>12&63|128)}else r+=t(i>>12|224);r+=t(i>>6&63|128)}r+=t(63&i|128)}}return r},toString:function(e){for(var t="",r=0,o=i(e);r127){if(a>191&&a<224){if(r>=o)return null;a=(31&a)<<6|63&n(e,r)}else if(a>223&&a<240){if(r+1>=o)return null;a=(15&a)<<12|(63&n(e,r))<<6|63&n(e,++r)}else{if(!(a>239&&a<248))return null;if(r+2>=o)return null;a=(7&a)<<18|(63&n(e,r))<<12|(63&n(e,++r))<<6|63&n(e,++r)}++r}if(a<=65535)t+=String.fromCharCode(a);else{if(!(a<=1114111))return null;a-=65536,t+=String.fromCharCode(a>>10|55296),t+=String.fromCharCode(1023&a|56320)}}return t},fromNumber:function(e){var t=e.toString(16);return t.length%2==0?"0x"+t:"0x0"+t},toNumber:function(e){return parseInt(e.slice(2),16)},fromNat:function(e){return"0x0"===e?"0x":e.length%2==0?e:"0x0"+e.slice(2)},toNat:function(e){return"0"===e[2]?"0x"+e.slice(3):e},fromArray:a,toArray:o,fromUint8Array:function(e){return a([].slice.call(e,0))},toUint8Array:function(e){return new Uint8Array(o(e))}}},{"./array.js":132}],134:[function(e,t,r){var n="0123456789abcdef".split(""),i=[1,256,65536,16777216],o=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],s=function(e){var t,r,n,i,o,s,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=a[n],e[1]^=a[n+1]},u=function(e){return function(t){var r;if("0x"===t.slice(0,2)){r=[];for(var a=2,u=t.length;a>2]|=t[d]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|63&r)<=57344?(u[y>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<=c){for(e.start=y-c,e.block=u[f],y=0;y>2]|=i[3&y],e.lastByteIndex===c)for(u[0]=u[f],y=1;y>4&15]+n[15&p]+n[p>>12&15]+n[p>>8&15]+n[p>>20&15]+n[p>>16&15]+n[p>>28&15]+n[p>>24&15];m%f==0&&(s(l),y=0)}return"0x"+b}(function(e){return{blocks:[],reset:!0,block:0,start:0,blockCount:1600-(e<<1)>>5,outputBlocks:e>>5,s:(t=[0,0,0,0,0,0,0,0,0,0],[].concat(t,t,t,t,t))};var t}(e),r)}};t.exports={keccak256:u(256),keccak512:u(512),keccak256s:u(256),keccak512s:u(512)}},{}],135:[function(e,t,r){const n=e("xtend"),i=e("json-rpc-random-id")();function o(e){this.currentProvider=e}function a(e){return function(){var t=[].slice.call(arguments),r=t.pop();this.sendAsync({method:e,params:t},r)}}function s(e,t){return function(){var r=[].slice.call(arguments),n=r.pop();r.lengtho)throw new Error("Elements exceed array size: "+o);for(d in h=[],e=e.slice(0,e.lastIndexOf("[")),"string"==typeof t&&(t=JSON.parse(t)),t)h.push(l(e,t[d]));if("dynamic"===o){var p=l("uint256",t.length);h.unshift(p)}return r.concat(h)}if("bytes"===e)return t=new r(t),h=r.concat([l("uint256",t.length),t]),t.length%32!=0&&(h=r.concat([h,n.zeros(32-t.length%32)])),h;if(e.startsWith("bytes")){if((o=s(e))<1||o>32)throw new Error("Invalid bytes width: "+o);return n.setLengthRight(t,32)}if(e.startsWith("uint")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid uint width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied uint exceeds width: "+o+" vs "+a.bitLength());if(a<0)throw new Error("Supplied uint is negative");return a.toArrayLike(r,"be",32)}if(e.startsWith("int")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid int width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied int exceeds width: "+o+" vs "+a.bitLength());return a.toTwos(256).toArrayLike(r,"be",32)}if(e.startsWith("ufixed")){if(o=u(e),(a=f(t))<0)throw new Error("Supplied ufixed is negative");return l("uint256",a.mul(new i(2).pow(new i(o[1]))))}if(e.startsWith("fixed"))return o=u(e),l("int256",f(t).mul(new i(2).pow(new i(o[1]))));throw new Error("Unsupported or invalid type: "+e)}function d(e,t,n){var o,a,s,u;if("string"==typeof e&&(e=p(e)),"address"===e.name)return d(e.rawType,t,n).toArrayLike(r,"be",20).toString("hex");if("bool"===e.name)return d(e.rawType,t,n).toString()===new i(1).toString();if("string"===e.name){var c=d(e.rawType,t,n);return new r(c,"utf8").toString()}if(e.isArray){for(s=[],o=e.size,"dynamic"===e.size&&(o=d("uint256",t,n=d("uint256",t,n).toNumber()).toNumber(),n+=32),u=0;ue.size)throw new Error("Decoded int exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("int")){if((a=new i(t.slice(n,n+32),16,"be").fromTwos(256)).bitLength()>e.size)throw new Error("Decoded uint exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("ufixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("uint256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}if(e.name.startsWith("fixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("int256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}throw new Error("Unsupported or invalid type: "+e.name)}function p(e){var t,r,n;if(y(e)){t=c(e);var i=e.slice(0,e.lastIndexOf("["));return i=p(i),r={isArray:!0,name:e,size:t,memoryUsage:"dynamic"===t?32:i.memoryUsage*t,subArray:i}}switch(e){case"address":n="uint160";break;case"bool":n="uint8";break;case"string":n="bytes"}if(r={rawType:n,name:e,memoryUsage:32},e.startsWith("bytes")&&"bytes"!==e||e.startsWith("uint")||e.startsWith("int")?r.size=s(e):(e.startsWith("ufixed")||e.startsWith("fixed"))&&(r.size=u(e)),e.startsWith("bytes")&&"bytes"!==e&&(r.size<1||r.size>32))throw new Error("Invalid bytes width: "+r.size);if((e.startsWith("uint")||e.startsWith("int"))&&(r.size%8||r.size<8||r.size>256))throw new Error("Invalid int/uint width: "+r.size);return r}function b(e){return"string"===e||"bytes"===e||"dynamic"===c(e)}function y(e){return e.lastIndexOf("]")===e.length-1}function m(e,t){return e.startsWith("address")||e.startsWith("bytes")?"0x"+t.toString("hex"):t.toString()}o.eventID=function(e,t){var i=e+"("+t.map(a).join(",")+")";return n.sha3(new r(i))},o.methodID=function(e,t){return o.eventID(e,t).slice(0,4)},o.rawEncode=function(e,t){var n=[],i=[],o=0;e.forEach(function(e){if(y(e)){var t=c(e);o+="dynamic"!==t?32*t:32}else o+=32});for(var s=0;s32)throw new Error("Invalid bytes width: "+i);u.push(n.setLengthRight(l,i))}else if(h.startsWith("uint")){if((i=s(h))%8||i<8||i>256)throw new Error("Invalid uint width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied uint exceeds width: "+i+" vs "+o.bitLength());u.push(o.toArrayLike(r,"be",i/8))}else{if(!h.startsWith("int"))throw new Error("Unsupported or invalid type: "+h);if((i=s(h))%8||i<8||i>256)throw new Error("Invalid int width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied int exceeds width: "+i+" vs "+o.bitLength());u.push(o.toTwos(i).toArrayLike(r,"be",i/8))}}return r.concat(u)},o.soliditySHA3=function(e,t){return n.sha3(o.solidityPack(e,t))},o.soliditySHA256=function(e,t){return n.sha256(o.solidityPack(e,t))},o.solidityRIPEMD160=function(e,t){return n.ripemd160(o.solidityPack(e,t),!0)},o.fromSerpent=function(e){for(var t,r=[],n=0;n="0"&&t<="9");)o+=e[a]-"0",a++;n=a-1,r.push(o)}else if("i"===i)r.push("int256");else{if("a"!==i)throw new Error("Unsupported or invalid type: "+i);r.push("int256[]")}}return r},o.toSerpent=function(e){for(var t=[],r=0;r0){var r=this.raw.slice();this.v=this._chainId,this.r=0,this.s=0,t=this.raw,this.raw=r}else t=this.raw.slice(0,6);return n.rlphash(t)},e.prototype.getChainId=function(){return this._chainId},e.prototype.getSenderAddress=function(){if(this._from)return this._from;var e=this.getSenderPublicKey();return this._from=n.publicToAddress(e),this._from},e.prototype.getSenderPublicKey=function(){if(!(this._senderPubKey&&this._senderPubKey.length||this.verifySignature()))throw new Error("Invalid Signature");return this._senderPubKey},e.prototype.verifySignature=function(){var e=this.hash(!1);if(this._homestead&&1===new o(this.s).cmp(a))return!1;try{var t=n.bufferToInt(this.v);this._chainId>0&&(t-=2*this._chainId+8),this._senderPubKey=n.ecrecover(e,t,this.r,this.s)}catch(e){return!1}return!!this._senderPubKey},e.prototype.sign=function(e){var t=this.hash(!1),r=n.ecsign(t,e);this._chainId>0&&(r.v+=2*this._chainId+8),Object.assign(this,r)},e.prototype.getDataFee=function(){for(var e=this.raw[5],t=new o(0),r=0;r0&&t.push(["gas limit is too low. Need at least "+this.getBaseFee()]),void 0===e||!1===e?0===t.length:t.join(" ")},e}();t.exports=s}).call(this,e("buffer").Buffer)},{buffer:84,"ethereum-common/params.json":137,"ethereumjs-util":141}],141:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("keccak"),o=e("secp256k1"),a=e("assert"),s=e("rlp"),u=e("bn.js"),c=e("create-hash"),f=e("safe-buffer").Buffer;Object.assign(r,e("ethjs-util")),r.MAX_INTEGER=new u("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16),r.TWO_POW256=new u("10000000000000000000000000000000000000000000000000000000000000000",16),r.KECCAK256_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",r.SHA3_NULL_S=r.KECCAK256_NULL_S,r.KECCAK256_NULL=f.from(r.KECCAK256_NULL_S,"hex"),r.SHA3_NULL=r.KECCAK256_NULL,r.KECCAK256_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",r.SHA3_RLP_ARRAY_S=r.KECCAK256_RLP_ARRAY_S,r.KECCAK256_RLP_ARRAY=f.from(r.KECCAK256_RLP_ARRAY_S,"hex"),r.SHA3_RLP_ARRAY=r.KECCAK256_RLP_ARRAY,r.KECCAK256_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",r.SHA3_RLP_S=r.KECCAK256_RLP_S,r.KECCAK256_RLP=f.from(r.KECCAK256_RLP_S,"hex"),r.SHA3_RLP=r.KECCAK256_RLP,r.BN=u,r.rlp=s,r.secp256k1=o,r.zeros=function(e){return f.allocUnsafe(e).fill(0)},r.zeroAddress=function(){var e=r.zeros(20);return r.bufferToHex(e)},r.setLengthLeft=r.setLength=function(e,t,n){var i=r.zeros(t);return e=r.toBuffer(e),n?e.length0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e},r.toBuffer=function(e){if(!f.isBuffer(e))if(Array.isArray(e))e=f.from(e);else if("string"==typeof e)e=r.isHexString(e)?f.from(r.padToEven(r.stripHexPrefix(e)),"hex"):f.from(e);else if("number"==typeof e)e=r.intToBuffer(e);else if(null==e)e=f.allocUnsafe(0);else if(u.isBN(e))e=e.toArrayLike(f);else{if(!e.toArray)throw new Error("invalid type");e=f.from(e.toArray())}return e},r.bufferToInt=function(e){return new u(r.toBuffer(e)).toNumber()},r.bufferToHex=function(e){return"0x"+(e=r.toBuffer(e)).toString("hex")},r.fromSigned=function(e){return new u(e).fromTwos(256)},r.toUnsigned=function(e){return f.from(e.toTwos(256).toArray())},r.keccak=function(e,t){return e=r.toBuffer(e),t||(t=256),i("keccak"+t).update(e).digest()},r.keccak256=function(e){return r.keccak(e)},r.sha3=r.keccak,r.sha256=function(e){return e=r.toBuffer(e),c("sha256").update(e).digest()},r.ripemd160=function(e,t){e=r.toBuffer(e);var n=c("rmd160").update(e).digest();return!0===t?r.setLength(n,32):n},r.rlphash=function(e){return r.keccak(s.encode(e))},r.isValidPrivate=function(e){return o.privateKeyVerify(e)},r.isValidPublic=function(e,t){return 64===e.length?o.publicKeyVerify(f.concat([f.from([4]),e])):!!t&&o.publicKeyVerify(e)},r.pubToAddress=r.publicToAddress=function(e,t){return e=r.toBuffer(e),t&&64!==e.length&&(e=o.publicKeyConvert(e,!1).slice(1)),a(64===e.length),r.keccak(e).slice(-20)};var h=r.privateToPublic=function(e){return e=r.toBuffer(e),o.publicKeyCreate(e,!1).slice(1)};r.importPublic=function(e){return 64!==(e=r.toBuffer(e)).length&&(e=o.publicKeyConvert(e,!1).slice(1)),e},r.ecsign=function(e,t){var r=o.sign(e,t),n={};return n.r=r.signature.slice(0,32),n.s=r.signature.slice(32,64),n.v=r.recovery+27,n},r.hashPersonalMessage=function(e){var t=r.toBuffer("Ethereum Signed Message:\n"+e.length.toString());return r.keccak(f.concat([t,e]))},r.ecrecover=function(e,t,n,i){var a=f.concat([r.setLength(n,32),r.setLength(i,32)],64),s=t-27;if(0!==s&&1!==s)throw new Error("Invalid signature v value");var u=o.recover(e,a,s);return o.publicKeyConvert(u,!1).slice(1)},r.toRpcSig=function(e,t,n){if(27!==e&&28!==e)throw new Error("Invalid recovery id");return r.bufferToHex(f.concat([r.setLengthLeft(t,32),r.setLengthLeft(n,32),r.toBuffer(e-27)]))},r.fromRpcSig=function(e){if(65!==(e=r.toBuffer(e)).length)throw new Error("Invalid signature length");var t=e[64];return t<27&&(t+=27),{v:t,r:e.slice(0,32),s:e.slice(32,64)}},r.privateToAddress=function(e){return r.publicToAddress(h(e))},r.isValidAddress=function(e){return/^0x[0-9a-fA-F]{40}$/.test(e)},r.isZeroAddress=function(e){return r.zeroAddress()===r.addHexPrefix(e)},r.toChecksumAddress=function(e){e=r.stripHexPrefix(e).toLowerCase();for(var t=r.keccak(e).toString("hex"),n="0x",i=0;i=8?n+=e[i].toUpperCase():n+=e[i];return n},r.isValidChecksumAddress=function(e){return r.isValidAddress(e)&&r.toChecksumAddress(e)===e},r.generateAddress=function(e,t){return e=r.toBuffer(e),t=(t=new u(t)).isZero()?null:f.from(t.toArray()),r.rlphash([e,t]).slice(-20)},r.isPrecompiled=function(e){var t=r.unpad(e);return 1===t.length&&t[0]>=1&&t[0]<=8},r.addHexPrefix=function(e){return"string"!=typeof e?e:r.isHexPrefixed(e)?e:"0x"+e},r.isValidSignature=function(e,t,r,n){var i=new u("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16),o=new u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16);return 32===t.length&&32===r.length&&((27===e||28===e)&&(t=new u(t),r=new u(r),!(t.isZero()||t.gt(o)||r.isZero()||r.gt(o))&&(!1!==n||1!==new u(r).cmp(i))))},r.baToJSON=function(e){if(f.isBuffer(e))return"0x"+e.toString("hex");if(e instanceof Array){for(var t=[],n=0;n=i.length,"The field "+t.name+" must not have more "+t.length+" bytes")):t.allowZero&&0===i.length||!t.length||a(t.length===i.length,"The field "+t.name+" must have byte length of "+t.length),e.raw[n]=i}e._fields.push(t.name),Object.defineProperty(e,t.name,{enumerable:!0,configurable:!0,get:i,set:o}),t.default&&(e[t.name]=t.default),t.alias&&Object.defineProperty(e,t.alias,{enumerable:!1,configurable:!0,set:o,get:i})}),i)if("string"==typeof i&&(i=f.from(r.stripHexPrefix(i),"hex")),f.isBuffer(i)&&(i=s.decode(i)),Array.isArray(i)){if(i.length>e._fields.length)throw new Error("wrong number of fields in data");i.forEach(function(t,n){e[e._fields[n]]=r.toBuffer(t)})}else{if("object"!==(void 0===i?"undefined":n(i)))throw new Error("invalid data");var o=Object.keys(i);t.forEach(function(t){-1!==o.indexOf(t.name)&&(e[t.name]=i[t.name]),-1!==o.indexOf(t.alias)&&(e[t.alias]=i[t.alias])})}}},{assert:19,"bn.js":53,"create-hash":91,"ethjs-util":155,keccak:195,rlp:289,"safe-buffer":290,secp256k1:295}],142:[function(e,t,r){arguments[4][128][0].apply(r,arguments)},{_process:257,dup:128}],143:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var a=e("./address"),s=e("./bignumber"),u=e("./bytes"),c=e("./utf8"),f=e("./properties"),h=o(e("./errors")),l=new RegExp(/^bytes([0-9]*)$/),d=new RegExp(/^(u?int)([0-9]*)$/),p=new RegExp(/^(.*)\[([0-9]*)\]$/);r.defaultCoerceFunc=function(e,t){var r=e.match(d);return r&&parseInt(r[2])<=48?t.toNumber():t};var b=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"),y=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function m(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}function v(e,t){function r(t){throw new Error('unexpected character "'+e[t]+'" at position '+t+' in "'+e+'"')}for(var n={type:"",name:"",state:{allowType:!0}},i=n,o=0;o1){var i=r[1].match(b);if(""!=i[1].trim()||""!=i[3].trim())throw new Error("unexpected tokens");L(i[2]).forEach(function(e){t.outputs.push(v(e))})}return t}(e.trim()));throw new Error("unknown signature")};var w=function(){return function(e,t,r,n,i){this.coerceFunc=e,this.name=t,this.type=r,this.localName=n,this.dynamic=i}}(),_=function(e){function t(t){var r=e.call(this,t.coerceFunc,t.name,t.type,void 0,t.dynamic)||this;return f.defineReadOnly(r,"coder",t),r}return i(t,e),t.prototype.encode=function(e){return this.coder.encode(e)},t.prototype.decode=function(e,t){return this.coder.decode(e,t)},t}(w),A=function(e){function t(t,r){return e.call(this,t,"null","",r,!1)||this}return i(t,e),t.prototype.encode=function(e){return u.arrayify([])},t.prototype.decode=function(e,t){if(t>e.length)throw new Error("invalid null");return{consumed:0,value:this.coerceFunc("null",void 0)}},t}(w),E=function(e){function t(t,r,n,i){var o=this,a=(n?"int":"uint")+8*r;return(o=e.call(this,t,a,a,i,!1)||this).size=r,o.signed=n,o}return i(t,e),t.prototype.encode=function(e){try{var t=s.bigNumberify(e);return t=t.toTwos(8*this.size).maskn(8*this.size),this.signed&&(t=t.fromTwos(8*this.size).toTwos(256)),u.padZeros(u.arrayify(t),32)}catch(t){h.throwError("invalid number value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:e})}return null},t.prototype.decode=function(e,t){e.length32)throw new Error;t.set(r)}catch(t){h.throwError("invalid "+this.name+" value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:t.value||e})}return t},t.prototype.decode=function(e,t){return e.length=0?n:"")+"]",s=-1===n||r.dynamic;return(o=e.call(this,t,"array",a,i,s)||this).coder=r,o.length=n,o}return i(t,e),t.prototype.encode=function(e){Array.isArray(e)||h.throwError("expected array value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:"array",value:e});var t=this.length,r=new Uint8Array(0);-1===t&&(t=e.length,r=x.encode(t)),h.checkArgumentCount(t,e.length,"in coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i256||i%8!=0)&&h.throwError("invalid "+r[1]+" bit length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new E(e,i/8,"int"===r[1],t.name);if(r=t.type.match(l))return(0===(i=parseInt(r[1]))||i>32)&&h.throwError("invalid bytes length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new S(e,i,t.name);if(r=t.type.match(p)){var i=parseInt(r[2]||"-1");return(t=f.jsonCopy(t)).type=r[1],new N(e,D(e,t),i,t.name)}return"tuple"===t.type.substring(0,5)?function(e,t,r){t||(t=[]);var n=[];return t.forEach(function(t){n.push(D(e,t))}),new R(e,n,r)}(e,t.components,t.name):""===t.type?new A(e,t.name):(h.throwError("invalid type",h.INVALID_ARGUMENT,{arg:"type",value:t.type}),null)}var F=function(){function e(t){h.checkNew(this,e),t||(t=r.defaultCoerceFunc),f.defineReadOnly(this,"coerceFunc",t)}return e.prototype.encode=function(e,t){e.length!==t.length&&h.throwError("types/values length mismatch",h.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):e,r.push(D(this.coerceFunc,t))},this),u.hexlify(new R(this.coerceFunc,r,"_").encode(t))},e.prototype.decode=function(e,t){var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):f.jsonCopy(e),r.push(D(this.coerceFunc,t))},this),new R(this.coerceFunc,r,"_").decode(u.arrayify(t),0).value},e}();r.AbiCoder=F,r.defaultAbiCoder=new F},{"./address":144,"./bignumber":145,"./bytes":146,"./errors":147,"./properties":149,"./utf8":152}],144:[function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var i=n(e("bn.js")),o=e("./bytes"),a=e("./keccak256"),s=e("./rlp"),u=e("./errors");function c(e){"string"==typeof e&&e.match(/^0x[0-9A-Fa-f]{40}$/)||u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=o.arrayify(a.keccak256(r));for(var i=0;i<40;i+=2)r[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(15&r[i>>1])>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}for(var f={},h=0;h<10;h++)f[String(h)]=String(h);for(h=0;h<26;h++)f[String.fromCharCode(65+h)]=String(10+h);var l,d=Math.floor((l=9007199254740991,Math.log10?Math.log10(l):Math.log(l)/Math.LN10));function p(e){e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00";var t="";for(e.split("").forEach(function(e){t+=f[e]});t.length>=d;){var r=t.substring(0,d);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function b(e){var t=null;if("string"!=typeof e&&u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e}),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=c(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&u.throwError("bad address checksum",u.INVALID_ARGUMENT,{arg:"address",value:e});else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==p(e)&&u.throwError("bad icap checksum",u.INVALID_ARGUMENT,{arg:"address",value:e}),t=new i.default.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=c("0x"+t)}else u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});return t}r.getAddress=b,r.getIcapAddress=function(e){for(var t=new i.default.BN(b(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+p("XE00"+t)+t},r.getContractAddress=function(e){if(!e.from)throw new Error("missing from address");var t=e.nonce;return b("0x"+a.keccak256(s.encode([b(e.from),o.stripZeros(o.hexlify(t))])).substring(26))}},{"./bytes":146,"./errors":147,"./keccak256":148,"./rlp":150,"bn.js":53}],145:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=o(e("bn.js")),u=e("./bytes"),c=e("./properties"),f=e("./types"),h=a(e("./errors")),l=new s.default.BN(-1);function d(e){var t=e.toString(16);return"-"===t[0]?t.length%2==0?"-0x0"+t.substring(1):"-0x"+t.substring(1):t.length%2==1?"0x0"+t:"0x"+t}function p(e){return m(e)._bn}function b(e){return new y(d(e))}var y=function(e){function t(r){var n=e.call(this)||this;if(h.checkNew(n,t),"string"==typeof r)u.isHexString(r)?("0x"==r&&(r="0x0"),c.defineReadOnly(n,"_hex",r)):"-"===r[0]&&u.isHexString(r.substring(1))?c.defineReadOnly(n,"_hex",r):r.match(/^-?[0-9]*$/)?(""==r&&(r="0"),c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))):h.throwError("invalid BigNumber string value",h.INVALID_ARGUMENT,{arg:"value",value:r});else if("number"==typeof r){parseInt(String(r))!==r&&h.throwError("underflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"underflow",value:r,outputValue:parseInt(String(r))});try{c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}}else r instanceof t?c.defineReadOnly(n,"_hex",r._hex):r.toHexString?c.defineReadOnly(n,"_hex",d(p(r.toHexString()))):u.isArrayish(r)?c.defineReadOnly(n,"_hex",d(new s.default.BN(u.hexlify(r).substring(2),16))):h.throwError("invalid BigNumber value",h.INVALID_ARGUMENT,{arg:"value",value:r});return n}return i(t,e),Object.defineProperty(t.prototype,"_bn",{get:function(){return"-"===this._hex[0]?new s.default.BN(this._hex.substring(3),16).mul(l):new s.default.BN(this._hex.substring(2),16)},enumerable:!0,configurable:!0}),t.prototype.fromTwos=function(e){return b(this._bn.fromTwos(e))},t.prototype.toTwos=function(e){return b(this._bn.toTwos(e))},t.prototype.add=function(e){return b(this._bn.add(p(e)))},t.prototype.sub=function(e){return b(this._bn.sub(p(e)))},t.prototype.div=function(e){return m(e).isZero()&&h.throwError("division by zero",h.NUMERIC_FAULT,{operation:"divide",fault:"division by zero"}),b(this._bn.div(p(e)))},t.prototype.mul=function(e){return b(this._bn.mul(p(e)))},t.prototype.mod=function(e){return b(this._bn.mod(p(e)))},t.prototype.pow=function(e){return b(this._bn.pow(p(e)))},t.prototype.maskn=function(e){return b(this._bn.maskn(e))},t.prototype.eq=function(e){return this._bn.eq(p(e))},t.prototype.lt=function(e){return this._bn.lt(p(e))},t.prototype.lte=function(e){return this._bn.lte(p(e))},t.prototype.gt=function(e){return this._bn.gt(p(e))},t.prototype.gte=function(e){return this._bn.gte(p(e))},t.prototype.isZero=function(){return this._bn.isZero()},t.prototype.toNumber=function(){try{return this._bn.toNumber()}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}return null},t.prototype.toString=function(){return this._bn.toString(10)},t.prototype.toHexString=function(){return this._hex},t}(f.BigNumber);function m(e){return e instanceof y?e:new y(e)}r.bigNumberify=m,r.ConstantNegativeOne=m(-1),r.ConstantZero=m(0),r.ConstantOne=m(1),r.ConstantTwo=m(2),r.ConstantWeiPerEther=m("1000000000000000000")},{"./bytes":146,"./errors":147,"./properties":149,"./types":151,"bn.js":53}],146:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./errors");function i(e){return!!e._bn}function o(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return new Uint8Array(Array.prototype.slice.apply(e,t))},e)}function a(e){if(!e||parseInt(String(e.length))!=e.length||"string"==typeof e)return!1;for(var t=0;t=256||parseInt(String(r))!=r)return!1}return!0}function s(e){if(null==e&&n.throwError("cannot convert null value to array",n.INVALID_ARGUMENT,{arg:"value",value:e}),i(e)&&(e=e.toHexString()),"string"==typeof e){var t=e.match(/^(0x)?[0-9a-fA-F]*$/);t||n.throwError("invalid hexadecimal string",n.INVALID_ARGUMENT,{arg:"value",value:e}),"0x"!==t[1]&&n.throwError("hex string must have 0x prefix",n.INVALID_ARGUMENT,{arg:"value",value:e}),(e=e.substring(2)).length%2&&(e="0"+e);for(var r=[],s=0;s>4]+f[15&u])}return"0x"+o.join("")}return n.throwError("invalid hexlify value",null,{arg:"value",value:e}),"never"}function l(e,t){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length<2*t+2;)e="0x0"+e.substring(2);return e}function d(e){var t,r=0,i="0x",o="0x";if((t=e)&&null!=t.r&&null!=t.s){null==e.v&&null==e.recoveryParam&&n.throwError("at least on of recoveryParam or v must be specified",n.INVALID_ARGUMENT,{argument:"signature",value:e}),i=l(e.r,32),o=l(e.s,32),"string"==typeof(r=e.v)&&(r=parseInt(r,16));var a=e.recoveryParam;null==a&&null!=e.v&&(a=1-r%2),r=27+a}else{var u=s(e);if(65!==u.length)throw new Error("invalid signature");i=h(u.slice(0,32)),o=h(u.slice(32,64)),27!==(r=u[64])&&28!==r&&(r=27+r%2)}return{r:i,s:o,recoveryParam:r-27,v:r}}r.hexlify=h,r.hexDataLength=function(e){return c(e)&&e.length%2==0?(e.length-2)/2:null},r.hexDataSlice=function(e,t,r){return c(e)||n.throwError("invalid hex data",n.INVALID_ARGUMENT,{arg:"value",value:e}),e.length%2!=0&&n.throwError("hex data length must be even",n.INVALID_ARGUMENT,{arg:"value",value:e}),t=2+2*t,null!=r?"0x"+e.substring(t,t+2*r):"0x"+e.substring(t)},r.hexStripZeros=function(e){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length>3&&"0x0"===e.substring(0,3);)e="0x"+e.substring(3);return e},r.hexZeroPad=l,r.splitSignature=d,r.joinSignature=function(e){return h(u([(e=d(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}},{"./errors":147}],147:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.MISSING_NEW="MISSING_NEW",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.NUMERIC_FAULT="NUMERIC_FAULT",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION";var n=!1,i=!1;function o(e,t,n){if(i)throw new Error("unknown error");t||(t=r.UNKNOWN_ERROR),n||(n={});var o=[];Object.keys(n).forEach(function(e){try{o.push(e+"="+JSON.stringify(n[e]))}catch(t){o.push(e+"="+JSON.stringify(n[e].toString()))}});var a=e;o.length&&(e+=" ("+o.join(", ")+")");var s=new Error(e);throw s.reason=a,s.code=t,Object.keys(n).forEach(function(e){s[e]=n[e]}),s}r.throwError=o,r.checkNew=function(e,t){e instanceof t||o("missing new",r.MISSING_NEW,{name:t.name})},r.checkArgumentCount=function(e,t,n){n||(n=""),et&&o("too many arguments"+n,r.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})},r.setCensorship=function(e,t){n&&o("error censorship permanent",r.UNSUPPORTED_OPERATION,{operation:"setCersorship"}),i=!!e,n=!!t}},{}],148:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("js-sha3"),i=e("./bytes");r.keccak256=function(e){return"0x"+n.keccak_256(i.arrayify(e))}},{"./bytes":146,"js-sha3":142}],149:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defineReadOnly=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})},r.defineFrozen=function(e,t,r){var n=JSON.stringify(r);Object.defineProperty(e,t,{enumerable:!0,get:function(){return JSON.parse(n)}})},r.resolveProperties=function(e){var t={},r=[];return Object.keys(e).forEach(function(n){var i=e[n];i instanceof Promise?r.push(i.then(function(e){return t[n]=e,null})):t[n]=i}),Promise.all(r).then(function(){return t})},r.shallowCopy=function(e){var t={};for(var r in e)t[r]=e[r];return t},r.jsonCopy=function(e){return JSON.parse(JSON.stringify(e))}},{}],150:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./bytes");function i(e){for(var t=[];e;)t.unshift(255&e),e>>=8;return t}function o(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function s(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(r=e[t]-247)>e.length)throw new Error("too short");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("to short");return a(e,t,t+1+r,r+i)}if(e[t]>=192){if(t+1+(i=e[t]-192)>e.length)throw new Error("invalid rlp data");return a(e,t,t+1,i)}if(e[t]>=184){var r;if(t+1+(r=e[t]-183)>e.length)throw new Error("invalid rlp data");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("invalid rlp data");return{consumed:1+r+i,result:n.hexlify(e.slice(t+1+r,t+1+r+i))}}if(e[t]>=128){var i;if(t+1+(i=e[t]-128)>e.length)throw new Error("invalid rlp data");return{consumed:1+i,result:n.hexlify(e.slice(t+1,t+1+i))}}return{consumed:1,result:n.hexlify(e[t])}}r.encode=function(e){return n.hexlify(function e(t){if(Array.isArray(t)){var r=[];return t.forEach(function(t){r=r.concat(e(t))}),r.length<=55?(r.unshift(192+r.length),r):((o=i(r.length)).unshift(247+o.length),o.concat(r))}var o,a=Array.prototype.slice.call(n.arrayify(t));return 1===a.length&&a[0]<=127?a:a.length<=55?(a.unshift(128+a.length),a):((o=i(a.length)).unshift(183+o.length),o.concat(a))}(e))},r.decode=function(e){var t=n.arrayify(e),r=s(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}},{"./bytes":146}],151:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=function(){return function(){}}();r.BigNumber=n;var i=function(){return function(){}}();r.Indexed=i;var o=function(){return function(){}}();r.MinimalProvider=o;var a=function(){return function(){}}();r.Signer=a;var s=function(){return function(){}}();r.HDNode=s},{}],152:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,i=e("./bytes");!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(n=r.UnicodeNormalizationForm||(r.UnicodeNormalizationForm={})),r.toUtf8Bytes=function(e,t){void 0===t&&(t=n.current),t!=n.current&&(e=e.normalize(t));for(var r=[],o=0,a=0;a>6|192,r[o++]=63&s|128):55296==(64512&s)&&a+1>18|240,r[o++]=s>>12&63|128,r[o++]=s>>6&63|128,r[o++]=63&s|128):(r[o++]=s>>12|224,r[o++]=s>>6&63|128,r[o++]=63&s|128)}return i.arrayify(r)},r.toUtf8String=function(e){e=i.arrayify(e);for(var t="",r=0;r>7!=0){if(n>>6!=2){var o=null;if(n>>5==6)o=1;else if(n>>4==14)o=2;else if(n>>3==30)o=3;else if(n>>2==62)o=4;else{if(n>>1!=126)continue;o=5}if(r+o>e.length){for(;r>6==2;r++);if(r!=e.length)continue;return t}var a,s=n&(1<<8-o-1)-1;for(a=0;a>6!=2)break;s=s<<6|63&u}a==o?s<=65535?t+=String.fromCharCode(s):(s-=65536,t+=String.fromCharCode(55296+(s>>10&1023),56320+(1023&s))):r--}}else t+=String.fromCharCode(n)}return t}},{"./bytes":146}],153:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("number-to-bn"),o=new n(0),a=new n(-1),s={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",Gwei:"1000000000",shannon:"1000000000",nanoether:"1000000000",nano:"1000000000",szabo:"1000000000000",microether:"1000000000000",micro:"1000000000000",finney:"1000000000000000",milliether:"1000000000000000",milli:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"};function u(e){var t=e?e.toLowerCase():"ether",r=s[t];if("string"!=typeof r)throw new Error("[ethjs-unit] the unit provided "+e+" doesn't exists, please use the one of the following units "+JSON.stringify(s,null,2));return new n(r,10)}function c(e){if("string"==typeof e){if(!e.match(/^-?[0-9.]+$/))throw new Error("while converting number to string, invalid number value '"+e+"', should be a number matching (^-?[0-9.]+).");return e}if("number"==typeof e)return String(e);if("object"==typeof e&&e.toString&&(e.toTwos||e.dividedToIntegerBy))return e.toPrecision?String(e.toPrecision()):e.toString(10);throw new Error("while converting number to string, invalid number value '"+e+"' type "+typeof e+".")}t.exports={unitMap:s,numberToString:c,getValueOfUnit:u,fromWei:function(e,t,r){var n=i(e),c=n.lt(o),f=u(t),h=s[t].length-1||1,l=r||{};c&&(n=n.mul(a));for(var d=n.mod(f).toString(10);d.length2)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal points");var l=h[0],d=h[1];if(l||(l="0"),d||(d="0"),d.length>o)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal places");for(;d.length=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{}],155:[function(e,t,r){(function(r){"use strict";var n=e("is-hex-prefixed"),i=e("strip-hex-prefix");function o(e){var t=e;if("string"!=typeof t)throw new Error("[ethjs-util] while padding to even, value must be string, is currently "+typeof t+", while padToEven.");return t.length%2&&(t="0"+t),t}function a(e){return"0x"+e.toString(16)}t.exports={arrayContainsArray:function(e,t,r){if(!0!==Array.isArray(e))throw new Error("[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '"+typeof e+"'");if(!0!==Array.isArray(t))throw new Error("[ethjs-util] method arrayContainsArray requires input 'subset' to be an array got type '"+typeof t+"'");return t[Boolean(r)?"some":"every"](function(t){return e.indexOf(t)>=0})},intToBuffer:function(e){var t=a(e);return new r(o(t.slice(2)),"hex")},getBinarySize:function(e){if("string"!=typeof e)throw new Error("[ethjs-util] while getting binary size, method getBinarySize requires input 'str' to be type String, got '"+typeof e+"'.");return r.byteLength(e,"utf8")},isHexPrefixed:n,stripHexPrefix:i,padToEven:o,intToHex:a,fromAscii:function(e){for(var t="",r=0;r0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var r,n,a,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(r=this._events[e]).length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=a;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){n=s;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],158:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("md5.js");t.exports=function(e,t,r,o){if(n.isBuffer(e)||(e=n.from(e,"binary")),t&&(n.isBuffer(t)||(t=n.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var a=r/8,s=n.alloc(a),u=n.alloc(o||0),c=n.alloc(0);a>0||o>0;){var f=new i;f.update(c),f.update(e),t&&f.update(t),c=f.digest();var h=0;if(a>0){var l=s.length-a;h=Math.min(a,c.length),c.copy(s,l,0,h),a-=h}if(h0){var d=u.length-o,p=Math.min(o,c.length-h);c.copy(u,d,h,h+p),o-=p}}return c.fill(0),{key:s,iv:u}}},{"md5.js":231,"safe-buffer":290}],159:[function(e,t,r){"use strict";var n=e("is-callable"),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.exports=function(e,t,r){if(!n(t))throw new TypeError("iterator must be a function");var a;arguments.length>=3&&(a=r),"[object Array]"===i.call(e)?function(e,t,r){for(var n=0,i=e.length;n=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},i.prototype._update=function(e){throw new Error("_update is not implemented")},i.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();return void 0!==e&&(t=t.toString(e)),t},i.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=i}).call(this,e("buffer").Buffer)},{buffer:84,inherits:180,stream:311}],162:[function(e,t,r){var n=r;n.utils=e("./hash/utils"),n.common=e("./hash/common"),n.sha=e("./hash/sha"),n.ripemd=e("./hash/ripemd"),n.hmac=e("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":163,"./hash/hmac":164,"./hash/ripemd":165,"./hash/sha":166,"./hash/utils":173}],163:[function(e,t,r){"use strict";var n=e("./utils"),i=e("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},{"../utils":173}],173:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits");function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function s(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=i,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,a=255&i;o?r.push(o,a):r.push(a)}else for(n=0;n>>0}return a},r.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},r.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},r.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},r.sum64_lo=function(e,t,r,n){return t+n>>>0},r.sum64_4_hi=function(e,t,r,n,i,o,a,s){var u=0,c=t;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},r.sum64_5_hi=function(e,t,r,n,i,o,a,s,u,c){var f=0,h=t;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,n,i,o,a,s,u,c){return t+n+o+s+c>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:180,"minimalistic-assert":234}],174:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("minimalistic-crypto-utils"),o=e("minimalistic-assert");function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}t.exports=a,a.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},a.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length\\$%@ءؤة\"'^|~⦅⦆・ゥャ¢£¬¦¥₩│←↑→↓■○𐐨𐐩𐐪𐐫𐐬𐐭𐐮𐐯𐐰𐐱𐐲𐐳𐐴𐐵𐐶𐐷𐐸𐐹𐐺𐐻𐐼𐐽𐐾𐐿𐑀𐑁𐑂𐑃𐑄𐑅𐑆𐑇𐑈𐑉𐑊𐑋𐑌𐑍𐑎𐑏𐓘𐓙𐓚𐓛𐓜𐓝𐓞𐓟𐓠𐓡𐓢𐓣𐓤𐓥𐓦𐓧𐓨𐓩𐓪𐓫𐓬𐓭𐓮𐓯𐓰𐓱𐓲𐓳𐓴𐓵𐓶𐓷𐓸𐓹𐓺𐓻𐳀𐳁𐳂𐳃𐳄𐳅𐳆𐳇𐳈𐳉𐳊𐳋𐳌𐳍𐳎𐳏𐳐𐳑𐳒𐳓𐳔𐳕𐳖𐳗𐳘𐳙𐳚𐳛𐳜𐳝𐳞𐳟𐳠𐳡𐳢𐳣𐳤𐳥𐳦𐳧𐳨𐳩𐳪𐳫𐳬𐳭𐳮𐳯𐳰𐳱𐳲𑣀𑣁𑣂𑣃𑣄𑣅𑣆𑣇𑣈𑣉𑣊𑣋𑣌𑣍𑣎𑣏𑣐𑣑𑣒𑣓𑣔𑣕𑣖𑣗𑣘𑣙𑣚𑣛𑣜𑣝𑣞𑣟ıȷ∇∂𞤢𞤣𞤤𞤥𞤦𞤧𞤨𞤩𞤪𞤫𞤬𞤭𞤮𞤯𞤰𞤱𞤲𞤳𞤴𞤵𞤶𞤷𞤸𞤹𞤺𞤻𞤼𞤽𞤾𞤿𞥀𞥁𞥂𞥃ٮڡٯ字双多解交映無前後再新初終販声吹演投捕遊指禁空合満申割営配得可丽丸乁𠄢你侻倂偺備像㒞𠘺兔兤具𠔜㒹內𠕋冗冤仌冬𩇟刃㓟刻剆剷㔕包匆卉博即卽卿𠨬灰及叟𠭣叫叱吆咞吸呈周咢哶唐啓啣善喫喳嗂圖圗噑噴壮城埴堍型堲報墬𡓤売壷夆夢奢𡚨𡛪姬娛娧姘婦㛮嬈嬾𡧈寃寘寳𡬘寿将㞁屠峀岍𡷤嵃𡷦嵮嵫嵼巡巢㠯巽帨帽幩㡢𢆃㡼庰庳庶𪎒𢌱舁弢㣇𣊸𦇚形彫㣣徚忍志忹悁㤺㤜𢛔惇慈慌慺憲憤憯懞戛扝抱拔捐𢬌挽拼捨掃揤𢯱搢揅掩㨮摩摾撝摷㩬敬𣀊旣書晉㬙㬈㫤冒冕最暜肭䏙朡杞杓𣏃㭉柺枅桒𣑭梎栟椔楂榣槪檨𣚣櫛㰘次𣢧歔㱎歲殟殻𣪍𡴋𣫺汎𣲼沿泍汧洖派浩浸涅𣴞洴港湮㴳滇𣻑淹潮𣽞𣾎濆瀹瀛㶖灊災灷炭𠔥煅𤉣熜爨牐𤘈犀犕𤜵𤠔獺王㺬玥㺸瑇瑜璅瓊㼛甤𤰶甾𤲒𢆟瘐𤾡𤾸𥁄㿼䀈𥃳𥃲𥄙𥄳眞真瞋䁆䂖𥐝硎䃣𥘦𥚚𥛅秫䄯穊穏𥥼𥪧䈂𥮫篆築䈧𥲀糒䊠糨糣紀𥾆絣䌁緇縂繅䌴𦈨𦉇䍙𦋙罺𦌾羕翺𦓚𦔣聠𦖨聰𣍟䏕育脃䐋脾媵𦞧𦞵𣎓𣎜舄辞䑫芑芋芝劳花芳芽苦𦬼茝荣莭茣莽菧荓菊菌菜𦰶𦵫𦳕䔫蓱蓳蔖𧏊蕤𦼬䕝䕡𦾱𧃒䕫虐虧虩蚩蚈蜎蛢蜨蝫螆蟡蠁䗹衠𧙧裗裞䘵裺㒻𧢮𧥦䚾䛇誠𧲨貫賁贛起𧼯𠠄跋趼跰𠣞軔𨗒𨗭邔郱鄑𨜮鄛鈸鋗鋘鉼鏹鐕𨯺開䦕閷𨵷䧦雃嶲霣𩅅𩈚䩮䩶韠𩐊䪲𩒖頩𩖶飢䬳餩馧駂駾䯎𩬰鱀鳽䳎䳭鵧𪃎䳸𪄅𪈎𪊑䵖黾鼅鼏鼖𪘀",mapChar:function(r){return r>=196608?r>=917760&&r<=917999?18874368:0:e[t[r>>4]][15&r]}}},"function"==typeof define&&define.amd?define([],function(){return i()}):"object"==typeof r?t.exports=i():n.uts46_map=i()},{}],177:[function(e,t,r){var n,i;n=this,i=function(e,t){function r(r,n,i){for(var o=[],a=e.ucs2.decode(r),s=0;s>23,l=f>>21&3,d=f>>5&65535,p=31&f,b=t.mapStr.substr(d,p);if(0===l||n&&1&h)throw new Error("Illegal char "+c);1===l?o.push(b):2===l?o.push(i?b:c):3===l&&o.push(c)}return o.join("").normalize("NFC")}function n(t,n,o){void 0===o&&(o=!1);var a=r(t,o,n).split(".");return(a=a.map(function(t){return t.startsWith("xn--")?i(t=e.decode(t.substring(4)),o,!1):i(t,o,n),t})).join(".")}function i(e,n,i){if("-"===e[2]&&"-"===e[3])throw new Error("Failed to validate "+e);if(e.startsWith("-")||e.endsWith("-"))throw new Error("Failed to validate "+e);if(e.includes("."))throw new Error("Failed to validate "+e);if(r(e,n,i)!==e)throw new Error("Failed to validate "+e);var o=e.codePointAt(0);if(t.mapChar(o)&2<<23)throw new Error("Label contains illegal character: "+o)}return{toUnicode:function(e,t){return void 0===t&&(t={}),n(e,!1,"useStd3ASCII"in t&&t.useStd3ASCII)},toAscii:function(t,r){void 0===r&&(r={});var i,o=!("transitional"in r)||r.transitional,a="useStd3ASCII"in r&&r.useStd3ASCII,s="verifyDnsLength"in r&&r.verifyDnsLength,u=n(t,o,a).split(".").map(e.toASCII),c=u.join(".");if(s){if(c.length<1||c.length>253)throw new Error("DNS name has wrong length: "+c);for(i=0;i63)throw new Error("DNS label has wrong length: "+f)}}return c}}},"function"==typeof define&&define.amd?define(["punycode","./idna-map"],function(e,t){return i(e,t)}):"object"==typeof r?t.exports=i(e("punycode"),e("./idna-map")):n.uts46=i(n.punycode,n.idna_map)},{"./idna-map":176,punycode:265}],178:[function(e,t,r){r.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,f=-7,h=r?i-1:0,l=r?-1:1,d=e[t+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=s;f>0;o=256*o+e[t+h],h+=l,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+e[t+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=c}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var a,s,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(a++,u/=2),a+h>=f?(s=0,a=f):a+h>=1?(s=(t*u-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;e[r+d]=255&a,d+=p,a/=256,c-=8);e[r+d-p]|=128*b}},{}],179:[function(e,t,r){var n=[].indexOf;t.exports=function(e,t){if(n)return e.indexOf(t);for(var r=0;r-32e3)throw new Error("Invalid error code");if(!(this instanceof f))return new f(e);i.call(this,"Server error",e)};n(f,i),i.ParseError=o,i.InvalidRequest=a,i.MethodNotFound=s,i.InvalidParams=u,i.InternalError=c,i.ServerError=f,t.exports=i},{inherits:180}],191:[function(e,t,r){t.exports=function(e){var t=(e=e||{}).max||Number.MAX_SAFE_INTEGER,r=void 0!==e.start?e.start:Math.floor(Math.random()*t);return function(){return r%=t,r++}}},{}],192:[function(e,t,r){r.parse=e("./lib/parse"),r.stringify=e("./lib/stringify")},{"./lib/parse":193,"./lib/stringify":194}],193:[function(e,t,r){var n,i,o,a,s={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},u=function(e){throw{name:"SyntaxError",message:e,at:n,text:o}},c=function(e){return e&&e!==i&&u("Expected '"+e+"' instead of '"+i+"'"),i=o.charAt(n),n+=1,i},f=function(){var e,t="";for("-"===i&&(t="-",c("-"));i>="0"&&i<="9";)t+=i,c();if("."===i)for(t+=".";c()&&i>="0"&&i<="9";)t+=i;if("e"===i||"E"===i)for(t+=i,c(),"-"!==i&&"+"!==i||(t+=i,c());i>="0"&&i<="9";)t+=i,c();if(e=+t,isFinite(e))return e;u("Bad number")},h=function(){var e,t,r,n="";if('"'===i)for(;c();){if('"'===i)return c(),n;if("\\"===i)if(c(),"u"===i){for(r=0,t=0;t<4&&(e=parseInt(c(),16),isFinite(e));t+=1)r=16*r+e;n+=String.fromCharCode(r)}else{if("string"!=typeof s[i])break;n+=s[i]}else n+=i}u("Bad string")},l=function(){for(;i&&i<=" ";)c()};a=function(){switch(l(),i){case"{":return function(){var e,t={};if("{"===i){if(c("{"),l(),"}"===i)return c("}"),t;for(;i;){if(e=h(),l(),c(":"),Object.hasOwnProperty.call(t,e)&&u('Duplicate key "'+e+'"'),t[e]=a(),l(),"}"===i)return c("}"),t;c(","),l()}}u("Bad object")}();case"[":return function(){var e=[];if("["===i){if(c("["),l(),"]"===i)return c("]"),e;for(;i;){if(e.push(a()),l(),"]"===i)return c("]"),e;c(","),l()}}u("Bad array")}();case'"':return h();case"-":return f();default:return i>="0"&&i<="9"?f():function(){switch(i){case"t":return c("t"),c("r"),c("u"),c("e"),!0;case"f":return c("f"),c("a"),c("l"),c("s"),c("e"),!1;case"n":return c("n"),c("u"),c("l"),c("l"),null}u("Unexpected '"+i+"'")}()}},t.exports=function(e,t){var r;return o=e,n=0,i=" ",r=a(),l(),i&&u("Syntax error"),"function"==typeof t?function e(r,n){var i,o,a=r[n];if(a&&"object"==typeof a)for(i in a)Object.prototype.hasOwnProperty.call(a,i)&&(void 0!==(o=e(a,i))?a[i]=o:delete a[i]);return t.call(r,n,a)}({"":r},""):r}},{}],194:[function(e,t,r){var n,i,o,a=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,s={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function u(e){return a.lastIndex=0,a.test(e)?'"'+e.replace(a,function(e){var t=s[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}t.exports=function(e,t,r){var a;if(n="",i="","number"==typeof r)for(a=0;a>>31),p=l^(a<<1|o>>>31),b=e[0]^d,y=e[1]^p,m=e[10]^d,v=e[11]^p,g=e[20]^d,w=e[21]^p,_=e[30]^d,A=e[31]^p,E=e[40]^d,x=e[41]^p;d=r^(s<<1|u>>>31),p=i^(u<<1|s>>>31);var k=e[2]^d,S=e[3]^p,M=e[12]^d,I=e[13]^p,T=e[22]^d,U=e[23]^p,j=e[32]^d,B=e[33]^p,P=e[42]^d,C=e[43]^p;d=o^(c<<1|f>>>31),p=a^(f<<1|c>>>31);var N=e[4]^d,R=e[5]^p,L=e[14]^d,O=e[15]^p,D=e[24]^d,F=e[25]^p,q=e[34]^d,H=e[35]^p,z=e[44]^d,K=e[45]^p;d=s^(h<<1|l>>>31),p=u^(l<<1|h>>>31);var V=e[6]^d,G=e[7]^p,W=e[16]^d,Y=e[17]^p,X=e[26]^d,Z=e[27]^p,J=e[36]^d,$=e[37]^p,Q=e[46]^d,ee=e[47]^p;d=c^(r<<1|i>>>31),p=f^(i<<1|r>>>31);var te=e[8]^d,re=e[9]^p,ne=e[18]^d,ie=e[19]^p,oe=e[28]^d,ae=e[29]^p,se=e[38]^d,ue=e[39]^p,ce=e[48]^d,fe=e[49]^p,he=b,le=y,de=v<<4|m>>>28,pe=m<<4|v>>>28,be=g<<3|w>>>29,ye=w<<3|g>>>29,me=A<<9|_>>>23,ve=_<<9|A>>>23,ge=E<<18|x>>>14,we=x<<18|E>>>14,_e=k<<1|S>>>31,Ae=S<<1|k>>>31,Ee=I<<12|M>>>20,xe=M<<12|I>>>20,ke=T<<10|U>>>22,Se=U<<10|T>>>22,Me=B<<13|j>>>19,Ie=j<<13|B>>>19,Te=P<<2|C>>>30,Ue=C<<2|P>>>30,je=R<<30|N>>>2,Be=N<<30|R>>>2,Pe=L<<6|O>>>26,Ce=O<<6|L>>>26,Ne=F<<11|D>>>21,Re=D<<11|F>>>21,Le=q<<15|H>>>17,Oe=H<<15|q>>>17,De=K<<29|z>>>3,Fe=z<<29|K>>>3,qe=V<<28|G>>>4,He=G<<28|V>>>4,ze=Y<<23|W>>>9,Ke=W<<23|Y>>>9,Ve=X<<25|Z>>>7,Ge=Z<<25|X>>>7,We=J<<21|$>>>11,Ye=$<<21|J>>>11,Xe=ee<<24|Q>>>8,Ze=Q<<24|ee>>>8,Je=te<<27|re>>>5,$e=re<<27|te>>>5,Qe=ne<<20|ie>>>12,et=ie<<20|ne>>>12,tt=ae<<7|oe>>>25,rt=oe<<7|ae>>>25,nt=se<<8|ue>>>24,it=ue<<8|se>>>24,ot=ce<<14|fe>>>18,at=fe<<14|ce>>>18;e[0]=he^~Ee&Ne,e[1]=le^~xe&Re,e[10]=qe^~Qe&be,e[11]=He^~et&ye,e[20]=_e^~Pe&Ve,e[21]=Ae^~Ce&Ge,e[30]=Je^~de&ke,e[31]=$e^~pe&Se,e[40]=je^~ze&tt,e[41]=Be^~Ke&rt,e[2]=Ee^~Ne&We,e[3]=xe^~Re&Ye,e[12]=Qe^~be&Me,e[13]=et^~ye&Ie,e[22]=Pe^~Ve&nt,e[23]=Ce^~Ge&it,e[32]=de^~ke&Le,e[33]=pe^~Se&Oe,e[42]=ze^~tt&me,e[43]=Ke^~rt&ve,e[4]=Ne^~We&ot,e[5]=Re^~Ye&at,e[14]=be^~Me&De,e[15]=ye^~Ie&Fe,e[24]=Ve^~nt&ge,e[25]=Ge^~it&we,e[34]=ke^~Le&Xe,e[35]=Se^~Oe&Ze,e[44]=tt^~me&Te,e[45]=rt^~ve&Ue,e[6]=We^~ot&he,e[7]=Ye^~at&le,e[16]=Me^~De&qe,e[17]=Ie^~Fe&He,e[26]=nt^~ge&_e,e[27]=it^~we&Ae,e[36]=Le^~Xe&Je,e[37]=Oe^~Ze&$e,e[46]=me^~Te&je,e[47]=ve^~Ue&Be,e[8]=ot^~he&Ee,e[9]=at^~le&xe,e[18]=De^~qe&Qe,e[19]=Fe^~He&et,e[28]=ge^~_e&Pe,e[29]=we^~Ae&Ce,e[38]=Xe^~Je&de,e[39]=Ze^~$e&pe,e[48]=Te^~je&ze,e[49]=Ue^~Be&Ke,e[0]^=n[2*t],e[1]^=n[2*t+1]}}},{}],200:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("./keccak-state-unroll");function o(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}o.prototype.initialize=function(e,t){for(var r=0;r<50;++r)this.state[r]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},o.prototype.absorb=function(e){for(var t=0;t>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(i.p1600(this.state),this.count=0);return t},o.prototype.copy=function(e){for(var t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},t.exports=o},{"./keccak-state-unroll":199,"safe-buffer":290}],201:[function(e,t,r){var n=e("./_root").Symbol;t.exports=n},{"./_root":217}],202:[function(e,t,r){var n=e("./_baseTimes"),i=e("./isArguments"),o=e("./isArray"),a=e("./isBuffer"),s=e("./_isIndex"),u=e("./isTypedArray"),c=Object.prototype.hasOwnProperty;t.exports=function(e,t){var r=o(e),f=!r&&i(e),h=!r&&!f&&a(e),l=!r&&!f&&!h&&u(e),d=r||f||h||l,p=d?n(e.length,String):[],b=p.length;for(var y in e)!t&&!c.call(e,y)||d&&("length"==y||h&&("offset"==y||"parent"==y)||l&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||s(y,b))||p.push(y);return p}},{"./_baseTimes":207,"./_isIndex":211,"./isArguments":219,"./isArray":220,"./isBuffer":222,"./isTypedArray":227}],203:[function(e,t,r){var n=e("./_Symbol"),i=e("./_getRawTag"),o=e("./_objectToString"),a="[object Null]",s="[object Undefined]",u=n?n.toStringTag:void 0;t.exports=function(e){return null==e?void 0===e?s:a:u&&u in Object(e)?i(e):o(e)}},{"./_Symbol":201,"./_getRawTag":210,"./_objectToString":215}],204:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isObjectLike"),o="[object Arguments]";t.exports=function(e){return i(e)&&n(e)==o}},{"./_baseGetTag":203,"./isObjectLike":226}],205:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isLength"),o=e("./isObjectLike"),a={};a["[object Float32Array]"]=a["[object Float64Array]"]=a["[object Int8Array]"]=a["[object Int16Array]"]=a["[object Int32Array]"]=a["[object Uint8Array]"]=a["[object Uint8ClampedArray]"]=a["[object Uint16Array]"]=a["[object Uint32Array]"]=!0,a["[object Arguments]"]=a["[object Array]"]=a["[object ArrayBuffer]"]=a["[object Boolean]"]=a["[object DataView]"]=a["[object Date]"]=a["[object Error]"]=a["[object Function]"]=a["[object Map]"]=a["[object Number]"]=a["[object Object]"]=a["[object RegExp]"]=a["[object Set]"]=a["[object String]"]=a["[object WeakMap]"]=!1,t.exports=function(e){return o(e)&&i(e.length)&&!!a[n(e)]}},{"./_baseGetTag":203,"./isLength":224,"./isObjectLike":226}],206:[function(e,t,r){var n=e("./_isPrototype"),i=e("./_nativeKeys"),o=Object.prototype.hasOwnProperty;t.exports=function(e){if(!n(e))return i(e);var t=[];for(var r in Object(e))o.call(e,r)&&"constructor"!=r&&t.push(r);return t}},{"./_isPrototype":212,"./_nativeKeys":213}],207:[function(e,t,r){t.exports=function(e,t){for(var r=-1,n=Array(e);++r-1&&e%1==0&&e-1&&e%1==0&&e<=n}},{}],225:[function(e,t,r){t.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},{}],226:[function(e,t,r){t.exports=function(e){return null!=e&&"object"==typeof e}},{}],227:[function(e,t,r){var n=e("./_baseIsTypedArray"),i=e("./_baseUnary"),o=e("./_nodeUtil"),a=o&&o.isTypedArray,s=a?i(a):n;t.exports=s},{"./_baseIsTypedArray":205,"./_baseUnary":208,"./_nodeUtil":214}],228:[function(e,t,r){var n=e("./_arrayLikeKeys"),i=e("./_baseKeys"),o=e("./isArrayLike");t.exports=function(e){return o(e)?n(e):i(e)}},{"./_arrayLikeKeys":202,"./_baseKeys":206,"./isArrayLike":221}],229:[function(e,t,r){t.exports=function(){}},{}],230:[function(e,t,r){t.exports=function(){return!1}},{}],231:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base"),o=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function s(e,t){return e<>>32-t}function u(e,t,r,n,i,o,a){return s(e+(t&r|~t&n)+i+o|0,a)+t|0}function c(e,t,r,n,i,o,a){return s(e+(t&n|r&~n)+i+o|0,a)+t|0}function f(e,t,r,n,i,o,a){return s(e+(t^r^n)+i+o|0,a)+t|0}function h(e,t,r,n,i,o,a){return s(e+(r^(t|~n))+i+o|0,a)+t|0}n(a,i),a.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,a=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,a=u(a,r=u(r,n,i,a,e[0],3614090360,7),n,i,e[1],3905402710,12),r,n,e[2],606105819,17),a,r,e[3],3250441966,22),i=u(i,a=u(a,r=u(r,n,i,a,e[4],4118548399,7),n,i,e[5],1200080426,12),r,n,e[6],2821735955,17),a,r,e[7],4249261313,22),i=u(i,a=u(a,r=u(r,n,i,a,e[8],1770035416,7),n,i,e[9],2336552879,12),r,n,e[10],4294925233,17),a,r,e[11],2304563134,22),i=u(i,a=u(a,r=u(r,n,i,a,e[12],1804603682,7),n,i,e[13],4254626195,12),r,n,e[14],2792965006,17),a,r,e[15],1236535329,22),i=c(i,a=c(a,r=c(r,n,i,a,e[1],4129170786,5),n,i,e[6],3225465664,9),r,n,e[11],643717713,14),a,r,e[0],3921069994,20),i=c(i,a=c(a,r=c(r,n,i,a,e[5],3593408605,5),n,i,e[10],38016083,9),r,n,e[15],3634488961,14),a,r,e[4],3889429448,20),i=c(i,a=c(a,r=c(r,n,i,a,e[9],568446438,5),n,i,e[14],3275163606,9),r,n,e[3],4107603335,14),a,r,e[8],1163531501,20),i=c(i,a=c(a,r=c(r,n,i,a,e[13],2850285829,5),n,i,e[2],4243563512,9),r,n,e[7],1735328473,14),a,r,e[12],2368359562,20),i=f(i,a=f(a,r=f(r,n,i,a,e[5],4294588738,4),n,i,e[8],2272392833,11),r,n,e[11],1839030562,16),a,r,e[14],4259657740,23),i=f(i,a=f(a,r=f(r,n,i,a,e[1],2763975236,4),n,i,e[4],1272893353,11),r,n,e[7],4139469664,16),a,r,e[10],3200236656,23),i=f(i,a=f(a,r=f(r,n,i,a,e[13],681279174,4),n,i,e[0],3936430074,11),r,n,e[3],3572445317,16),a,r,e[6],76029189,23),i=f(i,a=f(a,r=f(r,n,i,a,e[9],3654602809,4),n,i,e[12],3873151461,11),r,n,e[15],530742520,16),a,r,e[2],3299628645,23),i=h(i,a=h(a,r=h(r,n,i,a,e[0],4096336452,6),n,i,e[7],1126891415,10),r,n,e[14],2878612391,15),a,r,e[5],4237533241,21),i=h(i,a=h(a,r=h(r,n,i,a,e[12],1700485571,6),n,i,e[3],2399980690,10),r,n,e[10],4293915773,15),a,r,e[1],2240044497,21),i=h(i,a=h(a,r=h(r,n,i,a,e[8],1873313359,6),n,i,e[15],4264355552,10),r,n,e[6],2734768916,15),a,r,e[13],1309151649,21),i=h(i,a=h(a,r=h(r,n,i,a,e[4],4149444226,6),n,i,e[11],3174756917,10),r,n,e[2],718787259,15),a,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+a|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=a}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":232,inherits:180}],232:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("stream").Transform;function o(e){i.call(this),this._block=n.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}e("inherits")(o,i),o.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},o.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},o.prototype.update=function(e,t){if(function(e,t){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");n.isBuffer(e)||(e=n.from(e,t));for(var r=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},{inherits:180,"safe-buffer":290,stream:311}],233:[function(e,t,r){var n=e("bn.js"),i=e("brorand");function o(e){this.rand=e||new i.Rand}t.exports=o,o.create=function(e){return new o(e)},o.prototype._randbelow=function(e){var t=e.bitLength(),r=Math.ceil(t/8);do{var i=new n(this.rand.generate(r))}while(i.cmp(e)>=0);return i},o.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},o.prototype.test=function(e,t,r){var i=e.bitLength(),o=n.mont(e),a=new n(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var s=e.subn(1),u=0;!s.testn(u);u++);for(var c=e.shrn(u),f=s.toRed(o);t>0;t--){var h=this._randrange(new n(2),s);r&&r(h);var l=h.toRed(o).redPow(c);if(0!==l.cmp(a)&&0!==l.cmp(f)){for(var d=1;d0;t--){var f=this._randrange(new n(2),a),h=e.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(u);if(0!==l.cmp(o)&&0!==l.cmp(c)){for(var d=1;d>8,a=255&i;o?r.push(o,a):r.push(a)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},{}],236:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],237:[function(e,t,r){var n=e("bn.js"),i=e("strip-hex-prefix");t.exports=function(e){if("string"==typeof e||"number"==typeof e){var t=new n(1),r=String(e).toLowerCase().trim(),o="0x"===r.substr(0,2)||"-0x"===r.substr(0,3),a=i(r);if("-"===a.substr(0,1)&&(a=i(a.slice(1)),t=new n(-1,10)),!(a=""===a?"0":a).match(/^-?[0-9]+$/)&&a.match(/^[0-9A-Fa-f]+$/)||a.match(/^[a-fA-F]+$/)||!0===o&&a.match(/^[0-9A-Fa-f]+$/))return new n(a,16).mul(t);if((a.match(/^-?[0-9]+$/)||""===a)&&!1===o)return new n(a,10).mul(t)}else if("object"==typeof e&&e.toString&&!e.pop&&!e.push&&e.toString(10).match(/^-?[0-9]+$/)&&(e.mul||e.dividedToIntegerBy))return new n(e.toString(10),10);throw new Error("[number-to-bn] while converting number "+JSON.stringify(e)+" to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.")}},{"bn.js":236,"strip-hex-prefix":318}],238:[function(e,t,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,a,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),u=1;u0;)if(q+=r,r=e.charAt(o++),4===H?(N+=String.fromCharCode(parseInt(q,16)),H=0,c=o-1):H++,!r)break e;if('"'===r&&!L){D=F.pop()||p,N+=e.substring(c,o-1);break}if(!("\\"!==r||L||(L=!0,N+=e.substring(c,o-1),r=e.charAt(o++))))break;if(L){if(L=!1,"n"===r?N+="\n":"r"===r?N+="\r":"t"===r?N+="\t":"f"===r?N+="\f":"b"===r?N+="\b":"u"===r?(H=1,q=""):N+=r,r=e.charAt(o++),c=o-1,r)continue;break}h.lastIndex=o;var l=h.exec(e);if(!l){o=e.length+1,N+=e.substring(c,o-1);break}if(o=l.index+1,!(r=e.charAt(l.index))){N+=e.substring(c,o-1);break}}continue;case A:if(!r)continue;if("r"!==r)return W("Invalid true started with t"+r);D=E;continue;case E:if(!r)continue;if("u"!==r)return W("Invalid true started with tr"+r);D=x;continue;case x:if(!r)continue;if("e"!==r)return W("Invalid true started with tru"+r);a(!0),u(),D=F.pop()||p;continue;case k:if(!r)continue;if("a"!==r)return W("Invalid false started with f"+r);D=S;continue;case S:if(!r)continue;if("l"!==r)return W("Invalid false started with fa"+r);D=M;continue;case M:if(!r)continue;if("s"!==r)return W("Invalid false started with fal"+r);D=I;continue;case I:if(!r)continue;if("e"!==r)return W("Invalid false started with fals"+r);a(!1),u(),D=F.pop()||p;continue;case T:if(!r)continue;if("u"!==r)return W("Invalid null started with n"+r);D=U;continue;case U:if(!r)continue;if("l"!==r)return W("Invalid null started with nu"+r);D=j;continue;case j:if(!r)continue;if("l"!==r)return W("Invalid null started with nul"+r);a(null),u(),D=F.pop()||p;continue;case B:if("."!==r)return W("Leading zero not followed by .");R+=r,D=P;continue;case P:if(-1!=="0123456789".indexOf(r))R+=r;else if("."===r){if(-1!==R.indexOf("."))return W("Invalid number has two dots");R+=r}else if("e"===r||"E"===r){if(-1!==R.indexOf("e")||-1!==R.indexOf("E"))return W("Invalid number has two exponential");R+=r}else if("+"===r||"-"===r){if("e"!==n&&"E"!==n)return W("Invalid symbol in number");R+=r}else R&&(a(parseFloat(R)),u(),R=""),o--,D=F.pop()||p;continue;default:return W("Unknown state: "+D)}K>=C&&(X=0,N!==s&&N.length>f&&(W("Max buffer length exceeded: textNode"),X=Math.max(X,N.length)),R.length>f&&(W("Max buffer length exceeded: numberNode"),X=Math.max(X,R.length)),C=f-X+K);var X}),e(ce).on(function(){if(D==d)return a({}),u(),void(O=!0);D===p&&0===z||W("Unexpected end");N!==s&&(a(N),u(),N=s);O=!0})}var C,N,R,L,O,D,F,q,H,z,K,V=(C=d(function(e){return e.unshift(/^/),(t=RegExp(e.map(f("source")).join(""))).exec.bind(t);var t}),L=C(N=/(\$?)/,/([\w-_]+|\*)/,R=/(?:{([\w ]*?)})?/),O=C(N,/\["([^"]+)"\]/,R),D=C(N,/\[(\d+|\*)\]/,R),F=C(N,/()/,/{([\w ]*?)}/),q=C(/\.\./),H=C(/\./),z=C(N,/!/),K=C(/$/),function(e){return e(h(L,O,D,F),q,H,z,K)});function G(e,t){return{key:e,node:t}}var W=f("key"),Y=f("node"),X={};function Z(e){var t=e(ee).emit,r=e(te).emit,n=e(ae).emit,o=e(oe).emit;function a(e,t,r){Y(x(e))[t]=r}function s(e,r,n){e&&a(e,r,n);var i=A(G(r,n),e);return t(i),i}var u={};return u[le]=function(e,t){if(!e)return n(t),s(e,X,t);var r=function(e,t){var r=Y(x(e));return m(i,r)?s(e,v(r),t):e}(e,t),o=k(r),u=W(x(r));return a(o,u,t),A(G(u,t),o)},u[de]=function(e){return r(e),k(e)||o(Y(x(e)))},u[he]=s,u}var J=V(function(e,t,r,n,i){var a=1,s=2,f=3,l=c(W,x),d=c(Y,x);function b(e,t){return!!t[a]?p(e,x):e}function m(e){if(e==y)return y;return p(function(e){return l(e)!=X},c(e,k))}function g(){return function(e){return l(e)==X}}function w(e,t,r,n,i){var o=e(r);if(o){var a=function(e,t,r){return U(function(e,t){return t(e,r)},t,e)}(t,n,o);return i(r.substr(v(o[0])),a)}}function A(e,t){return u(w,e,t)}var E=h(A(e,M(b,function(e,t){var r=t[f];return r?p(c(u(_,S(r.split(/\W+/))),d),e):e},function(e,t){var r=t[s];return p(r&&"*"!=r?function(e){return l(e)==r}:y,e)},m)),A(t,M(function(e){if(e==y)return y;var t=g(),r=e,n=m(function(e){return i(e)}),i=h(t,r,n);return i})),A(r,M()),A(n,M(b,g)),A(i,M(function(e){return function(t){var r=e(t);return!0===r?x(t):r}})),function(e){throw o('"'+e+'" could not be tokenised')});function I(e,t){return t}function T(e,t){return E(e,t,e?T:I)}return function(e){try{return T(e,y)}catch(t){throw o('Could not compile "'+e+'" because '+t.message)}}});function $(e,t,r){var n,i;function o(e){return function(t){return t.id==e}}return{on:function(r,o){var a={listener:r,id:o||r};return t&&t.emit(e,r,a.id),n=A(a,n),i=A(r,i),this},emit:function(){!function e(t,r){t&&(x(t).apply(null,r),e(k(t),r))}(i,arguments)},un:function(t){var a;n=j(n,o(t),function(e){a=e}),a&&(i=j(i,function(e){return e==a.listener}),r&&r.emit(e,a.listener,a.id))},listeners:function(){return i},hasListener:function(e){return w(function e(t,r){return r&&(t(x(r))?x(r):e(t,k(r)))}(e?o(e):y,n))}}}var Q=1,ee=Q++,te=Q++,re=Q++,ne=Q++,ie="fail",oe=Q++,ae=Q++,se="start",ue="data",ce="end",fe=Q++,he=Q++,le=Q++,de=Q++;function pe(e,t,r){try{var n=a.parse(t)}catch(e){}return{statusCode:e,body:t,jsonBody:n,thrown:r}}function be(e,t){var r={node:e(te),path:e(ee)};function n(t,r,n){var i=e(t).emit;r.on(function(e){var t=n(e);!1!==t&&function(e,t,r){var n=B(r);e(t,I(k(T(W,n))),I(T(Y,n)))}(i,Y(t),e)},t),e("removeListener").on(function(n){n==t&&(e(n).listeners()||r.un(t))})}e("newListener").on(function(e){var i=/(node|path):(.*)/.exec(e);if(i){var o=r[i[1]];o.hasListener(e)||n(e,o,t(i[2]))}})}function ye(e,t){var r,n=/^(node|path):./,i=e(oe),o=e(ne).emit,a=e(re).emit,s=d(function(t,i){if(r[t])l(i,r[t]);else{var o=e(t),a=i[0];n.test(t)?c(o,a):o.on(a)}return r});function c(e,t,n){n=n||t;var i=f(t);return e.on(function(){var t=!1;r.forget=function(){t=!0},l(arguments,i),delete r.forget,t&&e.un(n)},n),r}function f(e){return function(){try{return e.apply(r,arguments)}catch(e){setTimeout(function(){throw e})}}}function h(t,r,n){var i;i="node"==t?function(e){return function(){var t=e.apply(this,arguments);w(t)&&(t==ge.drop?o():a(t))}}(n):n,c(function(t,r){return e(t+":"+r)}(t,r),i,n)}function p(e,t,n){return g(t)?h(e,t,n):function(e,t){for(var r in t)h(e,r,t[r])}(e,t),r}return e(ae).on(function(e){var t;r.root=(t=e,function(){return t})}),e(se).on(function(e,t){r.header=function(e){return e?t[e]:t}}),r={on:s,addListener:s,removeListener:function(t,n,o){if("done"==t)i.un(n);else if("node"==t||"path"==t)e.un(t+":"+n,o);else{var a=n;e(t).un(a)}return r},emit:e.emit,node:u(p,"node"),path:u(p,"path"),done:u(c,i),start:u(function(t,n){return e(t).on(f(n),n),r},se),fail:e(ie).on,abort:e(fe).emit,header:b,root:b,source:t}}function me(t,r,n,i,o){var a=function(){var e={},t=n("newListener"),r=n("removeListener");function n(n){return e[n]=$(n,t,r)}function i(t){return e[t]||n(t)}return["emit","on","un"].forEach(function(e){i[e]=d(function(t,r){l(r,i(t)[e])})}),i}();return r&&function(t,r,n,i,o,a,c){"use strict";var f=t(ue).emit,h=t(ie).emit,l=0,d=!0;function p(){var e=r.responseText,t=e.substr(l);t&&f(t),l=v(e)}t(fe).on(function(){r.onreadystatechange=null,r.abort()}),"onprogress"in r&&(r.onprogress=p),r.onreadystatechange=function(){function e(){try{d&&t(se).emit(r.status,(e=r.getAllResponseHeaders(),n={},e&&e.split("\r\n").forEach(function(e){var t=e.indexOf(": ");n[e.substring(0,t)]=e.substring(t+2)}),n)),d=!1}catch(e){}var e,n}switch(r.readyState){case 2:case 3:return e();case 4:e(),2==String(r.status)[0]?(p(),t(ce).emit()):h(pe(r.status,r.responseText))}};try{for(var b in r.open(n,i,!0),a)r.setRequestHeader(b,a[b]);(function(e,t){function r(t){return t.port||{"http:":80,"https:":443}[t.protocol||e.protocol]}return!!(t.protocol&&t.protocol!=e.protocol||t.host&&t.host!=e.host||t.host&&r(t)!=r(e))})(e.location,function(e){var t=/(\w+:)?(?:\/\/)([\w.-]+)?(?::(\d+))?\/?/.exec(e)||[];return{protocol:t[1]||"",host:t[2]||"",port:t[3]||""}}(i))||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.withCredentials=c,r.send(o)}catch(t){e.setTimeout(u(h,pe(s,s,t)),0)}}(a,new XMLHttpRequest,t,r,n,i,o),P(a),function(e,t){"use strict";var r,n={};function i(e){return function(t){r=e(r,t)}}for(var o in t)e(o).on(i(t[o]),n);e(re).on(function(e){var t=x(r),n=W(t),i=k(r);i&&(Y(x(i))[n]=e)}),e(ne).on(function(){var e=x(r),t=W(e),n=k(r);n&&delete Y(x(n))[t]}),e(fe).on(function(){for(var r in t)e(r).un(n)})}(a,Z(a)),be(a,J),ye(a,r)}function ve(e,t,r,n,i,o,s){return i=i?a.parse(a.stringify(i)):{},n?g(n)||(n=a.stringify(n),i["Content-Type"]=i["Content-Type"]||"application/json"):n=null,e(r||"GET",function(e,t){return!1===t&&(-1==e.indexOf("?")?e+="?":e+="&",e+="_="+(new Date).getTime()),e}(t,s),n,i,o||!1)}function ge(e){var t=M("resume","pause","pipe"),r=u(_,t);return e?r(e)||g(e)?ve(me,e):ve(me,e.url,e.method,e.body,e.headers,e.withCredentials,e.cached):me()}ge.drop=function(){return ge.drop},"function"==typeof define&&define.amd?define("oboe",[],function(){return ge}):"object"==typeof r?t.exports=ge:e.oboe=ge}(function(){try{return window}catch(e){return self}}(),Object,Array,Error,JSON)},{}],240:[function(e,t,r){r.endianness=function(){return"LE"},r.hostname=function(){return"undefined"!=typeof location?location.hostname:""},r.loadavg=function(){return[]},r.uptime=function(){return 0},r.freemem=function(){return Number.MAX_VALUE},r.totalmem=function(){return Number.MAX_VALUE},r.cpus=function(){return[]},r.type=function(){return"Browser"},r.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},r.networkInterfaces=r.getNetworkInterfaces=function(){return{}},r.arch=function(){return"javascript"},r.platform=function(){return"browser"},r.tmpdir=r.tmpDir=function(){return"/tmp"},r.EOL="\n",r.homedir=function(){return"/"}},{}],241:[function(e,t,r){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],242:[function(e,t,r){"use strict";var n=e("asn1.js");r.certificate=e("./certificate");var i=n.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});r.RSAPrivateKey=i;var o=n.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});r.RSAPublicKey=o;var a=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())});r.PublicKey=a;var s=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),u=n.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(s),this.key("subjectPrivateKey").octstr())});r.PrivateKey=u;var c=n.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});r.EncryptedPrivateKey=c;var f=n.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});r.DSAPrivateKey=f,r.DSAparam=n.define("DSAparam",function(){this.int()});var h=n.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(l),this.key("publicKey").optional().explicit(1).bitstr())});r.ECPrivateKey=h;var l=n.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});r.signature=n.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},{"./certificate":243,"asn1.js":5}],243:[function(e,t,r){"use strict";var n=e("asn1.js"),i=n.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),o=n.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),a=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional())}),s=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())}),u=n.define("RelativeDistinguishedName",function(){this.setof(o)}),c=n.define("RDNSequence",function(){this.seqof(u)}),f=n.define("Name",function(){this.choice({rdnSequence:this.use(c)})}),h=n.define("Validity",function(){this.seq().obj(this.key("notBefore").use(i),this.key("notAfter").use(i))}),l=n.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),d=n.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int(),this.key("serialNumber").int(),this.key("signature").use(a),this.key("issuer").use(f),this.key("validity").use(h),this.key("subject").use(f),this.key("subjectPublicKeyInfo").use(s),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(l).optional())}),p=n.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(a),this.key("signatureValue").bitstr())});t.exports=p},{"asn1.js":5}],244:[function(e,t,r){(function(r){var n=/Proc-Type: 4,ENCRYPTED\n\r?DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\n\r?\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?/m,i=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n/m,o=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?-----END \1-----$/m,a=e("evp_bytestokey"),s=e("browserify-aes");t.exports=function(e,t){var u,c=e.toString(),f=c.match(n);if(f){var h="aes"+f[1],l=new r(f[2],"hex"),d=new r(f[3].replace(/\r?\n/g,""),"base64"),p=a(t,l.slice(0,8),parseInt(f[1],10)).key,b=[],y=s.createDecipheriv(h,p,l);b.push(y.update(d)),b.push(y.final()),u=r.concat(b)}else{var m=c.match(o);u=new r(m[2].replace(/\r?\n/g,""),"base64")}return{tag:c.match(i)[1],data:u}}}).call(this,e("buffer").Buffer)},{"browserify-aes":58,buffer:84,evp_bytestokey:158}],245:[function(e,t,r){(function(r){var n=e("./asn1"),i=e("./aesid.json"),o=e("./fixProc"),a=e("browserify-aes"),s=e("pbkdf2");function u(e){var t;"object"!=typeof e||r.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=new r(e));var u,c,f=o(e,t),h=f.tag,l=f.data;switch(h){case"CERTIFICATE":c=n.certificate.decode(l,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(c||(c=n.PublicKey.decode(l,"der")),u=c.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPublicKey.decode(c.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return c.subjectPrivateKey=c.subjectPublicKey,{type:"ec",data:c};case"1.2.840.10040.4.1":return c.algorithm.params.pub_key=n.DSAparam.decode(c.subjectPublicKey.data,"der"),{type:"dsa",data:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"ENCRYPTED PRIVATE KEY":l=function(e,t){var n=e.algorithm.decrypt.kde.kdeparams.salt,o=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),u=i[e.algorithm.decrypt.cipher.algo.join(".")],c=e.algorithm.decrypt.cipher.iv,f=e.subjectPrivateKey,h=parseInt(u.split("-")[1],10)/8,l=s.pbkdf2Sync(t,n,o,h),d=a.createDecipheriv(u,l,c),p=[];return p.push(d.update(f)),p.push(d.final()),r.concat(p)}(l=n.EncryptedPrivateKey.decode(l,"der"),t);case"PRIVATE KEY":switch(u=(c=n.PrivateKey.decode(l,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPrivateKey.decode(c.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:c.algorithm.curve,privateKey:n.ECPrivateKey.decode(c.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return c.algorithm.params.priv_key=n.DSAparam.decode(c.subjectPrivateKey,"der"),{type:"dsa",params:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"RSA PUBLIC KEY":return n.RSAPublicKey.decode(l,"der");case"RSA PRIVATE KEY":return n.RSAPrivateKey.decode(l,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:n.DSAPrivateKey.decode(l,"der")};case"EC PRIVATE KEY":return{curve:(l=n.ECPrivateKey.decode(l,"der")).parameters.value,privateKey:l.privateKey};default:throw new Error("unknown key type "+h)}}t.exports=u,u.signature=n.signature}).call(this,e("buffer").Buffer)},{"./aesid.json":241,"./asn1":242,"./fixProc":244,"browserify-aes":58,buffer:84,pbkdf2:247}],246:[function(e,t,r){var n=e("trim"),i=e("for-each");t.exports=function(e){if(!e)return{};var t={};return i(n(e).split("\n"),function(e){var r,i=e.indexOf(":"),o=n(e.slice(0,i)).toLowerCase(),a=n(e.slice(i+1));void 0===t[o]?t[o]=a:(r=t[o],"[object Array]"===Object.prototype.toString.call(r)?t[o].push(a):t[o]=[t[o],a])}),t}},{"for-each":159,trim:324}],247:[function(e,t,r){r.pbkdf2=e("./lib/async"),r.pbkdf2Sync=e("./lib/sync")},{"./lib/async":248,"./lib/sync":251}],248:[function(e,t,r){(function(r,n){var i,o=e("./precondition"),a=e("./default-encoding"),s=e("./sync"),u=e("safe-buffer").Buffer,c=n.crypto&&n.crypto.subtle,f={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},h=[];function l(e,t,r,n,i){return c.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then(function(e){return c.deriveBits({name:"PBKDF2",salt:t,iterations:r,hash:{name:i}},e,n<<3)}).then(function(e){return u.from(e)})}t.exports=function(e,t,d,p,b,y){if(u.isBuffer(e)||(e=u.from(e,a)),u.isBuffer(t)||(t=u.from(t,a)),o(d,p),"function"==typeof b&&(y=b,b=void 0),"function"!=typeof y)throw new Error("No callback provided to pbkdf2");var m=f[(b=b||"sha1").toLowerCase()];if(!m||"function"!=typeof n.Promise)return r.nextTick(function(){var r;try{r=s(e,t,d,p,b)}catch(e){return y(e)}y(null,r)});!function(e,t){e.then(function(e){r.nextTick(function(){t(null,e)})},function(e){r.nextTick(function(){t(e)})})}(function(e){if(n.process&&!n.process.browser)return Promise.resolve(!1);if(!c||!c.importKey||!c.deriveBits)return Promise.resolve(!1);if(void 0!==h[e])return h[e];var t=l(i=i||u.alloc(8),i,10,128,e).then(function(){return!0}).catch(function(){return!1});return h[e]=t,t}(m).then(function(r){return r?l(e,t,d,p,m):s(e,t,d,p,b)}),y)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-encoding":249,"./precondition":250,"./sync":251,_process:257,"safe-buffer":290}],249:[function(e,t,r){(function(e){var r;e.browser?r="utf-8":r=parseInt(e.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary";t.exports=r}).call(this,e("_process"))},{_process:257}],250:[function(e,t,r){var n=Math.pow(2,30)-1;t.exports=function(e,t){if("number"!=typeof e)throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if("number"!=typeof t)throw new TypeError("Key length not a number");if(t<0||t>n||t!=t)throw new TypeError("Bad key length")}},{}],251:[function(e,t,r){var n=e("create-hash/md5"),i=e("ripemd160"),o=e("sha.js"),a=e("./precondition"),s=e("./default-encoding"),u=e("safe-buffer").Buffer,c=u.alloc(128),f={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function h(e,t,r){var a=function(e){return"rmd160"===e||"ripemd160"===e?i:"md5"===e?n:function(t){return o(e).update(t).digest()}}(e),s="sha512"===e||"sha384"===e?128:64;t.length>s?t=a(t):t.length1)for(var r=1;rp||new a(t).cmp(d.modulus)>=0)throw new Error("decryption error");l=f?c(new a(t),d):s(t,d);var b=new r(p-l.length);if(b.fill(0),l=r.concat([b,l],p),4===h)return function(e,t){e.modulus;var n=e.modulus.byteLength(),a=(t.length,u("sha1").update(new r("")).digest()),s=a.length;if(0!==t[0])throw new Error("decryption error");var c=t.slice(1,s+1),f=t.slice(s+1),h=o(c,i(f,s)),l=o(f,i(h,n-s-1));if(function(e,t){e=new r(e),t=new r(t);var n=0,i=e.length;e.length!==t.length&&(n++,i=Math.min(e.length,t.length));var o=-1;for(;++o=t.length){o++;break}var a=t.slice(2,i-1);t.slice(i-1,i);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;a.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,l,f);if(3===h)return l;throw new Error("unknown padding")}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245}],262:[function(e,t,r){(function(r){var n=e("parse-asn1"),i=e("randombytes"),o=e("create-hash"),a=e("./mgf"),s=e("./xor"),u=e("bn.js"),c=e("./withPublic"),f=e("browserify-rsa");t.exports=function(e,t,h){var l;l=e.padding?e.padding:h?1:4;var d,p=n(e);if(4===l)d=function(e,t){var n=e.modulus.byteLength(),c=t.length,f=o("sha1").update(new r("")).digest(),h=f.length,l=2*h;if(c>n-l-2)throw new Error("message too long");var d=new r(n-c-l-2);d.fill(0);var p=n-h-1,b=i(h),y=s(r.concat([f,d,new r([1]),t],p),a(b,p)),m=s(b,a(y,h));return new u(r.concat([new r([0]),m,y],n))}(p,t);else if(1===l)d=function(e,t,n){var o,a=t.length,s=e.modulus.byteLength();if(a>s-11)throw new Error("message too long");n?(o=new r(s-a-3)).fill(255):o=function(e,t){var n,o=new r(e),a=0,s=i(2*e),u=0;for(;a=0)throw new Error("data too long for modulus")}return h?f(d,p):c(d,p)}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245,randombytes:270}],263:[function(e,t,r){(function(r){var n=e("bn.js");t.exports=function(e,t){return new r(e.toRed(n.mont(t.modulus)).redPow(new n(t.publicExponent)).fromRed().toArray())}}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84}],264:[function(e,t,r){t.exports=function(e,t){for(var r=e.length,n=-1;++n= 0x80 (not a basic code point)","invalid-input":"Invalid input"},A=f-h,E=Math.floor,x=String.fromCharCode;function k(e){throw new RangeError(_[e])}function S(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function M(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+S((e=e.replace(w,".")).split("."),t).join(".")}function I(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=x((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=x(e)}).join("")}function U(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function j(e,t,r){var n=0;for(e=r?E(e/p):e>>1,e+=E(e/t);e>A*l>>1;n+=f)e=E(e/A);return E(n+(A+1)*e/(e+d))}function B(e){var t,r,n,i,o,a,s,u,d,p,v,g=[],w=e.length,_=0,A=y,x=b;for((r=e.lastIndexOf(m))<0&&(r=0),n=0;n=128&&k("not-basic"),g.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=w&&k("invalid-input"),((u=(v=e.charCodeAt(i++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:f)>=f||u>E((c-_)/a))&&k("overflow"),_+=u*a,!(u<(d=s<=x?h:s>=x+l?l:s-x));s+=f)a>E(c/(p=f-d))&&k("overflow"),a*=p;x=j(_-o,t=g.length+1,0==o),E(_/t)>c-A&&k("overflow"),A+=E(_/t),_%=t,g.splice(_++,0,A)}return T(g)}function P(e){var t,r,n,i,o,a,s,u,d,p,v,g,w,_,A,S=[];for(g=(e=I(e)).length,t=y,r=0,o=b,a=0;a=t&&vE((c-r)/(w=n+1))&&k("overflow"),r+=(s-t)*w,t=s,a=0;ac&&k("overflow"),v==t){for(u=r,d=f;!(u<(p=d<=o?h:d>=o+l?l:d-o));d+=f)A=u-p,_=f-p,S.push(x(U(p+A%_,0))),u=E(A/_);S.push(x(U(u,0))),o=j(r,w,n==i),r=0,++n}++r,++t}return S.join("")}if(s={version:"1.4.1",ucs2:{decode:I,encode:T},decode:B,encode:P,toASCII:function(e){return M(e,function(e){return g.test(e)?"xn--"+P(e):e})},toUnicode:function(e){return M(e,function(e){return v.test(e)?B(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return s});else if(i&&o)if(t.exports==i)o.exports=s;else for(u in s)s.hasOwnProperty(u)&&(i[u]=s[u]);else n.punycode=s}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],266:[function(e,t,r){"use strict";var n=e("strict-uri-encode"),i=e("object-assign"),o=e("decode-uri-component");function a(e,t){return t.encode?t.strict?n(e):encodeURIComponent(e):e}function s(e){var t=e.indexOf("?");return-1===t?"":e.slice(t+1)}function u(e,t){var r=function(e){var t;switch(e.arrayFormat){case"index":return function(e,r,n){t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return function(e,r,n){t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};default:return function(e,t,r){void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t=i({arrayFormat:"none"},t)),n=Object.create(null);return"string"!=typeof e?n:(e=e.trim().replace(/^[?#&]/,""))?(e.split("&").forEach(function(e){var t=e.replace(/\+/g," ").split("="),i=t.shift(),a=t.length>0?t.join("="):void 0;a=void 0===a?null:o(a),r(o(i),a,n)}),Object.keys(n).sort().reduce(function(e,t){var r=n[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=function e(t){return Array.isArray(t)?t.sort():"object"==typeof t?e(Object.keys(t)).sort(function(e,t){return Number(e)-Number(t)}).map(function(e){return t[e]}):t}(r):e[t]=r,e},Object.create(null))):n}r.extract=s,r.parse=u,r.stringify=function(e,t){!1===(t=i({encode:!0,strict:!0,arrayFormat:"none"},t)).sort&&(t.sort=function(){});var r=function(e){switch(e.arrayFormat){case"index":return function(t,r,n){return null===r?[a(t,e),"[",n,"]"].join(""):[a(t,e),"[",a(n,e),"]=",a(r,e)].join("")};case"bracket":return function(t,r){return null===r?a(t,e):[a(t,e),"[]=",a(r,e)].join("")};default:return function(t,r){return null===r?a(t,e):[a(t,e),"=",a(r,e)].join("")}}}(t);return e?Object.keys(e).sort(t.sort).map(function(n){var i=e[n];if(void 0===i)return"";if(null===i)return a(n,t);if(Array.isArray(i)){var o=[];return i.slice().forEach(function(e){void 0!==e&&o.push(r(n,e,o.length))}),o.join("&")}return a(n,t)+"="+a(i,t)}).filter(function(e){return e.length>0}).join("&"):""},r.parseUrl=function(e,t){return{url:e.split("?")[0]||"",query:u(s(e),t)}}},{"decode-uri-component":98,"object-assign":238,"strict-uri-encode":316}],267:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&",r=r||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(a,d)?i(a[d])?a[d].push(p):a[d]=[a[d],p]:a[d]=p}return a};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],268:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,s){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),function(a){var s=encodeURIComponent(n(a))+r;return i(e[a])?o(e[a],function(e){return s+encodeURIComponent(n(e))}).join(t):s+encodeURIComponent(n(e[a]))}).join(t):s?encodeURIComponent(n(s))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n65536)throw new Error("requested too many random bytes");var a=new n.Uint8Array(e);e>0&&o.getRandomValues(a);var s=i.from(a.buffer);if("function"==typeof t)return r.nextTick(function(){t(null,s)});return s}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,"safe-buffer":290}],271:[function(e,t,r){(function(t,n){"use strict";function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=e("safe-buffer"),a=e("randombytes"),s=o.Buffer,u=o.kMaxLength,c=n.crypto||n.msCrypto,f=Math.pow(2,32)-1;function h(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>f||e<0)throw new TypeError("offset must be a uint32");if(e>u||e>t)throw new RangeError("offset out of range")}function l(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>f||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>u)throw new RangeError("buffer too small")}function d(e,r,n,i){if(t.browser){var o=e.buffer,s=new Uint8Array(o,r,n);return c.getRandomValues(s),i?void t.nextTick(function(){i(null,e)}):e}if(!i)return a(n).copy(e,r),e;a(n,function(t,n){if(t)return i(t);n.copy(e,r),i(null,e)})}c&&c.getRandomValues||!t.browser?(r.randomFill=function(e,t,r,i){if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)i=t,t=0,r=e.length;else if("function"==typeof r)i=r,r=e.length-t;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return h(t,e.length),l(r,t,e.length),d(e,t,r,i)},r.randomFillSync=function(e,t,r){void 0===t&&(t=0);if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');h(t,e.length),void 0===r&&(r=e.length-t);return l(r,t,e.length),d(e,t,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,randombytes:270,"safe-buffer":290}],272:[function(e,t,r){t.exports=window.crypto},{}],273:[function(e,t,r){t.exports=e("crypto")},{crypto:272}],274:[function(e,t,r){t.exports=function(t,r){var n=e("./crypto.js"),i="function"==typeof r;if(t>65536){if(!i)throw new Error("Requested too many random bytes.");r(new Error("Requested too many random bytes."))}if(void 0!==n&&n.randomBytes){if(!i)return"0x"+n.randomBytes(t).toString("hex");n.randomBytes(t,function(e,t){e?r(u):r(null,"0x"+t.toString("hex"))})}else{var o;if(void 0!==n?o=n:"undefined"!=typeof msCrypto&&(o=msCrypto),o&&o.getRandomValues){var a=o.getRandomValues(new Uint8Array(t)),s="0x"+Array.from(a).map(function(e){return e.toString(16)}).join("");if(!i)return s;r(null,s)}else{var u=new Error('No "crypto" object available. This Browser doesn\'t support generating secure random bytes.');if(!i)throw u;r(u)}}}},{"./crypto.js":273}],275:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":276}],276:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick,i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=h;var o=e("core-util-is");o.inherits=e("inherits");var a=e("./_stream_readable"),s=e("./_stream_writable");o.inherits(h,a);for(var u=i(s.prototype),c=0;c0?("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),n?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):_(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?_(e,a,t,!1):S(e,a)):_(e,a,t,!1))):n||(a.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=A?e=A:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(d("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i(k,e):k(e))}function k(e){d("emit readable"),e.emit("readable"),U(e)}function S(e,t){t.readingMore||(t.readingMore=!0,i(M,e,t))}function M(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=c.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,a),0===(e-=a)){a===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function B(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i(P,t,e))}function P(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function C(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return d("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?B(this):x(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&B(this),null;var n,i=t.needReadable;return d("need readable",i),(0===t.length||t.length-e0?j(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&B(this)),null!==n&&this.emit("data",n),n},g.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},g.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,d("pipe count=%d opts=%j",o.pipesCount,t);var u=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?f:g;function c(t,r){d("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,d("cleanup"),e.removeListener("close",m),e.removeListener("finish",v),e.removeListener("drain",h),e.removeListener("error",y),e.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",g),n.removeListener("data",b),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||h())}function f(){d("onend"),e.end()}o.endEmitted?i(u):n.once("end",u),e.on("unpipe",c);var h=function(e){return function(){var t=e._readableState;d("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,U(e))}}(n);e.on("drain",h);var l=!1;var p=!1;function b(t){d("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==C(o.pipes,e))&&!l&&(d("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(t){d("onerror",t),g(),e.removeListener("error",y),0===s(e,"error")&&e.emit("error",t)}function m(){e.removeListener("finish",v),g()}function v(){d("onfinish"),e.removeListener("close",m),g()}function g(){d("unpipe"),n.unpipe(e)}return n.on("data",b),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?a(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",y),e.once("close",m),e.once("finish",v),e.emit("pipe",n),o.flowing||(d("pipe resume"),n.resume()),e},g.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:i;m.WritableState=y;var u=e("core-util-is");u.inherits=e("inherits");var c={deprecate:e("util-deprecate")},f=e("./internal/streams/stream"),h=e("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=e("./internal/streams/destroy");function b(){}function y(t,r){a=a||e("./_stream_duplex"),t=t||{};var n=r instanceof a;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var u=t.highWaterMark,c=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=u||0===u?u:n&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===t.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,o=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,o){--t.pendingcb,r?(i(o,n),i(E,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(o(n),e._writableState.errorEmitted=!0,e.emit("error",n),E(e,t))}(e,r,n,t,o);else{var a=_(r);a||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),n?s(g,e,r,a,o):g(e,r,a,o)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function m(t){if(a=a||e("./_stream_duplex"),!(d.call(m,this)||this instanceof a))return new m(t);this._writableState=new y(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),f.call(this)}function v(e,t,r,n,i,o,a){t.writelen=n,t.writecb=a,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function g(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),E(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),a=t.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,v(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,h=r.callback;if(v(e,t,!1,t.objectMode?1:c.length,c,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function A(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),E(e,t)})}function E(e,t){var r=_(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,i(A,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}u.inherits(m,f),y.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(y.prototype,"buffer",{get:c.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===m&&(e&&e._writableState instanceof y)}})):d=function(e){return e instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(e,t,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=e,h.isBuffer(n)||n instanceof l);return s&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof r&&(r=b),o.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),i(t,r)}(this,r):(s||function(e,t,r,n){var o=!0,a=!1;return null===r?a=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),i(n,a),o=!1),o}(this,o,e,r))&&(o.pendingcb++,a=function(e,t,r,n,i,o){if(!r){var a=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,r));return t}(t,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=t.objectMode?1:n.length;t.length+=s;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},m.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,E(e,t),r&&(t.finished?i(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),m.prototype.destroy=p.destroy,m.prototype._undestroy=p.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":276,"./internal/streams/destroy":282,"./internal/streams/stream":283,_process:257,"core-util-is":89,inherits:180,"process-nextick-args":256,"safe-buffer":290,"util-deprecate":330}],281:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,i,o=n.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,r=o,i=s,t.copy(r,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":290,util:55}],282:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick;function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var r=this,o=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return o||a?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||n(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n(i,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":256}],283:[function(e,t,r){t.exports=e("events").EventEmitter},{events:157}],284:[function(e,t,r){t.exports=e("./readable").PassThrough},{"./readable":285}],285:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":276,"./lib/_stream_passthrough.js":277,"./lib/_stream_readable.js":278,"./lib/_stream_transform.js":279,"./lib/_stream_writable.js":280}],286:[function(e,t,r){t.exports=e("./readable").Transform},{"./readable":285}],287:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":280}],288:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base");function o(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function a(e,t){return e<>>32-t}function s(e,t,r,n,i,o,s,u){return a(e+(t^r^n)+o+s|0,u)+i|0}function u(e,t,r,n,i,o,s,u){return a(e+(t&r|~t&n)+o+s|0,u)+i|0}function c(e,t,r,n,i,o,s,u){return a(e+((t|~r)^n)+o+s|0,u)+i|0}function f(e,t,r,n,i,o,s,u){return a(e+(t&n|r&~n)+o+s|0,u)+i|0}function h(e,t,r,n,i,o,s,u){return a(e+(t^(r|~n))+o+s|0,u)+i|0}n(o,i),o.prototype._update=function(){for(var e=new Array(16),t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,o=this._d,l=this._e;l=s(l,r=s(r,n,i,o,l,e[0],0,11),n,i=a(i,10),o,e[1],0,14),n=s(n=a(n,10),i=s(i,o=s(o,l,r,n,i,e[2],0,15),l,r=a(r,10),n,e[3],0,12),o,l=a(l,10),r,e[4],0,5),o=s(o=a(o,10),l=s(l,r=s(r,n,i,o,l,e[5],0,8),n,i=a(i,10),o,e[6],0,7),r,n=a(n,10),i,e[7],0,9),r=s(r=a(r,10),n=s(n,i=s(i,o,l,r,n,e[8],0,11),o,l=a(l,10),r,e[9],0,13),i,o=a(o,10),l,e[10],0,14),i=s(i=a(i,10),o=s(o,l=s(l,r,n,i,o,e[11],0,15),r,n=a(n,10),i,e[12],0,6),l,r=a(r,10),n,e[13],0,7),l=u(l=a(l,10),r=s(r,n=s(n,i,o,l,r,e[14],0,9),i,o=a(o,10),l,e[15],0,8),n,i=a(i,10),o,e[7],1518500249,7),n=u(n=a(n,10),i=u(i,o=u(o,l,r,n,i,e[4],1518500249,6),l,r=a(r,10),n,e[13],1518500249,8),o,l=a(l,10),r,e[1],1518500249,13),o=u(o=a(o,10),l=u(l,r=u(r,n,i,o,l,e[10],1518500249,11),n,i=a(i,10),o,e[6],1518500249,9),r,n=a(n,10),i,e[15],1518500249,7),r=u(r=a(r,10),n=u(n,i=u(i,o,l,r,n,e[3],1518500249,15),o,l=a(l,10),r,e[12],1518500249,7),i,o=a(o,10),l,e[0],1518500249,12),i=u(i=a(i,10),o=u(o,l=u(l,r,n,i,o,e[9],1518500249,15),r,n=a(n,10),i,e[5],1518500249,9),l,r=a(r,10),n,e[2],1518500249,11),l=u(l=a(l,10),r=u(r,n=u(n,i,o,l,r,e[14],1518500249,7),i,o=a(o,10),l,e[11],1518500249,13),n,i=a(i,10),o,e[8],1518500249,12),n=c(n=a(n,10),i=c(i,o=c(o,l,r,n,i,e[3],1859775393,11),l,r=a(r,10),n,e[10],1859775393,13),o,l=a(l,10),r,e[14],1859775393,6),o=c(o=a(o,10),l=c(l,r=c(r,n,i,o,l,e[4],1859775393,7),n,i=a(i,10),o,e[9],1859775393,14),r,n=a(n,10),i,e[15],1859775393,9),r=c(r=a(r,10),n=c(n,i=c(i,o,l,r,n,e[8],1859775393,13),o,l=a(l,10),r,e[1],1859775393,15),i,o=a(o,10),l,e[2],1859775393,14),i=c(i=a(i,10),o=c(o,l=c(l,r,n,i,o,e[7],1859775393,8),r,n=a(n,10),i,e[0],1859775393,13),l,r=a(r,10),n,e[6],1859775393,6),l=c(l=a(l,10),r=c(r,n=c(n,i,o,l,r,e[13],1859775393,5),i,o=a(o,10),l,e[11],1859775393,12),n,i=a(i,10),o,e[5],1859775393,7),n=f(n=a(n,10),i=f(i,o=c(o,l,r,n,i,e[12],1859775393,5),l,r=a(r,10),n,e[1],2400959708,11),o,l=a(l,10),r,e[9],2400959708,12),o=f(o=a(o,10),l=f(l,r=f(r,n,i,o,l,e[11],2400959708,14),n,i=a(i,10),o,e[10],2400959708,15),r,n=a(n,10),i,e[0],2400959708,14),r=f(r=a(r,10),n=f(n,i=f(i,o,l,r,n,e[8],2400959708,15),o,l=a(l,10),r,e[12],2400959708,9),i,o=a(o,10),l,e[4],2400959708,8),i=f(i=a(i,10),o=f(o,l=f(l,r,n,i,o,e[13],2400959708,9),r,n=a(n,10),i,e[3],2400959708,14),l,r=a(r,10),n,e[7],2400959708,5),l=f(l=a(l,10),r=f(r,n=f(n,i,o,l,r,e[15],2400959708,6),i,o=a(o,10),l,e[14],2400959708,8),n,i=a(i,10),o,e[5],2400959708,6),n=h(n=a(n,10),i=f(i,o=f(o,l,r,n,i,e[6],2400959708,5),l,r=a(r,10),n,e[2],2400959708,12),o,l=a(l,10),r,e[4],2840853838,9),o=h(o=a(o,10),l=h(l,r=h(r,n,i,o,l,e[0],2840853838,15),n,i=a(i,10),o,e[5],2840853838,5),r,n=a(n,10),i,e[9],2840853838,11),r=h(r=a(r,10),n=h(n,i=h(i,o,l,r,n,e[7],2840853838,6),o,l=a(l,10),r,e[12],2840853838,8),i,o=a(o,10),l,e[2],2840853838,13),i=h(i=a(i,10),o=h(o,l=h(l,r,n,i,o,e[10],2840853838,12),r,n=a(n,10),i,e[14],2840853838,5),l,r=a(r,10),n,e[1],2840853838,12),l=h(l=a(l,10),r=h(r,n=h(n,i,o,l,r,e[3],2840853838,13),i,o=a(o,10),l,e[8],2840853838,14),n,i=a(i,10),o,e[11],2840853838,11),n=h(n=a(n,10),i=h(i,o=h(o,l,r,n,i,e[6],2840853838,8),l,r=a(r,10),n,e[15],2840853838,5),o,l=a(l,10),r,e[13],2840853838,6),o=a(o,10);var d=this._a,p=this._b,b=this._c,y=this._d,m=this._e;m=h(m,d=h(d,p,b,y,m,e[5],1352829926,8),p,b=a(b,10),y,e[14],1352829926,9),p=h(p=a(p,10),b=h(b,y=h(y,m,d,p,b,e[7],1352829926,9),m,d=a(d,10),p,e[0],1352829926,11),y,m=a(m,10),d,e[9],1352829926,13),y=h(y=a(y,10),m=h(m,d=h(d,p,b,y,m,e[2],1352829926,15),p,b=a(b,10),y,e[11],1352829926,15),d,p=a(p,10),b,e[4],1352829926,5),d=h(d=a(d,10),p=h(p,b=h(b,y,m,d,p,e[13],1352829926,7),y,m=a(m,10),d,e[6],1352829926,7),b,y=a(y,10),m,e[15],1352829926,8),b=h(b=a(b,10),y=h(y,m=h(m,d,p,b,y,e[8],1352829926,11),d,p=a(p,10),b,e[1],1352829926,14),m,d=a(d,10),p,e[10],1352829926,14),m=f(m=a(m,10),d=h(d,p=h(p,b,y,m,d,e[3],1352829926,12),b,y=a(y,10),m,e[12],1352829926,6),p,b=a(b,10),y,e[6],1548603684,9),p=f(p=a(p,10),b=f(b,y=f(y,m,d,p,b,e[11],1548603684,13),m,d=a(d,10),p,e[3],1548603684,15),y,m=a(m,10),d,e[7],1548603684,7),y=f(y=a(y,10),m=f(m,d=f(d,p,b,y,m,e[0],1548603684,12),p,b=a(b,10),y,e[13],1548603684,8),d,p=a(p,10),b,e[5],1548603684,9),d=f(d=a(d,10),p=f(p,b=f(b,y,m,d,p,e[10],1548603684,11),y,m=a(m,10),d,e[14],1548603684,7),b,y=a(y,10),m,e[15],1548603684,7),b=f(b=a(b,10),y=f(y,m=f(m,d,p,b,y,e[8],1548603684,12),d,p=a(p,10),b,e[12],1548603684,7),m,d=a(d,10),p,e[4],1548603684,6),m=f(m=a(m,10),d=f(d,p=f(p,b,y,m,d,e[9],1548603684,15),b,y=a(y,10),m,e[1],1548603684,13),p,b=a(b,10),y,e[2],1548603684,11),p=c(p=a(p,10),b=c(b,y=c(y,m,d,p,b,e[15],1836072691,9),m,d=a(d,10),p,e[5],1836072691,7),y,m=a(m,10),d,e[1],1836072691,15),y=c(y=a(y,10),m=c(m,d=c(d,p,b,y,m,e[3],1836072691,11),p,b=a(b,10),y,e[7],1836072691,8),d,p=a(p,10),b,e[14],1836072691,6),d=c(d=a(d,10),p=c(p,b=c(b,y,m,d,p,e[6],1836072691,6),y,m=a(m,10),d,e[9],1836072691,14),b,y=a(y,10),m,e[11],1836072691,12),b=c(b=a(b,10),y=c(y,m=c(m,d,p,b,y,e[8],1836072691,13),d,p=a(p,10),b,e[12],1836072691,5),m,d=a(d,10),p,e[2],1836072691,14),m=c(m=a(m,10),d=c(d,p=c(p,b,y,m,d,e[10],1836072691,13),b,y=a(y,10),m,e[0],1836072691,13),p,b=a(b,10),y,e[4],1836072691,7),p=u(p=a(p,10),b=u(b,y=c(y,m,d,p,b,e[13],1836072691,5),m,d=a(d,10),p,e[8],2053994217,15),y,m=a(m,10),d,e[6],2053994217,5),y=u(y=a(y,10),m=u(m,d=u(d,p,b,y,m,e[4],2053994217,8),p,b=a(b,10),y,e[1],2053994217,11),d,p=a(p,10),b,e[3],2053994217,14),d=u(d=a(d,10),p=u(p,b=u(b,y,m,d,p,e[11],2053994217,14),y,m=a(m,10),d,e[15],2053994217,6),b,y=a(y,10),m,e[0],2053994217,14),b=u(b=a(b,10),y=u(y,m=u(m,d,p,b,y,e[5],2053994217,6),d,p=a(p,10),b,e[12],2053994217,9),m,d=a(d,10),p,e[2],2053994217,12),m=u(m=a(m,10),d=u(d,p=u(p,b,y,m,d,e[13],2053994217,9),b,y=a(y,10),m,e[9],2053994217,12),p,b=a(b,10),y,e[7],2053994217,5),p=s(p=a(p,10),b=u(b,y=u(y,m,d,p,b,e[10],2053994217,15),m,d=a(d,10),p,e[14],2053994217,8),y,m=a(m,10),d,e[12],0,8),y=s(y=a(y,10),m=s(m,d=s(d,p,b,y,m,e[15],0,5),p,b=a(b,10),y,e[10],0,12),d,p=a(p,10),b,e[4],0,9),d=s(d=a(d,10),p=s(p,b=s(b,y,m,d,p,e[1],0,12),y,m=a(m,10),d,e[5],0,5),b,y=a(y,10),m,e[8],0,14),b=s(b=a(b,10),y=s(y,m=s(m,d,p,b,y,e[7],0,6),d,p=a(p,10),b,e[6],0,8),m,d=a(d,10),p,e[2],0,13),m=s(m=a(m,10),d=s(d,p=s(p,b,y,m,d,e[13],0,6),b,y=a(y,10),m,e[14],0,5),p,b=a(b,10),y,e[0],0,15),p=s(p=a(p,10),b=s(b,y=s(y,m,d,p,b,e[3],0,13),m,d=a(d,10),p,e[9],0,11),y,m=a(m,10),d,e[11],0,11),y=a(y,10);var v=this._b+i+y|0;this._b=this._c+o+m|0,this._c=this._d+l+d|0,this._d=this._e+r+p|0,this._e=this._a+n+b|0,this._a=v},o.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=o}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":161,inherits:180}],289:[function(e,t,r){const n=e("assert"),i=e("safe-buffer").Buffer;function o(e,t){if("00"===e.slice(0,2))throw new Error("invalid RLP: extra zeros");return parseInt(e,t)}function a(e,t){if(e<56)return i.from([e+t]);var r=u(e),n=u(t+55+r.length/2);return i.from(n+r,"hex")}function s(e){return"0x"===e.slice(0,2)}function u(e){var t=e.toString(16);return t.length%2&&(t="0"+t),t}function c(e){if(!i.isBuffer(e))if("string"==typeof e)e=s(e)?i.from(((r="string"!=typeof(n=e)?n:s(n)?n.slice(2):n).length%2&&(r="0"+r),r),"hex"):i.from(e);else if("number"==typeof e)e?(t=u(e),e=i.from(t,"hex")):e=i.from([]);else if(null==e)e=i.from([]);else{if(!e.toArray)throw new Error("invalid type");e=i.from(e.toArray())}var t,r,n;return e}r.encode=function(e){if(e instanceof Array){for(var t=[],n=0;nt.length)throw new Error("invalid rlp: total length is larger than the data");if(0===(s=t.slice(n,h)).length)throw new Error("invalid rlp, List has a invalid length");for(;s.length;)u=e(s),c.push(u.data),s=u.remainder;return{data:c,remainder:t.slice(h)}}(e=c(e));return t?r:(n.equal(r.remainder.length,0,"invalid remainder"),r.data)},r.getLength=function(e){if(!e||0===e.length)return i.from([]);var t=(e=c(e))[0];if(t<=127)return e.length;if(t<=183)return t-127;if(t<=191)return t-182;if(t<=247)return t-191;var r=t-246;return r+o(e.slice(1,r).toString("hex"),16)}},{assert:19,"safe-buffer":290}],290:[function(e,t,r){var n=e("buffer"),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function a(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,r),r.Buffer=a),o(i,a),a.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:84}],291:[function(e,t,r){const n=e("util"),i=e("events/");var o="object"==typeof Reflect?Reflect:null,a=o&&"function"==typeof o.apply?o.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};function s(){i.call(this)}function u(e,t,r){try{a(e,t,r)}catch(e){setTimeout(()=>{throw e})}}t.exports=s,n.inherits(s,i),s.prototype.emit=function(e){for(var t=[],r=1;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var s=i[e];if(void 0===s)return!1;if("function"==typeof s)u(s,this,t);else{var c=s.length,f=function(e,t){for(var r=new Array(t),n=0;n0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=function(){for(var e=[],t=0;t0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var c=u.length,f=p(u,c);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return l(this,e,!0)},s.prototype.rawListeners=function(e){return l(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},{}],293:[function(e,t,r){t.exports=e("scryptsy")},{scryptsy:294}],294:[function(e,t,r){(function(r){var n=e("pbkdf2").pbkdf2Sync,i=2147483647;function o(e,t,n,i,o){if(r.isBuffer(e)&&r.isBuffer(n))e.copy(n,i,t,t+o);else for(;o--;)n[i++]=e[t++]}t.exports=function(e,t,a,s,u,c,f){if(0===a||0!=(a&a-1))throw Error("N must be > 0 and a power of 2");if(a>i/128/s)throw Error("Parameter N is too large");if(s>i/128/u)throw Error("Parameter r is too large");var h,l=new r(256*s),d=new r(128*s*a),p=new Int32Array(16),b=new Int32Array(16),y=new r(64),m=n(e,t,1,128*u*s,"sha256");if(f){var v=u*a*2,g=0;h=function(){++g%1e3==0&&f({current:g,total:v,percent:g/v*100})}}for(var w=0;w>>32-t}function x(e){var t;for(t=0;t<16;t++)p[t]=(255&e[4*t+0])<<0,p[t]|=(255&e[4*t+1])<<8,p[t]|=(255&e[4*t+2])<<16,p[t]|=(255&e[4*t+3])<<24;for(o(p,0,b,0,16),t=8;t>0;t-=2)b[4]^=E(b[0]+b[12],7),b[8]^=E(b[4]+b[0],9),b[12]^=E(b[8]+b[4],13),b[0]^=E(b[12]+b[8],18),b[9]^=E(b[5]+b[1],7),b[13]^=E(b[9]+b[5],9),b[1]^=E(b[13]+b[9],13),b[5]^=E(b[1]+b[13],18),b[14]^=E(b[10]+b[6],7),b[2]^=E(b[14]+b[10],9),b[6]^=E(b[2]+b[14],13),b[10]^=E(b[6]+b[2],18),b[3]^=E(b[15]+b[11],7),b[7]^=E(b[3]+b[15],9),b[11]^=E(b[7]+b[3],13),b[15]^=E(b[11]+b[7],18),b[1]^=E(b[0]+b[3],7),b[2]^=E(b[1]+b[0],9),b[3]^=E(b[2]+b[1],13),b[0]^=E(b[3]+b[2],18),b[6]^=E(b[5]+b[4],7),b[7]^=E(b[6]+b[5],9),b[4]^=E(b[7]+b[6],13),b[5]^=E(b[4]+b[7],18),b[11]^=E(b[10]+b[9],7),b[8]^=E(b[11]+b[10],9),b[9]^=E(b[8]+b[11],13),b[10]^=E(b[9]+b[8],18),b[12]^=E(b[15]+b[14],7),b[13]^=E(b[12]+b[15],9),b[14]^=E(b[13]+b[12],13),b[15]^=E(b[14]+b[13],18);for(t=0;t<16;++t)p[t]=b[t]+p[t];for(t=0;t<16;t++){var r=4*t;e[r+0]=p[t]>>0&255,e[r+1]=p[t]>>8&255,e[r+2]=p[t]>>16&255,e[r+3]=p[t]>>24&255}}function k(e,t,r,n,i){for(var o=0;o=r)throw RangeError(n)}}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":181}],297:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("bip66"),o=n.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),a=n.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(e,t,r){var i=n.from(r?o:a);return e.copy(i,r?8:9),t.copy(i,r?181:214),i},r.privateKeyImport=function(e){var t=e.length,r=0;if(!(t2||t1?e[r+n-2]<<8:0);if(!(t<(r+=n)+i||t32||t1&&0===t[o]&&!(128&t[o+1]);--r,++o);for(var a=n.concat([n.from([0]),e.s]),s=33,u=0;s>1&&0===a[u]&&!(128&a[u+1]);--s,++u);return i.encode(t.slice(o),a.slice(u))},r.signatureImport=function(e){var t=n.alloc(32,0),r=n.alloc(32,0);try{var o=i.decode(e);if(33===o.r.length&&0===o.r[0]&&(o.r=o.r.slice(1)),o.r.length>32)throw new Error("R length is too long");if(33===o.s.length&&0===o.s[0]&&(o.s=o.s.slice(1)),o.s.length>32)throw new Error("S length is too long")}catch(e){return}return o.r.copy(t,32-o.r.length),o.s.copy(r,32-o.s.length),{r:t,s:r}},r.signatureImportLax=function(e){var t=n.alloc(32,0),r=n.alloc(32,0),i=e.length,o=0;if(48===e[o++]){var a=e[o++];if(!(128&a&&(o+=a-128)>i)&&2===e[o++]){var s=e[o++];if(128&s){if(o+(a=s-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(s=0;a>0;o+=1,a-=1)s=(s<<8)+e[o]}if(!(s>i-o)){var u=o;if(o+=s,2===e[o++]){var c=e[o++];if(128&c){if(o+(a=c-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(c=0;a>0;o+=1,a-=1)c=(c<<8)+e[o]}if(!(c>i-o)){var f=o;for(o+=c;s>0&&0===e[u];s-=1,u+=1);if(!(s>32)){var h=e.slice(u,u+s);for(h.copy(t,32-h.length);c>0&&0===e[f];c-=1,f+=1);if(!(c>32)){var l=e.slice(f,f+c);return l.copy(r,32-l.length),{r:t,s:r}}}}}}}}}},{bip66:52,"safe-buffer":290}],298:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("create-hash"),o=e("bn.js"),a=e("elliptic").ec,s=e("../messages.json"),u=new a("secp256k1"),c=u.curve;function f(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new o(t);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),u.keyPair({pub:{x:r,y:n}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new o(t),i=new o(r);if(n.cmp(c.p)>=0||i.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),i=i.toRed(c.red),(6===e||7===e)&&i.isOdd()!==(7===e))return null;var a=n.redSqr().redIMul(n);return i.redSqr().redISub(a.redIAdd(c.b)).isZero()?u.keyPair({pub:{x:n,y:i}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}r.privateKeyVerify=function(e){var t=new o(e);return t.cmp(c.n)<0&&!t.isZero()},r.privateKeyExport=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.privateKeyNegate=function(e){var t=new o(e);return t.isZero()?n.alloc(32):c.n.sub(t).umod(c.n).toArrayLike(n,"be",32)},r.privateKeyModInverse=function(e){var t=new o(e);if(t.cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(c.n).toArrayLike(n,"be",32)},r.privateKeyTweakAdd=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new o(e)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(n,"be",32)},r.privateKeyTweakMul=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new o(e)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(n,"be",32)},r.publicKeyCreate=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.publicKeyConvert=function(e,t){var r=f(e);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return n.from(r.getPublic(t,!0))},r.publicKeyVerify=function(e){return null!==f(e)},r.publicKeyTweakAdd=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return n.from(c.g.mul(t).add(i.pub).encode(!0,r))},r.publicKeyTweakMul=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return n.from(i.pub.mul(t).encode(!0,r))},r.publicKeyCombine=function(e,t){for(var r=new Array(e.length),i=0;i=0||r.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var i=n.from(e);return 1===r.cmp(u.nh)&&c.n.sub(r).toArrayLike(n,"be",32).copy(i,32),i},r.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new o(t).cmp(c.n)>=0||new o(r).cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},r.signatureImport=function(e){var t=new o(e.r);t.cmp(c.n)>=0&&(t=new o(0));var r=new o(e.s);return r.cmp(c.n)>=0&&(r=new o(0)),n.concat([t.toArrayLike(n,"be",32),r.toArrayLike(n,"be",32)])},r.sign=function(e,t,r,i){if("function"==typeof r){var a=r;r=function(r){var u=a(e,t,null,i,r);if(!n.isBuffer(u)||32!==u.length)throw new Error(s.ECDSA_SIGN_FAIL);return new o(u)}}var f=new o(t);if(f.cmp(c.n)>=0||f.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var h=u.sign(e,t,{canonical:!0,k:r,pers:i});return{signature:n.concat([h.r.toArrayLike(n,"be",32),h.s.toArrayLike(n,"be",32)]),recovery:h.recoveryParam}},r.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},i=new o(n.r),a=new o(n.s);if(i.cmp(c.n)>=0||a.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===a.cmp(u.nh)||i.isZero()||a.isZero())return!1;var h=f(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return u.verify(e,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(e,t,r,i){var a={r:t.slice(0,32),s:t.slice(32,64)},f=new o(a.r),h=new o(a.s);if(f.cmp(c.n)>=0||h.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(f.isZero()||h.isZero())throw new Error;var l=u.recoverPubKey(e,a,r);return n.from(l.encode(!0,i))}catch(e){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(e,t){var n=r.ecdhUnsafe(e,t,!0);return i("sha256").update(n).digest()},r.ecdhUnsafe=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var a=new o(t);if(a.cmp(c.n)>=0||a.isZero())throw new Error(s.ECDH_FAIL);return n.from(i.pub.mul(a).encode(!0,r))}},{"../messages.json":300,"bn.js":53,"create-hash":91,elliptic:109,"safe-buffer":290}],299:[function(e,t,r){"use strict";var n=e("./assert"),i=e("./der"),o=e("./messages.json");function a(e,t){return void 0===e?t:(n.isBoolean(e,o.COMPRESSED_TYPE_INVALID),e)}t.exports=function(e){return{privateKeyVerify:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0);var s=e.privateKeyExport(t,r);return i.privateKeyExport(t,s,r)},privateKeyImport:function(t){if(n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),(t=i.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakAdd(t,r,i)},publicKeyTweakMul:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakMul(t,r,i)},publicKeyCombine:function(t,r){n.isArray(t,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(t,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=2&&("function"==typeof arguments[1]?r.task=arguments[1]:r.n=arguments[1]);var n=r.task;if(r.task=function(){n(t.leave)},t.current+r.n-e>t.capacity)return 1===e&&(t.current--,t.firstHere=!1),t.queue.push(r);t.current+=r.n-e,r.task(t.leave),1===e&&(t.firstHere=!1)},leave:function(e){if(e=e||1,t.current-=e,t.queue.length){var r=t.queue[0];r.n+t.current>t.capacity||(t.queue.shift(),t.current+=r.n,i(r.task))}else if(t.current<0)throw new Error("leave called too many times.")},available:function(e){return e=e||1,t.current+e<=t.capacity}};return t}void 0!==e&&e&&"function"==typeof e.nextTick&&(i=e.nextTick),"object"==typeof r?t.exports=o:"function"==typeof define&&define.amd?define(function(){return o}):n.semaphore=o}(this)}).call(this,e("_process"))},{_process:257}],302:[function(e,t,r){"use strict";t.exports="function"==typeof setImmediate?setImmediate:function(){var e=[].slice.apply(arguments);e.splice(1,0,0),setTimeout.apply(null,e)}},{}],303:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t){this._block=n.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}i.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=n.from(e,t));for(var r=this._block,i=this._blockSize,o=e.length,a=this._len,s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},{"safe-buffer":290}],304:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":305,"./sha1":306,"./sha224":307,"./sha256":308,"./sha384":309,"./sha512":310}],305:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((t=n)<<5|t>>>27)+f(d,i,o,s)+u+r[l]+a[d];u=s,s=o,o=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],306:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function h(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=(t=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=c(n)+h(p,i,o,s)+u+r[d]+a[p]|0;u=s,s=o,o=f(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],307:[function(e,t,r){var n=e("inherits"),i=e("./sha256"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}n(u,i),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=u},{"./hash":303,"./sha256":308,inherits:180,"safe-buffer":290}],308:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function l(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(u,i),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,m=0;m<16;++m)r[m]=e.readInt32BE(4*m);for(;m<64;++m)r[m]=0|(((t=r[m-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[m-7]+d(r[m-15])+r[m-16];for(var v=0;v<64;++v){var g=y+l(u)+c(u,p,b)+a[v]+r[v]|0,w=h(n)+f(n,i,o)|0;y=b,b=p,p=u,u=s+g|0,s=o,o=i,i=n,n=g+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},u.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],309:[function(e,t,r){var n=e("inherits"),i=e("./sha512"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}n(u,i),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=u},{"./hash":303,"./sha512":310,inherits:180,"safe-buffer":290}],310:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function l(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function y(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function m(e,t){return e>>>0>>0?1:0}n(u,i),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,s=0|this._eh,u=0|this._fh,v=0|this._gh,g=0|this._hh,w=0|this._al,_=0|this._bl,A=0|this._cl,E=0|this._dl,x=0|this._el,k=0|this._fl,S=0|this._gl,M=0|this._hl,I=0;I<32;I+=2)t[I]=e.readInt32BE(4*I),t[I+1]=e.readInt32BE(4*I+4);for(;I<160;I+=2){var T=t[I-30],U=t[I-30+1],j=d(T,U),B=p(U,T),P=b(T=t[I-4],U=t[I-4+1]),C=y(U,T),N=t[I-14],R=t[I-14+1],L=t[I-32],O=t[I-32+1],D=B+R|0,F=j+N+m(D,B)|0;F=(F=F+P+m(D=D+C|0,C)|0)+L+m(D=D+O|0,O)|0,t[I]=F,t[I+1]=D}for(var q=0;q<160;q+=2){F=t[q],D=t[q+1];var H=f(r,n,i),z=f(w,_,A),K=h(r,w),V=h(w,r),G=l(s,x),W=l(x,s),Y=a[q],X=a[q+1],Z=c(s,u,v),J=c(x,k,S),$=M+W|0,Q=g+G+m($,M)|0;Q=(Q=(Q=Q+Z+m($=$+J|0,J)|0)+Y+m($=$+X|0,X)|0)+F+m($=$+D|0,D)|0;var ee=V+z|0,te=K+H+m(ee,V)|0;g=v,M=S,v=u,S=k,u=s,k=x,s=o+Q+m(x=E+$|0,E)|0,o=i,E=A,i=n,A=_,n=r,_=w,r=Q+te+m(w=$+ee|0,$)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+A|0,this._dl=this._dl+E|0,this._el=this._el+x|0,this._fl=this._fl+k|0,this._gl=this._gl+S|0,this._hl=this._hl+M|0,this._ah=this._ah+r+m(this._al,w)|0,this._bh=this._bh+n+m(this._bl,_)|0,this._ch=this._ch+i+m(this._cl,A)|0,this._dh=this._dh+o+m(this._dl,E)|0,this._eh=this._eh+s+m(this._el,x)|0,this._fh=this._fh+u+m(this._fl,k)|0,this._gh=this._gh+v+m(this._gl,S)|0,this._hh=this._hh+g+m(this._hl,M)|0},u.prototype._hash=function(){var e=o.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],311:[function(e,t,r){t.exports=i;var n=e("events").EventEmitter;function i(){n.call(this)}e("inherits")(i,n),i.Readable=e("readable-stream/readable.js"),i.Writable=e("readable-stream/writable.js"),i.Duplex=e("readable-stream/duplex.js"),i.Transform=e("readable-stream/transform.js"),i.PassThrough=e("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,e.end())}function u(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(f(),0===n.listenerCount(this,"error"))throw e}function f(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),e.removeListener("close",f)}return r.on("error",c),e.on("error",c),r.on("end",f),r.on("close",f),e.on("close",f),e.emit("pipe",r),e}},{events:157,inherits:180,"readable-stream/duplex.js":275,"readable-stream/passthrough.js":284,"readable-stream/readable.js":285,"readable-stream/transform.js":286,"readable-stream/writable.js":287}],312:[function(e,t,r){(function(t){var n=e("./lib/request"),i=e("./lib/response"),o=e("xtend"),a=e("builtin-status-codes"),s=e("url"),u=r;u.request=function(e,r){e="string"==typeof e?s.parse(e):o(e);var i=-1===t.location.protocol.search(/^https?:$/)?"http:":"",a=e.protocol||i,u=e.hostname||e.host,c=e.port,f=e.path||"/";u&&-1!==u.indexOf(":")&&(u="["+u+"]"),e.url=(u?a+"//"+u:"")+(c?":"+c:"")+f,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var h=new n(e);return r&&h.on("response",r),h},u.get=function(e,t){var r=u.request(e,t);return r.end(),r},u.ClientRequest=n,u.IncomingMessage=i,u.Agent=function(){},u.Agent.defaultMaxSockets=4,u.STATUS_CODES=a,u.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/request":314,"./lib/response":315,"builtin-status-codes":85,url:327,xtend:423}],313:[function(e,t,r){(function(e){r.fetch=s(e.fetch)&&s(e.ReadableStream),r.writableStream=s(e.WritableStream),r.abortController=s(e.AbortController),r.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),r.blobConstructor=!0}catch(e){}var t;function n(){if(void 0!==t)return t;if(e.XMLHttpRequest){t=new e.XMLHttpRequest;try{t.open("GET",e.XDomainRequest?"/":"https://example.com")}catch(e){t=null}}else t=null;return t}function i(e){var t=n();if(!t)return!1;try{return t.responseType=e,t.responseType===e}catch(e){}return!1}var o=void 0!==e.ArrayBuffer,a=o&&s(e.ArrayBuffer.prototype.slice);function s(e){return"function"==typeof e}r.arraybuffer=r.fetch||o&&i("arraybuffer"),r.msstream=!r.fetch&&a&&i("ms-stream"),r.mozchunkedarraybuffer=!r.fetch&&o&&i("moz-chunked-arraybuffer"),r.overrideMimeType=r.fetch||!!n()&&s(n().overrideMimeType),r.vbArray=s(e.VBArray),t=null}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],314:[function(e,t,r){(function(r,n,i){var o=e("./capability"),a=e("inherits"),s=e("./response"),u=e("readable-stream"),c=e("to-arraybuffer"),f=s.IncomingMessage,h=s.readyStates;var l=t.exports=function(e){var t,r=this;u.Writable.call(r),r._opts=e,r._body=[],r._headers={},e.auth&&r.setHeader("Authorization","Basic "+new i(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){r.setHeader(t,e.headers[t])});var n=!0;if("disable-fetch"===e.mode||"requestTimeout"in e&&!o.abortController)n=!1,t=!0;else if("prefer-streaming"===e.mode)t=!1;else if("allow-wrong-content-type"===e.mode)t=!o.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");t=!0}r._mode=function(e,t){return o.fetch&&t?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&e?"arraybuffer":o.vbArray&&e?"text:vbarray":"text"}(t,n),r.on("finish",function(){r._onFinish()})};a(l,u.Writable),l.prototype.setHeader=function(e,t){var r=e.toLowerCase();-1===d.indexOf(r)&&(this._headers[r]={name:e,value:t})},l.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},l.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},l.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,a=e._headers,s=null;"GET"!==t.method&&"HEAD"!==t.method&&(s=o.arraybuffer?c(i.concat(e._body)):o.blobConstructor?new n.Blob(e._body.map(function(e){return c(e)}),{type:(a["content-type"]||{}).value||""}):i.concat(e._body).toString());var u=[];if(Object.keys(a).forEach(function(e){var t=a[e].name,r=a[e].value;Array.isArray(r)?r.forEach(function(e){u.push([t,e])}):u.push([t,r])}),"fetch"===e._mode){var f=null;if(o.abortController){var l=new AbortController;f=l.signal,e._fetchAbortController=l,"requestTimeout"in t&&0!==t.requestTimeout&&n.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},t.requestTimeout)}n.fetch(e._opts.url,{method:e._opts.method,headers:u,body:s||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin",signal:f}).then(function(t){e._fetchResponse=t,e._connect()},function(t){e.emit("error",t)})}else{var d=e._xhr=new n.XMLHttpRequest;try{d.open(e._opts.method,e._opts.url,!0)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}"responseType"in d&&(d.responseType=e._mode.split(":")[0]),"withCredentials"in d&&(d.withCredentials=!!t.withCredentials),"text"===e._mode&&"overrideMimeType"in d&&d.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in t&&(d.timeout=t.requestTimeout,d.ontimeout=function(){e.emit("requestTimeout")}),u.forEach(function(e){d.setRequestHeader(e[0],e[1])}),e._response=null,d.onreadystatechange=function(){switch(d.readyState){case h.LOADING:case h.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(d.onprogress=function(){e._onXHRProgress()}),d.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{d.send(s)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}}}},l.prototype._onXHRProgress=function(){(function(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}})(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},l.prototype._connect=function(){var e=this;e._destroyed||(e._response=new f(e._xhr,e._fetchResponse,e._mode),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},l.prototype._write=function(e,t,r){this._body.push(e),r()},l.prototype.abort=l.prototype.destroy=function(){this._destroyed=!0,this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},l.prototype.end=function(e,t,r){"function"==typeof e&&(r=e,e=void 0),u.Writable.prototype.end.call(this,e,t,r)},l.prototype.flushHeaders=function(){},l.prototype.setTimeout=function(){},l.prototype.setNoDelay=function(){},l.prototype.setSocketKeepAlive=function(){};var d=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referrer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,"./response":315,_process:257,buffer:84,inherits:180,"readable-stream":285,"to-arraybuffer":323}],315:[function(e,t,r){(function(t,n,i){var o=e("./capability"),a=e("inherits"),s=e("readable-stream"),u=r.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},c=r.IncomingMessage=function(e,r,n){var a=this;if(s.Readable.call(a),a._mode=n,a.headers={},a.rawHeaders=[],a.trailers={},a.rawTrailers=[],a.on("end",function(){t.nextTick(function(){a.emit("close")})}),"fetch"===n){if(a._fetchResponse=r,a.url=r.url,a.statusCode=r.status,a.statusMessage=r.statusText,r.headers.forEach(function(e,t){a.headers[t.toLowerCase()]=e,a.rawHeaders.push(t,e)}),o.writableStream){var u=new WritableStream({write:function(e){return new Promise(function(t,r){a._destroyed||(a.push(new i(e))?t():a._resumeFetch=t)})},close:function(){a._destroyed||a.push(null)},abort:function(e){a._destroyed||a.emit("error",e)}});try{return void r.body.pipeTo(u)}catch(e){}}var c=r.body.getReader();!function e(){c.read().then(function(t){a._destroyed||(t.done?a.push(null):(a.push(new i(t.value)),e()))}).catch(function(e){a._destroyed||a.emit("error",e)})}()}else{if(a._xhr=e,a._pos=0,a.url=e.responseURL,a.statusCode=e.status,a.statusMessage=e.statusText,e.getAllResponseHeaders().split(/\r?\n/).forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var r=t[1].toLowerCase();"set-cookie"===r?(void 0===a.headers[r]&&(a.headers[r]=[]),a.headers[r].push(t[2])):void 0!==a.headers[r]?a.headers[r]+=", "+t[2]:a.headers[r]=t[2],a.rawHeaders.push(t[1],t[2])}}),a._charset="x-user-defined",!o.overrideMimeType){var f=a.rawHeaders["mime-type"];if(f){var h=f.match(/;\s*charset=([^;])(;|$)/);h&&(a._charset=h[1].toLowerCase())}a._charset||(a._charset="utf-8")}}};a(c,s.Readable),c.prototype._read=function(){var e=this._resumeFetch;e&&(this._resumeFetch=null,e())},c.prototype._onXHRProgress=function(){var e=this,t=e._xhr,r=null;switch(e._mode){case"text:vbarray":if(t.readyState!==u.DONE)break;try{r=new n.VBArray(t.responseBody).toArray()}catch(e){}if(null!==r){e.push(new i(r));break}case"text":try{r=t.responseText}catch(t){e._mode="text:vbarray";break}if(r.length>e._pos){var o=r.substr(e._pos);if("x-user-defined"===e._charset){for(var a=new i(o.length),s=0;se._pos&&(e.push(new i(new Uint8Array(c.result.slice(e._pos)))),e._pos=c.result.byteLength)},c.onload=function(){e.push(null)},c.readAsArrayBuffer(r)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,_process:257,buffer:84,inherits:180,"readable-stream":285}],316:[function(e,t,r){"use strict";t.exports=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}},{}],317:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=f,this.end=h,t=3;break;default:return this.write=l,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:-1}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�".repeat(r);if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�".repeat(r+1);if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�".repeat(r+2)}}(this,e,t);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function l(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}r.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":290}],318:[function(e,t,r){var n=e("is-hex-prefixed");t.exports=function(e){return"string"!=typeof e?e:n(e)?e.slice(2):e}},{"is-hex-prefixed":185}],319:[function(e,t,r){var n=function(){throw"This swarm.js function isn't available on the browser."},i={readFile:n},o={download:n,safeDownloadArchived:n,directoryTree:n},a={platform:n,arch:n},s={join:n,slice:n},u={spawn:n},c={lookup:n},f=e("xhr-request-promise"),h=e("eth-lib/lib/bytes"),l=e("./swarm-hash.js"),d=e("./pick.js"),p=e("./swarm");t.exports=p({fsp:i,files:o,os:a,path:s,child_process:u,defaultArchives:{},mimetype:c,request:f,downloadUrl:null,bytes:h,hash:l,pick:d})},{"./pick.js":320,"./swarm":322,"./swarm-hash.js":321,"eth-lib/lib/bytes":133,"xhr-request-promise":411}],320:[function(e,t,r){var n=function(e){return function(){return new Promise(function(t,r){var n=function(r){var n={},i=r.target.files.length,o=0;[].map.call(r.target.files,function(r){var a=new FileReader;a.onload=function(a){var s=new Uint8Array(a.target.result);if("directory"===e){var u=r.webkitRelativePath;n[u.slice(u.indexOf("/")+1)]={type:"text/plain",data:s},++o===i&&t(n)}else if("file"===e){var c=r.webkitRelativePath;t({type:mimetype.lookup(c),data:s})}else t(s)},a.readAsArrayBuffer(r)})},i=void 0;"directory"===e?((i=document.createElement("input")).addEventListener("change",n),i.type="file",i.webkitdirectory=!0,i.mozdirectory=!0,i.msdirectory=!0,i.odirectory=!0,i.directory=!0):((i=document.createElement("input")).addEventListener("change",n),i.type="file");var o=document.createEvent("MouseEvents");o.initEvent("click",!0,!1),i.dispatchEvent(o)})}};t.exports={data:n("data"),file:n("file"),directory:n("directory")}},{}],321:[function(e,t,r){var n=e("eth-lib/lib/hash").keccak256,i=e("eth-lib/lib/bytes"),o=function(e,t){var r=i.reverse(i.pad(6,i.fromNumber(e))),o=i.flatten([r,"0x0000",t]);return n(o).slice(2)};t.exports=function e(t){"string"==typeof t&&"0x"!==t.slice(0,2)?t=i.fromString(t):"string"!=typeof t&&void 0!==t.length&&(t=i.fromUint8Array(t));var r=i.length(t);if(r<=4096)return o(r,t);for(var n=4096;128*n0){var a=i.join(r,o);n.push(g(e)(t[o])(a))}return Promise.all(n).then(function(){return r})})}}},_=function(e){return function(t){return u(e+"/bzzr:/",{body:"string"==typeof t?L(t):t,method:"POST"})}},A=function(e){return function(t){return function(r){return function(n){return function i(o){var a="/"===r[0]?r:"/"+r,s=e+"/bzz:/"+t+a,c={method:"PUT",headers:{"Content-Type":n.type},body:n.data};return u(s,c).then(function(e){if(-1!==e.indexOf("error"))throw e;return e}).catch(function(e){return o>0&&i(o-1)})}(3)}}}},E=function(e){return function(t){return k(e)({"":t})}},x=function(e){return function(r){return t.readFile(r).then(function(t){return E(e)({type:a.lookup(r),data:t})})}},k=function(e){return function(t){return _(e)("{}").then(function(r){return Object.keys(t).reduce(function(r,n){return r.then(function(r){return function(n){return A(e)(n)(r)(t[r])}}(n))},Promise.resolve(r))})}},S=function(e){return function(r){return t.readFile(r).then(_(e))}},M=function(e){return function(n){return function(i){return r.directoryTree(i).then(function(e){return Promise.all(e.map(function(e){return t.readFile(e)})).then(function(t){var r=e.map(function(e){return e.slice(i.length)}),n=e.map(function(e){return a.lookup(e)||"text/plain"});return d(r)(t.map(function(e,t){return{type:n[t],data:e}}))})}).then(function(e){return(t=n?{"":e[n]}:{},function(e){var r={};for(var n in t)r[n]=t[n];for(var i in e)r[i]=e[i];return r})(e);var t}).then(k(e))}}},I=function(e){return function(t){if("data"===t.pick)return l.data().then(_(e));if("file"===t.pick)return l.file().then(E(e));if("directory"===t.pick)return l.directory().then(k(e));if(t.path)switch(t.kind){case"data":return S(e)(t.path);case"file":return x(e)(t.path);case"directory":return M(e)(t.defaultFile)(t.path)}else{if(t.length||"string"==typeof t)return _(e)(t);if(t instanceof Object)return k(e)(t)}return Promise.reject(new Error("Bad arguments"))}},T=function(e){return function(t){return function(r){return C(e)(t).then(function(n){return n?r?w(e)(t)(r):v(e)(t):r?g(e)(t)(r):b(e)(t)})}}},U=function(e,t){var i=n.platform().replace("win32","windows")+"-"+("x64"===n.arch()?"amd64":"386"),o=(t||s)[i],a=c+o.archive+".tar.gz",u=o.archiveMD5,f=o.binaryMD5;return r.safeDownloadArchived(a)(u)(f)(e)},j=function(e){return new Promise(function(t,r){var n=o.spawn,i=function(e){return function(t){return-1!==(""+t).indexOf(e)}},a=e.account,s=e.password,u=e.dataDir,c=e.ensApi,f=e.privateKey,h=0,l=n(e.binPath,["--bzzaccount",a||f,"--datadir",u,"--ens-api",c]),d=function(e){0===h&&i("Passphrase")(e)?setTimeout(function(){h=1,l.stdin.write(s+"\n")},500):i("Swarm http proxy started")(e)&&(h=2,clearTimeout(p),t(l))};l.stdout.on("data",d),l.stderr.on("data",d);var p=setTimeout(function(){return r(new Error("Couldn't start swarm process."))},2e4)})},B=function(e){return new Promise(function(t,r){e.stderr.removeAllListeners("data"),e.stdout.removeAllListeners("data"),e.stdin.removeAllListeners("error"),e.removeAllListeners("error"),e.removeAllListeners("exit"),e.kill("SIGINT");var n=setTimeout(function(){return e.kill("SIGKILL")},8e3);e.once("close",function(){clearTimeout(n),t()})})},P=function(e){return _(e)("test").then(function(e){return"c9a99c7d326dcc6316f32fe2625b311f6dc49a175e6877681ded93137d3569e7"===e}).catch(function(){return!1})},C=function(e){return function(t){return b(e)(t).then(function(e){try{return!!JSON.parse(R(e)).entries}catch(e){return!1}})}},N=function(e){return function(t,r,n,i,o){var a;return void 0!==t&&(a=e(t)),void 0!==r&&(a=e(r)),void 0!==n&&(a=e(n)),void 0!==i&&(a=e(i)),void 0!==o&&(a=e(o)),a}},R=function(e){return f.toString(f.fromUint8Array(e))},L=function(e){return f.toUint8Array(f.fromString(e))},O=function(e){return{download:function(t,r){return T(e)(t)(r)},downloadData:N(b(e)),downloadDataToDisk:N(g(e)),downloadDirectory:N(v(e)),downloadDirectoryToDisk:N(w(e)),downloadEntries:N(y(e)),downloadRoutes:N(m(e)),isAvailable:function(){return P(e)},upload:function(t){return I(e)(t)},uploadData:N(_(e)),uploadFile:N(E(e)),uploadFileFromDisk:N(E(e)),uploadDataFromDisk:N(S(e)),uploadDirectory:N(k(e)),uploadDirectoryFromDisk:N(M(e)),uploadToManifest:N(A(e)),pick:l,hash:h,fromString:L,toString:R}};return{at:O,local:function(e){return function(t){return P("http://localhost:8500").then(function(r){return r?t(O("http://localhost:8500")).then(function(){}):U(e.binPath,e.archives).onData(function(t){return(e.onProgress||function(){})(t.length)}).then(function(){return j(e)}).then(function(e){return t(O("http://localhost:8500")).then(function(){return e})}).then(B)})}},download:T,downloadBinary:U,downloadData:b,downloadDataToDisk:g,downloadDirectory:v,downloadDirectoryToDisk:w,downloadEntries:y,downloadRoutes:m,isAvailable:P,startProcess:j,stopProcess:B,upload:I,uploadData:_,uploadDataFromDisk:S,uploadFile:E,uploadFileFromDisk:x,uploadDirectory:k,uploadDirectoryFromDisk:M,uploadToManifest:A,pick:l,hash:h,fromString:L,toString:R}}},{}],323:[function(e,t,r){var n=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(n.isBuffer(e)){for(var t=new Uint8Array(e.length),r=e.length,i=0;i=0&&t<=A};function k(e){return function(t,r,n,i){r=m(r,i,4);var o=!x(t)&&y.keys(t),a=(o||t).length,s=e>0?0:a-1;return arguments.length<3&&(n=t[o?o[s]:s],s+=e),function(t,r,n,i,o,a){for(;o>=0&&o=0},y.invoke=function(e,t){var r=u.call(arguments,2),n=y.isFunction(t);return y.map(e,function(e){var i=n?t:e[t];return null==i?i:i.apply(e,r)})},y.pluck=function(e,t){return y.map(e,y.property(t))},y.where=function(e,t){return y.filter(e,y.matcher(t))},y.findWhere=function(e,t){return y.find(e,y.matcher(t))},y.max=function(e,t,r){var n,i,o=-1/0,a=-1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;so&&(o=n);else t=v(t,r),y.each(e,function(e,r,n){((i=t(e,r,n))>a||i===-1/0&&o===-1/0)&&(o=e,a=i)});return o},y.min=function(e,t,r){var n,i,o=1/0,a=1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;sn||void 0===r)return 1;if(r0?0:i-1;o>=0&&o0?a=o>=0?o:Math.max(o+s,a):s=o>=0?Math.min(o+1,s):o+s+1;else if(r&&o&&s)return n[o=r(n,i)]===i?o:-1;if(i!=i)return(o=t(u.call(n,a,s),y.isNaN))>=0?o+a:-1;for(o=e>0?a:s-1;o>=0&&ot?(a&&(clearTimeout(a),a=null),s=c,o=e.apply(n,i),a||(n=i=null)):a||!1===r.trailing||(a=setTimeout(u,f)),o}},y.debounce=function(e,t,r){var n,i,o,a,s,u=function(){var c=y.now()-a;c=0?n=setTimeout(u,t-c):(n=null,r||(s=e.apply(o,i),n||(o=i=null)))};return function(){o=this,i=arguments,a=y.now();var c=r&&!n;return n||(n=setTimeout(u,t)),c&&(s=e.apply(o,i),o=i=null),s}},y.wrap=function(e,t){return y.partial(t,e)},y.negate=function(e){return function(){return!e.apply(this,arguments)}},y.compose=function(){var e=arguments,t=e.length-1;return function(){for(var r=t,n=e[t].apply(this,arguments);r--;)n=e[r].call(this,n);return n}},y.after=function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},y.before=function(e,t){var r;return function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=null),r}},y.once=y.partial(y.before,2);var j=!{toString:null}.propertyIsEnumerable("toString"),B=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];function P(e,t){var r=B.length,n=e.constructor,i=y.isFunction(n)&&n.prototype||o,a="constructor";for(y.has(e,a)&&!y.contains(t,a)&&t.push(a);r--;)(a=B[r])in e&&e[a]!==i[a]&&!y.contains(t,a)&&t.push(a)}y.keys=function(e){if(!y.isObject(e))return[];if(l)return l(e);var t=[];for(var r in e)y.has(e,r)&&t.push(r);return j&&P(e,t),t},y.allKeys=function(e){if(!y.isObject(e))return[];var t=[];for(var r in e)t.push(r);return j&&P(e,t),t},y.values=function(e){for(var t=y.keys(e),r=t.length,n=Array(r),i=0;i":">",'"':""","'":"'","`":"`"},R=y.invert(N),L=function(e){var t=function(t){return e[t]},r="(?:"+y.keys(e).join("|")+")",n=RegExp(r),i=RegExp(r,"g");return function(e){return e=null==e?"":""+e,n.test(e)?e.replace(i,t):e}};y.escape=L(N),y.unescape=L(R),y.result=function(e,t,r){var n=null==e?void 0:e[t];return void 0===n&&(n=r),y.isFunction(n)?n.call(e):n};var O=0;y.uniqueId=function(e){var t=++O+"";return e?e+t:t},y.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var D=/(.)^/,F={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},q=/\\|'|\r|\n|\u2028|\u2029/g,H=function(e){return"\\"+F[e]};y.template=function(e,t,r){!t&&r&&(t=r),t=y.defaults({},t,y.templateSettings);var n=RegExp([(t.escape||D).source,(t.interpolate||D).source,(t.evaluate||D).source].join("|")+"|$","g"),i=0,o="__p+='";e.replace(n,function(t,r,n,a,s){return o+=e.slice(i,s).replace(q,H),i=s+t.length,r?o+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":n?o+="'+\n((__t=("+n+"))==null?'':__t)+\n'":a&&(o+="';\n"+a+"\n__p+='"),t}),o+="';\n",t.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{var a=new Function(t.variable||"obj","_",o)}catch(e){throw e.source=o,e}var s=function(e){return a.call(this,e,y)},u=t.variable||"obj";return s.source="function("+u+"){\n"+o+"}",s},y.chain=function(e){var t=y(e);return t._chain=!0,t};var z=function(e,t){return e._chain?y(t).chain():t};y.mixin=function(e){y.each(y.functions(e),function(t){var r=y[t]=e[t];y.prototype[t]=function(){var e=[this._wrapped];return s.apply(e,arguments),z(this,r.apply(y,e))}})},y.mixin(y),y.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=i[e];y.prototype[e]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==e&&"splice"!==e||0!==r.length||delete r[0],z(this,r)}}),y.each(["concat","join","slice"],function(e){var t=i[e];y.prototype[e]=function(){return z(this,t.apply(this._wrapped,arguments))}}),y.prototype.value=function(){return this._wrapped},y.prototype.valueOf=y.prototype.toJSON=y.prototype.value,y.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return y})}).call(this)},{}],326:[function(e,t,r){t.exports=function(e,t){if(t){t=(t=t.trim().replace(/^(\?|#|&)/,""))?"?"+t:t;var r=e.split(/[\?\#]/),n=r[0];t&&/\:\/\/[^\/]*$/.test(n)&&(n+="/");var i=e.match(/(\#.*)$/);e=n+t,i&&(e+=i[0])}return e}},{}],327:[function(e,t,r){"use strict";var n=e("punycode"),i=e("./util");function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}r.parse=g,r.resolve=function(e,t){return g(e,!1,!0).resolve(t)},r.resolveObject=function(e,t){return e?g(e,!1,!0).resolveObject(t):t},r.format=function(e){i.isString(e)&&(e=g(e));return e instanceof o?e.format():o.prototype.format.call(e)},r.Url=o;var a=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=e("querystring");function g(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o127?P+="x":P+=B[C];if(!P.match(d)){var R=U.slice(0,M),L=U.slice(M+1),O=B.match(p);O&&(R.push(O[1]),L.unshift(O[2])),L.length&&(g="/"+L.join(".")+g),this.hostname=R.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),T||(this.hostname=n.toASCII(this.hostname));var D=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+D,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==g[0]&&(g="/"+g))}if(!b[A])for(M=0,j=f.length;M0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift());return r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!E.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var k=E.slice(-1)[0],S=(r.host||e.host||E.length>1)&&("."===k||".."===k)||""===k,M=0,I=E.length;I>=0;I--)"."===(k=E[I])?E.splice(I,1):".."===k?(E.splice(I,1),M++):M&&(E.splice(I,1),M--);if(!_&&!A)for(;M--;M)E.unshift("..");!_||""===E[0]||E[0]&&"/"===E[0].charAt(0)||E.unshift(""),S&&"/"!==E.join("/").substr(-1)&&E.push("");var T,U=""===E[0]||E[0]&&"/"===E[0].charAt(0);x&&(r.hostname=r.host=U?"":E.length?E.shift():"",(T=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift()));return(_=_||r.host&&E.length)&&!U&&E.unshift(""),E.length?r.pathname=E.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":328,punycode:265,querystring:269}],328:[function(e,t,r){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],329:[function(e,t,r){(function(e){!function(n){var i="object"==typeof r&&r,o="object"==typeof t&&t&&t.exports==i&&t,a="object"==typeof e&&e;a.global!==a&&a.window!==a||(n=a);var s,u,c,f=String.fromCharCode;function h(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i=55296&&e<=57343)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value")}function d(e,t){return f(e>>t&63|128)}function p(e){if(0==(4294967168&e))return f(e);var t="";return 0==(4294965248&e)?t=f(e>>6&31|192):0==(4294901760&e)?(l(e),t=f(e>>12&15|224),t+=d(e,6)):0==(4292870144&e)&&(t=f(e>>18&7|240),t+=d(e,12),t+=d(e,6)),t+=f(63&e|128)}function b(){if(c>=u)throw Error("Invalid byte index");var e=255&s[c];if(c++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function y(){var e,t;if(c>u)throw Error("Invalid byte index");if(c==u)return!1;if(e=255&s[c],c++,0==(128&e))return e;if(192==(224&e)){if((t=(31&e)<<6|b())>=128)return t;throw Error("Invalid continuation byte")}if(224==(240&e)){if((t=(15&e)<<12|b()<<6|b())>=2048)return l(t),t;throw Error("Invalid continuation byte")}if(240==(248&e)&&(t=(15&e)<<18|b()<<12|b()<<6|b())>=65536&&t<=1114111)return t;throw Error("Invalid UTF-8 detected")}var m={version:"2.0.0",encode:function(e){for(var t=h(e),r=t.length,n=-1,i="";++n65535&&(i+=f((t-=65536)>>>10&1023|55296),t=56320|1023&t),i+=f(t);return i}(r)}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return m});else if(i&&!i.nodeType)if(o)o.exports=m;else{var v={}.hasOwnProperty;for(var g in m)v.call(m,g)&&(i[g]=m[g])}else n.utf8=m}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],330:[function(e,t,r){(function(e){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],331:[function(e,t,r){arguments[4][180][0].apply(r,arguments)},{dup:180}],332:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],333:[function(e,t,r){(function(t,n){var i=/%[sdj%]/g;r.format=function(e){if(!m(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(t)?n.showHidden=t:t&&r._extend(n,t),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,e,n.depth)}function u(e,t){var r=s.styles[t];return r?"["+s.colors[r][0]+"m"+e+"["+s.colors[r][1]+"m":e}function c(e,t){return e}function f(e,t,n){if(e.customInspect&&t&&E(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return m(i)||(i=f(e,i,n)),i}var o=function(e,t){if(v(t))return e.stylize("undefined","undefined");if(m(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(y(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(b(t))return e.stylize("null","null")}(e,t);if(o)return o;var a=Object.keys(t),s=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),A(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return h(t);if(0===a.length){if(E(t)){var u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","special")}if(g(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(_(t))return e.stylize(Date.prototype.toString.call(t),"date");if(A(t))return h(t)}var c,w="",x=!1,k=["{","}"];(d(t)&&(x=!0,k=["[","]"]),E(t))&&(w=" [Function"+(t.name?": "+t.name:"")+"]");return g(t)&&(w=" "+RegExp.prototype.toString.call(t)),_(t)&&(w=" "+Date.prototype.toUTCString.call(t)),A(t)&&(w=" "+h(t)),0!==a.length||x&&0!=t.length?n<0?g(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=x?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(c,w,k)):k[0]+w+k[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),M(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=b(r)?f(e,u.value,null):f(e,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n")):s=e.stylize("[Circular]","special")),v(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function b(e){return null===e}function y(e){return"number"==typeof e}function m(e){return"string"==typeof e}function v(e){return void 0===e}function g(e){return w(e)&&"[object RegExp]"===x(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===x(e)}function A(e){return w(e)&&("[object Error]"===x(e)||e instanceof Error)}function E(e){return"function"==typeof e}function x(e){return Object.prototype.toString.call(e)}function k(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(v(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=t.pid;a[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else a[e]=function(){};return a[e]},r.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(e){return null==e},r.isNumber=y,r.isString=m,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=v,r.isRegExp=g,r.isObject=w,r.isDate=_,r.isError=A,r.isFunction=E,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[k(e.getHours()),k(e.getMinutes()),k(e.getSeconds())].join(":"),[e.getDate(),S[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":332,_process:257,inherits:331}],334:[function(require,module,exports){var indexOf=require("indexof"),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},c.prototype.getCall=function(e){return n.isFunction(this.call)?this.call(e):this.call},c.prototype.extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},c.prototype.validateArgs=function(e){if(e.length!==this.params)throw i.InvalidNumberOfParams(e.length,this.params,this.name)},c.prototype.formatInput=function(e){var t=this;return this.inputFormatter?this.inputFormatter.map(function(r,n){return r?r.call(t,e[n]):e[n]}):e},c.prototype.formatOutput=function(e){var t=this;return n.isArray(e)?e.map(function(e){return t.outputFormatter&&e?t.outputFormatter(e):e}):this.outputFormatter&&e?this.outputFormatter(e):e},c.prototype.toPayload=function(e){var t=this.getCall(e),r=this.extractCallback(e),n=this.formatInput(e);this.validateArgs(n);var i={method:t,params:n,callback:r};return this.transformPayload&&(i=this.transformPayload(i)),i},c.prototype._confirmTransaction=function(e,t,r){var i=this,f=!1,h=!0,l=0,d=0,p=null,b="",y=n.isObject(r.params[0])&&r.params[0].gas?r.params[0].gas:null,m=n.isObject(r.params[0])&&r.params[0].data&&r.params[0].from&&!r.params[0].to,v=[new c({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:o.outputTransactionReceiptFormatter}),new c({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[o.inputAddressFormatter,o.inputDefaultBlockNumberFormatter]}),new u({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:o.outputBlockFormatter}}})],g={};n.each(v,function(e){e.attachToObject(g),e.requestManager=i.requestManager});var w=function(r,n,o,u,c){if(!o)return c||(c={unsubscribe:function(){clearInterval(p)}}),(r?s.resolve(r):g.getTransactionReceipt(t)).catch(function(t){c.unsubscribe(),f=!0,a._fireError({message:"Failed to check for transaction receipt:",data:t},e.eventEmitter,e.reject)}).then(function(t){if(!t||!t.blockHash)throw new Error("Receipt missing or blockHash null");return i.extraFormatters&&i.extraFormatters.receiptFormatter&&(t=i.extraFormatters.receiptFormatter(t)),e.eventEmitter.listeners("confirmation").length>0&&(void 0!==r&&0===d||e.eventEmitter.emit("confirmation",d,t),h=!1,25===++d&&(c.unsubscribe(),e.eventEmitter.removeAllListeners())),t}).then(function(t){if(m&&!f){if(!t.contractAddress)return h&&(c.unsubscribe(),f=!0),void a._fireError(new Error("The transaction receipt didn't contain a contract address."),e.eventEmitter,e.reject);g.getCode(t.contractAddress,function(r,n){n&&(n.length>2?(e.eventEmitter.emit("receipt",t),i.extraFormatters&&i.extraFormatters.contractDeployFormatter?e.resolve(i.extraFormatters.contractDeployFormatter(t)):e.resolve(t),h&&e.eventEmitter.removeAllListeners()):a._fireError(new Error("The contract code couldn't be stored, please check your gas limit."),e.eventEmitter,e.reject),h&&c.unsubscribe(),f=!0)})}return t}).then(function(t){m||f||(t.outOfGas||y&&y===t.gasUsed||!0!==t.status&&"0x1"!==t.status&&void 0!==t.status?(b=JSON.stringify(t,null,2),!1===t.status||"0x0"===t.status?a._fireError(new Error("Transaction has been reverted by the EVM:\n"+b),e.eventEmitter,e.reject):a._fireError(new Error("Transaction ran out of gas. Please provide more gas:\n"+b),e.eventEmitter,e.reject)):(e.eventEmitter.emit("receipt",t),e.resolve(t),h&&e.eventEmitter.removeAllListeners()),h&&c.unsubscribe(),f=!0)}).catch(function(){l++,n?l-1>=750&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject)):l-1>=50&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject))});c.unsubscribe(),f=!0,a._fireError({message:"Failed to subscribe to new newBlockHeaders to confirm the transaction receipts.",data:o},e.eventEmitter,e.reject)},_=function(e){n.isFunction(this.requestManager.provider.on)?g.subscribe("newBlockHeaders",w.bind(null,e,!1)):p=setInterval(w.bind(null,e,!0),1e3)}.bind(this);g.getTransactionReceipt(t).then(function(t){t&&t.blockHash?(e.eventEmitter.listeners("confirmation").length>0&&_(t),w(t,!1)):f||_()}).catch(function(){f||_()})};var f=function(e,t){return n.isNumber(e)?t.wallet[e]:n.isObject(e)&&e.address&&e.privateKey?e:t.wallet[e.toLowerCase()]};c.prototype.buildCall=function(){var e=this,t="eth_sendTransaction"===e.call||"eth_sendRawTransaction"===e.call,r=function(){var r=s(!t),i=e.toPayload(Array.prototype.slice.call(arguments)),o=function(n,o){try{o=e.formatOutput(o)}catch(e){n=e}if(o instanceof Error&&(n=o),n)return n.error&&(n=n.error),a._fireError(n,r.eventEmitter,r.reject,i.callback);i.callback&&i.callback(null,o),t?(r.eventEmitter.emit("transactionHash",o),e._confirmTransaction(r,o,i)):n||r.resolve(o)},u=function(t){var r=n.extend({},i,{method:"eth_sendRawTransaction",params:[t.rawTransaction]});e.requestManager.send(r,o)},h=function(e,t){var i;if(t&&t.accounts&&t.accounts.wallet&&t.accounts.wallet.length)if("eth_sendTransaction"===e.method){var a=e.params[0];if((i=f(n.isObject(a)?a.from:null,t.accounts))&&i.privateKey)return t.accounts.signTransaction(n.omit(a,"from"),i.privateKey).then(u)}else if("eth_sign"===e.method){var s=e.params[1];if((i=f(e.params[0],t.accounts))&&i.privateKey){var c=t.accounts.sign(s,i.privateKey);return e.callback&&e.callback(null,c.signature),void r.resolve(c.signature)}}return t.requestManager.send(e,o)};t&&n.isObject(i.params[0])&&void 0===i.params[0].gasPrice?new c({name:"getGasPrice",call:"eth_gasPrice",params:0}).createFunction(e.requestManager)(function(t,r){r&&(i.params[0].gasPrice=r),h(i,e)}):h(i,e);return r.eventEmitter};return r.method=e,r.request=this.request.bind(this),r},c.prototype.request=function(){var e=this.toPayload(Array.prototype.slice.call(arguments));return e.format=this.formatOutput.bind(this),e},t.exports=c},{underscore:325,"web3-core-helpers":338,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-utils":403}],340:[function(e,t,r){"use strict";var n=e("eventemitter3"),i=e("any-promise"),o=function(e){var t,r,o=new i(function(){t=arguments[0],r=arguments[1]});if(e)return{resolve:t,reject:r,eventEmitter:o};var a=new n;return o._events=a._events,o.emit=a.emit,o.on=a.on,o.once=a.once,o.off=a.off,o.listeners=a.listeners,o.addListener=a.addListener,o.removeListener=a.removeListener,o.removeAllListeners=a.removeAllListeners,{resolve:t,reject:r,eventEmitter:o}};o.resolve=function(e){var t=o(!0);return t.resolve(e),t.eventEmitter},t.exports=o},{"any-promise":2,eventemitter3:156}],341:[function(e,t,r){"use strict";var n=e("./jsonrpc"),i=e("web3-core-helpers").errors,o=function(e){this.requestManager=e,this.requests=[]};o.prototype.add=function(e){this.requests.push(e)},o.prototype.execute=function(){var e=this.requests;this.requestManager.sendBatch(e,function(t,r){r=r||[],e.map(function(e,t){return r[t]||{}}).forEach(function(t,r){if(e[r].callback){if(t&&t.error)return e[r].callback(i.ErrorResponse(t));if(!n.isValidResponse(t))return e[r].callback(i.InvalidResponse(t));try{e[r].callback(null,e[r].format?e[r].format(t.result):t.result)}catch(t){e[r].callback(t)}}})})},t.exports=o},{"./jsonrpc":344,"web3-core-helpers":338}],342:[function(e,t,r){"use strict";var n=null,i=window;void 0!==i.ethereumProvider?n=i.ethereumProvider:void 0!==i.web3&&i.web3.currentProvider&&(i.web3.currentProvider.sendAsync&&(i.web3.currentProvider.send=i.web3.currentProvider.sendAsync,delete i.web3.currentProvider.sendAsync),!i.web3.currentProvider.on&&i.web3.currentProvider.connection&&"ipcProviderWrapper"===i.web3.currentProvider.connection.constructor.name&&(i.web3.currentProvider.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.connection.on("data",function(e){var r="";e=e.toString();try{r=JSON.parse(e)}catch(r){return t(new Error("Couldn't parse response data"+e))}r.id||-1===r.method.indexOf("_subscription")||t(null,r)});break;default:this.connection.on(e,t)}}),n=i.web3.currentProvider),t.exports=n},{}],343:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("./jsonrpc.js"),a=e("./batch.js"),s=e("./givenProvider.js"),u=function e(t){this.provider=null,this.providers=e.providers,this.setProvider(t),this.subscriptions={}};u.givenProvider=s,u.providers={WebsocketProvider:e("web3-providers-ws"),HttpProvider:e("web3-providers-http"),IpcProvider:e("web3-providers-ipc")},u.prototype.setProvider=function(e,t){var r=this;if(e&&"string"==typeof e&&this.providers)if(/^http(s)?:\/\//i.test(e))e=new this.providers.HttpProvider(e);else if(/^ws(s)?:\/\//i.test(e))e=new this.providers.WebsocketProvider(e);else if(e&&"object"==typeof t&&"function"==typeof t.connect)e=new this.providers.IpcProvider(e,t);else if(e)throw new Error("Can't autodetect provider for \""+e+'"');this.provider&&this.provider.connected&&this.clearSubscriptions(),this.provider=e||null,this.provider&&this.provider.on&&this.provider.on("data",function(e,t){(e=e||t).method&&r.subscriptions[e.params.subscription]&&r.subscriptions[e.params.subscription].callback&&r.subscriptions[e.params.subscription].callback(null,e.params.result)})},u.prototype.send=function(e,t){if(t=t||function(){},!this.provider)return t(i.InvalidProvider());var r=o.toPayload(e.method,e.params);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,n){return n&&n.id&&r.id!==n.id?t(new Error('Wrong response id "'+n.id+'" (expected: "'+r.id+'") in '+JSON.stringify(r))):e?t(e):n&&n.error?t(i.ErrorResponse(n)):o.isValidResponse(n)?void t(null,n.result):t(i.InvalidResponse(n))})},u.prototype.sendBatch=function(e,t){if(!this.provider)return t(i.InvalidProvider());var r=o.toBatchPayload(e);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,r){return e?t(e):n.isArray(r)?void t(null,r):t(i.InvalidResponse(r))})},u.prototype.addSubscription=function(e,t,r,n){if(!this.provider.on)throw new Error("The provider doesn't support subscriptions: "+this.provider.constructor.name);this.subscriptions[e]={callback:n,type:r,name:t}},u.prototype.removeSubscription=function(e,t){this.subscriptions[e]&&(this.send({method:this.subscriptions[e].type+"_unsubscribe",params:[e]},t),delete this.subscriptions[e])},u.prototype.clearSubscriptions=function(e){var t=this;Object.keys(this.subscriptions).forEach(function(r){e&&"syncing"===t.subscriptions[r].name||t.removeSubscription(r)}),this.provider.reset&&this.provider.reset()},t.exports={Manager:u,BatchManager:a}},{"./batch.js":341,"./givenProvider.js":342,"./jsonrpc.js":344,underscore:325,"web3-core-helpers":338,"web3-providers-http":398,"web3-providers-ipc":399,"web3-providers-ws":400}],344:[function(e,t,r){"use strict";var n={messageId:0,toPayload:function(e,t){if(!e)throw new Error('JSONRPC method should be specified for params: "'+JSON.stringify(t)+'"!');return n.messageId++,{jsonrpc:"2.0",id:n.messageId,method:e,params:t||[]}},isValidResponse:function(e){return Array.isArray(e)?e.every(t):t(e);function t(e){return!(!e||e.error||"2.0"!==e.jsonrpc||"number"!=typeof e.id&&"string"!=typeof e.id||void 0===e.result)}},toBatchPayload:function(e){return e.map(function(e){return n.toPayload(e.method,e.params)})}};t.exports=n},{}],345:[function(e,t,r){"use strict";var n=e("./subscription.js"),i=function(e){this.name=e.name,this.type=e.type,this.subscriptions=e.subscriptions||{},this.requestManager=null};i.prototype.setRequestManager=function(e){this.requestManager=e},i.prototype.attachToObject=function(e){var t=this.buildCall(),r=this.name.split(".");r.length>1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},i.prototype.buildCall=function(){var e=this;return function(){e.subscriptions[arguments[0]]||console.warn("Subscription "+JSON.stringify(arguments[0])+" doesn't exist. Subscribing anyway.");var t=new n({subscription:e.subscriptions[arguments[0]],requestManager:e.requestManager,type:e.type});return t.subscribe.apply(t,arguments)}},t.exports={subscriptions:i,subscription:n}},{"./subscription.js":346}],346:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("eventemitter3");function a(e){o.call(this),this.id=null,this.callback=n.identity,this.arguments=null,this._reconnectIntervalId=null,this.options={subscription:e.subscription,type:e.type,requestManager:e.requestManager}}a.prototype=Object.create(o.prototype),a.prototype.constructor=a,a.prototype._extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},a.prototype._validateArgs=function(e){var t=this.options.subscription;if(t||(t={}),t.params||(t.params=0),e.length!==t.params)throw i.InvalidNumberOfParams(e.length,t.params+1,e[0])},a.prototype._formatInput=function(e){var t=this.options.subscription;return t&&t.inputFormatter?t.inputFormatter.map(function(t,r){return t?t(e[r]):e[r]}):e},a.prototype._formatOutput=function(e){var t=this.options.subscription;return t&&t.outputFormatter&&e?t.outputFormatter(e):e},a.prototype._toPayload=function(e){var t=[];if(this.callback=this._extractCallback(e)||n.identity,this.subscriptionMethod||(this.subscriptionMethod=e.shift(),this.options.subscription.subscriptionName&&(this.subscriptionMethod=this.options.subscription.subscriptionName)),this.arguments||(this.arguments=this._formatInput(e),this._validateArgs(this.arguments),e=[]),t.push(this.subscriptionMethod),t=t.concat(this.arguments),e.length)throw new Error("Only a callback is allowed as parameter on an already instantiated subscription.");return{method:this.options.type+"_subscribe",params:t}},a.prototype.unsubscribe=function(e){this.options.requestManager.removeSubscription(this.id,e),this.id=null,this.removeAllListeners(),clearInterval(this._reconnectIntervalId)},a.prototype.subscribe=function(){var e=this,t=Array.prototype.slice.call(arguments),r=this._toPayload(t);if(!r)return this;if(!this.options.requestManager.provider){var i=new Error("No provider set.");return this.callback(i,null,this),this.emit("error",i),this}if(!this.options.requestManager.provider.on){var o=new Error("The current provider doesn't support subscriptions: "+this.options.requestManager.provider.constructor.name);return this.callback(o,null,this),this.emit("error",o),this}return this.id&&this.unsubscribe(),this.options.params=r.params[1],"logs"===r.params[0]&&n.isObject(r.params[1])&&r.params[1].hasOwnProperty("fromBlock")&&isFinite(r.params[1].fromBlock)&&this.options.requestManager.send({method:"eth_getLogs",params:[r.params[1]]},function(t,r){t?(e.callback(t,null,e),e.emit("error",t)):r.forEach(function(t){var r=e._formatOutput(t);e.callback(null,r,e),e.emit("data",r)})}),"object"==typeof r.params[1]&&delete r.params[1].fromBlock,this.options.requestManager.send(r,function(t,i){!t&&i?(e.id=i,e.options.requestManager.addSubscription(e.id,r.params[0],e.options.type,function(t,r){t?(e.options.requestManager.removeSubscription(e.id),e.options.requestManager.provider.once&&(e._reconnectIntervalId=setInterval(function(){e.options.requestManager.provider.reconnect&&e.options.requestManager.provider.reconnect()},500),e.options.requestManager.provider.once("connect",function(){clearInterval(e._reconnectIntervalId),e.subscribe(e.callback)})),e.emit("error",t),e.callback(t,null,e)):(n.isArray(r)||(r=[r]),r.forEach(function(t){var r=e._formatOutput(t);if(n.isFunction(e.options.subscription.subscriptionHandler))return e.options.subscription.subscriptionHandler.call(e,r);e.emit("data",r),e.callback(null,r,e)}))})):(e.callback(t,null,e),e.emit("error",t))}),this},t.exports=a},{eventemitter3:156,underscore:325,"web3-core-helpers":338}],347:[function(e,t,r){"use strict";var n=e("web3-core-helpers").formatters,i=e("web3-core-method"),o=e("web3-utils");t.exports=function(e){var t=function(t){var r;return t.property?(e[t.property]||(e[t.property]={}),r=e[t.property]):r=e,t.methods&&t.methods.forEach(function(t){t instanceof i||(t=new i(t)),t.attachToObject(r),t.setRequestManager(e._requestManager)}),e};return t.formatters=n,t.utils=o,t.Method=i,t}},{"web3-core-helpers":338,"web3-core-method":339,"web3-utils":403}],348:[function(e,t,r){"use strict";var n=e("web3-core-requestmanager"),i=e("./extend.js");t.exports={packageInit:function(e,t){if(t=Array.prototype.slice.call(t),!e)throw new Error('You need to instantiate using the "new" keyword.');Object.defineProperty(e,"currentProvider",{get:function(){return e._provider},set:function(t){return e.setProvider(t)},enumerable:!0,configurable:!0}),t[0]&&t[0]._requestManager?e._requestManager=new n.Manager(t[0].currentProvider):(e._requestManager=new n.Manager,e._requestManager.setProvider(t[0],t[1])),e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers,e._provider=e._requestManager.provider,e.setProvider||(e.setProvider=function(t,r){return e._requestManager.setProvider(t,r),e._provider=e._requestManager.provider,!0}),e.BatchRequest=n.BatchManager.bind(null,e._requestManager),e.extend=i(e)},addProviders:function(e){e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers}}},{"./extend.js":347,"web3-core-requestmanager":343}],349:[function(e,t,r){var n=e("underscore"),i=e("web3-utils"),o=new(0,e("ethers/utils/abi-coder").AbiCoder)(function(e,t){return!e.match(/^u?int/)||n.isArray(t)||n.isObject(t)&&"BN"===t.constructor.name?t:t.toString()});function a(){}var s=function(){};s.prototype.encodeFunctionSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e).slice(0,10)},s.prototype.encodeEventSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e)},s.prototype.encodeParameter=function(e,t){return this.encodeParameters([e],[t])},s.prototype.encodeParameters=function(e,t){return o.encode(this.mapTypes(e),t)},s.prototype.mapTypes=function(e){var t=this,r=[];return e.forEach(function(e){if(t.isSimplifiedStructFormat(e)){var n=Object.keys(e)[0];r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}else r.push(e)}),r},s.prototype.isSimplifiedStructFormat=function(e){return"object"==typeof e&&void 0===e.components&&void 0===e.name},s.prototype.mapStructNameAndType=function(e){var t="tuple";return e.indexOf("[]")>-1&&(t="tuple[]",e=e.slice(0,-2)),{type:t,name:e}},s.prototype.mapStructToCoderFormat=function(e){var t=this,r=[];return Object.keys(e).forEach(function(n){"object"!=typeof e[n]?r.push({name:n,type:e[n]}):r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}),r},s.prototype.encodeFunctionCall=function(e,t){return this.encodeFunctionSignature(e)+this.encodeParameters(e.inputs,t).replace("0x","")},s.prototype.decodeParameter=function(e,t){return this.decodeParameters([e],t)[0]},s.prototype.decodeParameters=function(e,t){if(!t||"0x"===t||"0X"===t)throw new Error("Returned values aren't valid, did it run Out of Gas?");var r=o.decode(this.mapTypes(e),"0x"+t.replace(/0x/i,"")),i=new a;return i.__length__=0,e.forEach(function(e,t){var o=r[i.__length__];o="0x"===o?null:o,i[t]=o,n.isObject(e)&&e.name&&(i[e.name]=o),i.__length__++}),i},s.prototype.decodeLog=function(e,t,r){var i=this;r=n.isArray(r)?r:[r],t=t||"";var o=[],s=[],u=0;e.forEach(function(e,t){e.indexed?(s[t]=["bool","int","uint","address","fixed","ufixed"].find(function(t){return-1!==e.type.indexOf(t)})?i.decodeParameter(e.type,r[u]):r[u],u++):o[t]=e});var c=t,f=c?this.decodeParameters(o,c):[],h=new a;return h.__length__=0,e.forEach(function(e,t){h[t]="string"===e.type?"":null,void 0!==f[t]&&(h[t]=f[t]),void 0!==s[t]&&(h[t]=s[t]),e.name&&(h[e.name]=h[t]),h.__length__++}),h};var u=new s;t.exports=u},{"ethers/utils/abi-coder":143,underscore:325,"web3-utils":403}],350:[function(e,t,r){(function(r){var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=e("./bytes"),o=e("./nat"),a=e("elliptic"),s=(e("./rlp"),new a.ec("secp256k1")),u=e("./hash"),c=u.keccak256,f=u.keccak256s,h=function(e){for(var t=f(e.slice(2)),r="0x",n=0;n<40;n++)r+=parseInt(t[n+2],16)>7?e[n+2].toUpperCase():e[n+2];return r},l=function(e){var t=new r(e.slice(2),"hex"),n="0x"+s.keyFromPrivate(t).getPublic(!1,"hex").slice(2),i=c(n);return{address:h("0x"+i.slice(-40)),privateKey:e}},d=function(e){var t=n(e,3),r=t[0],o=i.pad(32,t[1]),a=i.pad(32,t[2]);return i.flatten([o,a,r])},p=function(e){return[i.slice(64,i.length(e),e),i.slice(0,32,e),i.slice(32,64,e)]},b=function(e){return function(t,n){var a=s.keyFromPrivate(new r(n.slice(2),"hex")).sign(new r(t.slice(2),"hex"),{canonical:!0});return d([o.fromString(i.fromNumber(e+a.recoveryParam)),i.pad(32,i.fromNat("0x"+a.r.toString(16))),i.pad(32,i.fromNat("0x"+a.s.toString(16)))])}},y=b(27);t.exports={create:function(e){var t=c(i.concat(i.random(32),e||i.random(32))),r=i.concat(i.concat(i.random(32),t),i.random(32)),n=c(r);return l(n)},toChecksum:h,fromPrivate:l,sign:y,makeSigner:b,recover:function(e,t){var n=p(t),o={v:i.toNumber(n[0]),r:n[1].slice(2),s:n[2].slice(2)},a="0x"+s.recoverPubKey(new r(e.slice(2),"hex"),o,o.v<2?o.v:1-o.v%2).encode("hex",!1).slice(2),u=c(a);return h("0x"+u.slice(-40))},encodeSignature:d,decodeSignature:p}}).call(this,e("buffer").Buffer)},{"./bytes":352,"./hash":353,"./nat":354,"./rlp":355,buffer:84,elliptic:109}],351:[function(e,t,r){arguments[4][132][0].apply(r,arguments)},{dup:132}],352:[function(e,t,r){arguments[4][133][0].apply(r,arguments)},{"./array.js":351,dup:133}],353:[function(e,t,r){arguments[4][134][0].apply(r,arguments)},{dup:134}],354:[function(e,t,r){var n=e("bn.js"),i=e("./bytes"),o=function(e){return new n(e.slice(2),16)},a=function(e){var t="0x"+("0x"===e.slice(0,2)?new n(e.slice(2),16):new n(e,10)).toString("hex");return"0x0"===t?"0x":t},s=function(e){return"string"==typeof e?/^0x/.test(e)?e:"0x"+e:"0x"+new n(e).toString("hex")},u=function(e){return o(e).toNumber()},c=function(e){return function(t,r){return"0x"+o(t)[e](o(r)).toString("hex")}},f=c("add"),h=c("mul"),l=c("div"),d=c("sub");t.exports={toString:function(e){return o(e).toString(10)},fromString:a,toNumber:u,fromNumber:s,toEther:function(e){return u(l(e,a("10000000000")))/1e8},fromEther:function(e){return h(s(Math.floor(1e8*e)),a("10000000000"))},toUint256:function(e){return i.pad(32,e)},add:f,mul:h,div:l,sub:d}},{"./bytes":352,"bn.js":53}],355:[function(e,t,r){t.exports={encode:function(e){var t=function(e){return(t=e.toString(16)).length%2==0?t:"0"+t;var t},r=function(e,r){return e<56?t(r+e):t(r+t(e).length/2+55)+t(e)};return"0x"+function e(t){if("string"==typeof t){var n=t.slice(2);return(2!=n.length||n>="80"?r(n.length/2,128):"")+n}var i=t.map(e).join("");return r(i.length/2,192)+i}(e)},decode:function(e){var t=2,r=function(){if(t>=e.length)throw"";var r=e.slice(t,t+2);return r<"80"?(t+=2,"0x"+r):r<"c0"?i():o()},n=function(){var r=parseInt(e.slice(t,t+=2),16)%64;return r<56?r:parseInt(e.slice(t,t+=2*(r-55)),16)},i=function(){var r=n();return"0x"+e.slice(t,t+=2*r)},o=function(){for(var e=2*n()+t,i=[];t>>((3&t)<<3)&255;return i}}t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],357:[function(e,t,r){for(var n=e("./rng"),i=[],o={},a=0;a<256;a++)i[a]=(a+256).toString(16).substr(1),o[i[a]]=a;function s(e,t){var r=t||0,n=i;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var u=n(),c=[1|u[0],u[1],u[2],u[3],u[4],u[5]],f=16383&(u[6]<<8|u[7]),h=0,l=0;function d(e,t,r){var i=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||n)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var a=0;a<16;a++)t[i+a]=o[a];return t||s(o)}var p=d;p.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:f,a=void 0!==e.msecs?e.msecs:(new Date).getTime(),u=void 0!==e.nsecs?e.nsecs:l+1,d=a-h+(u-l)/1e4;if(d<0&&void 0===e.clockseq&&(o=o+1&16383),(d<0||a>h)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");h=a,l=u,f=o;var p=(1e4*(268435455&(a+=122192928e5))+u)%4294967296;i[n++]=p>>>24&255,i[n++]=p>>>16&255,i[n++]=p>>>8&255,i[n++]=255&p;var b=a/4294967296*1e4&268435455;i[n++]=b>>>8&255,i[n++]=255&b,i[n++]=b>>>24&15|16,i[n++]=b>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var y=e.node||c,m=0;m<6;m++)i[n+m]=y[m];return t||s(i)},p.v4=d,p.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=o[e])});i<16;)t[n+i++]=0;return t},p.unparse=s,t.exports=p},{"./rng":356}],358:[function(e,t,r){(function(r,n){"use strict";var i=e("underscore"),o=e("web3-core"),a=e("web3-core-method"),s=e("any-promise"),u=e("eth-lib/lib/account"),c=e("eth-lib/lib/hash"),f=e("eth-lib/lib/rlp"),h=e("eth-lib/lib/nat"),l=e("eth-lib/lib/bytes"),d=e(void 0===r?"crypto-browserify":"crypto"),p=e("scrypt.js"),b=e("uuid"),y=e("web3-utils"),m=e("web3-core-helpers"),v=function(e){return i.isUndefined(e)||i.isNull(e)},g=function(e){for(;e&&e.startsWith("0x0");)e="0x"+e.slice(3);return e},w=function(e){return e.length%2==1&&(e=e.replace("0x","0x0")),e},_=function(){var e=this;o.packageInit(this,arguments),delete this.BatchRequest,delete this.extend;var t=[new a({name:"getId",call:"net_version",params:0,outputFormatter:y.hexToNumber}),new a({name:"getGasPrice",call:"eth_gasPrice",params:0}),new a({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[function(e){if(y.isAddress(e))return e;throw new Error("Address "+e+' is not a valid address to get the "transactionCount".')},function(){return"latest"}]})];this._ethereumCall={},i.each(t,function(t){t.attachToObject(e._ethereumCall),t.setRequestManager(e._requestManager)}),this.wallet=new A(this)};function A(e){this._accounts=e,this.length=0,this.defaultKeyName="web3js_wallet"}_.prototype._addAccountFunctions=function(e){var t=this;return e.signTransaction=function(r,n){return t.signTransaction(r,e.privateKey,n)},e.sign=function(r){return t.sign(r,e.privateKey)},e.encrypt=function(r,n){return t.encrypt(e.privateKey,r,n)},e},_.prototype.create=function(e){return this._addAccountFunctions(u.create(e||y.randomHex(32)))},_.prototype.privateKeyToAccount=function(e){return this._addAccountFunctions(u.fromPrivate(e))},_.prototype.signTransaction=function(e,t,r){var n,o=!1;if(r=r||function(){},!e)return o=new Error("No transaction object given!"),r(o),s.reject(o);function a(e){if(e.gas||e.gasLimit||(o=new Error('"gas" is missing')),(e.nonce<0||e.gas<0||e.gasPrice<0||e.chainId<0)&&(o=new Error("Gas, gasPrice, nonce or chainId is lower than 0")),o)return r(o),s.reject(o);try{var i=e=m.formatters.inputCallFormatter(e);i.to=e.to||"0x",i.data=e.data||"0x",i.value=e.value||"0x",i.chainId=y.numberToHex(e.chainId);var a=f.encode([l.fromNat(i.nonce),l.fromNat(i.gasPrice),l.fromNat(i.gas),i.to.toLowerCase(),l.fromNat(i.value),i.data,l.fromNat(i.chainId||"0x1"),"0x","0x"]),d=c.keccak256(a),p=u.makeSigner(2*h.toNumber(i.chainId||"0x1")+35)(c.keccak256(a),t),b=f.decode(a).slice(0,6).concat(u.decodeSignature(p));b[6]=w(g(b[6])),b[7]=w(g(b[7])),b[8]=w(g(b[8]));var v=f.encode(b),_=f.decode(v);n={messageHash:d,v:g(_[6]),r:g(_[7]),s:g(_[8]),rawTransaction:v}}catch(e){return r(e),s.reject(e)}return r(null,n),n}return void 0!==e.nonce&&void 0!==e.chainId&&void 0!==e.gasPrice?s.resolve(a(e)):s.all([v(e.chainId)?this._ethereumCall.getId():e.chainId,v(e.gasPrice)?this._ethereumCall.getGasPrice():e.gasPrice,v(e.nonce)?this._ethereumCall.getTransactionCount(this.privateKeyToAccount(t).address):e.nonce]).then(function(t){if(v(t[0])||v(t[1])||v(t[2]))throw new Error('One of the values "chainId", "gasPrice", or "nonce" couldn\'t be fetched: '+JSON.stringify(t));return a(i.extend(e,{chainId:t[0],gasPrice:t[1],nonce:t[2]}))})},_.prototype.recoverTransaction=function(e){var t=f.decode(e),r=u.encodeSignature(t.slice(6,9)),n=l.toNumber(t[6]),i=n<35?[]:[l.fromNumber(n-35>>1),"0x","0x"],o=t.slice(0,6).concat(i),a=f.encode(o);return u.recover(c.keccak256(a),r)},_.prototype.hashMessage=function(e){var t=y.isHexStrict(e)?y.hexToBytes(e):e,r=n.from(t),i="Ethereum Signed Message:\n"+t.length,o=n.from(i),a=n.concat([o,r]);return c.keccak256s(a)},_.prototype.sign=function(e,t){var r=this.hashMessage(e),n=u.sign(r,t),i=u.decodeSignature(n);return{message:e,messageHash:r,v:i[0],r:i[1],s:i[2],signature:n}},_.prototype.recover=function(e,t,r){var n=[].slice.apply(arguments);return i.isObject(e)?this.recover(e.messageHash,u.encodeSignature([e.v,e.r,e.s]),!0):(r||(e=this.hashMessage(e)),n.length>=4?(r=n.slice(-1)[0],r=!!i.isBoolean(r)&&!!r,this.recover(e,u.encodeSignature(n.slice(1,4)),r)):u.recover(e,t))},_.prototype.decrypt=function(e,t,r){if(!i.isString(t))throw new Error("No password given.");var o,a,s=i.isObject(e)?e:JSON.parse(r?e.toLowerCase():e);if(3!==s.version)throw new Error("Not a valid V3 wallet");if("scrypt"===s.crypto.kdf)a=s.crypto.kdfparams,o=p(new n(t),new n(a.salt,"hex"),a.n,a.r,a.p,a.dklen);else{if("pbkdf2"!==s.crypto.kdf)throw new Error("Unsupported key derivation scheme");if("hmac-sha256"!==(a=s.crypto.kdfparams).prf)throw new Error("Unsupported parameters to PBKDF2");o=d.pbkdf2Sync(new n(t),new n(a.salt,"hex"),a.c,a.dklen,"sha256")}var u=new n(s.crypto.ciphertext,"hex");if(y.sha3(n.concat([o.slice(16,32),u])).replace("0x","")!==s.crypto.mac)throw new Error("Key derivation failed - possibly wrong password");var c=d.createDecipheriv(s.crypto.cipher,o.slice(0,16),new n(s.crypto.cipherparams.iv,"hex")),f="0x"+n.concat([c.update(u),c.final()]).toString("hex");return this.privateKeyToAccount(f)},_.prototype.encrypt=function(e,t,r){var i,o=this.privateKeyToAccount(e),a=(r=r||{}).salt||d.randomBytes(32),s=r.iv||d.randomBytes(16),u=r.kdf||"scrypt",c={dklen:r.dklen||32,salt:a.toString("hex")};if("pbkdf2"===u)c.c=r.c||262144,c.prf="hmac-sha256",i=d.pbkdf2Sync(new n(t),a,c.c,c.dklen,"sha256");else{if("scrypt"!==u)throw new Error("Unsupported kdf");c.n=r.n||8192,c.r=r.r||8,c.p=r.p||1,i=p(new n(t),a,c.n,c.r,c.p,c.dklen)}var f=d.createCipheriv(r.cipher||"aes-128-ctr",i.slice(0,16),s);if(!f)throw new Error("Unsupported cipher");var h=n.concat([f.update(new n(o.privateKey.replace("0x",""),"hex")),f.final()]),l=y.sha3(n.concat([i.slice(16,32),new n(h,"hex")])).replace("0x","");return{version:3,id:b.v4({random:r.uuid||d.randomBytes(16)}),address:o.address.toLowerCase().replace("0x",""),crypto:{ciphertext:h.toString("hex"),cipherparams:{iv:s.toString("hex")},cipher:r.cipher||"aes-128-ctr",kdf:u,kdfparams:c,mac:l.toString("hex")}}},A.prototype._findSafeIndex=function(e){return e=e||0,i.has(this,e)?this._findSafeIndex(e+1):e},A.prototype._currentIndexes=function(){return Object.keys(this).map(function(e){return parseInt(e)}).filter(function(e){return e<9e20})},A.prototype.create=function(e,t){for(var r=0;r=2?t.slice(2):t;var r=h.decodeParameters(e,t);return 1===r.__length__?r[0]:(delete r.__length__,r)},l.prototype.deploy=function(e,t){if((e=e||{}).arguments=e.arguments||[],!(e=this._getOrSetDefaultOptions(e)).data)return a._fireError(new Error('No "data" specified in neither the given options, nor the default options.'),null,null,t);var r=n.find(this.options.jsonInterface,function(e){return"constructor"===e.type})||{};return r.signature="constructor",this._createTxObject.apply({method:r,parent:this,deployData:e.data,_ethAccounts:this.constructor._ethAccounts},e.arguments)},l.prototype._generateEventOptions=function(){var e=Array.prototype.slice.call(arguments),t=this._getCallback(e),r=n.isObject(e[e.length-1])?e.pop():{},i=n.isString(e[0])?e[0]:"allevents";if(!(i="allevents"===i.toLowerCase()?{name:"ALLEVENTS",jsonInterface:this.options.jsonInterface}:this.options.jsonInterface.find(function(e){return"event"===e.type&&(e.name===i||e.signature==="0x"+i.replace("0x",""))})))throw new Error('Event "'+i.name+"\" doesn't exist in this contract.");if(!a.isAddress(this.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return{params:this._encodeEventABI(i,r),event:i,callback:t}},l.prototype.clone=function(){return new this.constructor(this.options.jsonInterface,this.options.address,this.options)},l.prototype.once=function(e,t,r){var i=Array.prototype.slice.call(arguments);if(!(r=this._getCallback(i)))throw new Error("Once requires a callback as the second parameter.");t&&delete t.fromBlock,this._on(e,t,function(e,t,i){i.unsubscribe(),n.isFunction(r)&&r(e,t,i)})},l.prototype._on=function(){var e=this._generateEventOptions.apply(this,arguments);this._checkListener("newListener",e.event.name,e.callback),this._checkListener("removeListener",e.event.name,e.callback);var t=new s({subscription:{params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event),subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},type:"eth",requestManager:this._requestManager});return t.subscribe("logs",e.params,e.callback||function(){}),t},l.prototype.getPastEvents=function(){var e=this._generateEventOptions.apply(this,arguments),t=new o({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event)});t.setRequestManager(this._requestManager);var r=t.buildCall();return t=null,r(e.params,e.callback)},l.prototype._createTxObject=function(){var e=Array.prototype.slice.call(arguments),t={};if("function"===this.method.type&&(t.call=this.parent._executeMethod.bind(t,"call"),t.call.request=this.parent._executeMethod.bind(t,"call",!0)),t.send=this.parent._executeMethod.bind(t,"send"),t.send.request=this.parent._executeMethod.bind(t,"send",!0),t.encodeABI=this.parent._encodeMethodABI.bind(t),t.estimateGas=this.parent._executeMethod.bind(t,"estimate"),e&&this.method.inputs&&e.length!==this.method.inputs.length){if(this.nextMethod)return this.nextMethod.apply(null,e);throw c.InvalidNumberOfParams(e.length,this.method.inputs.length,this.method.name)}return t.arguments=e||[],t._method=this.method,t._parent=this.parent,t._ethAccounts=this.parent.constructor._ethAccounts||this._ethAccounts,this.deployData&&(t._deployData=this.deployData),t},l.prototype._processExecuteArguments=function(e,t){var r={};if(r.type=e.shift(),r.callback=this._parent._getCallback(e),"call"===r.type&&!0!==e[e.length-1]&&(n.isString(e[e.length-1])||isFinite(e[e.length-1]))&&(r.defaultBlock=e.pop()),r.options=n.isObject(e[e.length-1])?e.pop():{},r.generateRequest=!0===e[e.length-1]&&e.pop(),r.options=this._parent._getOrSetDefaultOptions(r.options),r.options.data=this.encodeABI(),!this._deployData&&!a.isAddress(this._parent.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return this._deployData||(r.options.to=this._parent.options.address),r.options.data?r:a._fireError(new Error("Couldn't find a matching contract method, or the number of parameters is wrong."),t.eventEmitter,t.reject,r.callback)},l.prototype._executeMethod=function(){var e=this,t=this._parent._processExecuteArguments.call(this,Array.prototype.slice.call(arguments),r),r=f("send"!==t.type),i=e.constructor._ethAccounts||e._ethAccounts;if(t.generateRequest){var s={params:[u.inputCallFormatter.call(this._parent,t.options)],callback:t.callback};return"call"===t.type?(s.params.push(u.inputDefaultBlockNumberFormatter.call(this._parent,t.defaultBlock)),s.method="eth_call",s.format=this._parent._decodeMethodReturn.bind(null,this._method.outputs)):s.method="eth_sendTransaction",s}switch(t.type){case"estimate":return new o({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[u.inputCallFormatter],outputFormatter:a.hexToNumber,requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.callback);case"call":return new o({name:"call",call:"eth_call",params:2,inputFormatter:[u.inputCallFormatter,u.inputDefaultBlockNumberFormatter],outputFormatter:function(t){return e._parent._decodeMethodReturn(e._method.outputs,t)},requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.defaultBlock,t.callback);case"send":if(!a.isAddress(t.options.from))return a._fireError(new Error('No "from" address specified in neither the given options, nor the default options.'),r.eventEmitter,r.reject,t.callback);if(n.isBoolean(this._method.payable)&&!this._method.payable&&t.options.value&&t.options.value>0)return a._fireError(new Error("Can not send value to non-payable contract method or constructor"),r.eventEmitter,r.reject,t.callback);var c={receiptFormatter:function(t){if(n.isArray(t.logs)){var r=n.map(t.logs,function(t){return e._parent._decodeEventABI.call({name:"ALLEVENTS",jsonInterface:e._parent.options.jsonInterface},t)});t.events={};var i=0;r.forEach(function(e){e.event?t.events[e.event]?Array.isArray(t.events[e.event])?t.events[e.event].push(e):t.events[e.event]=[t.events[e.event],e]:t.events[e.event]=e:(t.events[i]=e,i++)}),delete t.logs}return t},contractDeployFormatter:function(t){var r=e._parent.clone();return r.options.address=t.contractAddress,r}};return new o({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[u.inputTransactionFormatter],requestManager:e._parent._requestManager,accounts:e.constructor._ethAccounts||e._ethAccounts,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock,extraFormatters:c}).createFunction()(t.options,t.callback)}},t.exports=l},{underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-utils":403}],360:[function(e,t,r){"use strict";var n=e("./config"),i=e("./contracts/Registry"),o=e("./lib/ResolverMethodHandler");function a(e){this.eth=e}Object.defineProperty(a.prototype,"registry",{get:function(){return new i(this)},enumerable:!0}),Object.defineProperty(a.prototype,"resolverMethodHandler",{get:function(){return new o(this.registry)},enumerable:!0}),a.prototype.resolver=function(e){return this.registry.resolver(e)},a.prototype.getAddress=function(e,t){return this.resolverMethodHandler.method(e,"addr",[]).call(t)},a.prototype.setAddress=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setAddr",[t]).send(r,n)},a.prototype.getPubkey=function(e,t){return this.resolverMethodHandler.method(e,"pubkey",[],t).call(t)},a.prototype.setPubkey=function(e,t,r,n,i){return this.resolverMethodHandler.method(e,"setPubkey",[t,r]).send(n,i)},a.prototype.getContent=function(e,t){return this.resolverMethodHandler.method(e,"content",[]).call(t)},a.prototype.setContent=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setContent",[t]).send(r,n)},a.prototype.getMultihash=function(e,t){return this.resolverMethodHandler.method(e,"multihash",[]).call(t)},a.prototype.setMultihash=function(e,t,r,n){return this.resolverMethodHandler.method(e,"multihash",[t]).send(r,n)},a.prototype.checkNetwork=function(){var e=this;return e.eth.getBlock("latest").then(function(t){var r=new Date/1e3-t.timestamp;if(r>3600)throw new Error("Network not synced; last block was "+r+" seconds ago");return e.eth.net.getNetworkType()}).then(function(e){var t=n.addresses[e];if(void 0===t)throw new Error("ENS is not supported on network "+e);return t})},t.exports=a},{"./config":361,"./contracts/Registry":362,"./lib/ResolverMethodHandler":364}],361:[function(e,t,r){"use strict";t.exports={addresses:{main:"0x314159265dD8dbb310642f98f50C066173C1259b",ropsten:"0x112234455c3a32fd11230c42e7bccd4a84e02010",rinkeby:"0xe7410170f87102df0055eb195163a03b7f2bff4a"}}},{}],362:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-eth-contract"),o=e("eth-ens-namehash"),a=e("web3-core-promievent"),s=e("../ressources/ABI/Registry"),u=e("../ressources/ABI/Resolver");function c(e){var t=this;this.ens=e,this.contract=e.checkNetwork().then(function(e){var r=new i(s,e);return r.setProvider(t.ens.eth.currentProvider),r})}c.prototype.owner=function(e,t){var r=new a(!0);return this.contract.then(function(i){i.methods.owner(o.hash(e)).call().then(function(e){r.resolve(e),n.isFunction(t)&&t(e)}).catch(function(e){r.reject(e),n.isFunction(t)&&t(e)})}),r.eventEmitter},c.prototype.resolver=function(e){var t=this;return this.contract.then(function(t){return t.methods.resolver(o.hash(e)).call()}).then(function(e){var r=new i(u,e);return r.setProvider(t.ens.eth.currentProvider),r})},t.exports=c},{"../ressources/ABI/Registry":365,"../ressources/ABI/Resolver":366,"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340,"web3-eth-contract":359}],363:[function(e,t,r){"use strict";var n=e("./ENS");t.exports=n},{"./ENS":360}],364:[function(e,t,r){"use strict";var n=e("web3-core-promievent"),i=e("eth-ens-namehash"),o=e("underscore");function a(e){this.registry=e}a.prototype.method=function(e,t,r,n){return{call:this.call.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this}),send:this.send.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this})}},a.prototype.call=function(e){var t=this,r=new n,i=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){t.parent.handleCall(r,n.methods[t.methodName],i,e)}).catch(function(e){r.reject(e)}),r.eventEmitter},a.prototype.send=function(e,t){var r=this,i=new n,o=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){r.parent.handleSend(i,n.methods[r.methodName],o,e,t)}).catch(function(e){i.reject(e)}),i.eventEmitter},a.prototype.handleCall=function(e,t,r,n){return t.apply(this,r).call().then(function(t){e.resolve(t),o.isFunction(n)&&n(t)}).catch(function(t){e.reject(t),o.isFunction(n)&&n(t)}),e},a.prototype.handleSend=function(e,t,r,n,i){return t.apply(this,r).send(n).on("transactionHash",function(t){e.eventEmitter.emit("transactionHash",t)}).on("confirmation",function(t,r){e.eventEmitter.emit("confirmation",t,r)}).on("receipt",function(t){e.eventEmitter.emit("receipt",t),e.resolve(t),o.isFunction(i)&&i(t)}).on("error",function(t){e.eventEmitter.emit("error",t),e.reject(t),o.isFunction(i)&&i(t)}),e},a.prototype.prepareArguments=function(e,t){var r=i.hash(e);return t.length>0?(t.unshift(r),t):[r]},t.exports=a},{"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340}],365:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"resolver",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"owner",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"label",type:"bytes32"},{name:"owner",type:"address"}],name:"setSubnodeOwner",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"ttl",type:"uint64"}],name:"setTTL",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"ttl",outputs:[{name:"",type:"uint64"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"resolver",type:"address"}],name:"setResolver",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"owner",type:"address"}],name:"setOwner",outputs:[],payable:!1,type:"function"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"label",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"NewOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"resolver",type:"address"}],name:"NewResolver",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"ttl",type:"uint64"}],name:"NewTTL",type:"event"}]},{}],366:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"interfaceID",type:"bytes4"}],name:"supportsInterface",outputs:[{name:"",type:"bool"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"},{name:"contentTypes",type:"uint256"}],name:"ABI",outputs:[{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes"}],name:"setMultihash",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"multihash",outputs:[{name:"",type:"bytes"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"setPubkey",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"content",outputs:[{name:"ret",type:"bytes32"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"addr",outputs:[{name:"ret",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],name:"setABI",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"name",outputs:[{name:"ret",type:"string"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"name",type:"string"}],name:"setName",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes32"}],name:"setContent",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"pubkey",outputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"addr",type:"address"}],name:"setAddr",outputs:[],payable:!1,type:"function"},{inputs:[{name:"ensAddr",type:"address"}],payable:!1,type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"a",type:"address"}],name:"AddrChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"hash",type:"bytes32"}],name:"ContentChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"name",type:"string"}],name:"NameChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"contentType",type:"uint256"}],name:"ABIChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"x",type:"bytes32"},{indexed:!1,name:"y",type:"bytes32"}],name:"PubkeyChanged",type:"event"}]},{}],367:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],368:[function(e,t,r){"use strict";var n=e("web3-utils"),i=e("bn.js"),o=function(e){var t="A".charCodeAt(0),r="Z".charCodeAt(0);return(e=(e=e.toUpperCase()).substr(4)+e.substr(0,4)).split("").map(function(e){var n=e.charCodeAt(0);return n>=t&&n<=r?n-t+10:e}).join("")},a=function(e){for(var t,r=e;r.length>2;)t=r.slice(0,9),r=parseInt(t,10)%97+r.slice(t.length);return parseInt(r,10)%97},s=function(e){this._iban=e};s.toAddress=function(e){if(!(e=new s(e)).isDirect())throw new Error("IBAN is indirect and can't be converted");return e.toAddress()},s.toIban=function(e){return s.fromAddress(e).toString()},s.fromAddress=function(e){if(!n.isAddress(e))throw new Error("Provided address is not a valid address: "+e);e=e.replace("0x","").replace("0X","");var t=function(e,t){for(var r=e;r.length<2*t;)r="0"+r;return r}(new i(e,16).toString(36),15);return s.fromBban(t.toUpperCase())},s.fromBban=function(e){var t=("0"+(98-a(o("XE00"+e)))).slice(-2);return new s("XE"+t+e)},s.createIndirect=function(e){return s.fromBban("ETH"+e.institution+e.identifier)},s.isValid=function(e){return new s(e).isValid()},s.prototype.isValid=function(){return/^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban)&&1===a(o(this._iban))},s.prototype.isDirect=function(){return 34===this._iban.length||35===this._iban.length},s.prototype.isIndirect=function(){return 20===this._iban.length},s.prototype.checksum=function(){return this._iban.substr(2,2)},s.prototype.institution=function(){return this.isIndirect()?this._iban.substr(7,4):""},s.prototype.client=function(){return this.isIndirect()?this._iban.substr(11):""},s.prototype.toAddress=function(){if(this.isDirect()){var e=this._iban.substr(4),t=new i(e,36);return n.toChecksumAddress(t.toString(16,20))}return""},s.prototype.toString=function(){return this._iban},t.exports=s},{"bn.js":367,"web3-utils":403}],369:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=e("web3-net"),s=e("web3-core-helpers").formatters,u=function(){var e=this;n.packageInit(this,arguments),this.net=new a(this.currentProvider);var t=null,r="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return t},set:function(e){return e&&(t=o.toChecksumAddress(s.inputAddressFormatter(e))),u.forEach(function(e){e.defaultAccount=t}),e},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return r},set:function(e){return r=e,u.forEach(function(e){e.defaultBlock=r}),e},enumerable:!0});var u=[new i({name:"getAccounts",call:"personal_listAccounts",params:0,outputFormatter:o.toChecksumAddress}),new i({name:"newAccount",call:"personal_newAccount",params:1,inputFormatter:[null],outputFormatter:o.toChecksumAddress}),new i({name:"unlockAccount",call:"personal_unlockAccount",params:3,inputFormatter:[s.inputAddressFormatter,null,null]}),new i({name:"lockAccount",call:"personal_lockAccount",params:1,inputFormatter:[s.inputAddressFormatter]}),new i({name:"importRawKey",call:"personal_importRawKey",params:2}),new i({name:"sendTransaction",call:"personal_sendTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"signTransaction",call:"personal_signTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"sign",call:"personal_sign",params:3,inputFormatter:[s.inputSignFormatter,s.inputAddressFormatter,null]}),new i({name:"ecRecover",call:"personal_ecRecover",params:2,inputFormatter:[s.inputSignFormatter,null]})];u.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};n.addProviders(u),t.exports=u},{"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-net":372,"web3-utils":403}],370:[function(e,t,r){"use strict";var n=e("underscore");t.exports=function(e){var t,r=this;return this.net.getId().then(function(e){return t=e,r.getBlock(0)}).then(function(r){var i="private";return"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"===r.hash&&1===t&&(i="main"),"0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303"===r.hash&&2===t&&(i="morden"),"0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"===r.hash&&3===t&&(i="ropsten"),"0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177"===r.hash&&4===t&&(i="rinkeby"),"0xa3c565fc15c7478862d50ccd6561e3c06b24cc509bf388941c25ea985ce32cb9"===r.hash&&42===t&&(i="kovan"),n.isFunction(e)&&e(null,i),i}).catch(function(t){if(!n.isFunction(e))throw t;e(t)})}},{underscore:325}],371:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core"),o=e("web3-core-helpers"),a=e("web3-core-subscriptions").subscriptions,s=e("web3-core-method"),u=e("web3-utils"),c=e("web3-net"),f=e("web3-eth-ens"),h=e("web3-eth-personal"),l=e("web3-eth-contract"),d=e("web3-eth-iban"),p=e("web3-eth-accounts"),b=e("web3-eth-abi"),y=e("./getNetworkType.js"),m=o.formatters,v=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},g=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},w=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},_=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},A=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"},E=function(){var e=this;i.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments),e.personal.setProvider.apply(e,arguments),e.accounts.setProvider.apply(e,arguments),e.Contract.setProvider(e.currentProvider,e.accounts)};var r=null,o="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return r},set:function(t){return t&&(r=u.toChecksumAddress(m.inputAddressFormatter(t))),e.Contract.defaultAccount=r,e.personal.defaultAccount=r,k.forEach(function(e){e.defaultAccount=r}),t},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return o},set:function(t){return o=t,e.Contract.defaultBlock=o,e.personal.defaultBlock=o,k.forEach(function(e){e.defaultBlock=o}),t},enumerable:!0}),this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new c(this.currentProvider),this.net.getNetworkType=y.bind(this),this.accounts=new p(this.currentProvider),this.personal=new h(this.currentProvider),this.personal.defaultAccount=this.defaultAccount;var E=this,x=function(){l.apply(this,arguments);var e=this,t=E.setProvider;E.setProvider=function(){t.apply(E,arguments),i.packageInit(e,[E.currentProvider])}};x.setProvider=function(){l.setProvider.apply(this,arguments)},(x.prototype=Object.create(l.prototype)).constructor=x,this.Contract=x,this.Contract.defaultAccount=this.defaultAccount,this.Contract.defaultBlock=this.defaultBlock,this.Contract.setProvider(this.currentProvider,this.accounts),this.Iban=d,this.abi=b,this.ens=new f(this);var k=[new s({name:"getNodeInfo",call:"web3_clientVersion"}),new s({name:"getProtocolVersion",call:"eth_protocolVersion",params:0}),new s({name:"getCoinbase",call:"eth_coinbase",params:0}),new s({name:"isMining",call:"eth_mining",params:0}),new s({name:"getHashrate",call:"eth_hashrate",params:0,outputFormatter:u.hexToNumber}),new s({name:"isSyncing",call:"eth_syncing",params:0,outputFormatter:m.outputSyncingFormatter}),new s({name:"getGasPrice",call:"eth_gasPrice",params:0,outputFormatter:m.outputBigNumberFormatter}),new s({name:"getAccounts",call:"eth_accounts",params:0,outputFormatter:u.toChecksumAddress}),new s({name:"getBlockNumber",call:"eth_blockNumber",params:0,outputFormatter:u.hexToNumber}),new s({name:"getBalance",call:"eth_getBalance",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:m.outputBigNumberFormatter}),new s({name:"getStorageAt",call:"eth_getStorageAt",params:3,inputFormatter:[m.inputAddressFormatter,u.numberToHex,m.inputDefaultBlockNumberFormatter]}),new s({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"getBlock",call:v,params:2,inputFormatter:[m.inputBlockNumberFormatter,function(e){return!!e}],outputFormatter:m.outputBlockFormatter}),new s({name:"getUncle",call:w,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputBlockFormatter}),new s({name:"getBlockTransactionCount",call:_,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getBlockUncleCount",call:A,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getTransaction",call:"eth_getTransactionByHash",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionFromBlock",call:g,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionReceiptFormatter}),new s({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"sendSignedTransaction",call:"eth_sendRawTransaction",params:1,inputFormatter:[null]}),new s({name:"signTransaction",call:"eth_signTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sign",call:"eth_sign",params:2,inputFormatter:[m.inputSignFormatter,m.inputAddressFormatter],transformPayload:function(e){return e.params.reverse(),e}}),new s({name:"call",call:"eth_call",params:2,inputFormatter:[m.inputCallFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[m.inputCallFormatter],outputFormatter:u.hexToNumber}),new s({name:"submitWork",call:"eth_submitWork",params:3}),new s({name:"getWork",call:"eth_getWork",params:0}),new s({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter}),new a({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:m.outputBlockFormatter},pendingTransactions:{subscriptionName:"newPendingTransactions",params:0},logs:{params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter,subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},syncing:{params:0,outputFormatter:m.outputSyncingFormatter,subscriptionHandler:function(e){var t=this;!0!==this._isSyncing?(this._isSyncing=!0,this.emit("changed",t._isSyncing),n.isFunction(this.callback)&&this.callback(null,t._isSyncing,this),setTimeout(function(){t.emit("data",e),n.isFunction(t.callback)&&t.callback(null,e,t)},0)):(this.emit("data",e),n.isFunction(t.callback)&&this.callback(null,e,this),clearTimeout(this._isSyncingTimeout),this._isSyncingTimeout=setTimeout(function(){e.currentBlock>e.highestBlock-200&&(t._isSyncing=!1,t.emit("changed",t._isSyncing),n.isFunction(t.callback)&&t.callback(null,t._isSyncing,t))},500))}}}})];k.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager,e.accounts),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};i.addProviders(E),t.exports=E},{"./getNetworkType.js":370,underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-eth-accounts":358,"web3-eth-contract":359,"web3-eth-ens":363,"web3-eth-iban":368,"web3-eth-personal":369,"web3-net":372,"web3-utils":403}],372:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=function(){var e=this;n.packageInit(this,arguments),[new i({name:"getId",call:"net_version",params:0,outputFormatter:o.hexToNumber}),new i({name:"isListening",call:"net_listening",params:0}),new i({name:"getPeerCount",call:"net_peerCount",params:0,outputFormatter:o.hexToNumber})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(a),t.exports=a},{"web3-core":348,"web3-core-method":339,"web3-utils":403}],373:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits,o=e("ethereumjs-util"),a=e("eth-block-tracker"),s=e("async/map"),u=e("async/eachSeries"),c=e("./util/stoplight.js");e("./util/rpc-cache-utils.js"),e("./util/create-payload.js");function f(e){const t=this;n.call(t),t.setMaxListeners(30),e=e||{};const r={sendAsync:t._handleAsync.bind(t)},i=e.blockTrackerProvider||r;t._blockTracker=e.blockTracker||new a({provider:i,pollingInterval:e.pollingInterval||4e3}),t._blockTracker.on("block",e=>{const r=function(e){return{number:o.toBuffer(e.number),hash:o.toBuffer(e.hash),parentHash:o.toBuffer(e.parentHash),nonce:o.toBuffer(e.nonce),mixHash:o.toBuffer(e.mixHash),sha3Uncles:o.toBuffer(e.sha3Uncles),logsBloom:o.toBuffer(e.logsBloom),transactionsRoot:o.toBuffer(e.transactionsRoot),stateRoot:o.toBuffer(e.stateRoot),receiptsRoot:o.toBuffer(e.receiptRoot||e.receiptsRoot),miner:o.toBuffer(e.miner),difficulty:o.toBuffer(e.difficulty),totalDifficulty:o.toBuffer(e.totalDifficulty),size:o.toBuffer(e.size),extraData:o.toBuffer(e.extraData),gasLimit:o.toBuffer(e.gasLimit),gasUsed:o.toBuffer(e.gasUsed),timestamp:o.toBuffer(e.timestamp),transactions:e.transactions}}(e);t._setCurrentBlock(r)}),t._blockTracker.on("block",t.emit.bind(t,"rawBlock")),t._blockTracker.on("sync",t.emit.bind(t,"sync")),t._blockTracker.on("latest",t.emit.bind(t,"latest")),t._ready=new c,t._blockTracker.once("block",()=>{t._ready.go()}),t.currentBlock=null,t._providers=[]}t.exports=f,i(f,n),f.prototype.start=function(e=function(){}){this._blockTracker.start().then(e).catch(e)},f.prototype.stop=function(){this._blockTracker.stop()},f.prototype.addProvider=function(e){this._providers.push(e),e.setEngine(this)},f.prototype.send=function(e){throw new Error("Web3ProviderEngine does not support synchronous requests.")},f.prototype.sendAsync=function(e,t){const r=this;r._ready.await(function(){Array.isArray(e)?s(e,r._handleAsync.bind(r),t):r._handleAsync(e,t)})},f.prototype._handleAsync=function(e,t){var r=this,n=-1,i=null,o=null,a=[];function s(r,n){o=r,i=n,u(a,function(e,t){e?e(o,i,t):t()},function(){var r={id:e.id,jsonrpc:e.jsonrpc,result:i};null!=o?(r.error={message:o.stack||o.message||o,code:-32e3},t(o,r)):t(null,r)})}!function t(i){n+=1;a.unshift(i);if(n>=r._providers.length)s(new Error('Request for method "'+e.method+'" not handled by any subprovider. Please check your subprovider configuration to ensure this method is handled.'));else try{var o=r._providers[n];o.handleRequest(e,t,s)}catch(e){s(e)}}()},f.prototype._setCurrentBlock=function(e){this.currentBlock=e,this.emit("block",e)}},{"./util/create-payload.js":391,"./util/rpc-cache-utils.js":394,"./util/stoplight.js":396,"async/eachSeries":25,"async/map":41,"eth-block-tracker":126,"ethereumjs-util":141,events:157,util:333}],374:[function(e,t,r){var n="undefined"!=typeof JSON?JSON:e("jsonify");t.exports=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var r=t.space||"";"number"==typeof r&&(r=Array(r+1).join(" "));var a,s="boolean"==typeof t.cycles&&t.cycles,u=t.replacer||function(e,t){return t},c=t.cmp&&(a=t.cmp,function(e){return function(t,r){var n={key:t,value:e[t]},i={key:r,value:e[r]};return a(n,i)}}),f=[];return function e(t,a,h,l){var d=r?"\n"+new Array(l+1).join(r):"",p=r?": ":":";if(h&&h.toJSON&&"function"==typeof h.toJSON&&(h=h.toJSON()),void 0!==(h=u.call(t,a,h))){if("object"!=typeof h||null===h)return n.stringify(h);if(i(h)){for(var b=[],y=0;y dist/ProviderEngine.js","bundle-zero":"browserify -s ZeroClientProvider -e zero.js -t [ babelify --presets [ es2015 ] ] > dist/ZeroClientProvider.js",prepublish:"npm run build && npm run bundle",test:"node test/index.js"},version:"14.1.0"}},{}],376:[function(e,t,r){const n=e("util").inherits,i=e("ethereumjs-util"),o=i.BN,a=e("clone"),s=e("../util/rpc-cache-utils.js"),u=e("../util/stoplight.js"),c=e("./subprovider.js");function f(e){e=e||{},this._ready=new u,this.strategies={perma:new l({eth_getTransactionByHash:p,eth_getTransactionReceipt:p}),block:new d(this),fork:new d(this)}}function h(){var e=this;e.cache={};var t=setInterval(function(){e.cache={}},6e5);t.unref&&t.unref()}function l(e){this.strategy=new h,this.conditionals=e}function d(){this.cache={}}function p(e){if(!e)return!1;if(!e.blockHash)return!1;var t;return(t=e.blockHash,new o(i.toBuffer(t))).gt(new o(0))}t.exports=f,n(f,c),f.prototype.setEngine=function(e){const t=this;function r(e){var r=t.currentBlock;t.currentBlock=e,r&&(t.strategies.block.cacheRollOff(r),t.strategies.fork.cacheRollOff(r))}t.engine=e,e.once("block",function(n){t.currentBlock=n,t._ready.go(),e.on("block",r)})},f.prototype.handleRequest=function(e,t,r){const n=this;return e.skipCache?t():"eth_getBlockByNumber"===e.method&&"latest"===e.params[0]?t():void n._ready.await(function(){n._handleRequest(e,t,r)})},f.prototype._handleRequest=function(e,t,r){const n=this;var o=s.cacheTypeForPayload(e),a=this.strategies[o];if(!a)return t();if(!a.canCache(e))return t();var u,c=s.blockTagForPayload(e);c||(c="latest"),u="earliest"===c?"0x00":"latest"===c?i.bufferToHex(n.currentBlock.number):c,a.hitCheck(e,u,r,function(){t(function(t,r,n){if(t)return n();a.cacheResult(e,r,u,n)})})},h.prototype.hitCheck=function(e,t,r,n){var i,o,u,c,f=s.cacheIdentifierForPayload(e),h=this.cache[f];return h&&(i=t,o=h.blockNumber,u=parseInt(i,16),c=parseInt(o,16),(u===c?0:u>c?1:-1)>=0)?r(null,a(h.result)):n()},h.prototype.cacheResult=function(e,t,r,n){var i=s.cacheIdentifierForPayload(e);if(t){var o=a(t);this.cache[i]={blockNumber:r,result:o}}n()},h.prototype.canCache=function(e){return s.canCache(e)},l.prototype.hitCheck=function(e,t,r,n){return this.strategy.hitCheck(e,t,r,n)},l.prototype.cacheResult=function(e,t,r,n){var i=this.conditionals[e.method];i?i(t)?this.strategy.cacheResult(e,t,r,n):n():this.strategy.cacheResult(e,t,r,n)},l.prototype.canCache=function(e){return this.strategy.canCache(e)},d.prototype.getBlockCacheForPayload=function(e,t){const r=Number.parseInt(t,16);let n=this.cache[r];if(!n){const e={};this.cache[r]=e,n=e}return n},d.prototype.hitCheck=function(e,t,r,n){var i=this.getBlockCacheForPayload(e,t);if(!i)return n();var o=i[s.cacheIdentifierForPayload(e)];return o?r(null,o):n()},d.prototype.cacheResult=function(e,t,r,n){t&&(this.getBlockCacheForPayload(e,r)[s.cacheIdentifierForPayload(e)]=t);n()},d.prototype.canCache=function(e){return!!s.canCache(e)&&"pending"!==s.blockTagForPayload(e)},d.prototype.cacheRollOff=function(e){const t=this,r=i.bufferToHex(e.number),n=Number.parseInt(r,16);Object.keys(t.cache).map(Number).filter(e=>e<=n).forEach(e=>delete t.cache[e])}},{"../util/rpc-cache-utils.js":394,"../util/stoplight.js":396,"./subprovider.js":387,clone:87,"ethereumjs-util":141,util:333}],377:[function(e,t,r){const n=e("util").inherits,i=e("xtend"),o=e("./fixture.js"),a=e("../package.json").version;function s(e){var t=i({web3_clientVersion:"ProviderEngine/v"+a+"/javascript",net_listening:!0,eth_hashrate:"0x00",eth_mining:!1},e=e||{});o.call(this,t)}t.exports=s,n(s,o)},{"../package.json":375,"./fixture.js":380,util:333,xtend:423}],378:[function(e,t,r){const n=e("cross-fetch"),i=e("util").inherits,o=e("async/retry"),a=e("async/waterfall"),s=e("async/asyncify"),u=e("json-rpc-error"),c=e("promise-to-callback"),f=e("../util/create-payload.js"),h=e("./subprovider.js"),l=["Gateway timeout","ETIMEDOUT","SyntaxError"];function d(e){this.rpcUrl=e.rpcUrl,this.originHttpHeaderKey=e.originHttpHeaderKey}function p(e){const t=e.toString();return l.some(e=>t.includes(e))}t.exports=d,i(d,h),d.prototype.handleRequest=function(e,t,r){const n=this,i=e.origin,a=f(e);delete a.origin;const s={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(a)};n.originHttpHeaderKey&&i&&(s.headers[n.originHttpHeaderKey]=i),o({times:5,interval:1e3,errorFilter:p},e=>n._submitRequest(s,e),(e,t)=>{if(e&&p(e)){const t=`FetchSubprovider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,n=new Error(t);return r(n)}return r(e,t)})},d.prototype._submitRequest=function(e,t){const r=this.rpcUrl;c(n(r,e))((e,r)=>{if(e)return t(e);a([function(e){switch(r.status){case 405:return e(new u.MethodNotFound);case 418:return e(function(){const e=new Error("Request is being rate limited.");return new u.InternalError(e)}());case 503:case 504:return e(function(){let e="Gateway timeout. The request took too long to process. ";const t=new Error(e+="This can happen when querying logs over too wide a block range.");return new u.InternalError(t)}());default:return e()}},e=>c(r.text())(e),s(e=>JSON.parse(e)),function(e,t){if(200!==r.status)return t(new u.InternalError(e));if(e.error)return t(new u.InternalError(e.error));t(null,e.result)}],t)})}},{"../util/create-payload.js":391,"./subprovider.js":387,"async/asyncify":20,"async/retry":43,"async/waterfall":44,"cross-fetch":96,"json-rpc-error":189,"promise-to-callback":258,util:333}],379:[function(e,t,r){const n=e("async"),i=e("util").inherits,o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/stoplight.js"),u=e("events").EventEmitter;function c(e){e=e||{};const t=this;t.filterIndex=0,t.filters={},t.filterDestroyHandlers={},t.asyncBlockHandlers={},t.asyncPendingBlockHandlers={},t._ready=new s,t._ready.setMaxListeners(e.maxFilters||25),t._ready.go(),t.pendingBlockTimeout=e.pendingBlockTimeout||4e3,t.checkForPendingBlocksActive=!1,setTimeout(function(){t.engine.on("block",function(e){t._ready.stop();var r=v(t.asyncBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,function(e){e&&console.error(e),t._ready.go()})})})}function f(e){u.apply(this),this.type="block",this.engine=e.engine,this.blockNumber=e.blockNumber,this.updates=[]}function h(e){u.apply(this),this.type="log",this.fromBlock=void 0!==e.fromBlock?e.fromBlock:"latest",this.toBlock=void 0!==e.toBlock?e.toBlock:"latest";var t=e.address&&(Array.isArray(e.address)?e.address:[e.address]);this.address=t&&t.map(d),this.topics=e.topics||[],this.updates=[],this.allResults=[]}function l(){u.apply(this),this.type="pendingTx",this.updates=[],this.allResults=[]}function d(e){return"0x"===e.slice(0,2)?e:"0x"+e}function p(e){return o.intToHex(e)}function b(e){return Number(e)}function y(e){return function(e){let t=o.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}(e.toString("hex"))}function m(e){return e&&-1===["earliest","latest","pending"].indexOf(e)}function v(e){return Object.keys(e).map(function(t){return e[t]})}t.exports=c,i(c,a),c.prototype.handleRequest=function(e,t,r){const n=this;switch(e.method){case"eth_newBlockFilter":return void n.newBlockFilter(r);case"eth_newPendingTransactionFilter":return n.newPendingTransactionFilter(r),void n.checkForPendingBlocks();case"eth_newFilter":return void n.newLogFilter(e.params[0],r);case"eth_getFilterChanges":return void n._ready.await(function(){n.getFilterChanges(e.params[0],r)});case"eth_getFilterLogs":return void n._ready.await(function(){n.getFilterLogs(e.params[0],r)});case"eth_uninstallFilter":return void n._ready.await(function(){n.uninstallFilter(e.params[0],r)});default:return void t()}},c.prototype.newBlockFilter=function(e){const t=this;t._getBlockNumber(function(r,n){if(r)return e(r);var i=new f({blockNumber:n}),o=i.update.bind(i);t.engine.on("block",o);t.filterIndex++,t.filters[t.filterIndex]=i,t.filterDestroyHandlers[t.filterIndex]=function(){t.engine.removeListener("block",o)};var a=p(t.filterIndex);e(null,a)})},c.prototype.newLogFilter=function(e,t){const r=this;r._getBlockNumber(function(n,i){if(n)return t(n);var o=new h(e),a=o.update.bind(o);r.filterIndex++,r.asyncBlockHandlers[r.filterIndex]=function(e,t){r._logsForBlock(e,function(e,r){if(e)return t(e);a(r),t()})},r.filters[r.filterIndex]=o;var s=p(r.filterIndex);t(null,s)})},c.prototype.newPendingTransactionFilter=function(e){const t=this;var r=new l,n=r.update.bind(r);t.filterIndex++,t.asyncPendingBlockHandlers[t.filterIndex]=function(e,r){t._txHashesForBlock(e,function(e,t){if(e)return r(e);n(t),r()})},t.filters[t.filterIndex]=r,e(null,p(t.filterIndex))},c.prototype.getFilterChanges=function(e,t){var r=Number.parseInt(e,16),n=this.filters[r];if(n||console.warn("FilterSubprovider - no filter with that id:",e),!n)return t(null,[]);var i=n.getChanges();n.clearChanges(),t(null,i)},c.prototype.getFilterLogs=function(e,t){const r=this;var n=Number.parseInt(e,16),i=r.filters[n];if(i||console.warn("FilterSubprovider - no filter with that id:",e),!i)return t(null,[]);if("log"===i.type)r.emitPayload({method:"eth_getLogs",params:[{fromBlock:i.fromBlock,toBlock:i.toBlock,address:i.address,topics:i.topics}]},function(e,r){if(e)return t(e);t(null,r.result)});else{t(null,[])}},c.prototype.uninstallFilter=function(e,t){var r=Number.parseInt(e,16);if(this.filters[r]){this.filters[r].removeAllListeners();var n=this.filterDestroyHandlers[r];delete this.filters[r],delete this.asyncBlockHandlers[r],delete this.asyncPendingBlockHandlers[r],delete this.filterDestroyHandlers[r],n&&n(),t(null,!0)}else t(null,!1)},c.prototype.checkForPendingBlocks=function(){const e=this;e.checkForPendingBlocksActive||!!Object.keys(e.asyncPendingBlockHandlers).length&&(e.checkForPendingBlocksActive=!0,e.emitPayload({method:"eth_getBlockByNumber",params:["pending",!0]},function(t,r){if(t)return e.checkForPendingBlocksActive=!1,void console.error(t);e.onNewPendingBlock(r.result,function(t){t&&console.error(t),e.checkForPendingBlocksActive=!1,setTimeout(e.checkForPendingBlocks.bind(e),e.pendingBlockTimeout)})}))},c.prototype.onNewPendingBlock=function(e,t){var r=v(this.asyncPendingBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,t)},c.prototype._getBlockNumber=function(e){e(null,y(this.engine.currentBlock.number))},c.prototype._logsForBlock=function(e,t){var r=y(e.number);this.emitPayload({method:"eth_getLogs",params:[{fromBlock:r,toBlock:r}]},function(e,r){return e?t(e):r.error?t(r.error):void t(null,r.result)})},c.prototype._txHashesForBlock=function(e,t){var r=e.transactions;if(0===r.length)return t(null,[]);"string"==typeof r[0]?t(null,r):t(null,r.map(e=>e.hash))},i(f,u),f.prototype.update=function(e){var t="0x"+e.hash.toString("hex");this.updates.push(t),this.emit("data",e)},f.prototype.getChanges=function(){return this.updates},f.prototype.clearChanges=function(){this.updates=[]},i(h,u),h.prototype.validateLog=function(e){return!(m(this.fromBlock)&&b(this.fromBlock)>=b(e.blockNumber))&&(!(m(this.toBlock)&&b(this.toBlock)<=b(e.blockNumber))&&(!(this.address&&!this.address.map(e=>e.toLowerCase()).includes(e.address.toLowerCase()))&&this.topics.reduce(function(t,r,n){if(!t)return!1;if(!r)return!0;var i=e.topics[n];return!!i&&(Array.isArray(r)?r:[r]).filter(function(e){return i.toLowerCase()===e.toLowerCase()}).length>0},!0)))},h.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateLog(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},h.prototype.getChanges=function(){return this.updates},h.prototype.getAllResults=function(){return this.allResults},h.prototype.clearChanges=function(){this.updates=[]},i(l,u),l.prototype.validateUnique=function(e){return-1===this.allResults.indexOf(e)},l.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateUnique(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},l.prototype.getChanges=function(){return this.updates},l.prototype.getAllResults=function(){return this.allResults},l.prototype.clearChanges=function(){this.updates=[]}},{"../util/stoplight.js":396,"./subprovider.js":387,async:21,"ethereumjs-util":141,events:157,util:333}],380:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){e=e||{},this.staticResponses=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){var n=this.staticResponses[e.method];"function"==typeof n?n(e,t,r):void 0!==n?setTimeout(()=>r(null,n)):t()}},{"./subprovider.js":387,util:333}],381:[function(e,t,r){const n=e("async/waterfall"),i=e("async/parallel"),o=e("util").inherits,a=e("ethereumjs-util"),s=e("eth-sig-util"),u=e("xtend"),c=e("semaphore"),f=e("./subprovider.js"),h=e("../util/estimate-gas.js"),l=/^[0-9A-Fa-f]+$/g;function d(e){this.nonceLock=c(1),e.getAccounts&&(this.getAccounts=e.getAccounts),e.processTransaction&&(this.processTransaction=e.processTransaction),e.processMessage&&(this.processMessage=e.processMessage),e.processPersonalMessage&&(this.processPersonalMessage=e.processPersonalMessage),e.processTypedMessage&&(this.processTypedMessage=e.processTypedMessage),this.approveTransaction=e.approveTransaction||this.autoApprove,this.approveMessage=e.approveMessage||this.autoApprove,this.approvePersonalMessage=e.approvePersonalMessage||this.autoApprove,this.approveTypedMessage=e.approveTypedMessage||this.autoApprove,e.signTransaction&&(this.signTransaction=e.signTransaction||y("signTransaction")),e.signMessage&&(this.signMessage=e.signMessage||y("signMessage")),e.signPersonalMessage&&(this.signPersonalMessage=e.signPersonalMessage||y("signPersonalMessage")),e.signTypedMessage&&(this.signTypedMessage=e.signTypedMessage||y("signTypedMessage")),e.recoverPersonalSignature&&(this.recoverPersonalSignature=e.recoverPersonalSignature),e.publishTransaction&&(this.publishTransaction=e.publishTransaction)}function p(e){return e.toLowerCase()}function b(e){return"string"==typeof e&&("0x"===e.slice(0,2)&&e.slice(2).match(l))}function y(e){return function(t,r){r(new Error('ProviderEngine - HookedWalletSubprovider - Must provide "'+e+'" fn in constructor options'))}}t.exports=d,o(d,f),d.prototype.handleRequest=function(e,t,r){const i=this;let o,s,c,f,h;switch(i._parityRequests={},i._parityRequestCount=0,e.method){case"eth_coinbase":return void i.getAccounts(function(e,t){if(e)return r(e);let n=t[0]||null;r(null,n)});case"eth_accounts":return void i.getAccounts(function(e,t){if(e)return r(e);r(null,t)});case"eth_sendTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processTransaction(o,e)],r);case"eth_signTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processSignTransaction(o,e)],r);case"eth_sign":return h=e.params[0],f=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateMessage(s,e),e=>i.processMessage(s,e)],r);case"personal_sign":const l=e.params[0];if(function(e){const t=a.addHexPrefix(e);return!a.isValidAddress(t)&&b(e)}(e.params[1])&&function(e){const t=a.addHexPrefix(e);return a.isValidAddress(t)}(l)){let t="The eth_personalSign method requires params ordered ";t+="[message, address]. This was previously handled incorrectly, ",t+="and has been corrected automatically. ",t+="Please switch this param order for smooth behavior in the future.",console.warn(t),h=e.params[0],f=e.params[1]}else f=e.params[0],h=e.params[1];return c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validatePersonalMessage(s,e),e=>i.processPersonalMessage(s,e)],r);case"personal_ecRecover":f=e.params[0];let d=e.params[1];return c=e.params[2]||{},s=u(c,{sig:d,data:f}),void i.recoverPersonalSignature(s,r);case"eth_signTypedData":return f=e.params[0],h=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateTypedMessage(s,e),e=>i.processTypedMessage(s,e)],r);case"parity_postTransaction":return o=e.params[0],void i.parityPostTransaction(o,r);case"parity_postSign":return h=e.params[0],f=e.params[1],void i.parityPostSign(h,f,r);case"parity_checkRequest":const p=e.params[0];return void i.parityCheckRequest(p,r);case"parity_defaultAccount":return void i.getAccounts(function(e,t){if(e)return r(e);const n=t[0]||null;r(null,n)});default:return void t()}},d.prototype.getAccounts=function(e){e(null,[])},d.prototype.processTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeAndSubmitTx(e,t)],t)},d.prototype.processSignTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeTx(e,t)],t)},d.prototype.processMessage=function(e,t){const r=this;n([t=>r.approveMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signMessage(e,t)],t)},d.prototype.processPersonalMessage=function(e,t){const r=this;n([t=>r.approvePersonalMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signPersonalMessage(e,t)],t)},d.prototype.processTypedMessage=function(e,t){const r=this;n([t=>r.approveTypedMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signTypedMessage(e,t)],t)},d.prototype.autoApprove=function(e,t){t(null,!0)},d.prototype.checkApproval=function(e,t,r){r(t?null:new Error("User denied "+e+" signature."))},d.prototype.parityPostTransaction=function(e,t){const r=this,n=`0x${r._parityRequestCount.toString(16)}`;r._parityRequestCount++,r.emitPayload({method:"eth_sendTransaction",params:[e]},function(e,t){if(e)return void(r._parityRequests[n]={error:e});const i=t.result;r._parityRequests[n]=i}),t(null,n)},d.prototype.parityPostSign=function(e,t,r){const n=this,i=`0x${n._parityRequestCount.toString(16)}`;n._parityRequestCount++,n.emitPayload({method:"eth_sign",params:[e,t]},function(e,t){if(e)return void(n._parityRequests[i]={error:e});const r=t.result;n._parityRequests[i]=r}),r(null,i)},d.prototype.parityCheckRequest=function(e,t){const r=this._parityRequests[e]||null;return r?r.error?t(r.error):void t(null,r):t(null,null)},d.prototype.recoverPersonalSignature=function(e,t){let r;try{r=s.recoverPersonalSignature(e)}catch(e){return t(e)}t(null,r)},d.prototype.validateTransaction=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign transaction."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign transaction for this address: "${e.from}"`))})},d.prototype.validateMessage=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign message."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validatePersonalMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign personal message.")):void 0===e.data?t(new Error("Undefined message - message required to sign personal message.")):b(e.data)?void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))}):t(new Error("HookedWalletSubprovider - validateMessage - message was not encoded as hex."))},d.prototype.validateTypedMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign typed data.")):void 0===e.data?t(new Error("Undefined data - message required to sign typed data.")):void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validateSender=function(e,t){if(!e)return t(null,!1);this.getAccounts(function(r,n){if(r)return t(r);const i=-1!==n.map(p).indexOf(e.toLowerCase());t(null,i)})},d.prototype.finalizeAndSubmitTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r),r.publishTransaction.bind(r)],function(e,n){if(r.nonceLock.leave(),e)return t(e);t(null,n)})})},d.prototype.finalizeTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r)],function(n,i){if(r.nonceLock.leave(),n)return t(n);t(null,{raw:i,tx:e})})})},d.prototype.publishTransaction=function(e,t){this.emitPayload({method:"eth_sendRawTransaction",params:[e]},function(e,r){if(e)return t(e);t(null,r.result)})},d.prototype.fillInTxExtras=function(e,t){const r=this,n=e.from,o={};void 0===e.gasPrice&&(o.gasPrice=r.emitPayload.bind(r,{method:"eth_gasPrice",params:[]})),void 0===e.nonce&&(o.nonce=r.emitPayload.bind(r,{method:"eth_getTransactionCount",params:[n,"pending"]})),void 0===e.gas&&(o.gas=h.bind(null,r.engine,function(e){return{from:e.from,to:e.to,value:e.value,data:e.data,gas:e.gas,gasPrice:e.gasPrice,nonce:e.nonce}}(e))),i(o,function(r,n){if(r)return t(r);const i={};n.gasPrice&&(i.gasPrice=n.gasPrice.result),n.nonce&&(i.nonce=n.nonce.result),n.gas&&(i.gas=n.gas),t(null,u(e,i))})}},{"../util/estimate-gas.js":392,"./subprovider.js":387,"async/parallel":42,"async/waterfall":44,"eth-sig-util":136,"ethereumjs-util":141,semaphore:301,util:333,xtend:423}],382:[function(e,t,r){const n=e("../util/rpc-cache-utils.js").cacheIdentifierForPayload,i=e("./subprovider.js");t.exports=class extends i{constructor(e){super(),this.inflightRequests={}}addEngine(e){this.engine=e}handleRequest(e,t,r){const i=n(e,{includeBlockRef:!0});if(!i)return t();let o=this.inflightRequests[i];o?o.push(r):(o=[],this.inflightRequests[i]=o,t((e,t,r)=>{delete this.inflightRequests[i],o.forEach(r=>r(e,t)),r(e,t)}))}}},{"../util/rpc-cache-utils.js":394,"./subprovider.js":387}],383:[function(e,t,r){const n=e("eth-json-rpc-infura/src/createProvider"),i=e("./provider.js");t.exports=class extends i{constructor(e={}){super(n(e))}}},{"./provider.js":385,"eth-json-rpc-infura/src/createProvider":129}],384:[function(e,t,r){(function(r){const n=e("util").inherits,i=e("ethereumjs-tx"),o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/rpc-cache-utils").blockTagForPayload;function u(e){this.nonceCache={}}t.exports=u,n(u,a),u.prototype.handleRequest=function(e,t,n){const a=this;switch(e.method){case"eth_getTransactionCount":var u=s(e),c=e.params[0].toLowerCase(),f=a.nonceCache[c];return void("pending"===u?f?n(null,f):t(function(e,t,r){if(e)return r();void 0===a.nonceCache[c]&&(a.nonceCache[c]=t),r()}):t());case"eth_sendRawTransaction":return void t(function(t,n,s){if(t)return s();var u=e.params[0],c=(o.stripHexPrefix(u),new r(o.stripHexPrefix(u),"hex"),new i(new r(o.stripHexPrefix(u),"hex"))),f="0x"+c.getSenderAddress().toString("hex").toLowerCase(),h=o.bufferToInt(c.nonce),l=(++h).toString(16);l.length%2&&(l="0"+l),l="0x"+l,a.nonceCache[f]=l,s()});default:return void t()}}}).call(this,e("buffer").Buffer)},{"../util/rpc-cache-utils":394,"./subprovider.js":387,buffer:84,"ethereumjs-tx":140,"ethereumjs-util":141,util:333}],385:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){if(!e)throw new Error("ProviderSubprovider - no provider specified");if(!e.sendAsync)throw new Error("ProviderSubprovider - specified provider does not have a sendAsync method");this.provider=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){this.provider.sendAsync(e,function(e,t){return e?r(e):t.error?r(new Error(t.error.message)):void r(null,t.result)})}},{"./subprovider.js":387,util:333}],386:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js"),o=(e("xtend"),e("ethereumjs-util"));function a(e){}t.exports=a,n(a,i),a.prototype.handleRequest=function(e,t,r){var n=e.params[0];if("object"==typeof n&&!Array.isArray(n)){var i=function(e){return s.reduce(function(t,r){return r in e&&(Array.isArray(e[r])?t[r]=e[r].map(function(e){return u(e)}):t[r]=u(e[r])),t},{})}(n);e.params[0]=i}t()};var s=["from","to","value","data","gas","gasPrice","nonce","fromBlock","toBlock","address","topics"];function u(e){switch(e){case"latest":case"pending":case"earliest":return e;default:return"string"==typeof e?o.addHexPrefix(e.toLowerCase()):e}}},{"./subprovider.js":387,"ethereumjs-util":141,util:333,xtend:423}],387:[function(e,t,r){const n=e("../util/create-payload.js");function i(){}t.exports=i,i.prototype.setEngine=function(e){const t=this;t.engine=e,e.on("block",function(e){t.currentBlock=e})},i.prototype.handleRequest=function(e,t,r){throw new Error("Subproviders should override `handleRequest`.")},i.prototype.emitPayload=function(e,t){this.engine.sendAsync(n(e),t)}},{"../util/create-payload.js":391}],388:[function(e,t,r){const n=e("events").EventEmitter,i=e("./filters.js"),o=e("../util/rpc-hex-encoding.js"),a=e("util").inherits,s=e("ethereumjs-util");function u(e){e=e||{},n.apply(this,Array.prototype.slice.call(arguments)),i.apply(this,[e]),this.subscriptions={}}a(u,i),Object.assign(u.prototype,n.prototype),u.prototype.constructor=u,u.prototype.eth_subscribe=function(e,t){const r=this;let n=()=>{},i=e.params[0];switch(i){case"logs":let o=e.params[1];n=r.newLogFilter.bind(r,o);break;case"newPendingTransactions":n=r.newPendingTransactionFilter.bind(r);break;case"newHeads":n=r.newBlockFilter.bind(r);break;case"syncing":default:return void t(new Error("unsupported subscription type"))}n(function(e,n){if(e)return t(e);const o=Number.parseInt(n,16);r.subscriptions[o]=i,r.filters[o].on("data",function(e){Array.isArray(e)||(e=[e]);var t=r._notificationHandler.bind(r,n,i);e.forEach(t),r.filters[o].clearChanges()}),"newPendingTransactions"===i&&r.checkForPendingBlocks(),t(null,n)})},u.prototype.eth_unsubscribe=function(e,t){const r=this;let n=e.params[0];const i=Number.parseInt(n,16);if(r.subscriptions[i]){r.subscriptions[i];r.uninstallFilter(n,function(e,n){delete r.subscriptions[i],t(e,n)})}else t(new Error(`Subscription ID ${n} not found.`))},u.prototype._notificationHandler=function(e,t,r){const n=this;"newHeads"===t&&(r=n._notificationResultFromBlock(r)),n.emit("data",null,{jsonrpc:"2.0",method:"eth_subscription",params:{subscription:e,result:r}})},u.prototype._notificationResultFromBlock=function(e){return{hash:s.bufferToHex(e.hash),parentHash:s.bufferToHex(e.parentHash),sha3Uncles:s.bufferToHex(e.sha3Uncles),miner:s.bufferToHex(e.miner),stateRoot:s.bufferToHex(e.stateRoot),transactionsRoot:s.bufferToHex(e.transactionsRoot),receiptsRoot:s.bufferToHex(e.receiptsRoot),logsBloom:s.bufferToHex(e.logsBloom),difficulty:o.intToQuantityHex(s.bufferToInt(e.difficulty)),number:o.intToQuantityHex(s.bufferToInt(e.number)),gasLimit:o.intToQuantityHex(s.bufferToInt(e.gasLimit)),gasUsed:o.intToQuantityHex(s.bufferToInt(e.gasUsed)),nonce:e.nonce?s.bufferToHex(e.nonce):null,mixHash:s.bufferToHex(e.mixHash),timestamp:o.intToQuantityHex(s.bufferToInt(e.timestamp)),extraData:s.bufferToHex(e.extraData)}},u.prototype.handleRequest=function(e,t,r){switch(e.method){case"eth_subscribe":this.eth_subscribe(e,r);break;case"eth_unsubscribe":this.eth_unsubscribe(e,r);break;default:i.prototype.handleRequest.apply(this,Array.prototype.slice.call(arguments))}},t.exports=u},{"../util/rpc-hex-encoding.js":395,"./filters.js":379,"ethereumjs-util":141,events:157,util:333}],389:[function(e,t,r){(function(r){const n=e("backoff"),i=e("events"),o=(e("util").inherits,r.WebSocket||e("ws")),a=e("./subprovider"),s=e("../util/create-payload");class u extends a{constructor({rpcUrl:e,debug:t,origin:r}){super(),i.call(this),Object.defineProperties(this,{_backoff:{value:n.exponential({randomisationFactor:.2,maxDelay:5e3})},_connectTime:{value:null,writable:!0},_log:{value:t?(...e)=>console.info.apply(console,["[WSProvider]",...e]):()=>{}},_origin:{value:r},_pendingRequests:{value:new Map},_socket:{value:null,writable:!0},_unhandledRequests:{value:[]},_url:{value:e}}),this._handleSocketClose=this._handleSocketClose.bind(this),this._handleSocketMessage=this._handleSocketMessage.bind(this),this._handleSocketOpen=this._handleSocketOpen.bind(this),this._backoff.on("ready",()=>{this._openSocket()}),this._openSocket()}handleRequest(e,t,r){if(!this._socket||this._socket.readyState!==o.OPEN)return this._unhandledRequests.push(Array.from(arguments)),void this._log("Socket not open. Request queued.");this._pendingRequests.set(e.id,[e,r]);const n=s(e);delete n.origin,this._socket.send(JSON.stringify(n)),this._log(`Sent: ${n.method} #${n.id}`)}_handleSocketClose({reason:e,code:t}){this._log(`Socket closed, code ${t} (${e||"no reason"})`),this._connectTime&&Date.now()-this._connectTime>5e3&&this._backoff.reset(),this._socket.removeEventListener("close",this._handleSocketClose),this._socket.removeEventListener("message",this._handleSocketMessage),this._socket.removeEventListener("open",this._handleSocketOpen),this._socket=null,this._backoff.backoff()}_handleSocketMessage(e){let t;try{t=JSON.parse(e.data)}catch(e){return void this._log("Received a message that is not valid JSON:",t)}if(void 0===t.id)return this.emit("data",null,t);if(!this._pendingRequests.has(t.id))return;const[r,n]=this._pendingRequests.get(t.id);if(this._pendingRequests.delete(t.id),this._log(`Received: ${r.method} #${t.id}`),t.error)return n(new Error(t.error.message));n(null,t.result)}_handleSocketOpen(){this._log("Socket open."),this._connectTime=Date.now(),this._pendingRequests.forEach(([e,t])=>{this._unhandledRequests.push([e,null,t])}),this._pendingRequests.clear(),this._unhandledRequests.splice(0,this._unhandledRequests.length).forEach(e=>{this.handleRequest.apply(this,e)})}_openSocket(){this._log("Opening socket..."),this._socket=new o(this._url,null,{origin:this._origin}),this._socket.addEventListener("close",this._handleSocketClose),this._socket.addEventListener("message",this._handleSocketMessage),this._socket.addEventListener("open",this._handleSocketOpen)}}Object.assign(u.prototype,i.prototype),t.exports=u}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util/create-payload":391,"./subprovider":387,backoff:45,events:157,util:333,ws:55}],390:[function(e,t,r){t.exports=function(e,t){if(!e)throw t||"Assertion failed"}},{}],391:[function(e,t,r){const n=e("./random-id.js"),i=e("xtend");t.exports=function(e){return i({id:n(),jsonrpc:"2.0",params:[]},e)}},{"./random-id.js":393,xtend:423}],392:[function(e,t,r){const n=e("./create-payload.js");t.exports=function(e,t,r){e.sendAsync(n({method:"eth_estimateGas",params:[t]}),function(e,t){if(e)return"no contract code at given address"===e.message?r(null,"0xcf08"):r(e);r(null,t.result)})}},{"./create-payload.js":391}],393:[function(e,t,r){const n=3;t.exports=function(){var e=(new Date).getTime()*Math.pow(10,n),t=Math.floor(Math.random()*Math.pow(10,n));return e+t}},{}],394:[function(e,t,r){const n=e("json-stable-stringify");function i(e){return"never"!==s(e)}function o(e){var t=a(e);return t>=e.params.length?e.params:"eth_getBlockByNumber"===e.method?e.params.slice(1):e.params.slice(0,t)}function a(e){switch(e.method){case"eth_getStorageAt":return 2;case"eth_getBalance":case"eth_getCode":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":return 1;case"eth_getBlockByNumber":return 0;default:return}}function s(e){switch(e.method){case"web3_clientVersion":case"web3_sha3":case"eth_protocolVersion":case"eth_getBlockTransactionCountByHash":case"eth_getUncleCountByBlockHash":case"eth_getCode":case"eth_getBlockByHash":case"eth_getTransactionByHash":case"eth_getTransactionByBlockHashAndIndex":case"eth_getTransactionReceipt":case"eth_getUncleByBlockHashAndIndex":case"eth_getCompilers":case"eth_compileLLL":case"eth_compileSolidity":case"eth_compileSerpent":case"shh_version":return"perma";case"eth_getBlockByNumber":case"eth_getBlockTransactionCountByNumber":case"eth_getUncleCountByBlockNumber":case"eth_getTransactionByBlockNumberAndIndex":case"eth_getUncleByBlockNumberAndIndex":return"fork";case"eth_gasPrice":case"eth_blockNumber":case"eth_getBalance":case"eth_getStorageAt":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":case"eth_getFilterLogs":case"eth_getLogs":case"net_peerCount":return"block";case"net_version":case"net_peerCount":case"net_listening":case"eth_syncing":case"eth_sign":case"eth_coinbase":case"eth_mining":case"eth_hashrate":case"eth_accounts":case"eth_sendTransaction":case"eth_sendRawTransaction":case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_getFilterChanges":case"eth_getWork":case"eth_submitWork":case"eth_submitHashrate":case"db_putString":case"db_getString":case"db_putHex":case"db_getHex":case"shh_post":case"shh_newIdentity":case"shh_hasIdentity":case"shh_newGroup":case"shh_addToGroup":case"shh_newFilter":case"shh_uninstallFilter":case"shh_getFilterChanges":case"shh_getMessages":return"never"}}t.exports={cacheIdentifierForPayload:function(e,t={}){if(!i(e))return null;const{includeBlockRef:r}=t,a=r?e.params:o(e);return e.method+":"+n(a)},canCache:i,blockTagForPayload:function(e){var t=a(e);if(t>=e.params.length)return null;return e.params[t]},paramsWithoutBlockTag:o,blockTagParamIndex:a,cacheTypeForPayload:s}},{"json-stable-stringify":374}],395:[function(e,t,r){(function(r){const n=e("ethereumjs-util"),i=e("./assert.js");t.exports={intToQuantityHex:function(e){i("number"==typeof e&&e===Math.floor(e),"intToQuantityHex arg must be an integer");var t=n.toBuffer(e).toString("hex");"0"===t[0]&&(t=t.substring(1));return n.addHexPrefix(t)},quantityHexToInt:function(e){i("string"==typeof e,"arg to quantityHexToInt must be a string");var t=n.stripHexPrefix(e);t.length%2!=0&&(t="0"+t);var o=new r(t,"hex");return n.bufferToInt(o)}}}).call(this,e("buffer").Buffer)},{"./assert.js":390,buffer:84,"ethereumjs-util":141}],396:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits;function o(){n.call(this),this.isLocked=!0}t.exports=o,i(o,n),o.prototype.go=function(){this.isLocked=!1,this.emit("unlock")},o.prototype.stop=function(){this.isLocked=!0,this.emit("lock")},o.prototype.await=function(e){const t=this;t.isLocked?t.once("unlock",e):setTimeout(e)}},{events:157,util:333}],397:[function(e,t,r){const n=e("./index.js"),i=e("./subproviders/default-fixture.js"),o=e("./subproviders/nonce-tracker.js"),a=e("./subproviders/cache.js"),s=e("./subproviders/filters.js"),u=e("./subproviders/subscriptions"),c=e("./subproviders/inflight-cache"),f=e("./subproviders/hooked-wallet.js"),h=e("./subproviders/sanitizer.js"),l=e("./subproviders/infura.js"),d=e("./subproviders/fetch.js"),p=e("./subproviders/websocket.js");t.exports=function(e={}){const t=function({rpcUrl:e}){if(!e)return;switch(e.split(":")[0].toLowerCase()){case"http":case"https":return"http";case"ws":case"wss":return"ws";default:throw new Error(`ProviderEngine - unrecognized protocol in "${e}"`)}}(e),r=new n(e.engineParams),b=new i(e.static);r.addProvider(b),r.addProvider(new o);const y=new h;r.addProvider(y);const m=new a;if(r.addProvider(m),"ws"===t){const e=new s;r.addProvider(e)}else{const e=new u;e.on("data",(e,t)=>{r.emit("data",e,t)}),r.addProvider(e)}const v=new c;r.addProvider(v);const g=new f({getAccounts:e.getAccounts,processTransaction:e.processTransaction,approveTransaction:e.approveTransaction,signTransaction:e.signTransaction,publishTransaction:e.publishTransaction,processMessage:e.processMessage,approveMessage:e.approveMessage,signMessage:e.signMessage,processPersonalMessage:e.processPersonalMessage,processTypedMessage:e.processTypedMessage,approvePersonalMessage:e.approvePersonalMessage,approveTypedMessage:e.approveTypedMessage,signPersonalMessage:e.signPersonalMessage,signTypedMessage:e.signTypedMessage,personalRecoverSigner:e.personalRecoverSigner});r.addProvider(g);const w=e.dataSubprovider||function(e,t){const{rpcUrl:r,debug:n}=t;if(!e)return new l;if("http"===e)return new d({rpcUrl:r,debug:n});if("ws"===e)return new p({rpcUrl:r,debug:n});throw new Error(`ProviderEngine - unrecognized connectionType "${e}"`)}(t,e);"ws"===t&&w.on("data",(e,t)=>{r.emit("data",e,t)});r.addProvider(w),e.stopped||r.start();return r}},{"./index.js":373,"./subproviders/cache.js":376,"./subproviders/default-fixture.js":377,"./subproviders/fetch.js":378,"./subproviders/filters.js":379,"./subproviders/hooked-wallet.js":381,"./subproviders/inflight-cache":382,"./subproviders/infura.js":383,"./subproviders/nonce-tracker.js":384,"./subproviders/sanitizer.js":386,"./subproviders/subscriptions":388,"./subproviders/websocket.js":389}],398:[function(e,t,r){var n=e("web3-core-helpers").errors,i=e("xhr2-cookies").XMLHttpRequest,o=e("http"),a=e("https"),s=function(e,t){t=t||{},this.host=e||"http://localhost:8545","https"===this.host.substring(0,5)?this.httpsAgent=new a.Agent({keepAlive:!0}):this.httpAgent=new o.Agent({keepAlive:!0}),this.timeout=t.timeout||0,this.headers=t.headers,this.connected=!1};s.prototype._prepareRequest=function(){var e=new i;return e.nodejsSet({httpsAgent:this.httpsAgent,httpAgent:this.httpAgent}),e.open("POST",this.host,!0),e.setRequestHeader("Content-Type","application/json"),e.timeout=this.timeout&&1!==this.timeout?this.timeout:0,e.withCredentials=!0,this.headers&&this.headers.forEach(function(t){e.setRequestHeader(t.name,t.value)}),e},s.prototype.send=function(e,t){var r=this,i=this._prepareRequest();i.onreadystatechange=function(){if(4===i.readyState&&1!==i.timeout){var e=i.responseText,o=null;try{e=JSON.parse(e)}catch(e){o=n.InvalidResponse(i.responseText)}r.connected=!0,t(o,e)}},i.ontimeout=function(){r.connected=!1,t(n.ConnectionTimeout(this.timeout))};try{i.send(JSON.stringify(e))}catch(e){this.connected=!1,t(n.InvalidConnection(this.host))}},s.prototype.disconnect=function(){},t.exports=s},{http:312,https:175,"web3-core-helpers":338,"xhr2-cookies":418}],399:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("oboe"),a=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],this.path=e,this.connected=!1,this.connection=t.connect({path:this.path}),this.addDefaultEvents();var i=function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,t||-1===e.method.indexOf("_subscription")?r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t]):r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)})};"Socket"===t.constructor.name?o(this.connection).done(i):this.connection.on("data",function(e){r._parseResponse(e.toString()).forEach(i)})};a.prototype.addDefaultEvents=function(){var e=this;this.connection.on("connect",function(){e.connected=!0}),this.connection.on("close",function(){e.connected=!1}),this.connection.on("error",function(){e._timeout()}),this.connection.on("end",function(){e._timeout()}),this.connection.on("timeout",function(){e._timeout()})},a.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},a.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n},a.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on IPC")),delete this.responseCallbacks[e])},a.prototype.reconnect=function(){this.connection.connect({path:this.path})},a.prototype.send=function(e,t){this.connection.writable||this.connection.connect({path:this.path}),this.connection.write(JSON.stringify(e)),this._addResponseCallback(e,t)},a.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;default:this.connection.on(e,t)}},a.prototype.once=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");this.connection.once(e,t)},a.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)});break;default:this.connection.removeListener(e,t)}},a.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;default:this.connection.removeAllListeners(e)}},a.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.connection.removeAllListeners("error"),this.connection.removeAllListeners("end"),this.connection.removeAllListeners("timeout"),this.addDefaultEvents()},t.exports=a},{oboe:239,underscore:325,"web3-core-helpers":338}],400:[function(e,t,r){(function(r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=null,a=null,s=null;if("undefined"!=typeof window&&void 0!==window.WebSocket)o=function(e,t){return new window.WebSocket(e,t)},a=btoa,s=function(e){return new URL(e)};else{o=e("websocket").w3cwebsocket,a=function(e){return r(e).toString("base64")};var u=e("url");if(u.URL){var c=u.URL;s=function(e){return new c(e)}}else s=e("url").parse}var f=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],t=t||{},this._customTimeout=t.timeout;var i=s(e),u=t.headers||{},c=t.protocol||void 0;i.username&&i.password&&(u.authorization="Basic "+a(i.username+":"+i.password));var f=t.clientConfig||void 0;i.auth&&(u.authorization="Basic "+a(i.auth)),this.connection=new o(e,c,void 0,u,void 0,f),this.addDefaultEvents(),this.connection.onmessage=function(e){var t="string"==typeof e.data?e.data:"";r._parseResponse(t).forEach(function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,!t&&e&&e.method&&-1!==e.method.indexOf("_subscription")?r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)}):r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t])})},Object.defineProperty(this,"connected",{get:function(){return this.connection&&this.connection.readyState===this.connection.OPEN},enumerable:!0})};f.prototype.addDefaultEvents=function(){var e=this;this.connection.onerror=function(){e._timeout()},this.connection.onclose=function(){e._timeout(),e.reset()}},f.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},f.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n;var o=this;this._customTimeout&&setTimeout(function(){o.responseCallbacks[r]&&(o.responseCallbacks[r](i.ConnectionTimeout(o._customTimeout)),delete o.responseCallbacks[r])},this._customTimeout)},f.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on WS")),delete this.responseCallbacks[e])},f.prototype.send=function(e,t){var r=this;if(this.connection.readyState!==this.connection.CONNECTING){if(this.connection.readyState!==this.connection.OPEN)return console.error("connection not open on send()"),"function"==typeof this.connection.onerror?this.connection.onerror(new Error("connection not open")):console.error("no error callback"),void t(new Error("connection not open"));this.connection.send(JSON.stringify(e)),this._addResponseCallback(e,t)}else setTimeout(function(){r.send(e,t)},10)},f.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;case"connect":this.connection.onopen=t;break;case"end":this.connection.onclose=t;break;case"error":this.connection.onerror=t}},f.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)})}},f.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;case"connect":this.connection.onopen=null;break;case"end":this.connection.onclose=null;break;case"error":this.connection.onerror=null}},f.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.addDefaultEvents()},f.prototype.disconnect=function(){this.connection&&this.connection.close()},t.exports=f}).call(this,e("buffer").Buffer)},{buffer:84,underscore:325,url:327,"web3-core-helpers":338,websocket:408}],401:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-subscriptions").subscriptions,o=e("web3-core-method"),a=e("web3-net"),s=function(){var e=this;n.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments)},this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new a(this.currentProvider),[new i({name:"subscribe",type:"shh",subscriptions:{messages:{params:1}}}),new o({name:"getVersion",call:"shh_version",params:0}),new o({name:"getInfo",call:"shh_info",params:0}),new o({name:"setMaxMessageSize",call:"shh_setMaxMessageSize",params:1}),new o({name:"setMinPoW",call:"shh_setMinPoW",params:1}),new o({name:"markTrustedPeer",call:"shh_markTrustedPeer",params:1}),new o({name:"newKeyPair",call:"shh_newKeyPair",params:0}),new o({name:"addPrivateKey",call:"shh_addPrivateKey",params:1}),new o({name:"deleteKeyPair",call:"shh_deleteKeyPair",params:1}),new o({name:"hasKeyPair",call:"shh_hasKeyPair",params:1}),new o({name:"getPublicKey",call:"shh_getPublicKey",params:1}),new o({name:"getPrivateKey",call:"shh_getPrivateKey",params:1}),new o({name:"newSymKey",call:"shh_newSymKey",params:0}),new o({name:"addSymKey",call:"shh_addSymKey",params:1}),new o({name:"generateSymKeyFromPassword",call:"shh_generateSymKeyFromPassword",params:1}),new o({name:"hasSymKey",call:"shh_hasSymKey",params:1}),new o({name:"getSymKey",call:"shh_getSymKey",params:1}),new o({name:"deleteSymKey",call:"shh_deleteSymKey",params:1}),new o({name:"newMessageFilter",call:"shh_newMessageFilter",params:1}),new o({name:"getFilterMessages",call:"shh_getFilterMessages",params:1}),new o({name:"deleteMessageFilter",call:"shh_deleteMessageFilter",params:1}),new o({name:"post",call:"shh_post",params:1,inputFormatter:[null]}),new o({name:"unsubscribe",call:"shh_unsubscribe",params:1})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(s),t.exports=s},{"web3-core":348,"web3-core-method":339,"web3-core-subscriptions":345,"web3-net":372}],402:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],403:[function(e,t,r){var n=e("underscore"),i=e("ethjs-unit"),o=e("./utils.js"),a=e("./soliditySha3.js"),s=e("randomhex"),u=function(e,t){var r=[];return t.forEach(function(t){if("object"==typeof t.components){if("tuple"!==t.type.substring(0,5))throw new Error("components found but type is not tuple; report on GitHub");var i="",o=t.type.indexOf("[");o>=0&&(i=t.type.substring(o));var a=u(e,t.components);n.isArray(a)&&e?r.push("tuple("+a.join(",")+")"+i):e?r.push("("+a+")"):r.push("("+a.join(",")+")"+i)}else r.push(t.type)}),r},c=function(e){if(!o.isHexStrict(e))throw new Error("The parameter must be a valid HEX string.");var t="",r=0,n=e.length;for("0x"===e.substring(0,2)&&(r=2);r7?r+=e[n].toUpperCase():r+=e[n];return r},toHex:o.toHex,toBN:o.toBN,bytesToHex:o.bytesToHex,hexToBytes:o.hexToBytes,hexToNumberString:o.hexToNumberString,hexToNumber:o.hexToNumber,toDecimal:o.hexToNumber,numberToHex:o.numberToHex,fromDecimal:o.numberToHex,hexToUtf8:o.hexToUtf8,hexToString:o.hexToUtf8,toUtf8:o.hexToUtf8,utf8ToHex:o.utf8ToHex,stringToHex:o.utf8ToHex,fromUtf8:o.utf8ToHex,hexToAscii:c,toAscii:c,asciiToHex:f,fromAscii:f,unitMap:i.unitMap,toWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.toWei(e,t):i.toWei(e,t).toString(10)},fromWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.fromWei(e,t):i.fromWei(e,t).toString(10)},padLeft:o.leftPad,leftPad:o.leftPad,padRight:o.rightPad,rightPad:o.rightPad,toTwosComplement:o.toTwosComplement}},{"./soliditySha3.js":404,"./utils.js":405,"ethjs-unit":153,randomhex:274,underscore:325}],404:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("./utils.js"),a=function(e){var t=typeof e;if("string"===t)return o.isHexStrict(e)?new i(e.replace(/0x/i,""),16):new i(e,10);if("number"===t)return new i(e);if(o.isBigNumber(e))return new i(e.toString(10));if(o.isBN(e))return e;throw new Error(e+" is not a number")},s=function(e,t,r){var n,s,u;if("bytes"===(e=(u=e).startsWith("int[")?"int256"+u.slice(3):"int"===u?"int256":u.startsWith("uint[")?"uint256"+u.slice(4):"uint"===u?"uint256":u.startsWith("fixed[")?"fixed128x128"+u.slice(5):"fixed"===u?"fixed128x128":u.startsWith("ufixed[")?"ufixed128x128"+u.slice(6):"ufixed"===u?"ufixed128x128":u)){if(t.replace(/^0x/i,"").length%2!=0)throw new Error("Invalid bytes characters "+t.length);return t}if("string"===e)return o.utf8ToHex(t);if("bool"===e)return t?"01":"00";if(e.startsWith("address")){if(n=r?64:40,!o.isAddress(t))throw new Error(t+" is not a valid address, or the checksum is invalid.");return o.leftPad(t.toLowerCase(),n)}if(n=function(e){var t=/^\D+(\d+).*$/.exec(e);return t?parseInt(t[1],10):null}(e),e.startsWith("bytes")){if(!n)throw new Error("bytes[] not yet supported in solidity");if(r&&(n=32),n<1||n>32||n256)throw new Error("Invalid uint"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied uint exceeds width: "+n+" vs "+s.bitLength());if(s.lt(new i(0)))throw new Error("Supplied uint "+s.toString()+" is negative");return n?o.leftPad(s.toString("hex"),n/8*2):s}if(e.startsWith("int")){if(n%8||n<8||n>256)throw new Error("Invalid int"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied int exceeds width: "+n+" vs "+s.bitLength());return s.lt(new i(0))?s.toTwos(n).toString("hex"):n?o.leftPad(s.toString("hex"),n/8*2):s}throw new Error("Unsupported or invalid type: "+e)},u=function(e){if(n.isArray(e))throw new Error("Autodetection of array types is not supported.");var t,r,a="";if(n.isObject(e)&&(e.hasOwnProperty("v")||e.hasOwnProperty("t")||e.hasOwnProperty("value")||e.hasOwnProperty("type"))?(t=e.hasOwnProperty("t")?e.t:e.type,a=e.hasOwnProperty("v")?e.v:e.value):(t=o.toHex(e,!0),a=o.toHex(e),t.startsWith("int")||t.startsWith("uint")||(t="bytes")),!t.startsWith("int")&&!t.startsWith("uint")||"string"!=typeof a||/^(-)?0x/i.test(a)||(a=new i(a)),n.isArray(a)){if((r=function(e){var t=/^\D+\d*\[(\d+)\]$/.exec(e);return t?parseInt(t[1],10):null}(t))&&a.length!==r)throw new Error(t+" is not matching the given array "+JSON.stringify(a));r=a.length}return n.isArray(a)?a.map(function(e){return s(t,e,r).toString("hex").replace("0x","")}).join(""):s(t,a,r).toString("hex").replace("0x","")};t.exports=function(){var e=Array.prototype.slice.call(arguments),t=n.map(e,u);return o.sha3("0x"+t.join(""))}},{"./utils.js":405,"bn.js":402,underscore:325}],405:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("number-to-bn"),a=e("utf8"),s=e("eth-lib/lib/hash"),u=function(e){return e instanceof i||e&&e.constructor&&"BN"===e.constructor.name},c=function(e){return e&&e.constructor&&"BigNumber"===e.constructor.name},f=function(e){try{return o.apply(null,arguments)}catch(t){throw new Error(t+' Given value: "'+e+'"')}},h=function(e){return!!/^(0x)?[0-9a-f]{40}$/i.test(e)&&(!(!/^(0x|0X)?[0-9a-f]{40}$/.test(e)&&!/^(0x|0X)?[0-9A-F]{40}$/.test(e))||l(e))},l=function(e){e=e.replace(/^0x/i,"");for(var t=m(e.toLowerCase()).replace(/^0x/i,""),r=0;r<40;r++)if(parseInt(t[r],16)>7&&e[r].toUpperCase()!==e[r]||parseInt(t[r],16)<=7&&e[r].toLowerCase()!==e[r])return!1;return!0},d=function(e){var t="";e=(e=(e=(e=(e=a.encode(e)).replace(/^(?:\u0000)*/,"")).split("").reverse().join("")).replace(/^(?:\u0000)*/,"")).split("").reverse().join("");for(var r=0;r>>4).toString(16)),t.push((15&e[r]).toString(16));return"0x"+t.join("")},isHex:function(e){return(n.isString(e)||n.isNumber(e))&&/^(-0x|0x)?[0-9a-f]*$/i.test(e)},isHexStrict:y,leftPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+new Array(i).join(r||"0")+e},rightPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+e+new Array(i).join(r||"0")},toTwosComplement:function(e){return"0x"+f(e).toTwos(256).toString(16,64)},sha3:m}},{"bn.js":402,"eth-lib/lib/hash":134,"number-to-bn":237,underscore:325,utf8:329}],406:[function(e,t,r){t.exports={_from:"web3@1.0.0-beta.36",_id:"web3@1.0.0-beta.36",_inBundle:!1,_integrity:"sha512-fZDunw1V0AQS27r5pUN3eOVP7u8YAvyo6vOapdgVRolAu5LgaweP7jncYyLINqIX9ZgWdS5A090bt+ymgaYHsw==",_location:"/web3",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"web3@1.0.0-beta.36",name:"web3",escapedName:"web3",rawSpec:"1.0.0-beta.36",saveSpec:null,fetchSpec:"1.0.0-beta.36"},_requiredBy:["#USER","/"],_resolved:"https://registry.npmjs.org/web3/-/web3-1.0.0-beta.36.tgz",_shasum:"2954da9e431124c88396025510d840ba731c8373",_spec:"web3@1.0.0-beta.36",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy",author:{name:"ethereum.org"},authors:[{name:"Fabian Vogelsteller",email:"fabian@ethereum.org",homepage:"http://frozeman.de"},{name:"Marek Kotewicz",email:"marek@parity.io",url:"https://github.com/debris"},{name:"Marian Oancea",url:"https://github.com/cubedro"},{name:"Gav Wood",email:"g@parity.io",homepage:"http://gavwood.com"},{name:"Jeffery Wilcke",email:"jeffrey.wilcke@ethereum.org",url:"https://github.com/obscuren"}],bugs:{url:"https://github.com/ethereum/web3.js/issues"},bundleDependencies:!1,dependencies:{"web3-bzz":"1.0.0-beta.36","web3-core":"1.0.0-beta.36","web3-eth":"1.0.0-beta.36","web3-eth-personal":"1.0.0-beta.36","web3-net":"1.0.0-beta.36","web3-shh":"1.0.0-beta.36","web3-utils":"1.0.0-beta.36"},deprecated:!1,description:"Ethereum JavaScript API",keywords:["Ethereum","JavaScript","API"],license:"LGPL-3.0",main:"src/index.js",name:"web3",namespace:"ethereum",repository:{type:"git",url:"https://github.com/ethereum/web3.js/tree/master/packages/web3"},version:"1.0.0-beta.36"}},{}],407:[function(e,t,r){"use strict";var n=e("../package.json").version,i=e("web3-core"),o=e("web3-eth"),a=e("web3-net"),s=e("web3-eth-personal"),u=e("web3-shh"),c=e("web3-bzz"),f=e("web3-utils"),h=function(){var e=this;i.packageInit(this,arguments),this.version=n,this.utils=f,this.eth=new o(this),this.shh=new u(this),this.bzz=new c(this);var t=this.setProvider;this.setProvider=function(r,n){return t.apply(e,arguments),this.eth.setProvider(r,n),this.shh.setProvider(r,n),this.bzz.setProvider(r),!0}};h.version=n,h.utils=f,h.modules={Eth:o,Net:a,Personal:s,Shh:u,Bzz:c},i.addProviders(h),t.exports=h},{"../package.json":406,"web3-bzz":335,"web3-core":348,"web3-eth":371,"web3-eth-personal":369,"web3-net":372,"web3-shh":401,"web3-utils":403}],408:[function(e,t,r){var n=function(){return this||{}}(),i=n.WebSocket||n.MozWebSocket,o=e("./version");function a(e,t){return t?new i(e,t):new i(e)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(e){Object.defineProperty(a,e,{get:function(){return i[e]}})}),t.exports={w3cwebsocket:i?a:null,version:o}},{"./version":409}],409:[function(e,t,r){t.exports=e("../package.json").version},{"../package.json":410}],410:[function(e,t,r){t.exports={_from:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_id:"websocket@1.0.26",_inBundle:!1,_integrity:"",_location:"/websocket",_phantomChildren:{},_requested:{type:"git",raw:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",name:"websocket",escapedName:"websocket",rawSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",saveSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",fetchSpec:"git://github.com/frozeman/WebSocket-Node.git",gitCommittish:"browserifyCompatible"},_requiredBy:["/web3-providers-ws"],_resolved:"git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",_spec:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy/node_modules/web3-providers-ws",author:{name:"Brian McKelvey",email:"brian@worlize.com",url:"https://www.worlize.com/"},browser:"lib/browser.js",bugs:{url:"https://github.com/theturtle32/WebSocket-Node/issues"},bundleDependencies:!1,config:{verbose:!1},contributors:[{name:"Iñaki Baz Castillo",email:"ibc@aliax.net",url:"http://dev.sipdoc.net"}],dependencies:{debug:"^2.2.0",nan:"^2.3.3","typedarray-to-buffer":"^3.1.2",yaeti:"^0.0.6"},deprecated:!1,description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",devDependencies:{"buffer-equal":"^1.0.0",faucet:"^0.0.1",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-jshint":"^2.0.4",jshint:"^2.0.0","jshint-stylish":"^2.2.1",tape:"^4.0.1"},directories:{lib:"./lib"},engines:{node:">=0.10.0"},homepage:"https://github.com/theturtle32/WebSocket-Node",keywords:["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],license:"Apache-2.0",main:"index",name:"websocket",repository:{type:"git",url:"git+https://github.com/theturtle32/WebSocket-Node.git"},scripts:{gulp:"gulp",install:"(node-gyp rebuild 2> builderror.log) || (exit 0)",test:"faucet test/unit"},version:"1.0.26"}},{}],411:[function(e,t,r){var n=e("xhr-request");t.exports=function(e,t){return new Promise(function(r,i){n(e,t,function(e,t){e?i(e):r(t)})})}},{"xhr-request":412}],412:[function(e,t,r){var n=e("query-string"),i=e("url-set-query"),o=e("object-assign"),a=e("./lib/ensure-header.js"),s=e("./lib/request.js"),u="application/json",c=function(){};t.exports=function(e,t,r){if(!e||"string"!=typeof e)throw new TypeError("must specify a URL");"function"==typeof t&&(r=t,t={});if(r&&"function"!=typeof r)throw new TypeError("expected cb to be undefined or a function");r=r||c;var f=(t=t||{}).json?"json":"text",h=(t=o({responseType:f},t)).headers||{},l=(t.method||"GET").toUpperCase(),d=t.query;d&&("string"!=typeof d&&(d=n.stringify(d)),e=i(e,d));"json"===t.responseType&&a(h,"Accept",u);t.json&&"GET"!==l&&"HEAD"!==l&&(a(h,"Content-Type",u),t.body=JSON.stringify(t.body));return t.method=l,t.url=e,t.headers=h,delete t.query,delete t.json,s(t,r)}},{"./lib/ensure-header.js":413,"./lib/request.js":415,"object-assign":238,"query-string":266,"url-set-query":326}],413:[function(e,t,r){t.exports=function(e,t,r){var n=t.toLowerCase();e[t]||e[n]||(e[t]=r)}},{}],414:[function(e,t,r){t.exports=function(e,t){return t?{statusCode:t.statusCode,headers:t.headers,method:e.method,url:e.url,rawRequest:t.rawRequest?t.rawRequest:t}:null}},{}],415:[function(e,t,r){var n=e("xhr"),i=e("./normalize-response"),o=function(){};t.exports=function(e,t){delete e.uri;var r=!1;"json"===e.responseType&&(e.responseType="text",r=!0);var a=n(e,function(n,a,s){if(r&&!n)try{var u=a.rawRequest.responseText;s=JSON.parse(u)}catch(e){n=e}a=i(e,a),t(n,n?null:s,a),t=o}),s=a.onabort;return a.onabort=function(){var e=s.apply(a,Array.prototype.slice.call(arguments));return t(new Error("XHR Aborted")),t=o,e},a}},{"./normalize-response":414,xhr:416}],416:[function(e,t,r){"use strict";var n=e("global/window"),i=e("is-function"),o=e("parse-headers"),a=e("xtend");function s(e,t,r){var n=e;return i(t)?(r=t,"string"==typeof e&&(n={uri:e})):n=a(t,{uri:e}),n.callback=r,n}function u(e,t,r){return c(t=s(e,t,r))}function c(e){if(void 0===e.callback)throw new Error("callback argument missing");var t=!1,r=function(r,n,i){t||(t=!0,e.callback(r,n,i))};function n(e){return clearTimeout(f),e instanceof Error||(e=new Error(""+(e||"Unknown XMLHttpRequest Error"))),e.statusCode=0,r(e,m)}function i(){if(!s){var t;clearTimeout(f),t=e.useXDR&&void 0===c.status?200:1223===c.status?204:c.status;var n=m,i=null;return 0!==t?(n={body:function(){var e=void 0;if(e=c.response?c.response:c.responseText||function(e){try{if("document"===e.responseType)return e.responseXML;var t=e.responseXML&&"parsererror"===e.responseXML.documentElement.nodeName;if(""===e.responseType&&!t)return e.responseXML}catch(e){}return null}(c),y)try{e=JSON.parse(e)}catch(e){}return e}(),statusCode:t,method:l,headers:{},url:h,rawRequest:c},c.getAllResponseHeaders&&(n.headers=o(c.getAllResponseHeaders()))):i=new Error("Internal XMLHttpRequest Error"),r(i,n,n.body)}}var a,s,c=e.xhr||null;c||(c=e.cors||e.useXDR?new u.XDomainRequest:new u.XMLHttpRequest);var f,h=c.url=e.uri||e.url,l=c.method=e.method||"GET",d=e.body||e.data,p=c.headers=e.headers||{},b=!!e.sync,y=!1,m={body:void 0,headers:{},statusCode:0,method:l,url:h,rawRequest:c};if("json"in e&&!1!==e.json&&(y=!0,p.accept||p.Accept||(p.Accept="application/json"),"GET"!==l&&"HEAD"!==l&&(p["content-type"]||p["Content-Type"]||(p["Content-Type"]="application/json"),d=JSON.stringify(!0===e.json?d:e.json))),c.onreadystatechange=function(){4===c.readyState&&setTimeout(i,0)},c.onload=i,c.onerror=n,c.onprogress=function(){},c.onabort=function(){s=!0},c.ontimeout=n,c.open(l,h,!b,e.username,e.password),b||(c.withCredentials=!!e.withCredentials),!b&&e.timeout>0&&(f=setTimeout(function(){if(!s){s=!0,c.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT",n(e)}},e.timeout)),c.setRequestHeader)for(a in p)p.hasOwnProperty(a)&&c.setRequestHeader(a,p[a]);else if(e.headers&&!function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}(e.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in e&&(c.responseType=e.responseType),"beforeSend"in e&&"function"==typeof e.beforeSend&&e.beforeSend(c),c.send(d||null),c}t.exports=u,t.exports.default=u,u.XMLHttpRequest=n.XMLHttpRequest||function(){},u.XDomainRequest="withCredentials"in new u.XMLHttpRequest?u.XMLHttpRequest:n.XDomainRequest,function(e,t){for(var r=0;r=0)return this._url=this._parseUrl(t.headers.location),this._method="GET",this._loweredHeaders["content-type"]&&(delete this._headers[this._loweredHeaders["content-type"]],delete this._loweredHeaders["content-type"]),null!=this._headers["Content-Type"]&&delete this._headers["Content-Type"],delete this._headers["Content-Length"],this.upload._reset(),this._finalizeHeaders(),void this._sendHxxpRequest();this._response=t,this._response.on("data",function(e){return n._onHttpResponseData(t,e)}),this._response.on("end",function(){return n._onHttpResponseEnd(t)}),this._response.on("close",function(){return n._onHttpResponseClose(t)}),this.responseUrl=this._url.href.split("#")[0],this.status=t.statusCode,this.statusText=s.STATUS_CODES[this.status],this._parseResponseHeaders(t);var i=this._responseHeaders["content-length"]||"";this._totalBytes=+i,this._lengthComputable=!!i,this._setReadyState(r.HEADERS_RECEIVED)}},r.prototype._onHttpResponseData=function(e,t){this._response===e&&(this._responseParts.push(new n(t)),this._loadedBytes+=t.length,this.readyState!==r.LOADING&&this._setReadyState(r.LOADING),this._dispatchProgress("progress"))},r.prototype._onHttpResponseEnd=function(e){this._response===e&&(this._parseResponse(),this._request=null,this._response=null,this._setReadyState(r.DONE),this._dispatchProgress("load"),this._dispatchProgress("loadend"))},r.prototype._onHttpResponseClose=function(e){if(this._response===e){var t=this._request;this._setError(),t.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend")}},r.prototype._onHttpTimeout=function(e){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("timeout"),this._dispatchProgress("loadend"))},r.prototype._onHttpRequestError=function(e,t){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend"))},r.prototype._dispatchProgress=function(e){var t=new r.ProgressEvent(e);t.lengthComputable=this._lengthComputable,t.loaded=this._loadedBytes,t.total=this._totalBytes,this.dispatchEvent(t)},r.prototype._setError=function(){this._request=null,this._response=null,this._responseHeaders=null,this._responseParts=null},r.prototype._parseUrl=function(e,t,r){var n=null==this.nodejsBaseUrl?e:f.resolve(this.nodejsBaseUrl,e),i=f.parse(n,!1,!0);i.hash=null;var o=(i.auth||"").split(":"),a=o[0],s=o[1];return(a||s||t||r)&&(i.auth=(t||a||"")+":"+(r||s||"")),i},r.prototype._parseResponseHeaders=function(e){for(var t in this._responseHeaders={},e.headers){var r=t.toLowerCase();this._privateHeaders[r]||(this._responseHeaders[r]=e.headers[t])}null!=this._mimeOverride&&(this._responseHeaders["content-type"]=this._mimeOverride)},r.prototype._parseResponse=function(){var e=n.concat(this._responseParts);switch(this._responseParts=null,this.responseType){case"json":this.responseText=null;try{this.response=JSON.parse(e.toString("utf-8"))}catch(e){this.response=null}return;case"buffer":return this.responseText=null,void(this.response=e);case"arraybuffer":this.responseText=null;for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),i=0;i0&&(window.web3.eth.defaultAccount=t[0])})}window.ethereum=s}}},console.log("JS bridging rpc url access"),"undefined"!=typeof window&&window.bridge?window.bridge.post("getRPCurl",{},function(e,r){r&&t(r.description,null),t(null,e.rpcURL)}):(console.log("No bridge to native code is found"),t(!0,null))}()},{"./wk.bridge":424,web3:407,"web3-provider-engine/zero.js":397}],2:[function(e,t,r){t.exports=e("./register")().Promise},{"./register":4}],3:[function(e,t,r){"use strict";var n=null;t.exports=function(e,t){return function(r,i){r=r||null;var o=!1!==(i=i||{}).global;if(null===n&&o&&(n=e["@@any-promise/REGISTRATION"]||null),null!==n&&null!==r&&n.implementation!==r)throw new Error('any-promise already defined as "'+n.implementation+'". You can only register an implementation before the first call to require("any-promise") and an implementation cannot be changed');return null===n&&(n=null!==r&&void 0!==i.Promise?{Promise:i.Promise,implementation:r}:t(r),o&&(e["@@any-promise/REGISTRATION"]=n)),n}}},{}],4:[function(e,t,r){"use strict";t.exports=e("./loader")(window,function(){if(void 0===window.Promise)throw new Error("any-promise browser requires a polyfill or explicit registration e.g: require('any-promise/register/bluebird')");return{Promise:window.Promise,implementation:"window.Promise"}})},{"./loader":3}],5:[function(e,t,r){var n=r;n.bignum=e("bn.js"),n.define=e("./asn1/api").define,n.base=e("./asn1/base"),n.constants=e("./asn1/constants"),n.decoders=e("./asn1/decoders"),n.encoders=e("./asn1/encoders")},{"./asn1/api":6,"./asn1/base":8,"./asn1/constants":12,"./asn1/decoders":14,"./asn1/encoders":17,"bn.js":53}],6:[function(e,t,r){var n=e("../asn1"),i=e("inherits");function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}r.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(t){var r;try{r=e("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){r=function(e){this._initNamed(e)}}return i(r,t),r.prototype._initNamed=function(e){t.call(this,e)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(n.decoders[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(n.encoders[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},{"../asn1":5,inherits:180,vm:334}],7:[function(e,t,r){var n=e("inherits"),i=e("../base").Reporter,o=e("buffer").Buffer;function a(e,t){i.call(this,t),o.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function s(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return e instanceof s||(e=new s(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=o.byteLength(e);else{if(!o.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}n(a,i),r.DecoderBuffer=a,a.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},a.prototype.restore=function(e){var t=new a(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,i.prototype.restore.call(this,e.reporter),t},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},a.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new a(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},a.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},r.EncoderBuffer=s,s.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length?e:(Array.isArray(this.value)?this.value.forEach(function(r){r.join(e,t),t+=r.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):o.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},{"../base":8,buffer:84,inherits:180}],8:[function(e,t,r){var n=r;n.Reporter=e("./reporter").Reporter,n.DecoderBuffer=e("./buffer").DecoderBuffer,n.EncoderBuffer=e("./buffer").EncoderBuffer,n.Node=e("./node")},{"./buffer":7,"./node":9,"./reporter":10}],9:[function(e,t,r){var n=e("../base").Reporter,i=e("../base").EncoderBuffer,o=e("../base").DecoderBuffer,a=e("minimalistic-assert"),s=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],u=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function c(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}t.exports=c;var f=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){var e=this._baseState,t={};f.forEach(function(r){t[r]=e[r]});var r=new this.constructor(t.parent);return r._baseState=t,r},c.prototype._wrap=function(){var e=this._baseState;u.forEach(function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}},this)},c.prototype._init=function(e){var t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter(function(e){return e._baseState.parent===this},this),a.equal(t.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(e){var t=this._baseState,r=e.filter(function(e){return e instanceof this.constructor},this);e=e.filter(function(e){return!(e instanceof this.constructor)},this),0!==r.length&&(a(null===t.children),t.children=r,r.forEach(function(e){e._baseState.parent=this},this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map(function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach(function(r){r==(0|r)&&(r|=0);var n=e[r];t[n]=r}),t}))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(e){c.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}}),s.forEach(function(e){c.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(r),this}}),c.prototype.use=function(e){a(e);var t=this._baseState;return a(null===t.use),t.use=e,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(e){var t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},c.prototype.explicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},c.prototype.implicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},c.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},c.prototype.key=function(e){var t=this._baseState;return a(null===t.key),t.key=e,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(e){var t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map(function(t){return e[t]})),this},c.prototype.contains=function(e){var t=this._baseState;return a(null===t.use),t.contains=e,this},c.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var n,i=r.default,a=!0,s=null;if(null!==r.key&&(s=e.enterKey(r.key)),r.optional){var u=null;if(null!==r.explicit?u=r.explicit:null!==r.implicit?u=r.implicit:null!==r.tag&&(u=r.tag),null!==u||r.any){if(a=this._peekTag(e,u,r.any),e.isError(a))return a}else{var c=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(c)}}if(r.obj&&a&&(n=e.enterObject()),a){if(null!==r.explicit){var f=this._decodeTag(e,r.explicit);if(e.isError(f))return f;e=f}var h=e.offset;if(null===r.use&&null===r.choice){if(r.any)c=e.save();var l=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(l))return l;r.any?i=e.raw(c):e=l}if(t&&t.track&&null!==r.tag&&t.track(e.path(),h,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),i=r.any?i:null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),e.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach(function(r){r._decode(e,t)}),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var d=new o(i);i=this._getUse(r.contains,e._reporterState.obj)._decode(d,t)}}return r.obj&&a&&(i=e.leaveObject(n)),null===r.key||null===i&&!0!==a?null!==s&&e.exitKey(s):e.leaveKey(s,r.key,i),i},c.prototype._decodeGeneric=function(e,t,r){var n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},c.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},c.prototype._decodeChoice=function(e,t){var r=this._baseState,n=null,i=!1;return Object.keys(r.choice).some(function(o){var a=e.save(),s=r.choice[o];try{var u=s._decode(e,t);if(e.isError(u))return!1;n={type:o,value:u},i=!0}catch(t){return e.restore(a),!1}return!0},this),i?n:e.error("Choice not matched")},c.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},c.prototype._encode=function(e,t,r){var n=this._baseState;if(null===n.default||n.default!==e){var i=this._encodeValue(e,t,r);if(void 0!==i&&!this._skipDefault(i,t,r))return i}},c.prototype._encodeValue=function(e,t,r){var i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);var o=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}var a=null,s=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)a=this._getUse(i.contains,r)._encode(e,t),s=!0;else if(i.children)a=i.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i},this).filter(function(e){return e}),a=this._createEncoderBuffer(a);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var u=this.clone();u._baseState.implicit=null,a=this._createEncoderBuffer(e.map(function(r){var n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)},u))}else null!==i.use?o=this._getUse(i.use,r)._encode(e,t):(a=this._encodePrimitive(i.tag,e),s=!0);if(!i.any&&null===i.choice){var c=null!==i.implicit?i.implicit:i.tag,f=null===i.implicit?"universal":"context";null===c?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(c,s,f,a))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},c.prototype._encodeChoice=function(e,t){var r=this._baseState,n=r.choice[e.type];return n||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},c.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},c.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},c.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},{"../base":8,"minimalistic-assert":234}],10:[function(e,t,r){var n=e("inherits");function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}r.Reporter=i,i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,r){var n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){var t,r=this._reporterState,n=e instanceof o;if(t=n?e:new o(r.path.map(function(e){return"["+JSON.stringify(e)+"]"}).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},i.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},n(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{inherits:180}],11:[function(e,t,r){var n=e("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=n._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=n._reverse(r.tag)},{"../constants":12}],12:[function(e,t,r){var n=r;n._reverse=function(e){var t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r|=0);var n=e[r];t[n]=r}),t},n.der=e("./der")},{"./der":11}],13:[function(e,t,r){var n=e("inherits"),i=e("../../asn1"),o=i.base,a=i.bignum,s=i.constants.der;function u(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){o.Node.call(this,"der",e)}function f(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var n=s.tagClass[r>>6],i=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:s.tag[r]}}function h(e,t,r){var n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;var i=127&n;if(i>4)return e.error("length octet is too long");n=0;for(var o=0;o=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=s.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(n.length<128)return(o=new i(2))[0]=a,o[1]=n.length,this._createEncoderBuffer([o,n]);for(var u=1,c=n.length;c>=256;c>>=8)u++;(o=new i(2+u))[0]=a,o[1]=128|u;c=1+u;for(var f=n.length;f>0;c--,f>>=8)o[c]=255&f;return this._createEncoderBuffer([o,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new i(2*e.length),n=0;n=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var o=0;for(n=0;n=128;a>>=7)o++}var s=new i(o),u=s.length-1;for(n=e.length-1;n>=0;n--){a=e[n];for(s[u--]=127&a;(a>>=7)>0;)s[u--]=128|127&a}return this._createEncoderBuffer(s)},c.prototype._encodeTime=function(e,t){var r,n=new Date(e);return"gentime"===t?r=[f(n.getFullYear()),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[f(n.getFullYear()%100),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!i.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new i(r)}if(i.isBuffer(e)){var n=e.length;0===e.length&&n++;var o=new i(n);return e.copy(o),0===e.length&&(o[0]=0),this._createEncoderBuffer(o)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);n=1;for(var a=e;a>=256;a>>=8)n++;for(a=(o=new Array(n)).length-1;a>=0;a--)o[a]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new i(o))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){var n,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,r).join()),o.length!==i.defaultBuffer.length)return!1;for(n=0;n=0;c--)if(f[c]!==h[c])return!1;for(c=f.length-1;c>=0;c--)if(u=f[c],!v(e[u],t[u],r,n))return!1;return!0}(e,t,r,a))}return r?e===t:e==t}function g(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function w(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function _(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&y(i,r,"Missing expected exception"+n);var a="string"==typeof n,s=!e&&i&&!r;if((!e&&o.isError(i)&&a&&w(i,r)||s)&&y(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(i,r)||!e&&i)throw i}h.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=p(b((t=this).actual),128)+" "+t.operator+" "+p(b(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=d(r),a=i.indexOf("\n"+o);if(a>=0){var s=i.indexOf("\n",a+1);i=i.substring(s+1)}this.stack=i}}},o.inherits(h.AssertionError,Error),h.fail=y,h.ok=m,h.equal=function(e,t,r){e!=t&&y(e,t,r,"==",h.equal)},h.notEqual=function(e,t,r){e==t&&y(e,t,r,"!=",h.notEqual)},h.deepEqual=function(e,t,r){v(e,t,!1)||y(e,t,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(e,t,r){v(e,t,!0)||y(e,t,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(e,t,r){v(e,t,!1)&&y(e,t,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function e(t,r,n){v(t,r,!0)&&y(t,r,n,"notDeepStrictEqual",e)},h.strictEqual=function(e,t,r){e!==t&&y(e,t,r,"===",h.strictEqual)},h.notStrictEqual=function(e,t,r){e===t&&y(e,t,r,"!==",h.notStrictEqual)},h.throws=function(e,t,r){_(!0,e,t,r)},h.doesNotThrow=function(e,t,r){_(!1,e,t,r)},h.ifError=function(e){if(e)throw e};var A=Object.keys||function(e){var t=[];for(var r in e)a.call(e,r)&&t.push(r);return t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":333}],20:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){return(0,i.default)(function(t,r){var i;try{i=e.apply(this,t)}catch(e){return r(e)}(0,n.default)(i)&&"function"==typeof i.then?i.then(function(e){s(r,null,e)},function(e){s(r,e.message?e:new Error(e))}):r(null,i)})};var n=a(e("lodash/isObject")),i=a(e("./internal/initialParams")),o=a(e("./internal/setImmediate"));function a(e){return e&&e.__esModule?e:{default:e}}function s(e,t,r){try{e(t,r)}catch(e){(0,o.default)(u,e)}}function u(e){throw e}t.exports=r.default},{"./internal/initialParams":31,"./internal/setImmediate":37,"lodash/isObject":225}],21:[function(e,t,r){(function(e,n){!function(e,n){"object"==typeof r&&void 0!==t?n(r):"function"==typeof define&&define.amd?define(["exports"],n):n(e.async=e.async||{})}(this,function(r){"use strict";function i(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i-1&&e%1==0&&e<=L}function D(e){return null!=e&&O(e.length)&&!function(e){if(!s(e))return!1;var t=B(e);return t==C||t==N||t==P||t==R}(e)}var F={};function q(){}function H(e){return function(){if(null!==e){var t=e;e=null,t.apply(this,arguments)}}}var z="function"==typeof Symbol&&Symbol.iterator,K=function(e){return z&&e[z]&&e[z]()};function V(e){return null!=e&&"object"==typeof e}var G="[object Arguments]";function W(e){return V(e)&&B(e)==G}var Y=Object.prototype,X=Y.hasOwnProperty,Z=Y.propertyIsEnumerable,J=W(function(){return arguments}())?W:function(e){return V(e)&&X.call(e,"callee")&&!Z.call(e,"callee")},$=Array.isArray;var Q="object"==typeof r&&r&&!r.nodeType&&r,ee=Q&&"object"==typeof t&&t&&!t.nodeType&&t,te=ee&&ee.exports===Q?A.Buffer:void 0,re=(te?te.isBuffer:void 0)||function(){return!1},ne=9007199254740991,ie=/^(?:0|[1-9]\d*)$/;function oe(e,t){return!!(t=null==t?ne:t)&&("number"==typeof e||ie.test(e))&&e>-1&&e%1==0&&e2&&(n=i(arguments,1)),t){var c={};Fe(o,function(e,t){c[t]=e}),c[e]=n,s=!0,u=Object.create(null),r(t,c)}else o[e]=n,Le(u[e]||[],function(e){e()}),d()});a++;var c=v(t[t.length-1]);t.length>1?c(o,n):c(n)}(e,t)})}function d(){if(0===c.length&&0===a)return r(null,o);for(;c.length&&a=0&&r.push(n)}),r}Fe(e,function(t,r){if(!$(t))return l(r,[t]),void f.push(r);var n=t.slice(0,t.length-1),i=n.length;if(0===i)return l(r,t),void f.push(r);h[r]=i,Le(n,function(o){if(!e[o])throw new Error("async.auto task `"+r+"` has a non-existent dependency `"+o+"` in "+n.join(", "));!function(e,t){var r=u[e];r||(r=u[e]=[]);r.push(t)}(o,function(){0===--i&&l(r,t)})})}),function(){var e,t=0;for(;f.length;)e=f.pop(),t++,Le(p(e),function(e){0==--h[e]&&f.push(e)});if(t!==n)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),d()};function Ke(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r=n?e:function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n-1;);return r}(i,o),function(e,t){for(var r=e.length;r--&&He(t,e[r],0)>-1;);return r}(i,o)+1).join("")}var ht=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,lt=/,/,dt=/(=.+)?(\s*)$/,pt=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;function bt(e,t){var r={};Fe(e,function(e,t){var n,i,o=m(e),a=!o&&1===e.length||o&&0===e.length;if($(e))n=e.slice(0,-1),e=e[e.length-1],r[t]=n.concat(n.length>0?s:e);else if(a)r[t]=e;else{if(n=i=(i=(i=(i=(i=e).toString().replace(pt,"")).match(ht)[2].replace(" ",""))?i.split(lt):[]).map(function(e){return ft(e.replace(dt,""))}),0===e.length&&!o&&0===n.length)throw new Error("autoInject task functions require explicit parameters.");o||n.pop(),r[t]=n.concat(s)}function s(t,r){var i=Ke(n,function(e){return t[e]});i.push(r),v(e).apply(null,i)}}),ze(r,t)}function yt(){this.head=this.tail=null,this.length=0}function mt(e,t){e.length=1,e.head=e.tail=t}function vt(e,t,r){if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var n=v(e),i=0,o=[],a=!1;function s(e,t,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(f.started=!0,$(e)||(e=[e]),0===e.length&&f.idle())return l(function(){f.drain()});for(var n=0,i=e.length;n0&&o.splice(s,1),a.callback.apply(a,arguments),null!=t&&f.error(t,a.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()}}var c=!1,f={_tasks:new yt,concurrency:t,payload:r,saturated:q,unsaturated:q,buffer:t/4,empty:q,drain:q,error:q,started:!1,paused:!1,push:function(e,t){s(e,!1,t)},kill:function(){f.drain=q,f._tasks.empty()},unshift:function(e,t){s(e,!0,t)},remove:function(e){f._tasks.remove(e)},process:function(){if(!c){for(c=!0;!f.paused&&i2&&(o=i(arguments,1)),n[t]=o,r(e)})},function(e){r(e,n)})}function br(e,t){pr(Ie,e,t)}function yr(e,t,r){pr(Ee(t),e,r)}var mr=function(e,t){var r=v(e);return vt(function(e,t){r(e[0],t)},t,1)},vr=function(e,t){var r=mr(e,t);return r.push=function(e,t,n){if(null==n&&(n=q),"function"!=typeof n)throw new Error("task callback must be a function");if(r.started=!0,$(e)||(e=[e]),0===e.length)return l(function(){r.drain()});t=t||0;for(var i=r._tasks.head;i&&t>=i.priority;)i=i.next;for(var o=0,a=e.length;on?1:0}je(e,function(e,t){n(e,function(r,n){if(r)return t(r);t(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);r(null,Ke(t.sort(i),Zt("value")))})}function Nr(e,t,r){var n=v(e);return a(function(i,o){var a,s=!1;i.push(function(){s||(o.apply(null,arguments),clearTimeout(a))}),a=setTimeout(function(){var t=e.name||"anonymous",n=new Error('Callback function "'+t+'" timed out.');n.code="ETIMEDOUT",r&&(n.info=r),s=!0,o(n)},t),n.apply(null,i)})}var Rr=Math.ceil,Lr=Math.max;function Or(e,t,r,n){var i=v(r);Ce(function(e,t,r,n){for(var i=-1,o=Lr(Rr((t-e)/(r||1)),0),a=Array(o);o--;)a[n?o:++i]=e,e+=r;return a}(0,e,1),t,i,n)}var Dr=ke(Or,1/0),Fr=ke(Or,1);function qr(e,t,r,n){arguments.length<=3&&(n=r,r=t,t=$(e)?[]:{}),n=H(n||q);var i=v(r);Ie(e,function(e,r,n){i(t,e,r,n)},function(e){n(e,t)})}function Hr(e,t){var r,n=null;t=t||q,Kt(e,function(e,t){v(e)(function(e,o){r=arguments.length>2?i(arguments,1):o,n=e,t(!e)})},function(){t(n,r)})}function zr(e){return function(){return(e.unmemoized||e).apply(null,arguments)}}function Kr(e,t,r){r=Ae(r||q);var n=v(t);if(!e())return r(null);var o=function(t){if(t)return r(t);if(e())return n(o);var a=i(arguments,1);r.apply(null,[null].concat(a))};n(o)}function Vr(e,t,r){Kr(function(){return!e.apply(this,arguments)},t,r)}var Gr=function(e,t){if(t=H(t||q),!$(e))return t(new Error("First argument to waterfall must be an array of functions"));if(!e.length)return t();var r=0;function n(t){var n=v(e[r++]);t.push(Ae(o)),n.apply(null,t)}function o(o){if(o||r===e.length)return t.apply(null,arguments);n(i(arguments,1))}n([])},Wr={apply:o,applyEach:Be,applyEachSeries:Re,asyncify:d,auto:ze,autoInject:bt,cargo:gt,compose:Et,concat:St,concatLimit:kt,concatSeries:Mt,constant:It,detect:Bt,detectLimit:Pt,detectSeries:Ct,dir:Rt,doDuring:Lt,doUntil:Dt,doWhilst:Ot,during:Ft,each:Ht,eachLimit:zt,eachOf:Ie,eachOfLimit:xe,eachOfSeries:wt,eachSeries:Kt,ensureAsync:Vt,every:Wt,everyLimit:Yt,everySeries:Xt,filter:er,filterLimit:tr,filterSeries:rr,forever:nr,groupBy:or,groupByLimit:ir,groupBySeries:ar,log:sr,map:je,mapLimit:Ce,mapSeries:Ne,mapValues:cr,mapValuesLimit:ur,mapValuesSeries:fr,memoize:lr,nextTick:dr,parallel:br,parallelLimit:yr,priorityQueue:vr,queue:mr,race:gr,reduce:_t,reduceRight:wr,reflect:_r,reflectAll:Ar,reject:xr,rejectLimit:kr,rejectSeries:Sr,retry:Ir,retryable:Tr,seq:At,series:Ur,setImmediate:l,some:jr,someLimit:Br,someSeries:Pr,sortBy:Cr,timeout:Nr,times:Dr,timesLimit:Or,timesSeries:Fr,transform:qr,tryEach:Hr,unmemoize:zr,until:Vr,waterfall:Gr,whilst:Kr,all:Wt,allLimit:Yt,allSeries:Xt,any:jr,anyLimit:Br,anySeries:Pr,find:Bt,findLimit:Pt,findSeries:Ct,forEach:Ht,forEachSeries:Kt,forEachLimit:zt,forEachOf:Ie,forEachOfSeries:wt,forEachOfLimit:xe,inject:_t,foldl:_t,foldr:wr,select:er,selectLimit:tr,selectSeries:rr,wrapSync:d};r.default=Wr,r.apply=o,r.applyEach=Be,r.applyEachSeries=Re,r.asyncify=d,r.auto=ze,r.autoInject=bt,r.cargo=gt,r.compose=Et,r.concat=St,r.concatLimit=kt,r.concatSeries=Mt,r.constant=It,r.detect=Bt,r.detectLimit=Pt,r.detectSeries=Ct,r.dir=Rt,r.doDuring=Lt,r.doUntil=Dt,r.doWhilst=Ot,r.during=Ft,r.each=Ht,r.eachLimit=zt,r.eachOf=Ie,r.eachOfLimit=xe,r.eachOfSeries=wt,r.eachSeries=Kt,r.ensureAsync=Vt,r.every=Wt,r.everyLimit=Yt,r.everySeries=Xt,r.filter=er,r.filterLimit=tr,r.filterSeries=rr,r.forever=nr,r.groupBy=or,r.groupByLimit=ir,r.groupBySeries=ar,r.log=sr,r.map=je,r.mapLimit=Ce,r.mapSeries=Ne,r.mapValues=cr,r.mapValuesLimit=ur,r.mapValuesSeries=fr,r.memoize=lr,r.nextTick=dr,r.parallel=br,r.parallelLimit=yr,r.priorityQueue=vr,r.queue=mr,r.race=gr,r.reduce=_t,r.reduceRight=wr,r.reflect=_r,r.reflectAll=Ar,r.reject=xr,r.rejectLimit=kr,r.rejectSeries=Sr,r.retry=Ir,r.retryable=Tr,r.seq=At,r.series=Ur,r.setImmediate=l,r.some=jr,r.someLimit=Br,r.someSeries=Pr,r.sortBy=Cr,r.timeout=Nr,r.times=Dr,r.timesLimit=Or,r.timesSeries=Fr,r.transform=qr,r.tryEach=Hr,r.unmemoize=zr,r.until=Vr,r.waterfall=Gr,r.whilst=Kr,r.all=Wt,r.allLimit=Yt,r.allSeries=Xt,r.any=jr,r.anyLimit=Br,r.anySeries=Pr,r.find=Bt,r.findLimit=Pt,r.findSeries=Ct,r.forEach=Ht,r.forEachSeries=Kt,r.forEachLimit=zt,r.forEachOf=Ie,r.forEachOfSeries=wt,r.forEachOfLimit=xe,r.inject=_t,r.foldl=_t,r.foldr=wr,r.select=er,r.selectLimit=tr,r.selectSeries=rr,r.wrapSync=d,Object.defineProperty(r,"__esModule",{value:!0})})}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257}],22:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r,a){(0,n.default)(t)(e,(0,i.default)((0,o.default)(r)),a)};var n=a(e("./internal/eachOfLimit")),i=a(e("./internal/withoutIndex")),o=a(e("./internal/wrapAsync"));function a(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./internal/eachOfLimit":29,"./internal/withoutIndex":39,"./internal/wrapAsync":40}],23:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r){((0,n.default)(e)?l:d)(e,(0,f.default)(t),r)};var n=h(e("lodash/isArrayLike")),i=h(e("./internal/breakLoop")),o=h(e("./eachOfLimit")),a=h(e("./internal/doLimit")),s=h(e("lodash/noop")),u=h(e("./internal/once")),c=h(e("./internal/onlyOnce")),f=h(e("./internal/wrapAsync"));function h(e){return e&&e.__esModule?e:{default:e}}function l(e,t,r){r=(0,u.default)(r||s.default);var n=0,o=0,a=e.length;function f(e,t){e?r(e):++o!==a&&t!==i.default||r(null)}for(0===a&&r(null);n2&&(n=(0,o.default)(arguments,1)),s[t]=n,r(e)})},function(e){r(e,s)})};var n=s(e("lodash/noop")),i=s(e("lodash/isArrayLike")),o=s(e("./slice")),a=s(e("./wrapAsync"));function s(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./slice":38,"./wrapAsync":40,"lodash/isArrayLike":221,"lodash/noop":229}],37:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.hasNextTick=r.hasSetImmediate=void 0,r.fallback=c,r.wrap=f;var n,i=e("./slice"),o=(n=i)&&n.__esModule?n:{default:n};var a,s=r.hasSetImmediate="function"==typeof setImmediate&&setImmediate,u=r.hasNextTick="object"==typeof t&&"function"==typeof t.nextTick;function c(e){setTimeout(e,0)}function f(e){return function(t){var r=(0,o.default)(arguments,1);e(function(){t.apply(null,r)})}}a=s?setImmediate:u?t.nextTick:c,r.default=f(a)}).call(this,e("_process"))},{"./slice":38,_process:257}],38:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i0,"Expected a maximum number of retry greater than 0 but got %s.",e),this.maxNumberOfRetry_=e},o.prototype.backoff=function(e){i.checkState(-1===this.timeoutID_,"Backoff in progress."),this.backoffNumber_===this.maxNumberOfRetry_?(this.emit("fail",e),this.reset()):(this.backoffDelay_=this.backoffStrategy_.next(),this.timeoutID_=setTimeout(this.handlers.backoff,this.backoffDelay_),this.emit("backoff",this.backoffNumber_,this.backoffDelay_,e))},o.prototype.onBackoff_=function(){this.timeoutID_=-1,this.emit("ready",this.backoffNumber_,this.backoffDelay_),this.backoffNumber_++},o.prototype.reset=function(){this.backoffNumber_=0,this.backoffStrategy_.reset(),clearTimeout(this.timeoutID_),this.timeoutID_=-1},t.exports=o},{events:157,precond:253,util:333}],47:[function(e,t,r){var n=e("events"),i=e("precond"),o=e("util"),a=e("./backoff"),s=e("./strategy/fibonacci");function u(e,t,r){n.EventEmitter.call(this),i.checkIsFunction(e,"Expected fn to be a function."),i.checkIsArray(t,"Expected args to be an array."),i.checkIsFunction(r,"Expected callback to be a function."),this.function_=e,this.arguments_=t,this.callback_=r,this.lastResult_=[],this.numRetries_=0,this.backoff_=null,this.strategy_=null,this.failAfter_=-1,this.retryPredicate_=u.DEFAULT_RETRY_PREDICATE_,this.state_=u.State_.PENDING}o.inherits(u,n.EventEmitter),u.State_={PENDING:0,RUNNING:1,COMPLETED:2,ABORTED:3},u.DEFAULT_RETRY_PREDICATE_=function(e){return!0},u.prototype.isPending=function(){return this.state_==u.State_.PENDING},u.prototype.isRunning=function(){return this.state_==u.State_.RUNNING},u.prototype.isCompleted=function(){return this.state_==u.State_.COMPLETED},u.prototype.isAborted=function(){return this.state_==u.State_.ABORTED},u.prototype.setStrategy=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.strategy_=e,this},u.prototype.retryIf=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.retryPredicate_=e,this},u.prototype.getLastResult=function(){return this.lastResult_.concat()},u.prototype.getNumRetries=function(){return this.numRetries_},u.prototype.failAfter=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.failAfter_=e,this},u.prototype.abort=function(){this.isCompleted()||this.isAborted()||(this.isRunning()&&this.backoff_.reset(),this.state_=u.State_.ABORTED,this.lastResult_=[new Error("Backoff aborted.")],this.emit("abort"),this.doCallback_())},u.prototype.start=function(e){i.checkState(!this.isAborted(),"FunctionCall is aborted."),i.checkState(this.isPending(),"FunctionCall already started.");var t=this.strategy_||new s;this.backoff_=e?e(t):new a(t),this.backoff_.on("ready",this.doCall_.bind(this,!0)),this.backoff_.on("fail",this.doCallback_.bind(this)),this.backoff_.on("backoff",this.handleBackoff_.bind(this)),this.failAfter_>0&&this.backoff_.failAfter(this.failAfter_),this.state_=u.State_.RUNNING,this.doCall_(!1)},u.prototype.doCall_=function(e){e&&this.numRetries_++;var t=["call"].concat(this.arguments_);n.EventEmitter.prototype.emit.apply(this,t);var r=this.handleFunctionCallback_.bind(this);this.function_.apply(null,this.arguments_.concat(r))},u.prototype.doCallback_=function(){this.callback_.apply(null,this.lastResult_)},u.prototype.handleFunctionCallback_=function(){if(!this.isAborted()){var e=Array.prototype.slice.call(arguments);this.lastResult_=e,n.EventEmitter.prototype.emit.apply(this,["callback"].concat(e));var t=e[0];t&&this.retryPredicate_(t)?this.backoff_.backoff(t):(this.state_=u.State_.COMPLETED,this.doCallback_())}},u.prototype.handleBackoff_=function(e,t,r){this.emit("backoff",e,t,r)},t.exports=u},{"./backoff":46,"./strategy/fibonacci":49,events:157,precond:253,util:333}],48:[function(e,t,r){var n=e("util"),i=e("precond"),o=e("./strategy");function a(e){o.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay(),this.factor_=a.DEFAULT_FACTOR,e&&void 0!==e.factor&&(i.checkArgument(e.factor>1,"Exponential factor should be greater than 1 but got %s.",e.factor),this.factor_=e.factor)}n.inherits(a,o),a.DEFAULT_FACTOR=2,a.prototype.next_=function(){return this.backoffDelay_=Math.min(this.nextBackoffDelay_,this.getMaxDelay()),this.nextBackoffDelay_=this.backoffDelay_*this.factor_,this.backoffDelay_},a.prototype.reset_=function(){this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()},t.exports=a},{"./strategy":50,precond:253,util:333}],49:[function(e,t,r){var n=e("util"),i=e("./strategy");function o(e){i.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}n.inherits(o,i),o.prototype.next_=function(){var e=Math.min(this.nextBackoffDelay_,this.getMaxDelay());return this.nextBackoffDelay_+=this.backoffDelay_,this.backoffDelay_=e,e},o.prototype.reset_=function(){this.nextBackoffDelay_=this.getInitialDelay(),this.backoffDelay_=0},t.exports=o},{"./strategy":50,util:333}],50:[function(e,t,r){e("events"),e("util");function n(e){return null!=e}function i(e){if(n((e=e||{}).initialDelay)&&e.initialDelay<1)throw new Error("The initial timeout must be greater than 0.");if(n(e.maxDelay)&&e.maxDelay<1)throw new Error("The maximal timeout must be greater than 0.");if(this.initialDelay_=e.initialDelay||100,this.maxDelay_=e.maxDelay||1e4,this.maxDelay_<=this.initialDelay_)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");if(n(e.randomisationFactor)&&(e.randomisationFactor<0||e.randomisationFactor>1))throw new Error("The randomisation factor must be between 0 and 1.");this.randomisationFactor_=e.randomisationFactor||0}i.prototype.getMaxDelay=function(){return this.maxDelay_},i.prototype.getInitialDelay=function(){return this.initialDelay_},i.prototype.next=function(){var e=this.next_(),t=1+Math.random()*this.randomisationFactor_;return Math.round(e*t)},i.prototype.next_=function(){throw new Error("BackoffStrategy.next_() unimplemented.")},i.prototype.reset=function(){this.reset_()},i.prototype.reset_=function(){throw new Error("BackoffStrategy.reset_() unimplemented.")},t.exports=i},{events:157,util:333}],51:[function(e,t,r){"use strict";r.byteLength=function(e){return 3*e.length/4-c(e)},r.toByteArray=function(e){var t,r,n,a,s,u=e.length;a=c(e),s=new o(3*u/4-a),r=a>0?u-4:u;var f=0;for(t=0;t>16&255,s[f++]=n>>8&255,s[f++]=255&n;2===a?(n=i[e.charCodeAt(t)]<<2|i[e.charCodeAt(t+1)]>>4,s[f++]=255&n):1===a&&(n=i[e.charCodeAt(t)]<<10|i[e.charCodeAt(t+1)]<<4|i[e.charCodeAt(t+2)]>>2,s[f++]=n>>8&255,s[f++]=255&n);return s},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o="",a=[],s=0,u=r-i;su?u:s+16383));1===i?(t=e[r-1],o+=n[t>>2],o+=n[t<<4&63],o+="=="):2===i&&(t=(e[r-2]<<8)+e[r-1],o+=n[t>>10],o+=n[t>>4&63],o+=n[t<<2&63],o+="=");return a.push(o),a.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function f(e,t,r){for(var i,o,a=[],s=t;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],52:[function(e,t,r){var n=e("safe-buffer").Buffer;t.exports={check:function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))},decode:function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");var r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},encode:function(e,t){var r=e.length,i=t.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(i>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+r]=2,o[5+r]=t.length,t.copy(o,6+r),o}}},{"safe-buffer":290}],53:[function(e,t,r){!function(t,r){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var a;"object"==typeof t?t.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{a=e("buffer").Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:55}],54:[function(e,t,r){var n;function i(e){this.rand=e}if(t.exports=function(e){return n||(n=new i(null)),n.generate(e)},t.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^t[m++],a=c[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^t[m++],s=c[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^t[m++],u=c[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^t[m++],d=o,p=a,b=s,y=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^t[m++],a=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^t[m++],s=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[m++],u=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^t[m++],[o>>>=0,a>>>=0,s>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],u=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,u=0;u<256;++u){var c=s^s<<1^s<<2^s<<3^s<<4;c=c>>>8^255&c^99,r[a]=c,n[c]=a;var f=e[a],h=e[f],l=e[h],d=257*e[c]^16843008*c;i[0][a]=d<<24|d>>>8,i[1][a]=d<<16|d>>>16,i[2][a]=d<<8|d>>>24,i[3][a]=d,d=16843009*l^65537*h^257*f^16843008*a,o[0][c]=d<<24|d>>>8,o[1][c]=d<<16|d>>>16,o[2][c]=d<<8|d>>>24,o[3][c]=d,0===a?a=s=1:(a=f^e[e[e[l^f]]],s^=e[e[s]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(e){this._key=i(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a],a^=s[o/t|0]<<24):t>6&&o%t==4&&(a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a]),i[o]=i[o-t]^a}for(var c=[],f=0;f>>24]]^u.INV_SUB_MIX[1][u.SBOX[l>>>16&255]]^u.INV_SUB_MIX[2][u.SBOX[l>>>8&255]]^u.INV_SUB_MIX[3][u.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},c.prototype.encryptBlockRaw=function(e){return a(e=i(e),this._keySchedule,u.SUB_MIX,u.SBOX,this._nRounds)},c.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=n.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},c.prototype.decryptBlock=function(e){var t=(e=i(e))[1];e[1]=e[3],e[3]=t;var r=a(e,this._invKeySchedule,u.INV_SUB_MIX,u.INV_SBOX,this._nRounds),o=n.allocUnsafe(16);return o.writeUInt32BE(r[0],0),o.writeUInt32BE(r[3],4),o.writeUInt32BE(r[2],8),o.writeUInt32BE(r[1],12),o},c.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},t.exports.AES=c},{"safe-buffer":290}],57:[function(e,t,r){var n=e("./aes"),i=e("safe-buffer").Buffer,o=e("cipher-base"),a=e("inherits"),s=e("./ghash"),u=e("buffer-xor"),c=e("./incr32");function f(e,t,r,a){o.call(this);var u=i.alloc(4,0);this._cipher=new n.AES(t);var f=this._cipher.encryptBlock(u);this._ghash=new s(f),r=function(e,t,r){if(12===t.length)return e._finID=i.concat([t,i.from([0,0,0,1])]),i.concat([t,i.from([0,0,0,2])]);var n=new s(r),o=t.length,a=o%16;n.update(t),a&&(a=16-a,n.update(i.alloc(a,0))),n.update(i.alloc(8,0));var u=8*o,f=i.alloc(8);f.writeUIntBE(u,0,8),n.update(f),e._finID=n.state;var h=i.from(e._finID);return c(h),h}(this,r,f),this._prev=i.from(r),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=a,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}a(f,o),f.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=i.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},f.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=u(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var n=Math.min(e.length,t.length),i=0;i16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},h.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(e,t){var r=o[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(t,!1,r.key,r.iv);return l(e,n.key,n.iv)},r.createDecipheriv=l},{"./aes":56,"./authCipher":57,"./modes":69,"./streamCipher":72,"cipher-base":86,evp_bytestokey:158,inherits:180,"safe-buffer":290}],60:[function(e,t,r){var n=e("./modes"),i=e("./authCipher"),o=e("safe-buffer").Buffer,a=e("./streamCipher"),s=e("cipher-base"),u=e("./aes"),c=e("evp_bytestokey");function f(e,t,r){s.call(this),this._cache=new l,this._cipher=new u.AES(t),this._prev=o.from(r),this._mode=e,this._autopadding=!0}e("inherits")(f,s),f.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get();)r=this._mode.encrypt(this,t),n.push(r);return o.concat(n)};var h=o.alloc(16,16);function l(){this.cache=o.allocUnsafe(0)}function d(e,t,r){var s=n[e.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=o.from(t)),t.length!==s.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=o.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new a(s.module,t,r):"auth"===s.type?new i(s.module,t,r):new f(s.module,t,r)}f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(h))throw this._cipher.scrub(),new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},l.prototype.add=function(e){this.cache=o.concat([this.cache,e])},l.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},l.prototype.flush=function(){for(var e=16-this.cache.length,t=o.allocUnsafe(e),r=-1;++r>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function a(e){this.h=e,this.state=n.alloc(16,0),this.cache=n.allocUnsafe(0)}a.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=o(i)},a.prototype.update=function(e){var t;for(this.cache=n.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},a.prototype.final=function(e,t){return this.cache.length&&this.ghash(n.concat([this.cache,i],16)),this.ghash(o([0,e,0,t])),this.state},t.exports=a},{"safe-buffer":290}],62:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],63:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":83}],64:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("buffer-xor");function o(e,t,r){var o=t.length,a=i(t,e._cache);return e._cache=e._cache.slice(o),e._prev=n.concat([e._prev,r?t:a]),a}r.encrypt=function(e,t,r){for(var i,a=n.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=n.allocUnsafe(0)),!(e._cache.length<=t.length)){a=n.concat([a,o(e,t,r)]);break}i=e._cache.length,a=n.concat([a,o(e,t.slice(0,i),r)]),t=t.slice(i)}return a}},{"buffer-xor":83,"safe-buffer":290}],65:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t,r){for(var n,i,a=-1,s=0;++a<8;)n=t&1<<7-a?128:0,s+=(128&(i=e._cipher.encryptBlock(e._prev)[0]^n))>>a%8,e._prev=o(e._prev,r?n:i);return s}function o(e,t){var r=e.length,i=-1,o=n.allocUnsafe(e.length);for(e=n.concat([e,n.from([t])]);++i>7;return o}r.encrypt=function(e,t,r){for(var o=t.length,a=n.allocUnsafe(o),s=-1;++s=0||!r.umod(e.prime1)||!r.umod(e.prime2);)r=new n(i(t));return r}t.exports=o,o.getr=a}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84,randombytes:270}],77:[function(e,t,r){t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":78}],78:[function(e,t,r){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],79:[function(e,t,r){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],80:[function(e,t,r){(function(r){var n=e("create-hash"),i=e("stream"),o=e("inherits"),a=e("./sign"),s=e("./verify"),u=e("./algorithms.json");function c(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function f(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function h(e){return new c(e)}function l(e){return new f(e)}Object.keys(u).forEach(function(e){u[e].id=new r(u[e].id,"hex"),u[e.toLowerCase()]=u[e]}),o(c,i.Writable),c.prototype._write=function(e,t,r){this._hash.update(e),r()},c.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},c.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),n=a(r,e,this._hashType,this._signType,this._tag);return t?n.toString(t):n},o(f,i.Writable),f.prototype._write=function(e,t,r){this._hash.update(e),r()},f.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},f.prototype.verify=function(e,t,n){"string"==typeof t&&(t=new r(t,n)),this.end();var i=this._hash.digest();return s(t,i,e,this._signType,this._tag)},t.exports={Sign:h,Verify:l,createSign:h,createVerify:l}}).call(this,e("buffer").Buffer)},{"./algorithms.json":78,"./sign":81,"./verify":82,buffer:84,"create-hash":91,inherits:180,stream:311}],81:[function(e,t,r){(function(r){var n=e("create-hmac"),i=e("browserify-rsa"),o=e("elliptic").ec,a=e("bn.js"),s=e("parse-asn1"),u=e("./curves.json");function c(e,t,i,o){if((e=new r(e.toArray())).length0&&r.ishrn(n),r}function h(e,t,i){var o,a;do{for(o=new r(0);8*o.length=t)throw new Error("invalid sig")}t.exports=function(e,t,u,c,f){var h=o(u);if("ec"===h.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var n=a[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),s=r.data.subjectPrivateKey.data;return o.verify(t,e,s)}(e,t,h)}if("dsa"===h.type){if("dsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var i=r.data.p,a=r.data.q,u=r.data.g,c=r.data.pub_key,f=o.signature.decode(e,"der"),h=f.s,l=f.r;s(h,a),s(l,a);var d=n.mont(i),p=h.invm(a);return 0===u.toRed(d).redPow(new n(t).mul(p).mod(a)).fromRed().mul(c.toRed(d).redPow(l.mul(p).mod(a)).fromRed()).mod(i).mod(a).cmp(l)}(e,t,h)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");t=r.concat([f,t]);for(var l=h.modulus.byteLength(),d=[1],p=0;t.length+d.length+2o)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=s.prototype,t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(e)}return u(e,t,r)}function u(e,t,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return F(e)?function(e,t,r){if(t<0||e.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function d(e,t){if(s.isBuffer(e))return e.length;if(q(e)||F(e))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return O(e).length;default:if(n)return L(e).length;t=(""+t).toLowerCase(),n=!0}}function p(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var o,a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var f=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function x(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return x(this,t,r);case"ascii":return S(this,t,r);case"latin1":case"binary":return M(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},s.prototype.compare=function(e,t,r,n,i){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),u=Math.min(o,a),c=this.slice(n,i),f=e.slice(t,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return m(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return g(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function S(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,r,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function B(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function C(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,8),i.write(e,t,r,n,52,8),r+8}s.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},s.prototype.readUInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeFloatLE=function(e,t,r){return P(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return P(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return C(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return C(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(e){return n.toByteArray(function(e){if((e=e.trim().replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function F(e){return e instanceof ArrayBuffer||null!=e&&null!=e.constructor&&"ArrayBuffer"===e.constructor.name&&"number"==typeof e.byteLength}function q(e){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(e)}function H(e){return e!=e}},{"base64-js":51,ieee754:178}],85:[function(e,t,r){t.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],86:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("stream").Transform,o=e("string_decoder").StringDecoder;function a(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(a,i),a.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},a.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},a.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},a.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},t.exports=a},{inherits:180,"safe-buffer":290,stream:311,string_decoder:317}],87:[function(e,t,r){(function(e){var r=function(){"use strict";function t(e,t){return null!=t&&e instanceof t}var r,n,i;try{r=Map}catch(e){r=function(){}}try{n=Set}catch(e){n=function(){}}try{i=Promise}catch(e){i=function(){}}function o(a,u,c,f,h){"object"==typeof u&&(c=u.depth,f=u.prototype,h=u.includeNonEnumerable,u=u.circular);var l=[],d=[],p=void 0!==e;return void 0===u&&(u=!0),void 0===c&&(c=1/0),function a(c,b){if(null===c)return null;if(0===b)return c;var y,m;if("object"!=typeof c)return c;if(t(c,r))y=new r;else if(t(c,n))y=new n;else if(t(c,i))y=new i(function(e,t){c.then(function(t){e(a(t,b-1))},function(e){t(a(e,b-1))})});else if(o.__isArray(c))y=[];else if(o.__isRegExp(c))y=new RegExp(c.source,s(c)),c.lastIndex&&(y.lastIndex=c.lastIndex);else if(o.__isDate(c))y=new Date(c.getTime());else{if(p&&e.isBuffer(c))return y=e.allocUnsafe?e.allocUnsafe(c.length):new e(c.length),c.copy(y),y;t(c,Error)?y=Object.create(c):void 0===f?(m=Object.getPrototypeOf(c),y=Object.create(m)):(y=Object.create(f),m=f)}if(u){var v=l.indexOf(c);if(-1!=v)return d[v];l.push(c),d.push(y)}for(var g in t(c,r)&&c.forEach(function(e,t){var r=a(t,b-1),n=a(e,b-1);y.set(r,n)}),t(c,n)&&c.forEach(function(e){var t=a(e,b-1);y.add(t)}),c){var w;m&&(w=Object.getOwnPropertyDescriptor(m,g)),w&&null==w.set||(y[g]=a(c[g],b-1))}if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(c);for(g=0;g<_.length;g++){var A=_[g];(!(x=Object.getOwnPropertyDescriptor(c,A))||x.enumerable||h)&&(y[A]=a(c[A],b-1),x.enumerable||Object.defineProperty(y,A,{enumerable:!1}))}}if(h){var E=Object.getOwnPropertyNames(c);for(g=0;g>>2),a=0,s=0;a>5]|=128<>>9<<4)]=t;for(var r=1732584193,n=-271733879,i=-1732584194,o=271733878,h=0;h>>32-s,r);var a,s}function a(e,t,r,n,i,a,s){return o(t&r|~t&n,e,t,i,a,s)}function s(e,t,r,n,i,a,s){return o(t&n|r&~n,e,t,i,a,s)}function u(e,t,r,n,i,a,s){return o(t^r^n,e,t,i,a,s)}function c(e,t,r,n,i,a,s){return o(r^(t|~n),e,t,i,a,s)}function f(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}t.exports=function(e){return n(e,i)}},{"./make-hash":92}],94:[function(e,t,r){"use strict";var n=e("inherits"),i=e("./legacy"),o=e("cipher-base"),a=e("safe-buffer").Buffer,s=e("create-hash/md5"),u=e("ripemd160"),c=e("sha.js"),f=a.alloc(128);function h(e,t){o.call(this,"digest"),"string"==typeof t&&(t=a.from(t));var r="sha512"===e||"sha384"===e?128:64;(this._alg=e,this._key=t,t.length>r)?t=("rmd160"===e?new u:c(e)).update(t).digest():t.lengths?t=e(t):t.length-1};f.prototype.append=function(e,t){e=s(e),t=u(t);var r=this.map[e];this.map[e]=r?r+","+t:t},f.prototype.delete=function(e){delete this.map[s(e)]},f.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},f.prototype.set=function(e,t){this.map[s(e)]=u(t)},f.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},f.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),c(e)},f.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),c(e)},f.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),c(e)},t.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);var o=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},b.call(y.prototype),b.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:0,statusText:""});return e.type="error",e};var a=[301,302,303,307,308];v.redirect=function(e,t){if(-1===a.indexOf(t))throw new RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},e.Headers=f,e.Request=y,e.Response=v,e.fetch=function(e,r){return new Promise(function(n,i){var o=new y(e,r),a=new XMLHttpRequest;a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new v(i,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&t.blob&&(a.responseType="blob"),o.headers.forEach(function(e,t){a.setRequestHeader(t,e)}),a.send(void 0===o._bodyInit?null:o._bodyInit)})},e.fetch.polyfill=!0}function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function u(e){return"string"!=typeof e&&(e=String(e)),e}function c(e){var r={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t.iterable&&(r[Symbol.iterator]=function(){return r}),r}function f(e){this.map={},e instanceof f?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function h(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function l(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function d(e){var t=new FileReader,r=l(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(t.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(t.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(t.arrayBuffer&&t.blob&&n(e))this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!t.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(e)&&!i(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=p(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},t.blob&&(this.blob=function(){var e=h(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var e,t,r,n=h(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=l(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function v(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}}(void 0!==e?e:this)}).call(n,void 0);var i=n.fetch;i.Response=n.Response,i.Request=n.Request,i.Headers=n.Headers;"object"==typeof t&&t.exports&&(t.exports=i,t.exports.default=i)},{}],97:[function(e,t,r){"use strict";r.randomBytes=r.rng=r.pseudoRandomBytes=r.prng=e("randombytes"),r.createHash=r.Hash=e("create-hash"),r.createHmac=r.Hmac=e("create-hmac");var n=e("browserify-sign/algos"),i=Object.keys(n),o=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(i);r.getHashes=function(){return o};var a=e("pbkdf2");r.pbkdf2=a.pbkdf2,r.pbkdf2Sync=a.pbkdf2Sync;var s=e("browserify-cipher");r.Cipher=s.Cipher,r.createCipher=s.createCipher,r.Cipheriv=s.Cipheriv,r.createCipheriv=s.createCipheriv,r.Decipher=s.Decipher,r.createDecipher=s.createDecipher,r.Decipheriv=s.Decipheriv,r.createDecipheriv=s.createDecipheriv,r.getCiphers=s.getCiphers,r.listCiphers=s.listCiphers;var u=e("diffie-hellman");r.DiffieHellmanGroup=u.DiffieHellmanGroup,r.createDiffieHellmanGroup=u.createDiffieHellmanGroup,r.getDiffieHellman=u.getDiffieHellman,r.createDiffieHellman=u.createDiffieHellman,r.DiffieHellman=u.DiffieHellman;var c=e("browserify-sign");r.createSign=c.createSign,r.Sign=c.Sign,r.createVerify=c.createVerify,r.Verify=c.Verify,r.createECDH=e("create-ecdh");var f=e("public-encrypt");r.publicEncrypt=f.publicEncrypt,r.privateEncrypt=f.privateEncrypt,r.publicDecrypt=f.publicDecrypt,r.privateDecrypt=f.privateDecrypt;var h=e("randomfill");r.randomFill=h.randomFill,r.randomFillSync=h.randomFillSync,r.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))},r.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},{"browserify-cipher":73,"browserify-sign":80,"browserify-sign/algos":77,"create-ecdh":90,"create-hash":91,"create-hmac":94,"diffie-hellman":105,pbkdf2:247,"public-encrypt":259,randombytes:270,randomfill:271}],98:[function(e,t,r){"use strict";var n=new RegExp("%[a-f0-9]{2}","gi"),i=new RegExp("(%[a-f0-9]{2})+","gi");function o(e,t){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],o(r),o(n))}function a(e){try{return decodeURIComponent(e)}catch(i){for(var t=e.match(n),r=1;r0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];r=a.r28shl(r,s),i=a.r28shl(i,s),a.pc2(r,i,e.keys,o)}},u.prototype._update=function(e,t,r,n){var i=this._desState,o=a.readUInt32BE(e,t),s=a.readUInt32BE(e,t+4);a.ip(o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,s,i.tmp,0):this._decrypt(i,o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],a.writeUInt32BE(r,o,n),a.writeUInt32BE(r,s,n+4)},u.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,o=l}a.rip(s,o,n,i)},u.prototype._decrypt=function(e,t,r,n,i){for(var o=r,s=t,u=e.keys.length-2;u>=0;u-=2){var c=e.keys[u],f=e.keys[u+1];a.expand(o,e.tmp,0),c^=e.tmp[0],f^=e.tmp[1];var h=a.substitute(c,f),l=o;o=(s^a.permute(h))>>>0,s=l}a.rip(o,s,n,i)}},{"../des":99,inherits:180,"minimalistic-assert":234}],103:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits"),o=e("../des"),a=o.Cipher,s=o.DES;function u(e){a.call(this,e);var t=new function(e,t){n.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),i=t.slice(8,16),o=t.slice(16,24);this.ciphers="encrypt"===e?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edgeState=t}i(u,a),t.exports=u,u.create=function(e){return new u(e)},u.prototype._update=function(e,t,r,n){var i=this._edgeState;i.ciphers[0]._update(e,t,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},u.prototype._pad=s.prototype._pad,u.prototype._unpad=s.prototype._unpad},{"../des":99,inherits:180,"minimalistic-assert":234}],104:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,n){for(var i=0,o=0,a=6;a>=0;a-=2){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>>s+a&1}for(a=6;a>=0;a-=2){for(s=1;s<=25;s+=8)o<<=1,o|=t>>>s+a&1;for(s=1;s<=25;s+=8)o<<=1,o|=e>>>s+a&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(e,t,r,n){for(var i=0,o=0,a=0;a<4;a++)for(var s=24;s>=0;s-=8)i<<=1,i|=t>>>s+a&1,i<<=1,i|=e>>>s+a&1;for(a=4;a<8;a++)for(s=24;s>=0;s-=8)o<<=1,o|=t>>>s+a&1,o<<=1,o|=e>>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(e,t,r,n){for(var i=0,o=0,a=7;a>=5;a--){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+a&1}for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(a=1;a<=3;a++){for(s=0;s<=24;s+=8)o<<=1,o|=t>>s+a&1;for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1}for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,i){for(var o=0,a=0,s=n.length>>>1,u=0;u>>n[u]&1;for(u=s;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=a>>>0},r.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var n=e.toString(2);n.lengthe;)r.ishrn(1);if(r.isEven()&&r.iadd(s),r.testn(1)||r.iadd(u),t.cmp(u)){if(!t.cmp(c))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&m(p)&&m(r)&&a.test(p)&&a.test(r))return r}}},{"bn.js":53,"miller-rabin":233,randombytes:270}],108:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],109:[function(e,t,r){"use strict";var n=r;n.version=e("../package.json").version,n.utils=e("./elliptic/utils"),n.rand=e("brorand"),n.curve=e("./elliptic/curve"),n.curves=e("./elliptic/curves"),n.ec=e("./elliptic/ec"),n.eddsa=e("./elliptic/eddsa")},{"../package.json":124,"./elliptic/curve":112,"./elliptic/curves":115,"./elliptic/ec":116,"./elliptic/eddsa":119,"./elliptic/utils":123,brorand:54}],110:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.getNAF,a=i.getJSF,s=i.assert;function u(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){s(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=u;t--)c=(c<<1)+n[t];a.push(c)}for(var f=this.jpoint(null,null,null),h=this.jpoint(null,null,null),l=i;l>0;l--){for(u=0;u=0;c--){for(t=0;c>=0&&0===a[c];c--)t++;if(c>=0&&t++,u=u.dblp(t),c<0)break;var f=a[c];s(0!==f),u="affine"===e.type?f>0?u.mixedAdd(i[f-1>>1]):u.mixedAdd(i[-f-1>>1].neg()):f>0?u.add(i[f-1>>1]):u.add(i[-f-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){for(var s=this._wnafT1,u=this._wnafT2,c=this._wnafT3,f=0,h=0;h=1;h-=2){var d=h-1,p=h;if(1===s[d]&&1===s[p]){var b=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(b[1]=t[d].add(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].add(t[p].neg())):(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],m=a(r[d],r[p]);f=Math.max(m[0].length,f),c[d]=new Array(f),c[p]=new Array(f);for(var v=0;v=0;h--){for(var E=0;h>=0;){var x=!0;for(v=0;v=0&&E++,_=_.dblp(E),h<0)break;for(v=0;v0?k=u[v][S-1>>1]:S<0&&(k=u[v][-S-1>>1].neg()),_="affine"===k.type?_.mixedAdd(k):_.add(k))}}for(h=0;h=Math.ceil((e.bitLength()+1)/t.step)},c.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},f.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},f.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(r),s=n.redSub(t),u=i.redMul(a),c=o.redMul(s),f=i.redMul(s),h=a.redMul(o);return this.curve.point(u,c,h,f)},f.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var a=(c=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(a.redSub(this.curve.two)),t=a.redMul(c.redSub(o)),r=a.redSqr().redSub(a).redSub(a);else{var s=this.z.redSqr(),u=a.redSub(s).redISub(s);e=n.redSub(i).redISub(o).redMul(u),t=a.redMul(c.redSub(o)),r=a.redMul(u)}}else{var c=i.redAdd(o);s=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=c.redSub(s).redSub(s);e=this.curve._mulC(n.redISub(c)).redMul(u),t=this.curve._mulC(c).redMul(i.redISub(o)),r=c.redMul(u)}return this.curve.point(e,t,r)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},f.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=i.redSub(n),s=i.redAdd(n),u=r.redAdd(t),c=o.redMul(a),f=s.redMul(u),h=o.redMul(u),l=a.redMul(s);return this.curve.point(c,f,l,h)},f.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),c=i.redAdd(s),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),h=n.redMul(u).redMul(f);return this.curve.twisted?(t=n.redMul(c).redMul(a.redSub(this.curve._mulA(o))),r=u.redMul(c)):(t=n.redMul(c).redMul(a.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(h,t,r)},f.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},f.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},f.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},f.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},f.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()},f.prototype.getY=function(){return this.normalize(),this.y.fromRed()},f.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},f.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}return!1},f.prototype.toP=f.prototype.normalize,f.prototype.mixedAdd=f.prototype.add},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],112:[function(e,t,r){"use strict";var n=r;n.base=e("./base"),n.short=e("./short"),n.mont=e("./mont"),n.edwards=e("./edwards")},{"./base":110,"./edwards":111,"./mont":113,"./short":114}],113:[function(e,t,r){"use strict";var n=e("../curve"),i=e("bn.js"),o=e("inherits"),a=n.base,s=e("../../elliptic").utils;function u(e){a.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,r){a.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(u,a),t.exports=u,u.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},o(c,a.BasePoint),u.prototype.decodePoint=function(e,t){return this.point(s.toArray(e,t),1)},u.prototype.point=function(e,t){return new c(this,e,t)},u.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=i.redMul(n),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},c.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],114:[function(e,t,r){"use strict";var n=e("../curve"),i=e("../../elliptic"),o=e("bn.js"),a=e("inherits"),s=n.base,u=i.utils.assert;function c(e){s.call(this,"short",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function f(e,t,r,n){s.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new o(t,16),this.y=new o(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function h(e,t,r,n){s.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new o(0)):(this.x=new o(t,16),this.y=new o(r,16),this.z=new o(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}a(c,s),t.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new o(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new o(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?r=i[0]:(r=i[1],u(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new o(e.a,16),b:new o(e.b,16)}}):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:o.mont(e),r=new o(2).toRed(t).redInvm(),n=r.redNeg(),i=new o(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,r,n,i,a,s,u,c,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=e,d=this.n.clone(),p=new o(1),b=new o(0),y=new o(0),m=new o(1),v=0;0!==l.cmpn(0);){var g=d.div(l);c=d.sub(g.mul(l)),f=y.sub(g.mul(p));var w=m.sub(g.mul(b));if(!n&&c.cmp(h)<0)t=u.neg(),r=p,n=c.neg(),i=f;else if(n&&2==++v)break;u=c,d=l,l=c,y=p,p=f,m=b,b=w}a=c.neg(),s=f;var _=n.sqr().add(i.sqr());return a.sqr().add(s.sqr()).cmp(_)>=0&&(a=t,s=r),n.negative&&(n=n.neg(),i=i.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:n,b:i},{a:a,b:s}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(c).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},f.prototype.isInfinity=function(){return this.inf},f.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},f.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},f.prototype.getX=function(){return this.x.fromRed()},f.prototype.getY=function(){return this.y.fromRed()},f.prototype.mul=function(e){return e=new o(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},f.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},f.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},f.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},f.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},a(h,s.BasePoint),c.prototype.jpoint=function(e,t,r){return new h(this,e,t,r)},h.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},h.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},h.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),f=c.redMul(s),h=n.redMul(c),l=u.redSqr().redIAdd(f).redISub(h).redISub(h),d=u.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(l,d,p)},h.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),f=r.redMul(u),h=s.redSqr().redIAdd(c).redISub(f).redISub(f),l=s.redMul(f.redISub(h)).redISub(i.redMul(c)),d=this.z.redMul(a);return this.curve.jpoint(h,l,d)},h.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}return!1},h.prototype.inspect=function(){return this.isInfinity()?"":""},h.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],115:[function(e,t,r){"use strict";var n,i=r,o=e("hash.js"),a=e("../elliptic"),s=a.utils.assert;function u(e){"short"===e.type?this.curve=new a.curve.short(e):"edwards"===e.type?this.curve=new a.curve.edwards(e):this.curve=new a.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=e("./precomputed/secp256k1")}catch(e){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"../elliptic":109,"./precomputed/secp256k1":122,"hash.js":162}],116:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("hmac-drbg"),o=e("../../elliptic"),a=o.utils.assert,s=e("./key"),u=e("./signature");function c(e){if(!(this instanceof c))return new c(e);"string"==typeof e&&(a(o.curves.hasOwnProperty(e),"Unknown curve "+e),e=o.curves[e]),e instanceof o.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=c,c.prototype.keyPair=function(e){return new s(this,e)},c.prototype.keyFromPrivate=function(e,t){return s.fromPrivate(this,e,t)},c.prototype.keyFromPublic=function(e,t){return s.fromPublic(this,e,t)},c.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||o.rand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),a=this.n.sub(new n(2));;){var s=new n(t.generate(r));if(!(s.cmp(a)>0))return s.iaddn(1),this.keyFromPrivate(s)}},c.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},c.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),c=e.toArray("be",a),f=new i({hash:this.hash,entropy:s,nonce:c,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(f.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var m=d.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),v^=1),new u({r:y,s:m,recoveryParam:v})}}}}}},c.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new u(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,c=a.invm(this.n),f=c.mul(e).umod(this.n),h=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(f,r.getPublic(),h)).isInfinity()&&s.eqXToP(o):!(s=this.g.mulAdd(f,r.getPublic(),h)).isInfinity()&&0===s.getX().umod(this.n).cmp(o)},c.prototype.recoverPubKey=function(e,t,r,i){a((3&r)===r,"The recovery param is more than two bits"),t=new u(t,i);var o=this.n,s=new n(e),c=t.r,f=t.s,h=1&r,l=r>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find second key candidate");c=l?this.curve.pointFromX(c.add(this.curve.n),h):this.curve.pointFromX(c,h);var d=t.r.invm(o),p=o.sub(s).mul(d).umod(o),b=f.mul(d).umod(o);return this.g.mulAdd(p,c,b)},c.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new u(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":109,"./key":117,"./signature":118,"bn.js":53,"hmac-drbg":174}],117:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils.assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../../elliptic":109,"bn.js":53}],118:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new function(){this.place=0};if(48!==e[r.place++])return!1;if(s(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=s(e,r),a=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var u=s(e,r);if(e.length!==u+r.place)return!1;var c=e.slice(r.place,u+r.place);return 0===a[0]&&128&a[1]&&(a=a.slice(1)),0===c[0]&&128&c[1]&&(c=c.slice(1)),this.r=new n(a),this.s=new n(c),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=u(t),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),a=[48];return c(a,o.length),a=a.concat(o),i.encode(a,e)}},{"../../elliptic":109,"bn.js":53}],119:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("../../elliptic"),o=i.utils,a=o.assert,s=o.parseBytes,u=e("./key"),c=e("./signature");function f(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}t.exports=f,f.prototype.sign=function(e,t){e=s(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),u=n.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(e,t,r){e=s(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var s=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,c=t.andln(3)+i&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!=(s=e.andln(7)+n&7)&&5!==s||2!==c?u:-u,r[0].push(o),a=0==(1&c)?0:3!=(s=t.andln(7)+i&7)&&5!==s||2!==u?c:-c,r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},{"bn.js":53,"minimalistic-assert":234,"minimalistic-crypto-utils":235}],124:[function(e,t,r){t.exports={_from:"elliptic@^6.0.0",_id:"elliptic@6.4.0",_inBundle:!1,_integrity:"sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=",_location:"/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.0.0",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.0.0",saveSpec:null,fetchSpec:"^6.0.0"},_requiredBy:["/browserify-sign","/create-ecdh"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",_shasum:"cac9af8762c85836187003c8dfe193e5e2eae5df",_spec:"elliptic@^6.0.0",_where:"/Users/alexvlasov/Blockchain/web3swift_jsproxy/node_modules/browserify-sign",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.4.0"}},{}],125:[function(e,t,r){"use strict";const n=e("ethjs-util");function i(e){let t=n.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}t.exports={incrementHexNumber:function(e){return i(n.intToHex(parseInt(e,16)+1))},formatHex:i}},{"ethjs-util":155}],126:[function(e,t,r){const n=e("eth-query"),i=e("events"),o=e("pify"),a=e("./hexUtils"),s=a.incrementHexNumber,u=1e3,c=60*u;t.exports=class extends i{constructor(e={}){if(super(),!e.provider)throw new Error("RpcBlockTracker - no provider specified.");this._provider=e.provider,this._query=new n(e.provider),this._pollingInterval=e.pollingInterval||4*u,this._syncingTimeout=e.syncingTimeout||1*c,this._trackingBlock=null,this._trackingBlockTimestamp=null,this._currentBlock=null,this._isRunning=!1,this._performSync=this._performSync.bind(this),this._handleNewBlockNotification=this._handleNewBlockNotification.bind(this)}getTrackingBlock(){return this._trackingBlock}getCurrentBlock(){return this._currentBlock}async awaitCurrentBlock(){return this._currentBlock?this._currentBlock:(await new Promise(e=>this.once("latest",e)),this._currentBlock)}async start(e={}){this._isRunning||(this._isRunning=!0,e.fromBlock?await this._setTrackingBlock(await this._fetchBlockByNumber(e.fromBlock)):await this._setTrackingBlock(await this._fetchLatestBlock()),this._provider.on?await this._initSubscription():this._performSync().catch(e=>{e&&console.error(e)}))}async stop(){this._isRunning=!1,this._provider.on&&await this._removeSubscription()}async _setTrackingBlock(e){if(this._trackingBlock&&this._trackingBlock.hash===e.hash)return;const t=this._trackingBlockTimestamp,r=Date.now();t&&r-t>this._syncingTimeout?(this._trackingBlockTimestamp=null,await this._warpToLatest()):(this._trackingBlock=e,this._trackingBlockTimestamp=r,this.emit("block",e))}async _setCurrentBlock(e){if(this._currentBlock&&this._currentBlock.hash===e.hash)return;const t=this._currentBlock;this._currentBlock=e,this.emit("latest",e),this.emit("sync",{newBlock:e,oldBlock:t})}async _warpToLatest(){await this._setTrackingBlock(await this._fetchLatestBlock())}async _pollForNextBlock(){setTimeout(()=>this._performSync(),this._pollingInterval)}async _performSync(){if(!this._isRunning)return;const e=this.getTrackingBlock();if(!e)throw new Error("RpcBlockTracker - tracking block is missing");const t=s(e.number);try{const r=await this._fetchBlockByNumber(t);r?(await this._setTrackingBlock(r),this._performSync()):(await this._setCurrentBlock(e),this._pollForNextBlock())}catch(t){t.message.includes("index out of range")||t.message.includes("Couldn't find block by reference")?(await this._setCurrentBlock(e),this._pollForNextBlock()):(console.error(t),this._pollForNextBlock())}}async _handleNewBlockNotification(e,t){t.id==this._subscriptionId&&(e&&(this.emit("error",e),await this._removeSubscription()),await this._setTrackingBlock(await this._fetchBlockByNumber(t.result.number)))}async _initSubscription(){this._provider.on("data",this._handleNewBlockNotification);let e=await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_subscribe",params:["newHeads"]});this._subscriptionId=e.result}async _removeSubscription(){if(!this._subscriptionId)throw new Error("Not subscribed.");this._provider.removeListener("data",this._handleNewBlockNotification),await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_unsubscribe",params:[this._subscriptionId]}),delete this._subscriptionId}_fetchLatestBlock(){return o(this._query.getBlockByNumber).call(this._query,"latest",!0)}_fetchBlockByNumber(e){const t=a.formatHex(e);return o(this._query.getBlockByNumber).call(this._query,t,!0)}}},{"./hexUtils":125,"eth-query":135,events:157,pify:252}],127:[function(e,t,r){(function(t){var n=e("js-sha3").keccak_256,i=e("idna-uts46-hx");function o(e){return e?i.toUnicode(e,{useStd3ASCII:!0,transitional:!1}):e}r.hash=function(e){for(var r="",i=0;i<32;i++)r+="00";if(name=o(e),name){var a=name.split(".");for(i=a.length-1;i>=0;i--){var s=n(a[i]);r=n(new t(r+s,"hex"))}}return"0x"+r},r.normalize=o}).call(this,e("buffer").Buffer)},{buffer:84,"idna-uts46-hx":177,"js-sha3":128}],128:[function(e,t,r){(function(e,r){!function(){"use strict";var n="object"==typeof window?window:{};!n.JS_SHA3_NO_NODE_JS&&"object"==typeof e&&e.versions&&e.versions.node&&(n=r);for(var i=!n.JS_SHA3_NO_COMMON_JS&&"object"==typeof t&&t.exports,o="0123456789abcdef".split(""),a=[0,8,16,24],s=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],u=[224,256,384,512],c=["hex","buffer","arrayBuffer","array"],f=function(e,t,r){return function(n){return new _(e,t,e).update(n)[r]()}},h=function(e,t,r){return function(n,i){return new _(e,t,i).update(n)[r]()}},l=function(e,t){var r=f(e,t,"hex");r.create=function(){return new _(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}_.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,o=this.blocks,s=this.byteCount,u=this.blockCount,c=0,f=this.s;c>2]|=e[c]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(o[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=s){for(this.start=r-s,this.block=o[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+o[15&e]+o[e>>12&15]+o[e>>8&15]+o[e>>20&15]+o[e>>16&15]+o[e>>28&15]+o[e>>24&15];s%t==0&&(A(r),a=0)}return i&&(e=r[a],i>0&&(u+=o[e>>4&15]+o[15&e]),i>1&&(u+=o[e>>12&15]+o[e>>8&15]),i>2&&(u+=o[e>>20&15]+o[e>>16&15])),u},_.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&A(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var A=function(e){var t,r,n,i,o,a,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],a=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(a<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|a>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=a^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=s[n],e[1]^=s[n+1]};if(i)t.exports=p;else for(y=0;y{setTimeout(t,e)})}function c(e){const t=e.toString();return s.some(e=>t.includes(e))}async function f(e,t,r){const{fetchUrl:n,fetchParams:a}=h({network:e,req:t}),s=await o(n,a),u=await s.text();if(!s.ok)switch(s.status){case 405:throw new i.MethodNotFound;case 418:throw l("Request is being rate limited.");case 503:case 504:throw function(){let e="Gateway timeout. The request took too long to process. ";return e+="This can happen when querying logs over too wide a block range.",l("Gateway timeout. The request took too long to process. This can happen when querying logs over too wide a block range.")}();default:throw l(u)}if("eth_getBlockByNumber"===t.method&&"Not Found"===u)return void(r.result=null);const c=JSON.parse(u);r.result=c.result,r.error=c.error}function h({network:e,req:t}){const r=function(e){return{id:e.id,jsonrpc:e.jsonrpc,method:e.method,params:e.params}}(t),{method:n,params:i}=r,o={};let s=`https://api.infura.io/v1/jsonrpc/${e}`;if(a.includes(n))o.method="POST",o.headers={Accept:"application/json","Content-Type":"application/json"},o.body=JSON.stringify(r);else{o.method="GET",s+=`/${n}?params=${encodeURIComponent(JSON.stringify(i))}`}return{fetchUrl:s,fetchParams:o}}function l(e){const t=new Error(e);return new i.InternalError(t)}t.exports=function(e={}){const t=e.network||"mainnet",r=e.maxAttempts||5;if(!r)throw new Error(`Invalid value for 'maxAttempts': "${r}" (${typeof r})`);return n(async(e,n,i)=>{for(let i=1;i<=r;i++)try{await f(t,e,n);break}catch(e){if(!c(e))throw e;const t=r-i;if(!t){const t=`InfuraProvider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,r=new Error(t);throw r}await u(1e3)}})},t.exports.fetchConfigFromReq=h},{"cross-fetch":96,"json-rpc-engine/src/createAsyncMiddleware":187,"json-rpc-error":189}],131:[function(e,t,r){t.exports=function(e){return{sendAsync:e.handle.bind(e)}}},{}],132:[function(e,t,r){var n=function(e,t){for(var r=[],n=0;n>6|192);else{if(i>55295&&i<56320){if(++n==e.length)return null;var o=e.charCodeAt(n);if(o<56320||o>57343)return null;r+=t((i=65536+((1023&i)<<10)+(1023&o))>>18|240),r+=t(i>>12&63|128)}else r+=t(i>>12|224);r+=t(i>>6&63|128)}r+=t(63&i|128)}}return r},toString:function(e){for(var t="",r=0,o=i(e);r127){if(a>191&&a<224){if(r>=o)return null;a=(31&a)<<6|63&n(e,r)}else if(a>223&&a<240){if(r+1>=o)return null;a=(15&a)<<12|(63&n(e,r))<<6|63&n(e,++r)}else{if(!(a>239&&a<248))return null;if(r+2>=o)return null;a=(7&a)<<18|(63&n(e,r))<<12|(63&n(e,++r))<<6|63&n(e,++r)}++r}if(a<=65535)t+=String.fromCharCode(a);else{if(!(a<=1114111))return null;a-=65536,t+=String.fromCharCode(a>>10|55296),t+=String.fromCharCode(1023&a|56320)}}return t},fromNumber:function(e){var t=e.toString(16);return t.length%2==0?"0x"+t:"0x0"+t},toNumber:function(e){return parseInt(e.slice(2),16)},fromNat:function(e){return"0x0"===e?"0x":e.length%2==0?e:"0x0"+e.slice(2)},toNat:function(e){return"0"===e[2]?"0x"+e.slice(3):e},fromArray:a,toArray:o,fromUint8Array:function(e){return a([].slice.call(e,0))},toUint8Array:function(e){return new Uint8Array(o(e))}}},{"./array.js":132}],134:[function(e,t,r){var n="0123456789abcdef".split(""),i=[1,256,65536,16777216],o=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],s=function(e){var t,r,n,i,o,s,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=a[n],e[1]^=a[n+1]},u=function(e){return function(t){var r;if("0x"===t.slice(0,2)){r=[];for(var a=2,u=t.length;a>2]|=t[d]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|63&r)<=57344?(u[y>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<=c){for(e.start=y-c,e.block=u[f],y=0;y>2]|=i[3&y],e.lastByteIndex===c)for(u[0]=u[f],y=1;y>4&15]+n[15&p]+n[p>>12&15]+n[p>>8&15]+n[p>>20&15]+n[p>>16&15]+n[p>>28&15]+n[p>>24&15];m%f==0&&(s(l),y=0)}return"0x"+b}(function(e){return{blocks:[],reset:!0,block:0,start:0,blockCount:1600-(e<<1)>>5,outputBlocks:e>>5,s:(t=[0,0,0,0,0,0,0,0,0,0],[].concat(t,t,t,t,t))};var t}(e),r)}};t.exports={keccak256:u(256),keccak512:u(512),keccak256s:u(256),keccak512s:u(512)}},{}],135:[function(e,t,r){const n=e("xtend"),i=e("json-rpc-random-id")();function o(e){this.currentProvider=e}function a(e){return function(){var t=[].slice.call(arguments),r=t.pop();this.sendAsync({method:e,params:t},r)}}function s(e,t){return function(){var r=[].slice.call(arguments),n=r.pop();r.lengtho)throw new Error("Elements exceed array size: "+o);for(d in h=[],e=e.slice(0,e.lastIndexOf("[")),"string"==typeof t&&(t=JSON.parse(t)),t)h.push(l(e,t[d]));if("dynamic"===o){var p=l("uint256",t.length);h.unshift(p)}return r.concat(h)}if("bytes"===e)return t=new r(t),h=r.concat([l("uint256",t.length),t]),t.length%32!=0&&(h=r.concat([h,n.zeros(32-t.length%32)])),h;if(e.startsWith("bytes")){if((o=s(e))<1||o>32)throw new Error("Invalid bytes width: "+o);return n.setLengthRight(t,32)}if(e.startsWith("uint")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid uint width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied uint exceeds width: "+o+" vs "+a.bitLength());if(a<0)throw new Error("Supplied uint is negative");return a.toArrayLike(r,"be",32)}if(e.startsWith("int")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid int width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied int exceeds width: "+o+" vs "+a.bitLength());return a.toTwos(256).toArrayLike(r,"be",32)}if(e.startsWith("ufixed")){if(o=u(e),(a=f(t))<0)throw new Error("Supplied ufixed is negative");return l("uint256",a.mul(new i(2).pow(new i(o[1]))))}if(e.startsWith("fixed"))return o=u(e),l("int256",f(t).mul(new i(2).pow(new i(o[1]))));throw new Error("Unsupported or invalid type: "+e)}function d(e,t,n){var o,a,s,u;if("string"==typeof e&&(e=p(e)),"address"===e.name)return d(e.rawType,t,n).toArrayLike(r,"be",20).toString("hex");if("bool"===e.name)return d(e.rawType,t,n).toString()===new i(1).toString();if("string"===e.name){var c=d(e.rawType,t,n);return new r(c,"utf8").toString()}if(e.isArray){for(s=[],o=e.size,"dynamic"===e.size&&(o=d("uint256",t,n=d("uint256",t,n).toNumber()).toNumber(),n+=32),u=0;ue.size)throw new Error("Decoded int exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("int")){if((a=new i(t.slice(n,n+32),16,"be").fromTwos(256)).bitLength()>e.size)throw new Error("Decoded uint exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("ufixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("uint256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}if(e.name.startsWith("fixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("int256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}throw new Error("Unsupported or invalid type: "+e.name)}function p(e){var t,r,n;if(y(e)){t=c(e);var i=e.slice(0,e.lastIndexOf("["));return i=p(i),r={isArray:!0,name:e,size:t,memoryUsage:"dynamic"===t?32:i.memoryUsage*t,subArray:i}}switch(e){case"address":n="uint160";break;case"bool":n="uint8";break;case"string":n="bytes"}if(r={rawType:n,name:e,memoryUsage:32},e.startsWith("bytes")&&"bytes"!==e||e.startsWith("uint")||e.startsWith("int")?r.size=s(e):(e.startsWith("ufixed")||e.startsWith("fixed"))&&(r.size=u(e)),e.startsWith("bytes")&&"bytes"!==e&&(r.size<1||r.size>32))throw new Error("Invalid bytes width: "+r.size);if((e.startsWith("uint")||e.startsWith("int"))&&(r.size%8||r.size<8||r.size>256))throw new Error("Invalid int/uint width: "+r.size);return r}function b(e){return"string"===e||"bytes"===e||"dynamic"===c(e)}function y(e){return e.lastIndexOf("]")===e.length-1}function m(e,t){return e.startsWith("address")||e.startsWith("bytes")?"0x"+t.toString("hex"):t.toString()}o.eventID=function(e,t){var i=e+"("+t.map(a).join(",")+")";return n.sha3(new r(i))},o.methodID=function(e,t){return o.eventID(e,t).slice(0,4)},o.rawEncode=function(e,t){var n=[],i=[],o=0;e.forEach(function(e){if(y(e)){var t=c(e);o+="dynamic"!==t?32*t:32}else o+=32});for(var s=0;s32)throw new Error("Invalid bytes width: "+i);u.push(n.setLengthRight(l,i))}else if(h.startsWith("uint")){if((i=s(h))%8||i<8||i>256)throw new Error("Invalid uint width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied uint exceeds width: "+i+" vs "+o.bitLength());u.push(o.toArrayLike(r,"be",i/8))}else{if(!h.startsWith("int"))throw new Error("Unsupported or invalid type: "+h);if((i=s(h))%8||i<8||i>256)throw new Error("Invalid int width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied int exceeds width: "+i+" vs "+o.bitLength());u.push(o.toTwos(i).toArrayLike(r,"be",i/8))}}return r.concat(u)},o.soliditySHA3=function(e,t){return n.sha3(o.solidityPack(e,t))},o.soliditySHA256=function(e,t){return n.sha256(o.solidityPack(e,t))},o.solidityRIPEMD160=function(e,t){return n.ripemd160(o.solidityPack(e,t),!0)},o.fromSerpent=function(e){for(var t,r=[],n=0;n="0"&&t<="9");)o+=e[a]-"0",a++;n=a-1,r.push(o)}else if("i"===i)r.push("int256");else{if("a"!==i)throw new Error("Unsupported or invalid type: "+i);r.push("int256[]")}}return r},o.toSerpent=function(e){for(var t=[],r=0;r0){var r=this.raw.slice();this.v=this._chainId,this.r=0,this.s=0,t=this.raw,this.raw=r}else t=this.raw.slice(0,6);return n.rlphash(t)},e.prototype.getChainId=function(){return this._chainId},e.prototype.getSenderAddress=function(){if(this._from)return this._from;var e=this.getSenderPublicKey();return this._from=n.publicToAddress(e),this._from},e.prototype.getSenderPublicKey=function(){if(!(this._senderPubKey&&this._senderPubKey.length||this.verifySignature()))throw new Error("Invalid Signature");return this._senderPubKey},e.prototype.verifySignature=function(){var e=this.hash(!1);if(this._homestead&&1===new o(this.s).cmp(a))return!1;try{var t=n.bufferToInt(this.v);this._chainId>0&&(t-=2*this._chainId+8),this._senderPubKey=n.ecrecover(e,t,this.r,this.s)}catch(e){return!1}return!!this._senderPubKey},e.prototype.sign=function(e){var t=this.hash(!1),r=n.ecsign(t,e);this._chainId>0&&(r.v+=2*this._chainId+8),Object.assign(this,r)},e.prototype.getDataFee=function(){for(var e=this.raw[5],t=new o(0),r=0;r0&&t.push(["gas limit is too low. Need at least "+this.getBaseFee()]),void 0===e||!1===e?0===t.length:t.join(" ")},e}();t.exports=s}).call(this,e("buffer").Buffer)},{buffer:84,"ethereum-common/params.json":137,"ethereumjs-util":141}],141:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("keccak"),o=e("secp256k1"),a=e("assert"),s=e("rlp"),u=e("bn.js"),c=e("create-hash"),f=e("safe-buffer").Buffer;Object.assign(r,e("ethjs-util")),r.MAX_INTEGER=new u("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16),r.TWO_POW256=new u("10000000000000000000000000000000000000000000000000000000000000000",16),r.KECCAK256_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",r.SHA3_NULL_S=r.KECCAK256_NULL_S,r.KECCAK256_NULL=f.from(r.KECCAK256_NULL_S,"hex"),r.SHA3_NULL=r.KECCAK256_NULL,r.KECCAK256_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",r.SHA3_RLP_ARRAY_S=r.KECCAK256_RLP_ARRAY_S,r.KECCAK256_RLP_ARRAY=f.from(r.KECCAK256_RLP_ARRAY_S,"hex"),r.SHA3_RLP_ARRAY=r.KECCAK256_RLP_ARRAY,r.KECCAK256_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",r.SHA3_RLP_S=r.KECCAK256_RLP_S,r.KECCAK256_RLP=f.from(r.KECCAK256_RLP_S,"hex"),r.SHA3_RLP=r.KECCAK256_RLP,r.BN=u,r.rlp=s,r.secp256k1=o,r.zeros=function(e){return f.allocUnsafe(e).fill(0)},r.zeroAddress=function(){var e=r.zeros(20);return r.bufferToHex(e)},r.setLengthLeft=r.setLength=function(e,t,n){var i=r.zeros(t);return e=r.toBuffer(e),n?e.length0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e},r.toBuffer=function(e){if(!f.isBuffer(e))if(Array.isArray(e))e=f.from(e);else if("string"==typeof e)e=r.isHexString(e)?f.from(r.padToEven(r.stripHexPrefix(e)),"hex"):f.from(e);else if("number"==typeof e)e=r.intToBuffer(e);else if(null==e)e=f.allocUnsafe(0);else if(u.isBN(e))e=e.toArrayLike(f);else{if(!e.toArray)throw new Error("invalid type");e=f.from(e.toArray())}return e},r.bufferToInt=function(e){return new u(r.toBuffer(e)).toNumber()},r.bufferToHex=function(e){return"0x"+(e=r.toBuffer(e)).toString("hex")},r.fromSigned=function(e){return new u(e).fromTwos(256)},r.toUnsigned=function(e){return f.from(e.toTwos(256).toArray())},r.keccak=function(e,t){return e=r.toBuffer(e),t||(t=256),i("keccak"+t).update(e).digest()},r.keccak256=function(e){return r.keccak(e)},r.sha3=r.keccak,r.sha256=function(e){return e=r.toBuffer(e),c("sha256").update(e).digest()},r.ripemd160=function(e,t){e=r.toBuffer(e);var n=c("rmd160").update(e).digest();return!0===t?r.setLength(n,32):n},r.rlphash=function(e){return r.keccak(s.encode(e))},r.isValidPrivate=function(e){return o.privateKeyVerify(e)},r.isValidPublic=function(e,t){return 64===e.length?o.publicKeyVerify(f.concat([f.from([4]),e])):!!t&&o.publicKeyVerify(e)},r.pubToAddress=r.publicToAddress=function(e,t){return e=r.toBuffer(e),t&&64!==e.length&&(e=o.publicKeyConvert(e,!1).slice(1)),a(64===e.length),r.keccak(e).slice(-20)};var h=r.privateToPublic=function(e){return e=r.toBuffer(e),o.publicKeyCreate(e,!1).slice(1)};r.importPublic=function(e){return 64!==(e=r.toBuffer(e)).length&&(e=o.publicKeyConvert(e,!1).slice(1)),e},r.ecsign=function(e,t){var r=o.sign(e,t),n={};return n.r=r.signature.slice(0,32),n.s=r.signature.slice(32,64),n.v=r.recovery+27,n},r.hashPersonalMessage=function(e){var t=r.toBuffer("Ethereum Signed Message:\n"+e.length.toString());return r.keccak(f.concat([t,e]))},r.ecrecover=function(e,t,n,i){var a=f.concat([r.setLength(n,32),r.setLength(i,32)],64),s=t-27;if(0!==s&&1!==s)throw new Error("Invalid signature v value");var u=o.recover(e,a,s);return o.publicKeyConvert(u,!1).slice(1)},r.toRpcSig=function(e,t,n){if(27!==e&&28!==e)throw new Error("Invalid recovery id");return r.bufferToHex(f.concat([r.setLengthLeft(t,32),r.setLengthLeft(n,32),r.toBuffer(e-27)]))},r.fromRpcSig=function(e){if(65!==(e=r.toBuffer(e)).length)throw new Error("Invalid signature length");var t=e[64];return t<27&&(t+=27),{v:t,r:e.slice(0,32),s:e.slice(32,64)}},r.privateToAddress=function(e){return r.publicToAddress(h(e))},r.isValidAddress=function(e){return/^0x[0-9a-fA-F]{40}$/.test(e)},r.isZeroAddress=function(e){return r.zeroAddress()===r.addHexPrefix(e)},r.toChecksumAddress=function(e){e=r.stripHexPrefix(e).toLowerCase();for(var t=r.keccak(e).toString("hex"),n="0x",i=0;i=8?n+=e[i].toUpperCase():n+=e[i];return n},r.isValidChecksumAddress=function(e){return r.isValidAddress(e)&&r.toChecksumAddress(e)===e},r.generateAddress=function(e,t){return e=r.toBuffer(e),t=(t=new u(t)).isZero()?null:f.from(t.toArray()),r.rlphash([e,t]).slice(-20)},r.isPrecompiled=function(e){var t=r.unpad(e);return 1===t.length&&t[0]>=1&&t[0]<=8},r.addHexPrefix=function(e){return"string"!=typeof e?e:r.isHexPrefixed(e)?e:"0x"+e},r.isValidSignature=function(e,t,r,n){var i=new u("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16),o=new u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16);return 32===t.length&&32===r.length&&((27===e||28===e)&&(t=new u(t),r=new u(r),!(t.isZero()||t.gt(o)||r.isZero()||r.gt(o))&&(!1!==n||1!==new u(r).cmp(i))))},r.baToJSON=function(e){if(f.isBuffer(e))return"0x"+e.toString("hex");if(e instanceof Array){for(var t=[],n=0;n=i.length,"The field "+t.name+" must not have more "+t.length+" bytes")):t.allowZero&&0===i.length||!t.length||a(t.length===i.length,"The field "+t.name+" must have byte length of "+t.length),e.raw[n]=i}e._fields.push(t.name),Object.defineProperty(e,t.name,{enumerable:!0,configurable:!0,get:i,set:o}),t.default&&(e[t.name]=t.default),t.alias&&Object.defineProperty(e,t.alias,{enumerable:!1,configurable:!0,set:o,get:i})}),i)if("string"==typeof i&&(i=f.from(r.stripHexPrefix(i),"hex")),f.isBuffer(i)&&(i=s.decode(i)),Array.isArray(i)){if(i.length>e._fields.length)throw new Error("wrong number of fields in data");i.forEach(function(t,n){e[e._fields[n]]=r.toBuffer(t)})}else{if("object"!==(void 0===i?"undefined":n(i)))throw new Error("invalid data");var o=Object.keys(i);t.forEach(function(t){-1!==o.indexOf(t.name)&&(e[t.name]=i[t.name]),-1!==o.indexOf(t.alias)&&(e[t.alias]=i[t.alias])})}}},{assert:19,"bn.js":53,"create-hash":91,"ethjs-util":155,keccak:195,rlp:289,"safe-buffer":290,secp256k1:295}],142:[function(e,t,r){arguments[4][128][0].apply(r,arguments)},{_process:257,dup:128}],143:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var a=e("./address"),s=e("./bignumber"),u=e("./bytes"),c=e("./utf8"),f=e("./properties"),h=o(e("./errors")),l=new RegExp(/^bytes([0-9]*)$/),d=new RegExp(/^(u?int)([0-9]*)$/),p=new RegExp(/^(.*)\[([0-9]*)\]$/);r.defaultCoerceFunc=function(e,t){var r=e.match(d);return r&&parseInt(r[2])<=48?t.toNumber():t};var b=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"),y=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function m(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}function v(e,t){function r(t){throw new Error('unexpected character "'+e[t]+'" at position '+t+' in "'+e+'"')}for(var n={type:"",name:"",state:{allowType:!0}},i=n,o=0;o1){var i=r[1].match(b);if(""!=i[1].trim()||""!=i[3].trim())throw new Error("unexpected tokens");L(i[2]).forEach(function(e){t.outputs.push(v(e))})}return t}(e.trim()));throw new Error("unknown signature")};var w=function(){return function(e,t,r,n,i){this.coerceFunc=e,this.name=t,this.type=r,this.localName=n,this.dynamic=i}}(),_=function(e){function t(t){var r=e.call(this,t.coerceFunc,t.name,t.type,void 0,t.dynamic)||this;return f.defineReadOnly(r,"coder",t),r}return i(t,e),t.prototype.encode=function(e){return this.coder.encode(e)},t.prototype.decode=function(e,t){return this.coder.decode(e,t)},t}(w),A=function(e){function t(t,r){return e.call(this,t,"null","",r,!1)||this}return i(t,e),t.prototype.encode=function(e){return u.arrayify([])},t.prototype.decode=function(e,t){if(t>e.length)throw new Error("invalid null");return{consumed:0,value:this.coerceFunc("null",void 0)}},t}(w),E=function(e){function t(t,r,n,i){var o=this,a=(n?"int":"uint")+8*r;return(o=e.call(this,t,a,a,i,!1)||this).size=r,o.signed=n,o}return i(t,e),t.prototype.encode=function(e){try{var t=s.bigNumberify(e);return t=t.toTwos(8*this.size).maskn(8*this.size),this.signed&&(t=t.fromTwos(8*this.size).toTwos(256)),u.padZeros(u.arrayify(t),32)}catch(t){h.throwError("invalid number value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:e})}return null},t.prototype.decode=function(e,t){e.length32)throw new Error;t.set(r)}catch(t){h.throwError("invalid "+this.name+" value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:t.value||e})}return t},t.prototype.decode=function(e,t){return e.length=0?n:"")+"]",s=-1===n||r.dynamic;return(o=e.call(this,t,"array",a,i,s)||this).coder=r,o.length=n,o}return i(t,e),t.prototype.encode=function(e){Array.isArray(e)||h.throwError("expected array value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:"array",value:e});var t=this.length,r=new Uint8Array(0);-1===t&&(t=e.length,r=x.encode(t)),h.checkArgumentCount(t,e.length,"in coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i256||i%8!=0)&&h.throwError("invalid "+r[1]+" bit length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new E(e,i/8,"int"===r[1],t.name);if(r=t.type.match(l))return(0===(i=parseInt(r[1]))||i>32)&&h.throwError("invalid bytes length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new S(e,i,t.name);if(r=t.type.match(p)){var i=parseInt(r[2]||"-1");return(t=f.jsonCopy(t)).type=r[1],new N(e,D(e,t),i,t.name)}return"tuple"===t.type.substring(0,5)?function(e,t,r){t||(t=[]);var n=[];return t.forEach(function(t){n.push(D(e,t))}),new R(e,n,r)}(e,t.components,t.name):""===t.type?new A(e,t.name):(h.throwError("invalid type",h.INVALID_ARGUMENT,{arg:"type",value:t.type}),null)}var F=function(){function e(t){h.checkNew(this,e),t||(t=r.defaultCoerceFunc),f.defineReadOnly(this,"coerceFunc",t)}return e.prototype.encode=function(e,t){e.length!==t.length&&h.throwError("types/values length mismatch",h.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):e,r.push(D(this.coerceFunc,t))},this),u.hexlify(new R(this.coerceFunc,r,"_").encode(t))},e.prototype.decode=function(e,t){var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):f.jsonCopy(e),r.push(D(this.coerceFunc,t))},this),new R(this.coerceFunc,r,"_").decode(u.arrayify(t),0).value},e}();r.AbiCoder=F,r.defaultAbiCoder=new F},{"./address":144,"./bignumber":145,"./bytes":146,"./errors":147,"./properties":149,"./utf8":152}],144:[function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var i=n(e("bn.js")),o=e("./bytes"),a=e("./keccak256"),s=e("./rlp"),u=e("./errors");function c(e){"string"==typeof e&&e.match(/^0x[0-9A-Fa-f]{40}$/)||u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=o.arrayify(a.keccak256(r));for(var i=0;i<40;i+=2)r[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(15&r[i>>1])>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}for(var f={},h=0;h<10;h++)f[String(h)]=String(h);for(h=0;h<26;h++)f[String.fromCharCode(65+h)]=String(10+h);var l,d=Math.floor((l=9007199254740991,Math.log10?Math.log10(l):Math.log(l)/Math.LN10));function p(e){e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00";var t="";for(e.split("").forEach(function(e){t+=f[e]});t.length>=d;){var r=t.substring(0,d);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function b(e){var t=null;if("string"!=typeof e&&u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e}),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=c(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&u.throwError("bad address checksum",u.INVALID_ARGUMENT,{arg:"address",value:e});else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==p(e)&&u.throwError("bad icap checksum",u.INVALID_ARGUMENT,{arg:"address",value:e}),t=new i.default.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=c("0x"+t)}else u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});return t}r.getAddress=b,r.getIcapAddress=function(e){for(var t=new i.default.BN(b(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+p("XE00"+t)+t},r.getContractAddress=function(e){if(!e.from)throw new Error("missing from address");var t=e.nonce;return b("0x"+a.keccak256(s.encode([b(e.from),o.stripZeros(o.hexlify(t))])).substring(26))}},{"./bytes":146,"./errors":147,"./keccak256":148,"./rlp":150,"bn.js":53}],145:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=o(e("bn.js")),u=e("./bytes"),c=e("./properties"),f=e("./types"),h=a(e("./errors")),l=new s.default.BN(-1);function d(e){var t=e.toString(16);return"-"===t[0]?t.length%2==0?"-0x0"+t.substring(1):"-0x"+t.substring(1):t.length%2==1?"0x0"+t:"0x"+t}function p(e){return m(e)._bn}function b(e){return new y(d(e))}var y=function(e){function t(r){var n=e.call(this)||this;if(h.checkNew(n,t),"string"==typeof r)u.isHexString(r)?("0x"==r&&(r="0x0"),c.defineReadOnly(n,"_hex",r)):"-"===r[0]&&u.isHexString(r.substring(1))?c.defineReadOnly(n,"_hex",r):r.match(/^-?[0-9]*$/)?(""==r&&(r="0"),c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))):h.throwError("invalid BigNumber string value",h.INVALID_ARGUMENT,{arg:"value",value:r});else if("number"==typeof r){parseInt(String(r))!==r&&h.throwError("underflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"underflow",value:r,outputValue:parseInt(String(r))});try{c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}}else r instanceof t?c.defineReadOnly(n,"_hex",r._hex):r.toHexString?c.defineReadOnly(n,"_hex",d(p(r.toHexString()))):u.isArrayish(r)?c.defineReadOnly(n,"_hex",d(new s.default.BN(u.hexlify(r).substring(2),16))):h.throwError("invalid BigNumber value",h.INVALID_ARGUMENT,{arg:"value",value:r});return n}return i(t,e),Object.defineProperty(t.prototype,"_bn",{get:function(){return"-"===this._hex[0]?new s.default.BN(this._hex.substring(3),16).mul(l):new s.default.BN(this._hex.substring(2),16)},enumerable:!0,configurable:!0}),t.prototype.fromTwos=function(e){return b(this._bn.fromTwos(e))},t.prototype.toTwos=function(e){return b(this._bn.toTwos(e))},t.prototype.add=function(e){return b(this._bn.add(p(e)))},t.prototype.sub=function(e){return b(this._bn.sub(p(e)))},t.prototype.div=function(e){return m(e).isZero()&&h.throwError("division by zero",h.NUMERIC_FAULT,{operation:"divide",fault:"division by zero"}),b(this._bn.div(p(e)))},t.prototype.mul=function(e){return b(this._bn.mul(p(e)))},t.prototype.mod=function(e){return b(this._bn.mod(p(e)))},t.prototype.pow=function(e){return b(this._bn.pow(p(e)))},t.prototype.maskn=function(e){return b(this._bn.maskn(e))},t.prototype.eq=function(e){return this._bn.eq(p(e))},t.prototype.lt=function(e){return this._bn.lt(p(e))},t.prototype.lte=function(e){return this._bn.lte(p(e))},t.prototype.gt=function(e){return this._bn.gt(p(e))},t.prototype.gte=function(e){return this._bn.gte(p(e))},t.prototype.isZero=function(){return this._bn.isZero()},t.prototype.toNumber=function(){try{return this._bn.toNumber()}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}return null},t.prototype.toString=function(){return this._bn.toString(10)},t.prototype.toHexString=function(){return this._hex},t}(f.BigNumber);function m(e){return e instanceof y?e:new y(e)}r.bigNumberify=m,r.ConstantNegativeOne=m(-1),r.ConstantZero=m(0),r.ConstantOne=m(1),r.ConstantTwo=m(2),r.ConstantWeiPerEther=m("1000000000000000000")},{"./bytes":146,"./errors":147,"./properties":149,"./types":151,"bn.js":53}],146:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./errors");function i(e){return!!e._bn}function o(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return new Uint8Array(Array.prototype.slice.apply(e,t))},e)}function a(e){if(!e||parseInt(String(e.length))!=e.length||"string"==typeof e)return!1;for(var t=0;t=256||parseInt(String(r))!=r)return!1}return!0}function s(e){if(null==e&&n.throwError("cannot convert null value to array",n.INVALID_ARGUMENT,{arg:"value",value:e}),i(e)&&(e=e.toHexString()),"string"==typeof e){var t=e.match(/^(0x)?[0-9a-fA-F]*$/);t||n.throwError("invalid hexadecimal string",n.INVALID_ARGUMENT,{arg:"value",value:e}),"0x"!==t[1]&&n.throwError("hex string must have 0x prefix",n.INVALID_ARGUMENT,{arg:"value",value:e}),(e=e.substring(2)).length%2&&(e="0"+e);for(var r=[],s=0;s>4]+f[15&u])}return"0x"+o.join("")}return n.throwError("invalid hexlify value",null,{arg:"value",value:e}),"never"}function l(e,t){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length<2*t+2;)e="0x0"+e.substring(2);return e}function d(e){var t,r=0,i="0x",o="0x";if((t=e)&&null!=t.r&&null!=t.s){null==e.v&&null==e.recoveryParam&&n.throwError("at least on of recoveryParam or v must be specified",n.INVALID_ARGUMENT,{argument:"signature",value:e}),i=l(e.r,32),o=l(e.s,32),"string"==typeof(r=e.v)&&(r=parseInt(r,16));var a=e.recoveryParam;null==a&&null!=e.v&&(a=1-r%2),r=27+a}else{var u=s(e);if(65!==u.length)throw new Error("invalid signature");i=h(u.slice(0,32)),o=h(u.slice(32,64)),27!==(r=u[64])&&28!==r&&(r=27+r%2)}return{r:i,s:o,recoveryParam:r-27,v:r}}r.hexlify=h,r.hexDataLength=function(e){return c(e)&&e.length%2==0?(e.length-2)/2:null},r.hexDataSlice=function(e,t,r){return c(e)||n.throwError("invalid hex data",n.INVALID_ARGUMENT,{arg:"value",value:e}),e.length%2!=0&&n.throwError("hex data length must be even",n.INVALID_ARGUMENT,{arg:"value",value:e}),t=2+2*t,null!=r?"0x"+e.substring(t,t+2*r):"0x"+e.substring(t)},r.hexStripZeros=function(e){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length>3&&"0x0"===e.substring(0,3);)e="0x"+e.substring(3);return e},r.hexZeroPad=l,r.splitSignature=d,r.joinSignature=function(e){return h(u([(e=d(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}},{"./errors":147}],147:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.MISSING_NEW="MISSING_NEW",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.NUMERIC_FAULT="NUMERIC_FAULT",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION";var n=!1,i=!1;function o(e,t,n){if(i)throw new Error("unknown error");t||(t=r.UNKNOWN_ERROR),n||(n={});var o=[];Object.keys(n).forEach(function(e){try{o.push(e+"="+JSON.stringify(n[e]))}catch(t){o.push(e+"="+JSON.stringify(n[e].toString()))}});var a=e;o.length&&(e+=" ("+o.join(", ")+")");var s=new Error(e);throw s.reason=a,s.code=t,Object.keys(n).forEach(function(e){s[e]=n[e]}),s}r.throwError=o,r.checkNew=function(e,t){e instanceof t||o("missing new",r.MISSING_NEW,{name:t.name})},r.checkArgumentCount=function(e,t,n){n||(n=""),et&&o("too many arguments"+n,r.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})},r.setCensorship=function(e,t){n&&o("error censorship permanent",r.UNSUPPORTED_OPERATION,{operation:"setCersorship"}),i=!!e,n=!!t}},{}],148:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("js-sha3"),i=e("./bytes");r.keccak256=function(e){return"0x"+n.keccak_256(i.arrayify(e))}},{"./bytes":146,"js-sha3":142}],149:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defineReadOnly=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})},r.defineFrozen=function(e,t,r){var n=JSON.stringify(r);Object.defineProperty(e,t,{enumerable:!0,get:function(){return JSON.parse(n)}})},r.resolveProperties=function(e){var t={},r=[];return Object.keys(e).forEach(function(n){var i=e[n];i instanceof Promise?r.push(i.then(function(e){return t[n]=e,null})):t[n]=i}),Promise.all(r).then(function(){return t})},r.shallowCopy=function(e){var t={};for(var r in e)t[r]=e[r];return t},r.jsonCopy=function(e){return JSON.parse(JSON.stringify(e))}},{}],150:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./bytes");function i(e){for(var t=[];e;)t.unshift(255&e),e>>=8;return t}function o(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function s(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(r=e[t]-247)>e.length)throw new Error("too short");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("to short");return a(e,t,t+1+r,r+i)}if(e[t]>=192){if(t+1+(i=e[t]-192)>e.length)throw new Error("invalid rlp data");return a(e,t,t+1,i)}if(e[t]>=184){var r;if(t+1+(r=e[t]-183)>e.length)throw new Error("invalid rlp data");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("invalid rlp data");return{consumed:1+r+i,result:n.hexlify(e.slice(t+1+r,t+1+r+i))}}if(e[t]>=128){var i;if(t+1+(i=e[t]-128)>e.length)throw new Error("invalid rlp data");return{consumed:1+i,result:n.hexlify(e.slice(t+1,t+1+i))}}return{consumed:1,result:n.hexlify(e[t])}}r.encode=function(e){return n.hexlify(function e(t){if(Array.isArray(t)){var r=[];return t.forEach(function(t){r=r.concat(e(t))}),r.length<=55?(r.unshift(192+r.length),r):((o=i(r.length)).unshift(247+o.length),o.concat(r))}var o,a=Array.prototype.slice.call(n.arrayify(t));return 1===a.length&&a[0]<=127?a:a.length<=55?(a.unshift(128+a.length),a):((o=i(a.length)).unshift(183+o.length),o.concat(a))}(e))},r.decode=function(e){var t=n.arrayify(e),r=s(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}},{"./bytes":146}],151:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=function(){return function(){}}();r.BigNumber=n;var i=function(){return function(){}}();r.Indexed=i;var o=function(){return function(){}}();r.MinimalProvider=o;var a=function(){return function(){}}();r.Signer=a;var s=function(){return function(){}}();r.HDNode=s},{}],152:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,i=e("./bytes");!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(n=r.UnicodeNormalizationForm||(r.UnicodeNormalizationForm={})),r.toUtf8Bytes=function(e,t){void 0===t&&(t=n.current),t!=n.current&&(e=e.normalize(t));for(var r=[],o=0,a=0;a>6|192,r[o++]=63&s|128):55296==(64512&s)&&a+1>18|240,r[o++]=s>>12&63|128,r[o++]=s>>6&63|128,r[o++]=63&s|128):(r[o++]=s>>12|224,r[o++]=s>>6&63|128,r[o++]=63&s|128)}return i.arrayify(r)},r.toUtf8String=function(e){e=i.arrayify(e);for(var t="",r=0;r>7!=0){if(n>>6!=2){var o=null;if(n>>5==6)o=1;else if(n>>4==14)o=2;else if(n>>3==30)o=3;else if(n>>2==62)o=4;else{if(n>>1!=126)continue;o=5}if(r+o>e.length){for(;r>6==2;r++);if(r!=e.length)continue;return t}var a,s=n&(1<<8-o-1)-1;for(a=0;a>6!=2)break;s=s<<6|63&u}a==o?s<=65535?t+=String.fromCharCode(s):(s-=65536,t+=String.fromCharCode(55296+(s>>10&1023),56320+(1023&s))):r--}}else t+=String.fromCharCode(n)}return t}},{"./bytes":146}],153:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("number-to-bn"),o=new n(0),a=new n(-1),s={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",Gwei:"1000000000",shannon:"1000000000",nanoether:"1000000000",nano:"1000000000",szabo:"1000000000000",microether:"1000000000000",micro:"1000000000000",finney:"1000000000000000",milliether:"1000000000000000",milli:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"};function u(e){var t=e?e.toLowerCase():"ether",r=s[t];if("string"!=typeof r)throw new Error("[ethjs-unit] the unit provided "+e+" doesn't exists, please use the one of the following units "+JSON.stringify(s,null,2));return new n(r,10)}function c(e){if("string"==typeof e){if(!e.match(/^-?[0-9.]+$/))throw new Error("while converting number to string, invalid number value '"+e+"', should be a number matching (^-?[0-9.]+).");return e}if("number"==typeof e)return String(e);if("object"==typeof e&&e.toString&&(e.toTwos||e.dividedToIntegerBy))return e.toPrecision?String(e.toPrecision()):e.toString(10);throw new Error("while converting number to string, invalid number value '"+e+"' type "+typeof e+".")}t.exports={unitMap:s,numberToString:c,getValueOfUnit:u,fromWei:function(e,t,r){var n=i(e),c=n.lt(o),f=u(t),h=s[t].length-1||1,l=r||{};c&&(n=n.mul(a));for(var d=n.mod(f).toString(10);d.length2)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal points");var l=h[0],d=h[1];if(l||(l="0"),d||(d="0"),d.length>o)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal places");for(;d.length=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{}],155:[function(e,t,r){(function(r){"use strict";var n=e("is-hex-prefixed"),i=e("strip-hex-prefix");function o(e){var t=e;if("string"!=typeof t)throw new Error("[ethjs-util] while padding to even, value must be string, is currently "+typeof t+", while padToEven.");return t.length%2&&(t="0"+t),t}function a(e){return"0x"+e.toString(16)}t.exports={arrayContainsArray:function(e,t,r){if(!0!==Array.isArray(e))throw new Error("[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '"+typeof e+"'");if(!0!==Array.isArray(t))throw new Error("[ethjs-util] method arrayContainsArray requires input 'subset' to be an array got type '"+typeof t+"'");return t[Boolean(r)?"some":"every"](function(t){return e.indexOf(t)>=0})},intToBuffer:function(e){var t=a(e);return new r(o(t.slice(2)),"hex")},getBinarySize:function(e){if("string"!=typeof e)throw new Error("[ethjs-util] while getting binary size, method getBinarySize requires input 'str' to be type String, got '"+typeof e+"'.");return r.byteLength(e,"utf8")},isHexPrefixed:n,stripHexPrefix:i,padToEven:o,intToHex:a,fromAscii:function(e){for(var t="",r=0;r0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var r,n,a,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(r=this._events[e]).length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=a;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){n=s;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],158:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("md5.js");t.exports=function(e,t,r,o){if(n.isBuffer(e)||(e=n.from(e,"binary")),t&&(n.isBuffer(t)||(t=n.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var a=r/8,s=n.alloc(a),u=n.alloc(o||0),c=n.alloc(0);a>0||o>0;){var f=new i;f.update(c),f.update(e),t&&f.update(t),c=f.digest();var h=0;if(a>0){var l=s.length-a;h=Math.min(a,c.length),c.copy(s,l,0,h),a-=h}if(h0){var d=u.length-o,p=Math.min(o,c.length-h);c.copy(u,d,h,h+p),o-=p}}return c.fill(0),{key:s,iv:u}}},{"md5.js":231,"safe-buffer":290}],159:[function(e,t,r){"use strict";var n=e("is-callable"),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.exports=function(e,t,r){if(!n(t))throw new TypeError("iterator must be a function");var a;arguments.length>=3&&(a=r),"[object Array]"===i.call(e)?function(e,t,r){for(var n=0,i=e.length;n=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},i.prototype._update=function(e){throw new Error("_update is not implemented")},i.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();return void 0!==e&&(t=t.toString(e)),t},i.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=i}).call(this,e("buffer").Buffer)},{buffer:84,inherits:180,stream:311}],162:[function(e,t,r){var n=r;n.utils=e("./hash/utils"),n.common=e("./hash/common"),n.sha=e("./hash/sha"),n.ripemd=e("./hash/ripemd"),n.hmac=e("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":163,"./hash/hmac":164,"./hash/ripemd":165,"./hash/sha":166,"./hash/utils":173}],163:[function(e,t,r){"use strict";var n=e("./utils"),i=e("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},{"../utils":173}],173:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits");function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function s(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=i,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,a=255&i;o?r.push(o,a):r.push(a)}else for(n=0;n>>0}return a},r.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},r.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},r.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},r.sum64_lo=function(e,t,r,n){return t+n>>>0},r.sum64_4_hi=function(e,t,r,n,i,o,a,s){var u=0,c=t;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},r.sum64_5_hi=function(e,t,r,n,i,o,a,s,u,c){var f=0,h=t;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,n,i,o,a,s,u,c){return t+n+o+s+c>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:180,"minimalistic-assert":234}],174:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("minimalistic-crypto-utils"),o=e("minimalistic-assert");function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}t.exports=a,a.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},a.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length\\$%@ءؤة\"'^|~⦅⦆・ゥャ¢£¬¦¥₩│←↑→↓■○𐐨𐐩𐐪𐐫𐐬𐐭𐐮𐐯𐐰𐐱𐐲𐐳𐐴𐐵𐐶𐐷𐐸𐐹𐐺𐐻𐐼𐐽𐐾𐐿𐑀𐑁𐑂𐑃𐑄𐑅𐑆𐑇𐑈𐑉𐑊𐑋𐑌𐑍𐑎𐑏𐓘𐓙𐓚𐓛𐓜𐓝𐓞𐓟𐓠𐓡𐓢𐓣𐓤𐓥𐓦𐓧𐓨𐓩𐓪𐓫𐓬𐓭𐓮𐓯𐓰𐓱𐓲𐓳𐓴𐓵𐓶𐓷𐓸𐓹𐓺𐓻𐳀𐳁𐳂𐳃𐳄𐳅𐳆𐳇𐳈𐳉𐳊𐳋𐳌𐳍𐳎𐳏𐳐𐳑𐳒𐳓𐳔𐳕𐳖𐳗𐳘𐳙𐳚𐳛𐳜𐳝𐳞𐳟𐳠𐳡𐳢𐳣𐳤𐳥𐳦𐳧𐳨𐳩𐳪𐳫𐳬𐳭𐳮𐳯𐳰𐳱𐳲𑣀𑣁𑣂𑣃𑣄𑣅𑣆𑣇𑣈𑣉𑣊𑣋𑣌𑣍𑣎𑣏𑣐𑣑𑣒𑣓𑣔𑣕𑣖𑣗𑣘𑣙𑣚𑣛𑣜𑣝𑣞𑣟ıȷ∇∂𞤢𞤣𞤤𞤥𞤦𞤧𞤨𞤩𞤪𞤫𞤬𞤭𞤮𞤯𞤰𞤱𞤲𞤳𞤴𞤵𞤶𞤷𞤸𞤹𞤺𞤻𞤼𞤽𞤾𞤿𞥀𞥁𞥂𞥃ٮڡٯ字双多解交映無前後再新初終販声吹演投捕遊指禁空合満申割営配得可丽丸乁𠄢你侻倂偺備像㒞𠘺兔兤具𠔜㒹內𠕋冗冤仌冬𩇟刃㓟刻剆剷㔕包匆卉博即卽卿𠨬灰及叟𠭣叫叱吆咞吸呈周咢哶唐啓啣善喫喳嗂圖圗噑噴壮城埴堍型堲報墬𡓤売壷夆夢奢𡚨𡛪姬娛娧姘婦㛮嬈嬾𡧈寃寘寳𡬘寿将㞁屠峀岍𡷤嵃𡷦嵮嵫嵼巡巢㠯巽帨帽幩㡢𢆃㡼庰庳庶𪎒𢌱舁弢㣇𣊸𦇚形彫㣣徚忍志忹悁㤺㤜𢛔惇慈慌慺憲憤憯懞戛扝抱拔捐𢬌挽拼捨掃揤𢯱搢揅掩㨮摩摾撝摷㩬敬𣀊旣書晉㬙㬈㫤冒冕最暜肭䏙朡杞杓𣏃㭉柺枅桒𣑭梎栟椔楂榣槪檨𣚣櫛㰘次𣢧歔㱎歲殟殻𣪍𡴋𣫺汎𣲼沿泍汧洖派浩浸涅𣴞洴港湮㴳滇𣻑淹潮𣽞𣾎濆瀹瀛㶖灊災灷炭𠔥煅𤉣熜爨牐𤘈犀犕𤜵𤠔獺王㺬玥㺸瑇瑜璅瓊㼛甤𤰶甾𤲒𢆟瘐𤾡𤾸𥁄㿼䀈𥃳𥃲𥄙𥄳眞真瞋䁆䂖𥐝硎䃣𥘦𥚚𥛅秫䄯穊穏𥥼𥪧䈂𥮫篆築䈧𥲀糒䊠糨糣紀𥾆絣䌁緇縂繅䌴𦈨𦉇䍙𦋙罺𦌾羕翺𦓚𦔣聠𦖨聰𣍟䏕育脃䐋脾媵𦞧𦞵𣎓𣎜舄辞䑫芑芋芝劳花芳芽苦𦬼茝荣莭茣莽菧荓菊菌菜𦰶𦵫𦳕䔫蓱蓳蔖𧏊蕤𦼬䕝䕡𦾱𧃒䕫虐虧虩蚩蚈蜎蛢蜨蝫螆蟡蠁䗹衠𧙧裗裞䘵裺㒻𧢮𧥦䚾䛇誠𧲨貫賁贛起𧼯𠠄跋趼跰𠣞軔𨗒𨗭邔郱鄑𨜮鄛鈸鋗鋘鉼鏹鐕𨯺開䦕閷𨵷䧦雃嶲霣𩅅𩈚䩮䩶韠𩐊䪲𩒖頩𩖶飢䬳餩馧駂駾䯎𩬰鱀鳽䳎䳭鵧𪃎䳸𪄅𪈎𪊑䵖黾鼅鼏鼖𪘀",mapChar:function(r){return r>=196608?r>=917760&&r<=917999?18874368:0:e[t[r>>4]][15&r]}}},"function"==typeof define&&define.amd?define([],function(){return i()}):"object"==typeof r?t.exports=i():n.uts46_map=i()},{}],177:[function(e,t,r){var n,i;n=this,i=function(e,t){function r(r,n,i){for(var o=[],a=e.ucs2.decode(r),s=0;s>23,l=f>>21&3,d=f>>5&65535,p=31&f,b=t.mapStr.substr(d,p);if(0===l||n&&1&h)throw new Error("Illegal char "+c);1===l?o.push(b):2===l?o.push(i?b:c):3===l&&o.push(c)}return o.join("").normalize("NFC")}function n(t,n,o){void 0===o&&(o=!1);var a=r(t,o,n).split(".");return(a=a.map(function(t){return t.startsWith("xn--")?i(t=e.decode(t.substring(4)),o,!1):i(t,o,n),t})).join(".")}function i(e,n,i){if("-"===e[2]&&"-"===e[3])throw new Error("Failed to validate "+e);if(e.startsWith("-")||e.endsWith("-"))throw new Error("Failed to validate "+e);if(e.includes("."))throw new Error("Failed to validate "+e);if(r(e,n,i)!==e)throw new Error("Failed to validate "+e);var o=e.codePointAt(0);if(t.mapChar(o)&2<<23)throw new Error("Label contains illegal character: "+o)}return{toUnicode:function(e,t){return void 0===t&&(t={}),n(e,!1,"useStd3ASCII"in t&&t.useStd3ASCII)},toAscii:function(t,r){void 0===r&&(r={});var i,o=!("transitional"in r)||r.transitional,a="useStd3ASCII"in r&&r.useStd3ASCII,s="verifyDnsLength"in r&&r.verifyDnsLength,u=n(t,o,a).split(".").map(e.toASCII),c=u.join(".");if(s){if(c.length<1||c.length>253)throw new Error("DNS name has wrong length: "+c);for(i=0;i63)throw new Error("DNS label has wrong length: "+f)}}return c}}},"function"==typeof define&&define.amd?define(["punycode","./idna-map"],function(e,t){return i(e,t)}):"object"==typeof r?t.exports=i(e("punycode"),e("./idna-map")):n.uts46=i(n.punycode,n.idna_map)},{"./idna-map":176,punycode:265}],178:[function(e,t,r){r.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,f=-7,h=r?i-1:0,l=r?-1:1,d=e[t+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=s;f>0;o=256*o+e[t+h],h+=l,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+e[t+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=c}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var a,s,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(a++,u/=2),a+h>=f?(s=0,a=f):a+h>=1?(s=(t*u-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;e[r+d]=255&a,d+=p,a/=256,c-=8);e[r+d-p]|=128*b}},{}],179:[function(e,t,r){var n=[].indexOf;t.exports=function(e,t){if(n)return e.indexOf(t);for(var r=0;r-32e3)throw new Error("Invalid error code");if(!(this instanceof f))return new f(e);i.call(this,"Server error",e)};n(f,i),i.ParseError=o,i.InvalidRequest=a,i.MethodNotFound=s,i.InvalidParams=u,i.InternalError=c,i.ServerError=f,t.exports=i},{inherits:180}],191:[function(e,t,r){t.exports=function(e){var t=(e=e||{}).max||Number.MAX_SAFE_INTEGER,r=void 0!==e.start?e.start:Math.floor(Math.random()*t);return function(){return r%=t,r++}}},{}],192:[function(e,t,r){r.parse=e("./lib/parse"),r.stringify=e("./lib/stringify")},{"./lib/parse":193,"./lib/stringify":194}],193:[function(e,t,r){var n,i,o,a,s={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},u=function(e){throw{name:"SyntaxError",message:e,at:n,text:o}},c=function(e){return e&&e!==i&&u("Expected '"+e+"' instead of '"+i+"'"),i=o.charAt(n),n+=1,i},f=function(){var e,t="";for("-"===i&&(t="-",c("-"));i>="0"&&i<="9";)t+=i,c();if("."===i)for(t+=".";c()&&i>="0"&&i<="9";)t+=i;if("e"===i||"E"===i)for(t+=i,c(),"-"!==i&&"+"!==i||(t+=i,c());i>="0"&&i<="9";)t+=i,c();if(e=+t,isFinite(e))return e;u("Bad number")},h=function(){var e,t,r,n="";if('"'===i)for(;c();){if('"'===i)return c(),n;if("\\"===i)if(c(),"u"===i){for(r=0,t=0;t<4&&(e=parseInt(c(),16),isFinite(e));t+=1)r=16*r+e;n+=String.fromCharCode(r)}else{if("string"!=typeof s[i])break;n+=s[i]}else n+=i}u("Bad string")},l=function(){for(;i&&i<=" ";)c()};a=function(){switch(l(),i){case"{":return function(){var e,t={};if("{"===i){if(c("{"),l(),"}"===i)return c("}"),t;for(;i;){if(e=h(),l(),c(":"),Object.hasOwnProperty.call(t,e)&&u('Duplicate key "'+e+'"'),t[e]=a(),l(),"}"===i)return c("}"),t;c(","),l()}}u("Bad object")}();case"[":return function(){var e=[];if("["===i){if(c("["),l(),"]"===i)return c("]"),e;for(;i;){if(e.push(a()),l(),"]"===i)return c("]"),e;c(","),l()}}u("Bad array")}();case'"':return h();case"-":return f();default:return i>="0"&&i<="9"?f():function(){switch(i){case"t":return c("t"),c("r"),c("u"),c("e"),!0;case"f":return c("f"),c("a"),c("l"),c("s"),c("e"),!1;case"n":return c("n"),c("u"),c("l"),c("l"),null}u("Unexpected '"+i+"'")}()}},t.exports=function(e,t){var r;return o=e,n=0,i=" ",r=a(),l(),i&&u("Syntax error"),"function"==typeof t?function e(r,n){var i,o,a=r[n];if(a&&"object"==typeof a)for(i in a)Object.prototype.hasOwnProperty.call(a,i)&&(void 0!==(o=e(a,i))?a[i]=o:delete a[i]);return t.call(r,n,a)}({"":r},""):r}},{}],194:[function(e,t,r){var n,i,o,a=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,s={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function u(e){return a.lastIndex=0,a.test(e)?'"'+e.replace(a,function(e){var t=s[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}t.exports=function(e,t,r){var a;if(n="",i="","number"==typeof r)for(a=0;a>>31),p=l^(a<<1|o>>>31),b=e[0]^d,y=e[1]^p,m=e[10]^d,v=e[11]^p,g=e[20]^d,w=e[21]^p,_=e[30]^d,A=e[31]^p,E=e[40]^d,x=e[41]^p;d=r^(s<<1|u>>>31),p=i^(u<<1|s>>>31);var k=e[2]^d,S=e[3]^p,M=e[12]^d,I=e[13]^p,T=e[22]^d,U=e[23]^p,j=e[32]^d,B=e[33]^p,P=e[42]^d,C=e[43]^p;d=o^(c<<1|f>>>31),p=a^(f<<1|c>>>31);var N=e[4]^d,R=e[5]^p,L=e[14]^d,O=e[15]^p,D=e[24]^d,F=e[25]^p,q=e[34]^d,H=e[35]^p,z=e[44]^d,K=e[45]^p;d=s^(h<<1|l>>>31),p=u^(l<<1|h>>>31);var V=e[6]^d,G=e[7]^p,W=e[16]^d,Y=e[17]^p,X=e[26]^d,Z=e[27]^p,J=e[36]^d,$=e[37]^p,Q=e[46]^d,ee=e[47]^p;d=c^(r<<1|i>>>31),p=f^(i<<1|r>>>31);var te=e[8]^d,re=e[9]^p,ne=e[18]^d,ie=e[19]^p,oe=e[28]^d,ae=e[29]^p,se=e[38]^d,ue=e[39]^p,ce=e[48]^d,fe=e[49]^p,he=b,le=y,de=v<<4|m>>>28,pe=m<<4|v>>>28,be=g<<3|w>>>29,ye=w<<3|g>>>29,me=A<<9|_>>>23,ve=_<<9|A>>>23,ge=E<<18|x>>>14,we=x<<18|E>>>14,_e=k<<1|S>>>31,Ae=S<<1|k>>>31,Ee=I<<12|M>>>20,xe=M<<12|I>>>20,ke=T<<10|U>>>22,Se=U<<10|T>>>22,Me=B<<13|j>>>19,Ie=j<<13|B>>>19,Te=P<<2|C>>>30,Ue=C<<2|P>>>30,je=R<<30|N>>>2,Be=N<<30|R>>>2,Pe=L<<6|O>>>26,Ce=O<<6|L>>>26,Ne=F<<11|D>>>21,Re=D<<11|F>>>21,Le=q<<15|H>>>17,Oe=H<<15|q>>>17,De=K<<29|z>>>3,Fe=z<<29|K>>>3,qe=V<<28|G>>>4,He=G<<28|V>>>4,ze=Y<<23|W>>>9,Ke=W<<23|Y>>>9,Ve=X<<25|Z>>>7,Ge=Z<<25|X>>>7,We=J<<21|$>>>11,Ye=$<<21|J>>>11,Xe=ee<<24|Q>>>8,Ze=Q<<24|ee>>>8,Je=te<<27|re>>>5,$e=re<<27|te>>>5,Qe=ne<<20|ie>>>12,et=ie<<20|ne>>>12,tt=ae<<7|oe>>>25,rt=oe<<7|ae>>>25,nt=se<<8|ue>>>24,it=ue<<8|se>>>24,ot=ce<<14|fe>>>18,at=fe<<14|ce>>>18;e[0]=he^~Ee&Ne,e[1]=le^~xe&Re,e[10]=qe^~Qe&be,e[11]=He^~et&ye,e[20]=_e^~Pe&Ve,e[21]=Ae^~Ce&Ge,e[30]=Je^~de&ke,e[31]=$e^~pe&Se,e[40]=je^~ze&tt,e[41]=Be^~Ke&rt,e[2]=Ee^~Ne&We,e[3]=xe^~Re&Ye,e[12]=Qe^~be&Me,e[13]=et^~ye&Ie,e[22]=Pe^~Ve&nt,e[23]=Ce^~Ge&it,e[32]=de^~ke&Le,e[33]=pe^~Se&Oe,e[42]=ze^~tt&me,e[43]=Ke^~rt&ve,e[4]=Ne^~We&ot,e[5]=Re^~Ye&at,e[14]=be^~Me&De,e[15]=ye^~Ie&Fe,e[24]=Ve^~nt&ge,e[25]=Ge^~it&we,e[34]=ke^~Le&Xe,e[35]=Se^~Oe&Ze,e[44]=tt^~me&Te,e[45]=rt^~ve&Ue,e[6]=We^~ot&he,e[7]=Ye^~at&le,e[16]=Me^~De&qe,e[17]=Ie^~Fe&He,e[26]=nt^~ge&_e,e[27]=it^~we&Ae,e[36]=Le^~Xe&Je,e[37]=Oe^~Ze&$e,e[46]=me^~Te&je,e[47]=ve^~Ue&Be,e[8]=ot^~he&Ee,e[9]=at^~le&xe,e[18]=De^~qe&Qe,e[19]=Fe^~He&et,e[28]=ge^~_e&Pe,e[29]=we^~Ae&Ce,e[38]=Xe^~Je&de,e[39]=Ze^~$e&pe,e[48]=Te^~je&ze,e[49]=Ue^~Be&Ke,e[0]^=n[2*t],e[1]^=n[2*t+1]}}},{}],200:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("./keccak-state-unroll");function o(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}o.prototype.initialize=function(e,t){for(var r=0;r<50;++r)this.state[r]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},o.prototype.absorb=function(e){for(var t=0;t>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(i.p1600(this.state),this.count=0);return t},o.prototype.copy=function(e){for(var t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},t.exports=o},{"./keccak-state-unroll":199,"safe-buffer":290}],201:[function(e,t,r){var n=e("./_root").Symbol;t.exports=n},{"./_root":217}],202:[function(e,t,r){var n=e("./_baseTimes"),i=e("./isArguments"),o=e("./isArray"),a=e("./isBuffer"),s=e("./_isIndex"),u=e("./isTypedArray"),c=Object.prototype.hasOwnProperty;t.exports=function(e,t){var r=o(e),f=!r&&i(e),h=!r&&!f&&a(e),l=!r&&!f&&!h&&u(e),d=r||f||h||l,p=d?n(e.length,String):[],b=p.length;for(var y in e)!t&&!c.call(e,y)||d&&("length"==y||h&&("offset"==y||"parent"==y)||l&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||s(y,b))||p.push(y);return p}},{"./_baseTimes":207,"./_isIndex":211,"./isArguments":219,"./isArray":220,"./isBuffer":222,"./isTypedArray":227}],203:[function(e,t,r){var n=e("./_Symbol"),i=e("./_getRawTag"),o=e("./_objectToString"),a="[object Null]",s="[object Undefined]",u=n?n.toStringTag:void 0;t.exports=function(e){return null==e?void 0===e?s:a:u&&u in Object(e)?i(e):o(e)}},{"./_Symbol":201,"./_getRawTag":210,"./_objectToString":215}],204:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isObjectLike"),o="[object Arguments]";t.exports=function(e){return i(e)&&n(e)==o}},{"./_baseGetTag":203,"./isObjectLike":226}],205:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isLength"),o=e("./isObjectLike"),a={};a["[object Float32Array]"]=a["[object Float64Array]"]=a["[object Int8Array]"]=a["[object Int16Array]"]=a["[object Int32Array]"]=a["[object Uint8Array]"]=a["[object Uint8ClampedArray]"]=a["[object Uint16Array]"]=a["[object Uint32Array]"]=!0,a["[object Arguments]"]=a["[object Array]"]=a["[object ArrayBuffer]"]=a["[object Boolean]"]=a["[object DataView]"]=a["[object Date]"]=a["[object Error]"]=a["[object Function]"]=a["[object Map]"]=a["[object Number]"]=a["[object Object]"]=a["[object RegExp]"]=a["[object Set]"]=a["[object String]"]=a["[object WeakMap]"]=!1,t.exports=function(e){return o(e)&&i(e.length)&&!!a[n(e)]}},{"./_baseGetTag":203,"./isLength":224,"./isObjectLike":226}],206:[function(e,t,r){var n=e("./_isPrototype"),i=e("./_nativeKeys"),o=Object.prototype.hasOwnProperty;t.exports=function(e){if(!n(e))return i(e);var t=[];for(var r in Object(e))o.call(e,r)&&"constructor"!=r&&t.push(r);return t}},{"./_isPrototype":212,"./_nativeKeys":213}],207:[function(e,t,r){t.exports=function(e,t){for(var r=-1,n=Array(e);++r-1&&e%1==0&&e-1&&e%1==0&&e<=n}},{}],225:[function(e,t,r){t.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},{}],226:[function(e,t,r){t.exports=function(e){return null!=e&&"object"==typeof e}},{}],227:[function(e,t,r){var n=e("./_baseIsTypedArray"),i=e("./_baseUnary"),o=e("./_nodeUtil"),a=o&&o.isTypedArray,s=a?i(a):n;t.exports=s},{"./_baseIsTypedArray":205,"./_baseUnary":208,"./_nodeUtil":214}],228:[function(e,t,r){var n=e("./_arrayLikeKeys"),i=e("./_baseKeys"),o=e("./isArrayLike");t.exports=function(e){return o(e)?n(e):i(e)}},{"./_arrayLikeKeys":202,"./_baseKeys":206,"./isArrayLike":221}],229:[function(e,t,r){t.exports=function(){}},{}],230:[function(e,t,r){t.exports=function(){return!1}},{}],231:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base"),o=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function s(e,t){return e<>>32-t}function u(e,t,r,n,i,o,a){return s(e+(t&r|~t&n)+i+o|0,a)+t|0}function c(e,t,r,n,i,o,a){return s(e+(t&n|r&~n)+i+o|0,a)+t|0}function f(e,t,r,n,i,o,a){return s(e+(t^r^n)+i+o|0,a)+t|0}function h(e,t,r,n,i,o,a){return s(e+(r^(t|~n))+i+o|0,a)+t|0}n(a,i),a.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,a=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,a=u(a,r=u(r,n,i,a,e[0],3614090360,7),n,i,e[1],3905402710,12),r,n,e[2],606105819,17),a,r,e[3],3250441966,22),i=u(i,a=u(a,r=u(r,n,i,a,e[4],4118548399,7),n,i,e[5],1200080426,12),r,n,e[6],2821735955,17),a,r,e[7],4249261313,22),i=u(i,a=u(a,r=u(r,n,i,a,e[8],1770035416,7),n,i,e[9],2336552879,12),r,n,e[10],4294925233,17),a,r,e[11],2304563134,22),i=u(i,a=u(a,r=u(r,n,i,a,e[12],1804603682,7),n,i,e[13],4254626195,12),r,n,e[14],2792965006,17),a,r,e[15],1236535329,22),i=c(i,a=c(a,r=c(r,n,i,a,e[1],4129170786,5),n,i,e[6],3225465664,9),r,n,e[11],643717713,14),a,r,e[0],3921069994,20),i=c(i,a=c(a,r=c(r,n,i,a,e[5],3593408605,5),n,i,e[10],38016083,9),r,n,e[15],3634488961,14),a,r,e[4],3889429448,20),i=c(i,a=c(a,r=c(r,n,i,a,e[9],568446438,5),n,i,e[14],3275163606,9),r,n,e[3],4107603335,14),a,r,e[8],1163531501,20),i=c(i,a=c(a,r=c(r,n,i,a,e[13],2850285829,5),n,i,e[2],4243563512,9),r,n,e[7],1735328473,14),a,r,e[12],2368359562,20),i=f(i,a=f(a,r=f(r,n,i,a,e[5],4294588738,4),n,i,e[8],2272392833,11),r,n,e[11],1839030562,16),a,r,e[14],4259657740,23),i=f(i,a=f(a,r=f(r,n,i,a,e[1],2763975236,4),n,i,e[4],1272893353,11),r,n,e[7],4139469664,16),a,r,e[10],3200236656,23),i=f(i,a=f(a,r=f(r,n,i,a,e[13],681279174,4),n,i,e[0],3936430074,11),r,n,e[3],3572445317,16),a,r,e[6],76029189,23),i=f(i,a=f(a,r=f(r,n,i,a,e[9],3654602809,4),n,i,e[12],3873151461,11),r,n,e[15],530742520,16),a,r,e[2],3299628645,23),i=h(i,a=h(a,r=h(r,n,i,a,e[0],4096336452,6),n,i,e[7],1126891415,10),r,n,e[14],2878612391,15),a,r,e[5],4237533241,21),i=h(i,a=h(a,r=h(r,n,i,a,e[12],1700485571,6),n,i,e[3],2399980690,10),r,n,e[10],4293915773,15),a,r,e[1],2240044497,21),i=h(i,a=h(a,r=h(r,n,i,a,e[8],1873313359,6),n,i,e[15],4264355552,10),r,n,e[6],2734768916,15),a,r,e[13],1309151649,21),i=h(i,a=h(a,r=h(r,n,i,a,e[4],4149444226,6),n,i,e[11],3174756917,10),r,n,e[2],718787259,15),a,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+a|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=a}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":232,inherits:180}],232:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("stream").Transform;function o(e){i.call(this),this._block=n.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}e("inherits")(o,i),o.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},o.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},o.prototype.update=function(e,t){if(function(e,t){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");n.isBuffer(e)||(e=n.from(e,t));for(var r=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},{inherits:180,"safe-buffer":290,stream:311}],233:[function(e,t,r){var n=e("bn.js"),i=e("brorand");function o(e){this.rand=e||new i.Rand}t.exports=o,o.create=function(e){return new o(e)},o.prototype._randbelow=function(e){var t=e.bitLength(),r=Math.ceil(t/8);do{var i=new n(this.rand.generate(r))}while(i.cmp(e)>=0);return i},o.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},o.prototype.test=function(e,t,r){var i=e.bitLength(),o=n.mont(e),a=new n(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var s=e.subn(1),u=0;!s.testn(u);u++);for(var c=e.shrn(u),f=s.toRed(o);t>0;t--){var h=this._randrange(new n(2),s);r&&r(h);var l=h.toRed(o).redPow(c);if(0!==l.cmp(a)&&0!==l.cmp(f)){for(var d=1;d0;t--){var f=this._randrange(new n(2),a),h=e.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(u);if(0!==l.cmp(o)&&0!==l.cmp(c)){for(var d=1;d>8,a=255&i;o?r.push(o,a):r.push(a)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},{}],236:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],237:[function(e,t,r){var n=e("bn.js"),i=e("strip-hex-prefix");t.exports=function(e){if("string"==typeof e||"number"==typeof e){var t=new n(1),r=String(e).toLowerCase().trim(),o="0x"===r.substr(0,2)||"-0x"===r.substr(0,3),a=i(r);if("-"===a.substr(0,1)&&(a=i(a.slice(1)),t=new n(-1,10)),!(a=""===a?"0":a).match(/^-?[0-9]+$/)&&a.match(/^[0-9A-Fa-f]+$/)||a.match(/^[a-fA-F]+$/)||!0===o&&a.match(/^[0-9A-Fa-f]+$/))return new n(a,16).mul(t);if((a.match(/^-?[0-9]+$/)||""===a)&&!1===o)return new n(a,10).mul(t)}else if("object"==typeof e&&e.toString&&!e.pop&&!e.push&&e.toString(10).match(/^-?[0-9]+$/)&&(e.mul||e.dividedToIntegerBy))return new n(e.toString(10),10);throw new Error("[number-to-bn] while converting number "+JSON.stringify(e)+" to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.")}},{"bn.js":236,"strip-hex-prefix":318}],238:[function(e,t,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,a,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),u=1;u0;)if(q+=r,r=e.charAt(o++),4===H?(N+=String.fromCharCode(parseInt(q,16)),H=0,c=o-1):H++,!r)break e;if('"'===r&&!L){D=F.pop()||p,N+=e.substring(c,o-1);break}if(!("\\"!==r||L||(L=!0,N+=e.substring(c,o-1),r=e.charAt(o++))))break;if(L){if(L=!1,"n"===r?N+="\n":"r"===r?N+="\r":"t"===r?N+="\t":"f"===r?N+="\f":"b"===r?N+="\b":"u"===r?(H=1,q=""):N+=r,r=e.charAt(o++),c=o-1,r)continue;break}h.lastIndex=o;var l=h.exec(e);if(!l){o=e.length+1,N+=e.substring(c,o-1);break}if(o=l.index+1,!(r=e.charAt(l.index))){N+=e.substring(c,o-1);break}}continue;case A:if(!r)continue;if("r"!==r)return W("Invalid true started with t"+r);D=E;continue;case E:if(!r)continue;if("u"!==r)return W("Invalid true started with tr"+r);D=x;continue;case x:if(!r)continue;if("e"!==r)return W("Invalid true started with tru"+r);a(!0),u(),D=F.pop()||p;continue;case k:if(!r)continue;if("a"!==r)return W("Invalid false started with f"+r);D=S;continue;case S:if(!r)continue;if("l"!==r)return W("Invalid false started with fa"+r);D=M;continue;case M:if(!r)continue;if("s"!==r)return W("Invalid false started with fal"+r);D=I;continue;case I:if(!r)continue;if("e"!==r)return W("Invalid false started with fals"+r);a(!1),u(),D=F.pop()||p;continue;case T:if(!r)continue;if("u"!==r)return W("Invalid null started with n"+r);D=U;continue;case U:if(!r)continue;if("l"!==r)return W("Invalid null started with nu"+r);D=j;continue;case j:if(!r)continue;if("l"!==r)return W("Invalid null started with nul"+r);a(null),u(),D=F.pop()||p;continue;case B:if("."!==r)return W("Leading zero not followed by .");R+=r,D=P;continue;case P:if(-1!=="0123456789".indexOf(r))R+=r;else if("."===r){if(-1!==R.indexOf("."))return W("Invalid number has two dots");R+=r}else if("e"===r||"E"===r){if(-1!==R.indexOf("e")||-1!==R.indexOf("E"))return W("Invalid number has two exponential");R+=r}else if("+"===r||"-"===r){if("e"!==n&&"E"!==n)return W("Invalid symbol in number");R+=r}else R&&(a(parseFloat(R)),u(),R=""),o--,D=F.pop()||p;continue;default:return W("Unknown state: "+D)}K>=C&&(X=0,N!==s&&N.length>f&&(W("Max buffer length exceeded: textNode"),X=Math.max(X,N.length)),R.length>f&&(W("Max buffer length exceeded: numberNode"),X=Math.max(X,R.length)),C=f-X+K);var X}),e(ce).on(function(){if(D==d)return a({}),u(),void(O=!0);D===p&&0===z||W("Unexpected end");N!==s&&(a(N),u(),N=s);O=!0})}var C,N,R,L,O,D,F,q,H,z,K,V=(C=d(function(e){return e.unshift(/^/),(t=RegExp(e.map(f("source")).join(""))).exec.bind(t);var t}),L=C(N=/(\$?)/,/([\w-_]+|\*)/,R=/(?:{([\w ]*?)})?/),O=C(N,/\["([^"]+)"\]/,R),D=C(N,/\[(\d+|\*)\]/,R),F=C(N,/()/,/{([\w ]*?)}/),q=C(/\.\./),H=C(/\./),z=C(N,/!/),K=C(/$/),function(e){return e(h(L,O,D,F),q,H,z,K)});function G(e,t){return{key:e,node:t}}var W=f("key"),Y=f("node"),X={};function Z(e){var t=e(ee).emit,r=e(te).emit,n=e(ae).emit,o=e(oe).emit;function a(e,t,r){Y(x(e))[t]=r}function s(e,r,n){e&&a(e,r,n);var i=A(G(r,n),e);return t(i),i}var u={};return u[le]=function(e,t){if(!e)return n(t),s(e,X,t);var r=function(e,t){var r=Y(x(e));return m(i,r)?s(e,v(r),t):e}(e,t),o=k(r),u=W(x(r));return a(o,u,t),A(G(u,t),o)},u[de]=function(e){return r(e),k(e)||o(Y(x(e)))},u[he]=s,u}var J=V(function(e,t,r,n,i){var a=1,s=2,f=3,l=c(W,x),d=c(Y,x);function b(e,t){return!!t[a]?p(e,x):e}function m(e){if(e==y)return y;return p(function(e){return l(e)!=X},c(e,k))}function g(){return function(e){return l(e)==X}}function w(e,t,r,n,i){var o=e(r);if(o){var a=function(e,t,r){return U(function(e,t){return t(e,r)},t,e)}(t,n,o);return i(r.substr(v(o[0])),a)}}function A(e,t){return u(w,e,t)}var E=h(A(e,M(b,function(e,t){var r=t[f];return r?p(c(u(_,S(r.split(/\W+/))),d),e):e},function(e,t){var r=t[s];return p(r&&"*"!=r?function(e){return l(e)==r}:y,e)},m)),A(t,M(function(e){if(e==y)return y;var t=g(),r=e,n=m(function(e){return i(e)}),i=h(t,r,n);return i})),A(r,M()),A(n,M(b,g)),A(i,M(function(e){return function(t){var r=e(t);return!0===r?x(t):r}})),function(e){throw o('"'+e+'" could not be tokenised')});function I(e,t){return t}function T(e,t){return E(e,t,e?T:I)}return function(e){try{return T(e,y)}catch(t){throw o('Could not compile "'+e+'" because '+t.message)}}});function $(e,t,r){var n,i;function o(e){return function(t){return t.id==e}}return{on:function(r,o){var a={listener:r,id:o||r};return t&&t.emit(e,r,a.id),n=A(a,n),i=A(r,i),this},emit:function(){!function e(t,r){t&&(x(t).apply(null,r),e(k(t),r))}(i,arguments)},un:function(t){var a;n=j(n,o(t),function(e){a=e}),a&&(i=j(i,function(e){return e==a.listener}),r&&r.emit(e,a.listener,a.id))},listeners:function(){return i},hasListener:function(e){return w(function e(t,r){return r&&(t(x(r))?x(r):e(t,k(r)))}(e?o(e):y,n))}}}var Q=1,ee=Q++,te=Q++,re=Q++,ne=Q++,ie="fail",oe=Q++,ae=Q++,se="start",ue="data",ce="end",fe=Q++,he=Q++,le=Q++,de=Q++;function pe(e,t,r){try{var n=a.parse(t)}catch(e){}return{statusCode:e,body:t,jsonBody:n,thrown:r}}function be(e,t){var r={node:e(te),path:e(ee)};function n(t,r,n){var i=e(t).emit;r.on(function(e){var t=n(e);!1!==t&&function(e,t,r){var n=B(r);e(t,I(k(T(W,n))),I(T(Y,n)))}(i,Y(t),e)},t),e("removeListener").on(function(n){n==t&&(e(n).listeners()||r.un(t))})}e("newListener").on(function(e){var i=/(node|path):(.*)/.exec(e);if(i){var o=r[i[1]];o.hasListener(e)||n(e,o,t(i[2]))}})}function ye(e,t){var r,n=/^(node|path):./,i=e(oe),o=e(ne).emit,a=e(re).emit,s=d(function(t,i){if(r[t])l(i,r[t]);else{var o=e(t),a=i[0];n.test(t)?c(o,a):o.on(a)}return r});function c(e,t,n){n=n||t;var i=f(t);return e.on(function(){var t=!1;r.forget=function(){t=!0},l(arguments,i),delete r.forget,t&&e.un(n)},n),r}function f(e){return function(){try{return e.apply(r,arguments)}catch(e){setTimeout(function(){throw e})}}}function h(t,r,n){var i;i="node"==t?function(e){return function(){var t=e.apply(this,arguments);w(t)&&(t==ge.drop?o():a(t))}}(n):n,c(function(t,r){return e(t+":"+r)}(t,r),i,n)}function p(e,t,n){return g(t)?h(e,t,n):function(e,t){for(var r in t)h(e,r,t[r])}(e,t),r}return e(ae).on(function(e){var t;r.root=(t=e,function(){return t})}),e(se).on(function(e,t){r.header=function(e){return e?t[e]:t}}),r={on:s,addListener:s,removeListener:function(t,n,o){if("done"==t)i.un(n);else if("node"==t||"path"==t)e.un(t+":"+n,o);else{var a=n;e(t).un(a)}return r},emit:e.emit,node:u(p,"node"),path:u(p,"path"),done:u(c,i),start:u(function(t,n){return e(t).on(f(n),n),r},se),fail:e(ie).on,abort:e(fe).emit,header:b,root:b,source:t}}function me(t,r,n,i,o){var a=function(){var e={},t=n("newListener"),r=n("removeListener");function n(n){return e[n]=$(n,t,r)}function i(t){return e[t]||n(t)}return["emit","on","un"].forEach(function(e){i[e]=d(function(t,r){l(r,i(t)[e])})}),i}();return r&&function(t,r,n,i,o,a,c){"use strict";var f=t(ue).emit,h=t(ie).emit,l=0,d=!0;function p(){var e=r.responseText,t=e.substr(l);t&&f(t),l=v(e)}t(fe).on(function(){r.onreadystatechange=null,r.abort()}),"onprogress"in r&&(r.onprogress=p),r.onreadystatechange=function(){function e(){try{d&&t(se).emit(r.status,(e=r.getAllResponseHeaders(),n={},e&&e.split("\r\n").forEach(function(e){var t=e.indexOf(": ");n[e.substring(0,t)]=e.substring(t+2)}),n)),d=!1}catch(e){}var e,n}switch(r.readyState){case 2:case 3:return e();case 4:e(),2==String(r.status)[0]?(p(),t(ce).emit()):h(pe(r.status,r.responseText))}};try{for(var b in r.open(n,i,!0),a)r.setRequestHeader(b,a[b]);(function(e,t){function r(t){return t.port||{"http:":80,"https:":443}[t.protocol||e.protocol]}return!!(t.protocol&&t.protocol!=e.protocol||t.host&&t.host!=e.host||t.host&&r(t)!=r(e))})(e.location,function(e){var t=/(\w+:)?(?:\/\/)([\w.-]+)?(?::(\d+))?\/?/.exec(e)||[];return{protocol:t[1]||"",host:t[2]||"",port:t[3]||""}}(i))||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.withCredentials=c,r.send(o)}catch(t){e.setTimeout(u(h,pe(s,s,t)),0)}}(a,new XMLHttpRequest,t,r,n,i,o),P(a),function(e,t){"use strict";var r,n={};function i(e){return function(t){r=e(r,t)}}for(var o in t)e(o).on(i(t[o]),n);e(re).on(function(e){var t=x(r),n=W(t),i=k(r);i&&(Y(x(i))[n]=e)}),e(ne).on(function(){var e=x(r),t=W(e),n=k(r);n&&delete Y(x(n))[t]}),e(fe).on(function(){for(var r in t)e(r).un(n)})}(a,Z(a)),be(a,J),ye(a,r)}function ve(e,t,r,n,i,o,s){return i=i?a.parse(a.stringify(i)):{},n?g(n)||(n=a.stringify(n),i["Content-Type"]=i["Content-Type"]||"application/json"):n=null,e(r||"GET",function(e,t){return!1===t&&(-1==e.indexOf("?")?e+="?":e+="&",e+="_="+(new Date).getTime()),e}(t,s),n,i,o||!1)}function ge(e){var t=M("resume","pause","pipe"),r=u(_,t);return e?r(e)||g(e)?ve(me,e):ve(me,e.url,e.method,e.body,e.headers,e.withCredentials,e.cached):me()}ge.drop=function(){return ge.drop},"function"==typeof define&&define.amd?define("oboe",[],function(){return ge}):"object"==typeof r?t.exports=ge:e.oboe=ge}(function(){try{return window}catch(e){return self}}(),Object,Array,Error,JSON)},{}],240:[function(e,t,r){r.endianness=function(){return"LE"},r.hostname=function(){return"undefined"!=typeof location?location.hostname:""},r.loadavg=function(){return[]},r.uptime=function(){return 0},r.freemem=function(){return Number.MAX_VALUE},r.totalmem=function(){return Number.MAX_VALUE},r.cpus=function(){return[]},r.type=function(){return"Browser"},r.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},r.networkInterfaces=r.getNetworkInterfaces=function(){return{}},r.arch=function(){return"javascript"},r.platform=function(){return"browser"},r.tmpdir=r.tmpDir=function(){return"/tmp"},r.EOL="\n",r.homedir=function(){return"/"}},{}],241:[function(e,t,r){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],242:[function(e,t,r){"use strict";var n=e("asn1.js");r.certificate=e("./certificate");var i=n.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});r.RSAPrivateKey=i;var o=n.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});r.RSAPublicKey=o;var a=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())});r.PublicKey=a;var s=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),u=n.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(s),this.key("subjectPrivateKey").octstr())});r.PrivateKey=u;var c=n.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});r.EncryptedPrivateKey=c;var f=n.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});r.DSAPrivateKey=f,r.DSAparam=n.define("DSAparam",function(){this.int()});var h=n.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(l),this.key("publicKey").optional().explicit(1).bitstr())});r.ECPrivateKey=h;var l=n.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});r.signature=n.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},{"./certificate":243,"asn1.js":5}],243:[function(e,t,r){"use strict";var n=e("asn1.js"),i=n.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),o=n.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),a=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional())}),s=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())}),u=n.define("RelativeDistinguishedName",function(){this.setof(o)}),c=n.define("RDNSequence",function(){this.seqof(u)}),f=n.define("Name",function(){this.choice({rdnSequence:this.use(c)})}),h=n.define("Validity",function(){this.seq().obj(this.key("notBefore").use(i),this.key("notAfter").use(i))}),l=n.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),d=n.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int(),this.key("serialNumber").int(),this.key("signature").use(a),this.key("issuer").use(f),this.key("validity").use(h),this.key("subject").use(f),this.key("subjectPublicKeyInfo").use(s),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(l).optional())}),p=n.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(a),this.key("signatureValue").bitstr())});t.exports=p},{"asn1.js":5}],244:[function(e,t,r){(function(r){var n=/Proc-Type: 4,ENCRYPTED\n\r?DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\n\r?\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?/m,i=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n/m,o=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?-----END \1-----$/m,a=e("evp_bytestokey"),s=e("browserify-aes");t.exports=function(e,t){var u,c=e.toString(),f=c.match(n);if(f){var h="aes"+f[1],l=new r(f[2],"hex"),d=new r(f[3].replace(/\r?\n/g,""),"base64"),p=a(t,l.slice(0,8),parseInt(f[1],10)).key,b=[],y=s.createDecipheriv(h,p,l);b.push(y.update(d)),b.push(y.final()),u=r.concat(b)}else{var m=c.match(o);u=new r(m[2].replace(/\r?\n/g,""),"base64")}return{tag:c.match(i)[1],data:u}}}).call(this,e("buffer").Buffer)},{"browserify-aes":58,buffer:84,evp_bytestokey:158}],245:[function(e,t,r){(function(r){var n=e("./asn1"),i=e("./aesid.json"),o=e("./fixProc"),a=e("browserify-aes"),s=e("pbkdf2");function u(e){var t;"object"!=typeof e||r.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=new r(e));var u,c,f=o(e,t),h=f.tag,l=f.data;switch(h){case"CERTIFICATE":c=n.certificate.decode(l,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(c||(c=n.PublicKey.decode(l,"der")),u=c.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPublicKey.decode(c.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return c.subjectPrivateKey=c.subjectPublicKey,{type:"ec",data:c};case"1.2.840.10040.4.1":return c.algorithm.params.pub_key=n.DSAparam.decode(c.subjectPublicKey.data,"der"),{type:"dsa",data:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"ENCRYPTED PRIVATE KEY":l=function(e,t){var n=e.algorithm.decrypt.kde.kdeparams.salt,o=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),u=i[e.algorithm.decrypt.cipher.algo.join(".")],c=e.algorithm.decrypt.cipher.iv,f=e.subjectPrivateKey,h=parseInt(u.split("-")[1],10)/8,l=s.pbkdf2Sync(t,n,o,h),d=a.createDecipheriv(u,l,c),p=[];return p.push(d.update(f)),p.push(d.final()),r.concat(p)}(l=n.EncryptedPrivateKey.decode(l,"der"),t);case"PRIVATE KEY":switch(u=(c=n.PrivateKey.decode(l,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPrivateKey.decode(c.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:c.algorithm.curve,privateKey:n.ECPrivateKey.decode(c.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return c.algorithm.params.priv_key=n.DSAparam.decode(c.subjectPrivateKey,"der"),{type:"dsa",params:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"RSA PUBLIC KEY":return n.RSAPublicKey.decode(l,"der");case"RSA PRIVATE KEY":return n.RSAPrivateKey.decode(l,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:n.DSAPrivateKey.decode(l,"der")};case"EC PRIVATE KEY":return{curve:(l=n.ECPrivateKey.decode(l,"der")).parameters.value,privateKey:l.privateKey};default:throw new Error("unknown key type "+h)}}t.exports=u,u.signature=n.signature}).call(this,e("buffer").Buffer)},{"./aesid.json":241,"./asn1":242,"./fixProc":244,"browserify-aes":58,buffer:84,pbkdf2:247}],246:[function(e,t,r){var n=e("trim"),i=e("for-each");t.exports=function(e){if(!e)return{};var t={};return i(n(e).split("\n"),function(e){var r,i=e.indexOf(":"),o=n(e.slice(0,i)).toLowerCase(),a=n(e.slice(i+1));void 0===t[o]?t[o]=a:(r=t[o],"[object Array]"===Object.prototype.toString.call(r)?t[o].push(a):t[o]=[t[o],a])}),t}},{"for-each":159,trim:324}],247:[function(e,t,r){r.pbkdf2=e("./lib/async"),r.pbkdf2Sync=e("./lib/sync")},{"./lib/async":248,"./lib/sync":251}],248:[function(e,t,r){(function(r,n){var i,o=e("./precondition"),a=e("./default-encoding"),s=e("./sync"),u=e("safe-buffer").Buffer,c=n.crypto&&n.crypto.subtle,f={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},h=[];function l(e,t,r,n,i){return c.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then(function(e){return c.deriveBits({name:"PBKDF2",salt:t,iterations:r,hash:{name:i}},e,n<<3)}).then(function(e){return u.from(e)})}t.exports=function(e,t,d,p,b,y){if(u.isBuffer(e)||(e=u.from(e,a)),u.isBuffer(t)||(t=u.from(t,a)),o(d,p),"function"==typeof b&&(y=b,b=void 0),"function"!=typeof y)throw new Error("No callback provided to pbkdf2");var m=f[(b=b||"sha1").toLowerCase()];if(!m||"function"!=typeof n.Promise)return r.nextTick(function(){var r;try{r=s(e,t,d,p,b)}catch(e){return y(e)}y(null,r)});!function(e,t){e.then(function(e){r.nextTick(function(){t(null,e)})},function(e){r.nextTick(function(){t(e)})})}(function(e){if(n.process&&!n.process.browser)return Promise.resolve(!1);if(!c||!c.importKey||!c.deriveBits)return Promise.resolve(!1);if(void 0!==h[e])return h[e];var t=l(i=i||u.alloc(8),i,10,128,e).then(function(){return!0}).catch(function(){return!1});return h[e]=t,t}(m).then(function(r){return r?l(e,t,d,p,m):s(e,t,d,p,b)}),y)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-encoding":249,"./precondition":250,"./sync":251,_process:257,"safe-buffer":290}],249:[function(e,t,r){(function(e){var r;e.browser?r="utf-8":r=parseInt(e.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary";t.exports=r}).call(this,e("_process"))},{_process:257}],250:[function(e,t,r){var n=Math.pow(2,30)-1;t.exports=function(e,t){if("number"!=typeof e)throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if("number"!=typeof t)throw new TypeError("Key length not a number");if(t<0||t>n||t!=t)throw new TypeError("Bad key length")}},{}],251:[function(e,t,r){var n=e("create-hash/md5"),i=e("ripemd160"),o=e("sha.js"),a=e("./precondition"),s=e("./default-encoding"),u=e("safe-buffer").Buffer,c=u.alloc(128),f={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function h(e,t,r){var a=function(e){return"rmd160"===e||"ripemd160"===e?i:"md5"===e?n:function(t){return o(e).update(t).digest()}}(e),s="sha512"===e||"sha384"===e?128:64;t.length>s?t=a(t):t.length1)for(var r=1;rp||new a(t).cmp(d.modulus)>=0)throw new Error("decryption error");l=f?c(new a(t),d):s(t,d);var b=new r(p-l.length);if(b.fill(0),l=r.concat([b,l],p),4===h)return function(e,t){e.modulus;var n=e.modulus.byteLength(),a=(t.length,u("sha1").update(new r("")).digest()),s=a.length;if(0!==t[0])throw new Error("decryption error");var c=t.slice(1,s+1),f=t.slice(s+1),h=o(c,i(f,s)),l=o(f,i(h,n-s-1));if(function(e,t){e=new r(e),t=new r(t);var n=0,i=e.length;e.length!==t.length&&(n++,i=Math.min(e.length,t.length));var o=-1;for(;++o=t.length){o++;break}var a=t.slice(2,i-1);t.slice(i-1,i);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;a.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,l,f);if(3===h)return l;throw new Error("unknown padding")}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245}],262:[function(e,t,r){(function(r){var n=e("parse-asn1"),i=e("randombytes"),o=e("create-hash"),a=e("./mgf"),s=e("./xor"),u=e("bn.js"),c=e("./withPublic"),f=e("browserify-rsa");t.exports=function(e,t,h){var l;l=e.padding?e.padding:h?1:4;var d,p=n(e);if(4===l)d=function(e,t){var n=e.modulus.byteLength(),c=t.length,f=o("sha1").update(new r("")).digest(),h=f.length,l=2*h;if(c>n-l-2)throw new Error("message too long");var d=new r(n-c-l-2);d.fill(0);var p=n-h-1,b=i(h),y=s(r.concat([f,d,new r([1]),t],p),a(b,p)),m=s(b,a(y,h));return new u(r.concat([new r([0]),m,y],n))}(p,t);else if(1===l)d=function(e,t,n){var o,a=t.length,s=e.modulus.byteLength();if(a>s-11)throw new Error("message too long");n?(o=new r(s-a-3)).fill(255):o=function(e,t){var n,o=new r(e),a=0,s=i(2*e),u=0;for(;a=0)throw new Error("data too long for modulus")}return h?f(d,p):c(d,p)}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245,randombytes:270}],263:[function(e,t,r){(function(r){var n=e("bn.js");t.exports=function(e,t){return new r(e.toRed(n.mont(t.modulus)).redPow(new n(t.publicExponent)).fromRed().toArray())}}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84}],264:[function(e,t,r){t.exports=function(e,t){for(var r=e.length,n=-1;++n= 0x80 (not a basic code point)","invalid-input":"Invalid input"},A=f-h,E=Math.floor,x=String.fromCharCode;function k(e){throw new RangeError(_[e])}function S(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function M(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+S((e=e.replace(w,".")).split("."),t).join(".")}function I(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=x((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=x(e)}).join("")}function U(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function j(e,t,r){var n=0;for(e=r?E(e/p):e>>1,e+=E(e/t);e>A*l>>1;n+=f)e=E(e/A);return E(n+(A+1)*e/(e+d))}function B(e){var t,r,n,i,o,a,s,u,d,p,v,g=[],w=e.length,_=0,A=y,x=b;for((r=e.lastIndexOf(m))<0&&(r=0),n=0;n=128&&k("not-basic"),g.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=w&&k("invalid-input"),((u=(v=e.charCodeAt(i++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:f)>=f||u>E((c-_)/a))&&k("overflow"),_+=u*a,!(u<(d=s<=x?h:s>=x+l?l:s-x));s+=f)a>E(c/(p=f-d))&&k("overflow"),a*=p;x=j(_-o,t=g.length+1,0==o),E(_/t)>c-A&&k("overflow"),A+=E(_/t),_%=t,g.splice(_++,0,A)}return T(g)}function P(e){var t,r,n,i,o,a,s,u,d,p,v,g,w,_,A,S=[];for(g=(e=I(e)).length,t=y,r=0,o=b,a=0;a=t&&vE((c-r)/(w=n+1))&&k("overflow"),r+=(s-t)*w,t=s,a=0;ac&&k("overflow"),v==t){for(u=r,d=f;!(u<(p=d<=o?h:d>=o+l?l:d-o));d+=f)A=u-p,_=f-p,S.push(x(U(p+A%_,0))),u=E(A/_);S.push(x(U(u,0))),o=j(r,w,n==i),r=0,++n}++r,++t}return S.join("")}if(s={version:"1.4.1",ucs2:{decode:I,encode:T},decode:B,encode:P,toASCII:function(e){return M(e,function(e){return g.test(e)?"xn--"+P(e):e})},toUnicode:function(e){return M(e,function(e){return v.test(e)?B(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return s});else if(i&&o)if(t.exports==i)o.exports=s;else for(u in s)s.hasOwnProperty(u)&&(i[u]=s[u]);else n.punycode=s}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],266:[function(e,t,r){"use strict";var n=e("strict-uri-encode"),i=e("object-assign"),o=e("decode-uri-component");function a(e,t){return t.encode?t.strict?n(e):encodeURIComponent(e):e}function s(e){var t=e.indexOf("?");return-1===t?"":e.slice(t+1)}function u(e,t){var r=function(e){var t;switch(e.arrayFormat){case"index":return function(e,r,n){t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return function(e,r,n){t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};default:return function(e,t,r){void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t=i({arrayFormat:"none"},t)),n=Object.create(null);return"string"!=typeof e?n:(e=e.trim().replace(/^[?#&]/,""))?(e.split("&").forEach(function(e){var t=e.replace(/\+/g," ").split("="),i=t.shift(),a=t.length>0?t.join("="):void 0;a=void 0===a?null:o(a),r(o(i),a,n)}),Object.keys(n).sort().reduce(function(e,t){var r=n[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=function e(t){return Array.isArray(t)?t.sort():"object"==typeof t?e(Object.keys(t)).sort(function(e,t){return Number(e)-Number(t)}).map(function(e){return t[e]}):t}(r):e[t]=r,e},Object.create(null))):n}r.extract=s,r.parse=u,r.stringify=function(e,t){!1===(t=i({encode:!0,strict:!0,arrayFormat:"none"},t)).sort&&(t.sort=function(){});var r=function(e){switch(e.arrayFormat){case"index":return function(t,r,n){return null===r?[a(t,e),"[",n,"]"].join(""):[a(t,e),"[",a(n,e),"]=",a(r,e)].join("")};case"bracket":return function(t,r){return null===r?a(t,e):[a(t,e),"[]=",a(r,e)].join("")};default:return function(t,r){return null===r?a(t,e):[a(t,e),"=",a(r,e)].join("")}}}(t);return e?Object.keys(e).sort(t.sort).map(function(n){var i=e[n];if(void 0===i)return"";if(null===i)return a(n,t);if(Array.isArray(i)){var o=[];return i.slice().forEach(function(e){void 0!==e&&o.push(r(n,e,o.length))}),o.join("&")}return a(n,t)+"="+a(i,t)}).filter(function(e){return e.length>0}).join("&"):""},r.parseUrl=function(e,t){return{url:e.split("?")[0]||"",query:u(s(e),t)}}},{"decode-uri-component":98,"object-assign":238,"strict-uri-encode":316}],267:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&",r=r||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(a,d)?i(a[d])?a[d].push(p):a[d]=[a[d],p]:a[d]=p}return a};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],268:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,s){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),function(a){var s=encodeURIComponent(n(a))+r;return i(e[a])?o(e[a],function(e){return s+encodeURIComponent(n(e))}).join(t):s+encodeURIComponent(n(e[a]))}).join(t):s?encodeURIComponent(n(s))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n65536)throw new Error("requested too many random bytes");var a=new n.Uint8Array(e);e>0&&o.getRandomValues(a);var s=i.from(a.buffer);if("function"==typeof t)return r.nextTick(function(){t(null,s)});return s}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,"safe-buffer":290}],271:[function(e,t,r){(function(t,n){"use strict";function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=e("safe-buffer"),a=e("randombytes"),s=o.Buffer,u=o.kMaxLength,c=n.crypto||n.msCrypto,f=Math.pow(2,32)-1;function h(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>f||e<0)throw new TypeError("offset must be a uint32");if(e>u||e>t)throw new RangeError("offset out of range")}function l(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>f||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>u)throw new RangeError("buffer too small")}function d(e,r,n,i){if(t.browser){var o=e.buffer,s=new Uint8Array(o,r,n);return c.getRandomValues(s),i?void t.nextTick(function(){i(null,e)}):e}if(!i)return a(n).copy(e,r),e;a(n,function(t,n){if(t)return i(t);n.copy(e,r),i(null,e)})}c&&c.getRandomValues||!t.browser?(r.randomFill=function(e,t,r,i){if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)i=t,t=0,r=e.length;else if("function"==typeof r)i=r,r=e.length-t;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return h(t,e.length),l(r,t,e.length),d(e,t,r,i)},r.randomFillSync=function(e,t,r){void 0===t&&(t=0);if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');h(t,e.length),void 0===r&&(r=e.length-t);return l(r,t,e.length),d(e,t,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,randombytes:270,"safe-buffer":290}],272:[function(e,t,r){t.exports=window.crypto},{}],273:[function(e,t,r){t.exports=e("crypto")},{crypto:272}],274:[function(e,t,r){t.exports=function(t,r){var n=e("./crypto.js"),i="function"==typeof r;if(t>65536){if(!i)throw new Error("Requested too many random bytes.");r(new Error("Requested too many random bytes."))}if(void 0!==n&&n.randomBytes){if(!i)return"0x"+n.randomBytes(t).toString("hex");n.randomBytes(t,function(e,t){e?r(u):r(null,"0x"+t.toString("hex"))})}else{var o;if(void 0!==n?o=n:"undefined"!=typeof msCrypto&&(o=msCrypto),o&&o.getRandomValues){var a=o.getRandomValues(new Uint8Array(t)),s="0x"+Array.from(a).map(function(e){return e.toString(16)}).join("");if(!i)return s;r(null,s)}else{var u=new Error('No "crypto" object available. This Browser doesn\'t support generating secure random bytes.');if(!i)throw u;r(u)}}}},{"./crypto.js":273}],275:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":276}],276:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick,i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=h;var o=e("core-util-is");o.inherits=e("inherits");var a=e("./_stream_readable"),s=e("./_stream_writable");o.inherits(h,a);for(var u=i(s.prototype),c=0;c0?("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),n?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):_(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?_(e,a,t,!1):S(e,a)):_(e,a,t,!1))):n||(a.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=A?e=A:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(d("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i(k,e):k(e))}function k(e){d("emit readable"),e.emit("readable"),U(e)}function S(e,t){t.readingMore||(t.readingMore=!0,i(M,e,t))}function M(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=c.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,a),0===(e-=a)){a===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function B(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i(P,t,e))}function P(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function C(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return d("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?B(this):x(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&B(this),null;var n,i=t.needReadable;return d("need readable",i),(0===t.length||t.length-e0?j(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&B(this)),null!==n&&this.emit("data",n),n},g.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},g.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,d("pipe count=%d opts=%j",o.pipesCount,t);var u=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?f:g;function c(t,r){d("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,d("cleanup"),e.removeListener("close",m),e.removeListener("finish",v),e.removeListener("drain",h),e.removeListener("error",y),e.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",g),n.removeListener("data",b),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||h())}function f(){d("onend"),e.end()}o.endEmitted?i(u):n.once("end",u),e.on("unpipe",c);var h=function(e){return function(){var t=e._readableState;d("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,U(e))}}(n);e.on("drain",h);var l=!1;var p=!1;function b(t){d("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==C(o.pipes,e))&&!l&&(d("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(t){d("onerror",t),g(),e.removeListener("error",y),0===s(e,"error")&&e.emit("error",t)}function m(){e.removeListener("finish",v),g()}function v(){d("onfinish"),e.removeListener("close",m),g()}function g(){d("unpipe"),n.unpipe(e)}return n.on("data",b),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?a(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",y),e.once("close",m),e.once("finish",v),e.emit("pipe",n),o.flowing||(d("pipe resume"),n.resume()),e},g.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:i;m.WritableState=y;var u=e("core-util-is");u.inherits=e("inherits");var c={deprecate:e("util-deprecate")},f=e("./internal/streams/stream"),h=e("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=e("./internal/streams/destroy");function b(){}function y(t,r){a=a||e("./_stream_duplex"),t=t||{};var n=r instanceof a;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var u=t.highWaterMark,c=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=u||0===u?u:n&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===t.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,o=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,o){--t.pendingcb,r?(i(o,n),i(E,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(o(n),e._writableState.errorEmitted=!0,e.emit("error",n),E(e,t))}(e,r,n,t,o);else{var a=_(r);a||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),n?s(g,e,r,a,o):g(e,r,a,o)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function m(t){if(a=a||e("./_stream_duplex"),!(d.call(m,this)||this instanceof a))return new m(t);this._writableState=new y(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),f.call(this)}function v(e,t,r,n,i,o,a){t.writelen=n,t.writecb=a,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function g(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),E(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),a=t.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,v(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,h=r.callback;if(v(e,t,!1,t.objectMode?1:c.length,c,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function A(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),E(e,t)})}function E(e,t){var r=_(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,i(A,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}u.inherits(m,f),y.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(y.prototype,"buffer",{get:c.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===m&&(e&&e._writableState instanceof y)}})):d=function(e){return e instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(e,t,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=e,h.isBuffer(n)||n instanceof l);return s&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof r&&(r=b),o.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),i(t,r)}(this,r):(s||function(e,t,r,n){var o=!0,a=!1;return null===r?a=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),i(n,a),o=!1),o}(this,o,e,r))&&(o.pendingcb++,a=function(e,t,r,n,i,o){if(!r){var a=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,r));return t}(t,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=t.objectMode?1:n.length;t.length+=s;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},m.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,E(e,t),r&&(t.finished?i(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),m.prototype.destroy=p.destroy,m.prototype._undestroy=p.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":276,"./internal/streams/destroy":282,"./internal/streams/stream":283,_process:257,"core-util-is":89,inherits:180,"process-nextick-args":256,"safe-buffer":290,"util-deprecate":330}],281:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,i,o=n.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,r=o,i=s,t.copy(r,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":290,util:55}],282:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick;function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var r=this,o=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return o||a?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||n(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n(i,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":256}],283:[function(e,t,r){t.exports=e("events").EventEmitter},{events:157}],284:[function(e,t,r){t.exports=e("./readable").PassThrough},{"./readable":285}],285:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":276,"./lib/_stream_passthrough.js":277,"./lib/_stream_readable.js":278,"./lib/_stream_transform.js":279,"./lib/_stream_writable.js":280}],286:[function(e,t,r){t.exports=e("./readable").Transform},{"./readable":285}],287:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":280}],288:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base");function o(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function a(e,t){return e<>>32-t}function s(e,t,r,n,i,o,s,u){return a(e+(t^r^n)+o+s|0,u)+i|0}function u(e,t,r,n,i,o,s,u){return a(e+(t&r|~t&n)+o+s|0,u)+i|0}function c(e,t,r,n,i,o,s,u){return a(e+((t|~r)^n)+o+s|0,u)+i|0}function f(e,t,r,n,i,o,s,u){return a(e+(t&n|r&~n)+o+s|0,u)+i|0}function h(e,t,r,n,i,o,s,u){return a(e+(t^(r|~n))+o+s|0,u)+i|0}n(o,i),o.prototype._update=function(){for(var e=new Array(16),t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,o=this._d,l=this._e;l=s(l,r=s(r,n,i,o,l,e[0],0,11),n,i=a(i,10),o,e[1],0,14),n=s(n=a(n,10),i=s(i,o=s(o,l,r,n,i,e[2],0,15),l,r=a(r,10),n,e[3],0,12),o,l=a(l,10),r,e[4],0,5),o=s(o=a(o,10),l=s(l,r=s(r,n,i,o,l,e[5],0,8),n,i=a(i,10),o,e[6],0,7),r,n=a(n,10),i,e[7],0,9),r=s(r=a(r,10),n=s(n,i=s(i,o,l,r,n,e[8],0,11),o,l=a(l,10),r,e[9],0,13),i,o=a(o,10),l,e[10],0,14),i=s(i=a(i,10),o=s(o,l=s(l,r,n,i,o,e[11],0,15),r,n=a(n,10),i,e[12],0,6),l,r=a(r,10),n,e[13],0,7),l=u(l=a(l,10),r=s(r,n=s(n,i,o,l,r,e[14],0,9),i,o=a(o,10),l,e[15],0,8),n,i=a(i,10),o,e[7],1518500249,7),n=u(n=a(n,10),i=u(i,o=u(o,l,r,n,i,e[4],1518500249,6),l,r=a(r,10),n,e[13],1518500249,8),o,l=a(l,10),r,e[1],1518500249,13),o=u(o=a(o,10),l=u(l,r=u(r,n,i,o,l,e[10],1518500249,11),n,i=a(i,10),o,e[6],1518500249,9),r,n=a(n,10),i,e[15],1518500249,7),r=u(r=a(r,10),n=u(n,i=u(i,o,l,r,n,e[3],1518500249,15),o,l=a(l,10),r,e[12],1518500249,7),i,o=a(o,10),l,e[0],1518500249,12),i=u(i=a(i,10),o=u(o,l=u(l,r,n,i,o,e[9],1518500249,15),r,n=a(n,10),i,e[5],1518500249,9),l,r=a(r,10),n,e[2],1518500249,11),l=u(l=a(l,10),r=u(r,n=u(n,i,o,l,r,e[14],1518500249,7),i,o=a(o,10),l,e[11],1518500249,13),n,i=a(i,10),o,e[8],1518500249,12),n=c(n=a(n,10),i=c(i,o=c(o,l,r,n,i,e[3],1859775393,11),l,r=a(r,10),n,e[10],1859775393,13),o,l=a(l,10),r,e[14],1859775393,6),o=c(o=a(o,10),l=c(l,r=c(r,n,i,o,l,e[4],1859775393,7),n,i=a(i,10),o,e[9],1859775393,14),r,n=a(n,10),i,e[15],1859775393,9),r=c(r=a(r,10),n=c(n,i=c(i,o,l,r,n,e[8],1859775393,13),o,l=a(l,10),r,e[1],1859775393,15),i,o=a(o,10),l,e[2],1859775393,14),i=c(i=a(i,10),o=c(o,l=c(l,r,n,i,o,e[7],1859775393,8),r,n=a(n,10),i,e[0],1859775393,13),l,r=a(r,10),n,e[6],1859775393,6),l=c(l=a(l,10),r=c(r,n=c(n,i,o,l,r,e[13],1859775393,5),i,o=a(o,10),l,e[11],1859775393,12),n,i=a(i,10),o,e[5],1859775393,7),n=f(n=a(n,10),i=f(i,o=c(o,l,r,n,i,e[12],1859775393,5),l,r=a(r,10),n,e[1],2400959708,11),o,l=a(l,10),r,e[9],2400959708,12),o=f(o=a(o,10),l=f(l,r=f(r,n,i,o,l,e[11],2400959708,14),n,i=a(i,10),o,e[10],2400959708,15),r,n=a(n,10),i,e[0],2400959708,14),r=f(r=a(r,10),n=f(n,i=f(i,o,l,r,n,e[8],2400959708,15),o,l=a(l,10),r,e[12],2400959708,9),i,o=a(o,10),l,e[4],2400959708,8),i=f(i=a(i,10),o=f(o,l=f(l,r,n,i,o,e[13],2400959708,9),r,n=a(n,10),i,e[3],2400959708,14),l,r=a(r,10),n,e[7],2400959708,5),l=f(l=a(l,10),r=f(r,n=f(n,i,o,l,r,e[15],2400959708,6),i,o=a(o,10),l,e[14],2400959708,8),n,i=a(i,10),o,e[5],2400959708,6),n=h(n=a(n,10),i=f(i,o=f(o,l,r,n,i,e[6],2400959708,5),l,r=a(r,10),n,e[2],2400959708,12),o,l=a(l,10),r,e[4],2840853838,9),o=h(o=a(o,10),l=h(l,r=h(r,n,i,o,l,e[0],2840853838,15),n,i=a(i,10),o,e[5],2840853838,5),r,n=a(n,10),i,e[9],2840853838,11),r=h(r=a(r,10),n=h(n,i=h(i,o,l,r,n,e[7],2840853838,6),o,l=a(l,10),r,e[12],2840853838,8),i,o=a(o,10),l,e[2],2840853838,13),i=h(i=a(i,10),o=h(o,l=h(l,r,n,i,o,e[10],2840853838,12),r,n=a(n,10),i,e[14],2840853838,5),l,r=a(r,10),n,e[1],2840853838,12),l=h(l=a(l,10),r=h(r,n=h(n,i,o,l,r,e[3],2840853838,13),i,o=a(o,10),l,e[8],2840853838,14),n,i=a(i,10),o,e[11],2840853838,11),n=h(n=a(n,10),i=h(i,o=h(o,l,r,n,i,e[6],2840853838,8),l,r=a(r,10),n,e[15],2840853838,5),o,l=a(l,10),r,e[13],2840853838,6),o=a(o,10);var d=this._a,p=this._b,b=this._c,y=this._d,m=this._e;m=h(m,d=h(d,p,b,y,m,e[5],1352829926,8),p,b=a(b,10),y,e[14],1352829926,9),p=h(p=a(p,10),b=h(b,y=h(y,m,d,p,b,e[7],1352829926,9),m,d=a(d,10),p,e[0],1352829926,11),y,m=a(m,10),d,e[9],1352829926,13),y=h(y=a(y,10),m=h(m,d=h(d,p,b,y,m,e[2],1352829926,15),p,b=a(b,10),y,e[11],1352829926,15),d,p=a(p,10),b,e[4],1352829926,5),d=h(d=a(d,10),p=h(p,b=h(b,y,m,d,p,e[13],1352829926,7),y,m=a(m,10),d,e[6],1352829926,7),b,y=a(y,10),m,e[15],1352829926,8),b=h(b=a(b,10),y=h(y,m=h(m,d,p,b,y,e[8],1352829926,11),d,p=a(p,10),b,e[1],1352829926,14),m,d=a(d,10),p,e[10],1352829926,14),m=f(m=a(m,10),d=h(d,p=h(p,b,y,m,d,e[3],1352829926,12),b,y=a(y,10),m,e[12],1352829926,6),p,b=a(b,10),y,e[6],1548603684,9),p=f(p=a(p,10),b=f(b,y=f(y,m,d,p,b,e[11],1548603684,13),m,d=a(d,10),p,e[3],1548603684,15),y,m=a(m,10),d,e[7],1548603684,7),y=f(y=a(y,10),m=f(m,d=f(d,p,b,y,m,e[0],1548603684,12),p,b=a(b,10),y,e[13],1548603684,8),d,p=a(p,10),b,e[5],1548603684,9),d=f(d=a(d,10),p=f(p,b=f(b,y,m,d,p,e[10],1548603684,11),y,m=a(m,10),d,e[14],1548603684,7),b,y=a(y,10),m,e[15],1548603684,7),b=f(b=a(b,10),y=f(y,m=f(m,d,p,b,y,e[8],1548603684,12),d,p=a(p,10),b,e[12],1548603684,7),m,d=a(d,10),p,e[4],1548603684,6),m=f(m=a(m,10),d=f(d,p=f(p,b,y,m,d,e[9],1548603684,15),b,y=a(y,10),m,e[1],1548603684,13),p,b=a(b,10),y,e[2],1548603684,11),p=c(p=a(p,10),b=c(b,y=c(y,m,d,p,b,e[15],1836072691,9),m,d=a(d,10),p,e[5],1836072691,7),y,m=a(m,10),d,e[1],1836072691,15),y=c(y=a(y,10),m=c(m,d=c(d,p,b,y,m,e[3],1836072691,11),p,b=a(b,10),y,e[7],1836072691,8),d,p=a(p,10),b,e[14],1836072691,6),d=c(d=a(d,10),p=c(p,b=c(b,y,m,d,p,e[6],1836072691,6),y,m=a(m,10),d,e[9],1836072691,14),b,y=a(y,10),m,e[11],1836072691,12),b=c(b=a(b,10),y=c(y,m=c(m,d,p,b,y,e[8],1836072691,13),d,p=a(p,10),b,e[12],1836072691,5),m,d=a(d,10),p,e[2],1836072691,14),m=c(m=a(m,10),d=c(d,p=c(p,b,y,m,d,e[10],1836072691,13),b,y=a(y,10),m,e[0],1836072691,13),p,b=a(b,10),y,e[4],1836072691,7),p=u(p=a(p,10),b=u(b,y=c(y,m,d,p,b,e[13],1836072691,5),m,d=a(d,10),p,e[8],2053994217,15),y,m=a(m,10),d,e[6],2053994217,5),y=u(y=a(y,10),m=u(m,d=u(d,p,b,y,m,e[4],2053994217,8),p,b=a(b,10),y,e[1],2053994217,11),d,p=a(p,10),b,e[3],2053994217,14),d=u(d=a(d,10),p=u(p,b=u(b,y,m,d,p,e[11],2053994217,14),y,m=a(m,10),d,e[15],2053994217,6),b,y=a(y,10),m,e[0],2053994217,14),b=u(b=a(b,10),y=u(y,m=u(m,d,p,b,y,e[5],2053994217,6),d,p=a(p,10),b,e[12],2053994217,9),m,d=a(d,10),p,e[2],2053994217,12),m=u(m=a(m,10),d=u(d,p=u(p,b,y,m,d,e[13],2053994217,9),b,y=a(y,10),m,e[9],2053994217,12),p,b=a(b,10),y,e[7],2053994217,5),p=s(p=a(p,10),b=u(b,y=u(y,m,d,p,b,e[10],2053994217,15),m,d=a(d,10),p,e[14],2053994217,8),y,m=a(m,10),d,e[12],0,8),y=s(y=a(y,10),m=s(m,d=s(d,p,b,y,m,e[15],0,5),p,b=a(b,10),y,e[10],0,12),d,p=a(p,10),b,e[4],0,9),d=s(d=a(d,10),p=s(p,b=s(b,y,m,d,p,e[1],0,12),y,m=a(m,10),d,e[5],0,5),b,y=a(y,10),m,e[8],0,14),b=s(b=a(b,10),y=s(y,m=s(m,d,p,b,y,e[7],0,6),d,p=a(p,10),b,e[6],0,8),m,d=a(d,10),p,e[2],0,13),m=s(m=a(m,10),d=s(d,p=s(p,b,y,m,d,e[13],0,6),b,y=a(y,10),m,e[14],0,5),p,b=a(b,10),y,e[0],0,15),p=s(p=a(p,10),b=s(b,y=s(y,m,d,p,b,e[3],0,13),m,d=a(d,10),p,e[9],0,11),y,m=a(m,10),d,e[11],0,11),y=a(y,10);var v=this._b+i+y|0;this._b=this._c+o+m|0,this._c=this._d+l+d|0,this._d=this._e+r+p|0,this._e=this._a+n+b|0,this._a=v},o.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=o}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":161,inherits:180}],289:[function(e,t,r){const n=e("assert"),i=e("safe-buffer").Buffer;function o(e,t){if("00"===e.slice(0,2))throw new Error("invalid RLP: extra zeros");return parseInt(e,t)}function a(e,t){if(e<56)return i.from([e+t]);var r=u(e),n=u(t+55+r.length/2);return i.from(n+r,"hex")}function s(e){return"0x"===e.slice(0,2)}function u(e){var t=e.toString(16);return t.length%2&&(t="0"+t),t}function c(e){if(!i.isBuffer(e))if("string"==typeof e)e=s(e)?i.from(((r="string"!=typeof(n=e)?n:s(n)?n.slice(2):n).length%2&&(r="0"+r),r),"hex"):i.from(e);else if("number"==typeof e)e?(t=u(e),e=i.from(t,"hex")):e=i.from([]);else if(null==e)e=i.from([]);else{if(!e.toArray)throw new Error("invalid type");e=i.from(e.toArray())}var t,r,n;return e}r.encode=function(e){if(e instanceof Array){for(var t=[],n=0;nt.length)throw new Error("invalid rlp: total length is larger than the data");if(0===(s=t.slice(n,h)).length)throw new Error("invalid rlp, List has a invalid length");for(;s.length;)u=e(s),c.push(u.data),s=u.remainder;return{data:c,remainder:t.slice(h)}}(e=c(e));return t?r:(n.equal(r.remainder.length,0,"invalid remainder"),r.data)},r.getLength=function(e){if(!e||0===e.length)return i.from([]);var t=(e=c(e))[0];if(t<=127)return e.length;if(t<=183)return t-127;if(t<=191)return t-182;if(t<=247)return t-191;var r=t-246;return r+o(e.slice(1,r).toString("hex"),16)}},{assert:19,"safe-buffer":290}],290:[function(e,t,r){var n=e("buffer"),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function a(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,r),r.Buffer=a),o(i,a),a.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:84}],291:[function(e,t,r){const n=e("util"),i=e("events/");var o="object"==typeof Reflect?Reflect:null,a=o&&"function"==typeof o.apply?o.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};function s(){i.call(this)}function u(e,t,r){try{a(e,t,r)}catch(e){setTimeout(()=>{throw e})}}t.exports=s,n.inherits(s,i),s.prototype.emit=function(e){for(var t=[],r=1;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var s=i[e];if(void 0===s)return!1;if("function"==typeof s)u(s,this,t);else{var c=s.length,f=function(e,t){for(var r=new Array(t),n=0;n0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=function(){for(var e=[],t=0;t0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var c=u.length,f=p(u,c);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return l(this,e,!0)},s.prototype.rawListeners=function(e){return l(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},{}],293:[function(e,t,r){t.exports=e("scryptsy")},{scryptsy:294}],294:[function(e,t,r){(function(r){var n=e("pbkdf2").pbkdf2Sync,i=2147483647;function o(e,t,n,i,o){if(r.isBuffer(e)&&r.isBuffer(n))e.copy(n,i,t,t+o);else for(;o--;)n[i++]=e[t++]}t.exports=function(e,t,a,s,u,c,f){if(0===a||0!=(a&a-1))throw Error("N must be > 0 and a power of 2");if(a>i/128/s)throw Error("Parameter N is too large");if(s>i/128/u)throw Error("Parameter r is too large");var h,l=new r(256*s),d=new r(128*s*a),p=new Int32Array(16),b=new Int32Array(16),y=new r(64),m=n(e,t,1,128*u*s,"sha256");if(f){var v=u*a*2,g=0;h=function(){++g%1e3==0&&f({current:g,total:v,percent:g/v*100})}}for(var w=0;w>>32-t}function x(e){var t;for(t=0;t<16;t++)p[t]=(255&e[4*t+0])<<0,p[t]|=(255&e[4*t+1])<<8,p[t]|=(255&e[4*t+2])<<16,p[t]|=(255&e[4*t+3])<<24;for(o(p,0,b,0,16),t=8;t>0;t-=2)b[4]^=E(b[0]+b[12],7),b[8]^=E(b[4]+b[0],9),b[12]^=E(b[8]+b[4],13),b[0]^=E(b[12]+b[8],18),b[9]^=E(b[5]+b[1],7),b[13]^=E(b[9]+b[5],9),b[1]^=E(b[13]+b[9],13),b[5]^=E(b[1]+b[13],18),b[14]^=E(b[10]+b[6],7),b[2]^=E(b[14]+b[10],9),b[6]^=E(b[2]+b[14],13),b[10]^=E(b[6]+b[2],18),b[3]^=E(b[15]+b[11],7),b[7]^=E(b[3]+b[15],9),b[11]^=E(b[7]+b[3],13),b[15]^=E(b[11]+b[7],18),b[1]^=E(b[0]+b[3],7),b[2]^=E(b[1]+b[0],9),b[3]^=E(b[2]+b[1],13),b[0]^=E(b[3]+b[2],18),b[6]^=E(b[5]+b[4],7),b[7]^=E(b[6]+b[5],9),b[4]^=E(b[7]+b[6],13),b[5]^=E(b[4]+b[7],18),b[11]^=E(b[10]+b[9],7),b[8]^=E(b[11]+b[10],9),b[9]^=E(b[8]+b[11],13),b[10]^=E(b[9]+b[8],18),b[12]^=E(b[15]+b[14],7),b[13]^=E(b[12]+b[15],9),b[14]^=E(b[13]+b[12],13),b[15]^=E(b[14]+b[13],18);for(t=0;t<16;++t)p[t]=b[t]+p[t];for(t=0;t<16;t++){var r=4*t;e[r+0]=p[t]>>0&255,e[r+1]=p[t]>>8&255,e[r+2]=p[t]>>16&255,e[r+3]=p[t]>>24&255}}function k(e,t,r,n,i){for(var o=0;o=r)throw RangeError(n)}}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":181}],297:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("bip66"),o=n.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),a=n.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(e,t,r){var i=n.from(r?o:a);return e.copy(i,r?8:9),t.copy(i,r?181:214),i},r.privateKeyImport=function(e){var t=e.length,r=0;if(!(t2||t1?e[r+n-2]<<8:0);if(!(t<(r+=n)+i||t32||t1&&0===t[o]&&!(128&t[o+1]);--r,++o);for(var a=n.concat([n.from([0]),e.s]),s=33,u=0;s>1&&0===a[u]&&!(128&a[u+1]);--s,++u);return i.encode(t.slice(o),a.slice(u))},r.signatureImport=function(e){var t=n.alloc(32,0),r=n.alloc(32,0);try{var o=i.decode(e);if(33===o.r.length&&0===o.r[0]&&(o.r=o.r.slice(1)),o.r.length>32)throw new Error("R length is too long");if(33===o.s.length&&0===o.s[0]&&(o.s=o.s.slice(1)),o.s.length>32)throw new Error("S length is too long")}catch(e){return}return o.r.copy(t,32-o.r.length),o.s.copy(r,32-o.s.length),{r:t,s:r}},r.signatureImportLax=function(e){var t=n.alloc(32,0),r=n.alloc(32,0),i=e.length,o=0;if(48===e[o++]){var a=e[o++];if(!(128&a&&(o+=a-128)>i)&&2===e[o++]){var s=e[o++];if(128&s){if(o+(a=s-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(s=0;a>0;o+=1,a-=1)s=(s<<8)+e[o]}if(!(s>i-o)){var u=o;if(o+=s,2===e[o++]){var c=e[o++];if(128&c){if(o+(a=c-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(c=0;a>0;o+=1,a-=1)c=(c<<8)+e[o]}if(!(c>i-o)){var f=o;for(o+=c;s>0&&0===e[u];s-=1,u+=1);if(!(s>32)){var h=e.slice(u,u+s);for(h.copy(t,32-h.length);c>0&&0===e[f];c-=1,f+=1);if(!(c>32)){var l=e.slice(f,f+c);return l.copy(r,32-l.length),{r:t,s:r}}}}}}}}}},{bip66:52,"safe-buffer":290}],298:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("create-hash"),o=e("bn.js"),a=e("elliptic").ec,s=e("../messages.json"),u=new a("secp256k1"),c=u.curve;function f(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new o(t);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),u.keyPair({pub:{x:r,y:n}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new o(t),i=new o(r);if(n.cmp(c.p)>=0||i.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),i=i.toRed(c.red),(6===e||7===e)&&i.isOdd()!==(7===e))return null;var a=n.redSqr().redIMul(n);return i.redSqr().redISub(a.redIAdd(c.b)).isZero()?u.keyPair({pub:{x:n,y:i}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}r.privateKeyVerify=function(e){var t=new o(e);return t.cmp(c.n)<0&&!t.isZero()},r.privateKeyExport=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.privateKeyNegate=function(e){var t=new o(e);return t.isZero()?n.alloc(32):c.n.sub(t).umod(c.n).toArrayLike(n,"be",32)},r.privateKeyModInverse=function(e){var t=new o(e);if(t.cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(c.n).toArrayLike(n,"be",32)},r.privateKeyTweakAdd=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new o(e)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(n,"be",32)},r.privateKeyTweakMul=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new o(e)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(n,"be",32)},r.publicKeyCreate=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.publicKeyConvert=function(e,t){var r=f(e);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return n.from(r.getPublic(t,!0))},r.publicKeyVerify=function(e){return null!==f(e)},r.publicKeyTweakAdd=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return n.from(c.g.mul(t).add(i.pub).encode(!0,r))},r.publicKeyTweakMul=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return n.from(i.pub.mul(t).encode(!0,r))},r.publicKeyCombine=function(e,t){for(var r=new Array(e.length),i=0;i=0||r.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var i=n.from(e);return 1===r.cmp(u.nh)&&c.n.sub(r).toArrayLike(n,"be",32).copy(i,32),i},r.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new o(t).cmp(c.n)>=0||new o(r).cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},r.signatureImport=function(e){var t=new o(e.r);t.cmp(c.n)>=0&&(t=new o(0));var r=new o(e.s);return r.cmp(c.n)>=0&&(r=new o(0)),n.concat([t.toArrayLike(n,"be",32),r.toArrayLike(n,"be",32)])},r.sign=function(e,t,r,i){if("function"==typeof r){var a=r;r=function(r){var u=a(e,t,null,i,r);if(!n.isBuffer(u)||32!==u.length)throw new Error(s.ECDSA_SIGN_FAIL);return new o(u)}}var f=new o(t);if(f.cmp(c.n)>=0||f.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var h=u.sign(e,t,{canonical:!0,k:r,pers:i});return{signature:n.concat([h.r.toArrayLike(n,"be",32),h.s.toArrayLike(n,"be",32)]),recovery:h.recoveryParam}},r.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},i=new o(n.r),a=new o(n.s);if(i.cmp(c.n)>=0||a.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===a.cmp(u.nh)||i.isZero()||a.isZero())return!1;var h=f(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return u.verify(e,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(e,t,r,i){var a={r:t.slice(0,32),s:t.slice(32,64)},f=new o(a.r),h=new o(a.s);if(f.cmp(c.n)>=0||h.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(f.isZero()||h.isZero())throw new Error;var l=u.recoverPubKey(e,a,r);return n.from(l.encode(!0,i))}catch(e){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(e,t){var n=r.ecdhUnsafe(e,t,!0);return i("sha256").update(n).digest()},r.ecdhUnsafe=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var a=new o(t);if(a.cmp(c.n)>=0||a.isZero())throw new Error(s.ECDH_FAIL);return n.from(i.pub.mul(a).encode(!0,r))}},{"../messages.json":300,"bn.js":53,"create-hash":91,elliptic:109,"safe-buffer":290}],299:[function(e,t,r){"use strict";var n=e("./assert"),i=e("./der"),o=e("./messages.json");function a(e,t){return void 0===e?t:(n.isBoolean(e,o.COMPRESSED_TYPE_INVALID),e)}t.exports=function(e){return{privateKeyVerify:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0);var s=e.privateKeyExport(t,r);return i.privateKeyExport(t,s,r)},privateKeyImport:function(t){if(n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),(t=i.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakAdd(t,r,i)},publicKeyTweakMul:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakMul(t,r,i)},publicKeyCombine:function(t,r){n.isArray(t,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(t,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=2&&("function"==typeof arguments[1]?r.task=arguments[1]:r.n=arguments[1]);var n=r.task;if(r.task=function(){n(t.leave)},t.current+r.n-e>t.capacity)return 1===e&&(t.current--,t.firstHere=!1),t.queue.push(r);t.current+=r.n-e,r.task(t.leave),1===e&&(t.firstHere=!1)},leave:function(e){if(e=e||1,t.current-=e,t.queue.length){var r=t.queue[0];r.n+t.current>t.capacity||(t.queue.shift(),t.current+=r.n,i(r.task))}else if(t.current<0)throw new Error("leave called too many times.")},available:function(e){return e=e||1,t.current+e<=t.capacity}};return t}void 0!==e&&e&&"function"==typeof e.nextTick&&(i=e.nextTick),"object"==typeof r?t.exports=o:"function"==typeof define&&define.amd?define(function(){return o}):n.semaphore=o}(this)}).call(this,e("_process"))},{_process:257}],302:[function(e,t,r){"use strict";t.exports="function"==typeof setImmediate?setImmediate:function(){var e=[].slice.apply(arguments);e.splice(1,0,0),setTimeout.apply(null,e)}},{}],303:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t){this._block=n.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}i.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=n.from(e,t));for(var r=this._block,i=this._blockSize,o=e.length,a=this._len,s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},{"safe-buffer":290}],304:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":305,"./sha1":306,"./sha224":307,"./sha256":308,"./sha384":309,"./sha512":310}],305:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((t=n)<<5|t>>>27)+f(d,i,o,s)+u+r[l]+a[d];u=s,s=o,o=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],306:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function h(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=(t=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=c(n)+h(p,i,o,s)+u+r[d]+a[p]|0;u=s,s=o,o=f(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],307:[function(e,t,r){var n=e("inherits"),i=e("./sha256"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}n(u,i),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=u},{"./hash":303,"./sha256":308,inherits:180,"safe-buffer":290}],308:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function l(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(u,i),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,m=0;m<16;++m)r[m]=e.readInt32BE(4*m);for(;m<64;++m)r[m]=0|(((t=r[m-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[m-7]+d(r[m-15])+r[m-16];for(var v=0;v<64;++v){var g=y+l(u)+c(u,p,b)+a[v]+r[v]|0,w=h(n)+f(n,i,o)|0;y=b,b=p,p=u,u=s+g|0,s=o,o=i,i=n,n=g+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},u.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],309:[function(e,t,r){var n=e("inherits"),i=e("./sha512"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}n(u,i),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=u},{"./hash":303,"./sha512":310,inherits:180,"safe-buffer":290}],310:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function l(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function y(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function m(e,t){return e>>>0>>0?1:0}n(u,i),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,s=0|this._eh,u=0|this._fh,v=0|this._gh,g=0|this._hh,w=0|this._al,_=0|this._bl,A=0|this._cl,E=0|this._dl,x=0|this._el,k=0|this._fl,S=0|this._gl,M=0|this._hl,I=0;I<32;I+=2)t[I]=e.readInt32BE(4*I),t[I+1]=e.readInt32BE(4*I+4);for(;I<160;I+=2){var T=t[I-30],U=t[I-30+1],j=d(T,U),B=p(U,T),P=b(T=t[I-4],U=t[I-4+1]),C=y(U,T),N=t[I-14],R=t[I-14+1],L=t[I-32],O=t[I-32+1],D=B+R|0,F=j+N+m(D,B)|0;F=(F=F+P+m(D=D+C|0,C)|0)+L+m(D=D+O|0,O)|0,t[I]=F,t[I+1]=D}for(var q=0;q<160;q+=2){F=t[q],D=t[q+1];var H=f(r,n,i),z=f(w,_,A),K=h(r,w),V=h(w,r),G=l(s,x),W=l(x,s),Y=a[q],X=a[q+1],Z=c(s,u,v),J=c(x,k,S),$=M+W|0,Q=g+G+m($,M)|0;Q=(Q=(Q=Q+Z+m($=$+J|0,J)|0)+Y+m($=$+X|0,X)|0)+F+m($=$+D|0,D)|0;var ee=V+z|0,te=K+H+m(ee,V)|0;g=v,M=S,v=u,S=k,u=s,k=x,s=o+Q+m(x=E+$|0,E)|0,o=i,E=A,i=n,A=_,n=r,_=w,r=Q+te+m(w=$+ee|0,$)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+A|0,this._dl=this._dl+E|0,this._el=this._el+x|0,this._fl=this._fl+k|0,this._gl=this._gl+S|0,this._hl=this._hl+M|0,this._ah=this._ah+r+m(this._al,w)|0,this._bh=this._bh+n+m(this._bl,_)|0,this._ch=this._ch+i+m(this._cl,A)|0,this._dh=this._dh+o+m(this._dl,E)|0,this._eh=this._eh+s+m(this._el,x)|0,this._fh=this._fh+u+m(this._fl,k)|0,this._gh=this._gh+v+m(this._gl,S)|0,this._hh=this._hh+g+m(this._hl,M)|0},u.prototype._hash=function(){var e=o.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],311:[function(e,t,r){t.exports=i;var n=e("events").EventEmitter;function i(){n.call(this)}e("inherits")(i,n),i.Readable=e("readable-stream/readable.js"),i.Writable=e("readable-stream/writable.js"),i.Duplex=e("readable-stream/duplex.js"),i.Transform=e("readable-stream/transform.js"),i.PassThrough=e("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,e.end())}function u(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(f(),0===n.listenerCount(this,"error"))throw e}function f(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),e.removeListener("close",f)}return r.on("error",c),e.on("error",c),r.on("end",f),r.on("close",f),e.on("close",f),e.emit("pipe",r),e}},{events:157,inherits:180,"readable-stream/duplex.js":275,"readable-stream/passthrough.js":284,"readable-stream/readable.js":285,"readable-stream/transform.js":286,"readable-stream/writable.js":287}],312:[function(e,t,r){(function(t){var n=e("./lib/request"),i=e("./lib/response"),o=e("xtend"),a=e("builtin-status-codes"),s=e("url"),u=r;u.request=function(e,r){e="string"==typeof e?s.parse(e):o(e);var i=-1===t.location.protocol.search(/^https?:$/)?"http:":"",a=e.protocol||i,u=e.hostname||e.host,c=e.port,f=e.path||"/";u&&-1!==u.indexOf(":")&&(u="["+u+"]"),e.url=(u?a+"//"+u:"")+(c?":"+c:"")+f,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var h=new n(e);return r&&h.on("response",r),h},u.get=function(e,t){var r=u.request(e,t);return r.end(),r},u.ClientRequest=n,u.IncomingMessage=i,u.Agent=function(){},u.Agent.defaultMaxSockets=4,u.STATUS_CODES=a,u.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/request":314,"./lib/response":315,"builtin-status-codes":85,url:327,xtend:423}],313:[function(e,t,r){(function(e){r.fetch=s(e.fetch)&&s(e.ReadableStream),r.writableStream=s(e.WritableStream),r.abortController=s(e.AbortController),r.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),r.blobConstructor=!0}catch(e){}var t;function n(){if(void 0!==t)return t;if(e.XMLHttpRequest){t=new e.XMLHttpRequest;try{t.open("GET",e.XDomainRequest?"/":"https://example.com")}catch(e){t=null}}else t=null;return t}function i(e){var t=n();if(!t)return!1;try{return t.responseType=e,t.responseType===e}catch(e){}return!1}var o=void 0!==e.ArrayBuffer,a=o&&s(e.ArrayBuffer.prototype.slice);function s(e){return"function"==typeof e}r.arraybuffer=r.fetch||o&&i("arraybuffer"),r.msstream=!r.fetch&&a&&i("ms-stream"),r.mozchunkedarraybuffer=!r.fetch&&o&&i("moz-chunked-arraybuffer"),r.overrideMimeType=r.fetch||!!n()&&s(n().overrideMimeType),r.vbArray=s(e.VBArray),t=null}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],314:[function(e,t,r){(function(r,n,i){var o=e("./capability"),a=e("inherits"),s=e("./response"),u=e("readable-stream"),c=e("to-arraybuffer"),f=s.IncomingMessage,h=s.readyStates;var l=t.exports=function(e){var t,r=this;u.Writable.call(r),r._opts=e,r._body=[],r._headers={},e.auth&&r.setHeader("Authorization","Basic "+new i(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){r.setHeader(t,e.headers[t])});var n=!0;if("disable-fetch"===e.mode||"requestTimeout"in e&&!o.abortController)n=!1,t=!0;else if("prefer-streaming"===e.mode)t=!1;else if("allow-wrong-content-type"===e.mode)t=!o.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");t=!0}r._mode=function(e,t){return o.fetch&&t?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&e?"arraybuffer":o.vbArray&&e?"text:vbarray":"text"}(t,n),r.on("finish",function(){r._onFinish()})};a(l,u.Writable),l.prototype.setHeader=function(e,t){var r=e.toLowerCase();-1===d.indexOf(r)&&(this._headers[r]={name:e,value:t})},l.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},l.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},l.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,a=e._headers,s=null;"GET"!==t.method&&"HEAD"!==t.method&&(s=o.arraybuffer?c(i.concat(e._body)):o.blobConstructor?new n.Blob(e._body.map(function(e){return c(e)}),{type:(a["content-type"]||{}).value||""}):i.concat(e._body).toString());var u=[];if(Object.keys(a).forEach(function(e){var t=a[e].name,r=a[e].value;Array.isArray(r)?r.forEach(function(e){u.push([t,e])}):u.push([t,r])}),"fetch"===e._mode){var f=null;if(o.abortController){var l=new AbortController;f=l.signal,e._fetchAbortController=l,"requestTimeout"in t&&0!==t.requestTimeout&&n.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},t.requestTimeout)}n.fetch(e._opts.url,{method:e._opts.method,headers:u,body:s||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin",signal:f}).then(function(t){e._fetchResponse=t,e._connect()},function(t){e.emit("error",t)})}else{var d=e._xhr=new n.XMLHttpRequest;try{d.open(e._opts.method,e._opts.url,!0)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}"responseType"in d&&(d.responseType=e._mode.split(":")[0]),"withCredentials"in d&&(d.withCredentials=!!t.withCredentials),"text"===e._mode&&"overrideMimeType"in d&&d.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in t&&(d.timeout=t.requestTimeout,d.ontimeout=function(){e.emit("requestTimeout")}),u.forEach(function(e){d.setRequestHeader(e[0],e[1])}),e._response=null,d.onreadystatechange=function(){switch(d.readyState){case h.LOADING:case h.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(d.onprogress=function(){e._onXHRProgress()}),d.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{d.send(s)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}}}},l.prototype._onXHRProgress=function(){(function(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}})(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},l.prototype._connect=function(){var e=this;e._destroyed||(e._response=new f(e._xhr,e._fetchResponse,e._mode),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},l.prototype._write=function(e,t,r){this._body.push(e),r()},l.prototype.abort=l.prototype.destroy=function(){this._destroyed=!0,this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},l.prototype.end=function(e,t,r){"function"==typeof e&&(r=e,e=void 0),u.Writable.prototype.end.call(this,e,t,r)},l.prototype.flushHeaders=function(){},l.prototype.setTimeout=function(){},l.prototype.setNoDelay=function(){},l.prototype.setSocketKeepAlive=function(){};var d=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referrer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,"./response":315,_process:257,buffer:84,inherits:180,"readable-stream":285,"to-arraybuffer":323}],315:[function(e,t,r){(function(t,n,i){var o=e("./capability"),a=e("inherits"),s=e("readable-stream"),u=r.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},c=r.IncomingMessage=function(e,r,n){var a=this;if(s.Readable.call(a),a._mode=n,a.headers={},a.rawHeaders=[],a.trailers={},a.rawTrailers=[],a.on("end",function(){t.nextTick(function(){a.emit("close")})}),"fetch"===n){if(a._fetchResponse=r,a.url=r.url,a.statusCode=r.status,a.statusMessage=r.statusText,r.headers.forEach(function(e,t){a.headers[t.toLowerCase()]=e,a.rawHeaders.push(t,e)}),o.writableStream){var u=new WritableStream({write:function(e){return new Promise(function(t,r){a._destroyed||(a.push(new i(e))?t():a._resumeFetch=t)})},close:function(){a._destroyed||a.push(null)},abort:function(e){a._destroyed||a.emit("error",e)}});try{return void r.body.pipeTo(u)}catch(e){}}var c=r.body.getReader();!function e(){c.read().then(function(t){a._destroyed||(t.done?a.push(null):(a.push(new i(t.value)),e()))}).catch(function(e){a._destroyed||a.emit("error",e)})}()}else{if(a._xhr=e,a._pos=0,a.url=e.responseURL,a.statusCode=e.status,a.statusMessage=e.statusText,e.getAllResponseHeaders().split(/\r?\n/).forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var r=t[1].toLowerCase();"set-cookie"===r?(void 0===a.headers[r]&&(a.headers[r]=[]),a.headers[r].push(t[2])):void 0!==a.headers[r]?a.headers[r]+=", "+t[2]:a.headers[r]=t[2],a.rawHeaders.push(t[1],t[2])}}),a._charset="x-user-defined",!o.overrideMimeType){var f=a.rawHeaders["mime-type"];if(f){var h=f.match(/;\s*charset=([^;])(;|$)/);h&&(a._charset=h[1].toLowerCase())}a._charset||(a._charset="utf-8")}}};a(c,s.Readable),c.prototype._read=function(){var e=this._resumeFetch;e&&(this._resumeFetch=null,e())},c.prototype._onXHRProgress=function(){var e=this,t=e._xhr,r=null;switch(e._mode){case"text:vbarray":if(t.readyState!==u.DONE)break;try{r=new n.VBArray(t.responseBody).toArray()}catch(e){}if(null!==r){e.push(new i(r));break}case"text":try{r=t.responseText}catch(t){e._mode="text:vbarray";break}if(r.length>e._pos){var o=r.substr(e._pos);if("x-user-defined"===e._charset){for(var a=new i(o.length),s=0;se._pos&&(e.push(new i(new Uint8Array(c.result.slice(e._pos)))),e._pos=c.result.byteLength)},c.onload=function(){e.push(null)},c.readAsArrayBuffer(r)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,_process:257,buffer:84,inherits:180,"readable-stream":285}],316:[function(e,t,r){"use strict";t.exports=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}},{}],317:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=f,this.end=h,t=3;break;default:return this.write=l,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:-1}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�".repeat(r);if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�".repeat(r+1);if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�".repeat(r+2)}}(this,e,t);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function l(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}r.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":290}],318:[function(e,t,r){var n=e("is-hex-prefixed");t.exports=function(e){return"string"!=typeof e?e:n(e)?e.slice(2):e}},{"is-hex-prefixed":185}],319:[function(e,t,r){var n=function(){throw"This swarm.js function isn't available on the browser."},i={readFile:n},o={download:n,safeDownloadArchived:n,directoryTree:n},a={platform:n,arch:n},s={join:n,slice:n},u={spawn:n},c={lookup:n},f=e("xhr-request-promise"),h=e("eth-lib/lib/bytes"),l=e("./swarm-hash.js"),d=e("./pick.js"),p=e("./swarm");t.exports=p({fsp:i,files:o,os:a,path:s,child_process:u,defaultArchives:{},mimetype:c,request:f,downloadUrl:null,bytes:h,hash:l,pick:d})},{"./pick.js":320,"./swarm":322,"./swarm-hash.js":321,"eth-lib/lib/bytes":133,"xhr-request-promise":411}],320:[function(e,t,r){var n=function(e){return function(){return new Promise(function(t,r){var n=function(r){var n={},i=r.target.files.length,o=0;[].map.call(r.target.files,function(r){var a=new FileReader;a.onload=function(a){var s=new Uint8Array(a.target.result);if("directory"===e){var u=r.webkitRelativePath;n[u.slice(u.indexOf("/")+1)]={type:"text/plain",data:s},++o===i&&t(n)}else if("file"===e){var c=r.webkitRelativePath;t({type:mimetype.lookup(c),data:s})}else t(s)},a.readAsArrayBuffer(r)})},i=void 0;"directory"===e?((i=document.createElement("input")).addEventListener("change",n),i.type="file",i.webkitdirectory=!0,i.mozdirectory=!0,i.msdirectory=!0,i.odirectory=!0,i.directory=!0):((i=document.createElement("input")).addEventListener("change",n),i.type="file");var o=document.createEvent("MouseEvents");o.initEvent("click",!0,!1),i.dispatchEvent(o)})}};t.exports={data:n("data"),file:n("file"),directory:n("directory")}},{}],321:[function(e,t,r){var n=e("eth-lib/lib/hash").keccak256,i=e("eth-lib/lib/bytes"),o=function(e,t){var r=i.reverse(i.pad(6,i.fromNumber(e))),o=i.flatten([r,"0x0000",t]);return n(o).slice(2)};t.exports=function e(t){"string"==typeof t&&"0x"!==t.slice(0,2)?t=i.fromString(t):"string"!=typeof t&&void 0!==t.length&&(t=i.fromUint8Array(t));var r=i.length(t);if(r<=4096)return o(r,t);for(var n=4096;128*n0){var a=i.join(r,o);n.push(g(e)(t[o])(a))}return Promise.all(n).then(function(){return r})})}}},_=function(e){return function(t){return u(e+"/bzzr:/",{body:"string"==typeof t?L(t):t,method:"POST"})}},A=function(e){return function(t){return function(r){return function(n){return function i(o){var a="/"===r[0]?r:"/"+r,s=e+"/bzz:/"+t+a,c={method:"PUT",headers:{"Content-Type":n.type},body:n.data};return u(s,c).then(function(e){if(-1!==e.indexOf("error"))throw e;return e}).catch(function(e){return o>0&&i(o-1)})}(3)}}}},E=function(e){return function(t){return k(e)({"":t})}},x=function(e){return function(r){return t.readFile(r).then(function(t){return E(e)({type:a.lookup(r),data:t})})}},k=function(e){return function(t){return _(e)("{}").then(function(r){return Object.keys(t).reduce(function(r,n){return r.then(function(r){return function(n){return A(e)(n)(r)(t[r])}}(n))},Promise.resolve(r))})}},S=function(e){return function(r){return t.readFile(r).then(_(e))}},M=function(e){return function(n){return function(i){return r.directoryTree(i).then(function(e){return Promise.all(e.map(function(e){return t.readFile(e)})).then(function(t){var r=e.map(function(e){return e.slice(i.length)}),n=e.map(function(e){return a.lookup(e)||"text/plain"});return d(r)(t.map(function(e,t){return{type:n[t],data:e}}))})}).then(function(e){return(t=n?{"":e[n]}:{},function(e){var r={};for(var n in t)r[n]=t[n];for(var i in e)r[i]=e[i];return r})(e);var t}).then(k(e))}}},I=function(e){return function(t){if("data"===t.pick)return l.data().then(_(e));if("file"===t.pick)return l.file().then(E(e));if("directory"===t.pick)return l.directory().then(k(e));if(t.path)switch(t.kind){case"data":return S(e)(t.path);case"file":return x(e)(t.path);case"directory":return M(e)(t.defaultFile)(t.path)}else{if(t.length||"string"==typeof t)return _(e)(t);if(t instanceof Object)return k(e)(t)}return Promise.reject(new Error("Bad arguments"))}},T=function(e){return function(t){return function(r){return C(e)(t).then(function(n){return n?r?w(e)(t)(r):v(e)(t):r?g(e)(t)(r):b(e)(t)})}}},U=function(e,t){var i=n.platform().replace("win32","windows")+"-"+("x64"===n.arch()?"amd64":"386"),o=(t||s)[i],a=c+o.archive+".tar.gz",u=o.archiveMD5,f=o.binaryMD5;return r.safeDownloadArchived(a)(u)(f)(e)},j=function(e){return new Promise(function(t,r){var n=o.spawn,i=function(e){return function(t){return-1!==(""+t).indexOf(e)}},a=e.account,s=e.password,u=e.dataDir,c=e.ensApi,f=e.privateKey,h=0,l=n(e.binPath,["--bzzaccount",a||f,"--datadir",u,"--ens-api",c]),d=function(e){0===h&&i("Passphrase")(e)?setTimeout(function(){h=1,l.stdin.write(s+"\n")},500):i("Swarm http proxy started")(e)&&(h=2,clearTimeout(p),t(l))};l.stdout.on("data",d),l.stderr.on("data",d);var p=setTimeout(function(){return r(new Error("Couldn't start swarm process."))},2e4)})},B=function(e){return new Promise(function(t,r){e.stderr.removeAllListeners("data"),e.stdout.removeAllListeners("data"),e.stdin.removeAllListeners("error"),e.removeAllListeners("error"),e.removeAllListeners("exit"),e.kill("SIGINT");var n=setTimeout(function(){return e.kill("SIGKILL")},8e3);e.once("close",function(){clearTimeout(n),t()})})},P=function(e){return _(e)("test").then(function(e){return"c9a99c7d326dcc6316f32fe2625b311f6dc49a175e6877681ded93137d3569e7"===e}).catch(function(){return!1})},C=function(e){return function(t){return b(e)(t).then(function(e){try{return!!JSON.parse(R(e)).entries}catch(e){return!1}})}},N=function(e){return function(t,r,n,i,o){var a;return void 0!==t&&(a=e(t)),void 0!==r&&(a=e(r)),void 0!==n&&(a=e(n)),void 0!==i&&(a=e(i)),void 0!==o&&(a=e(o)),a}},R=function(e){return f.toString(f.fromUint8Array(e))},L=function(e){return f.toUint8Array(f.fromString(e))},O=function(e){return{download:function(t,r){return T(e)(t)(r)},downloadData:N(b(e)),downloadDataToDisk:N(g(e)),downloadDirectory:N(v(e)),downloadDirectoryToDisk:N(w(e)),downloadEntries:N(y(e)),downloadRoutes:N(m(e)),isAvailable:function(){return P(e)},upload:function(t){return I(e)(t)},uploadData:N(_(e)),uploadFile:N(E(e)),uploadFileFromDisk:N(E(e)),uploadDataFromDisk:N(S(e)),uploadDirectory:N(k(e)),uploadDirectoryFromDisk:N(M(e)),uploadToManifest:N(A(e)),pick:l,hash:h,fromString:L,toString:R}};return{at:O,local:function(e){return function(t){return P("http://localhost:8500").then(function(r){return r?t(O("http://localhost:8500")).then(function(){}):U(e.binPath,e.archives).onData(function(t){return(e.onProgress||function(){})(t.length)}).then(function(){return j(e)}).then(function(e){return t(O("http://localhost:8500")).then(function(){return e})}).then(B)})}},download:T,downloadBinary:U,downloadData:b,downloadDataToDisk:g,downloadDirectory:v,downloadDirectoryToDisk:w,downloadEntries:y,downloadRoutes:m,isAvailable:P,startProcess:j,stopProcess:B,upload:I,uploadData:_,uploadDataFromDisk:S,uploadFile:E,uploadFileFromDisk:x,uploadDirectory:k,uploadDirectoryFromDisk:M,uploadToManifest:A,pick:l,hash:h,fromString:L,toString:R}}},{}],323:[function(e,t,r){var n=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(n.isBuffer(e)){for(var t=new Uint8Array(e.length),r=e.length,i=0;i=0&&t<=A};function k(e){return function(t,r,n,i){r=m(r,i,4);var o=!x(t)&&y.keys(t),a=(o||t).length,s=e>0?0:a-1;return arguments.length<3&&(n=t[o?o[s]:s],s+=e),function(t,r,n,i,o,a){for(;o>=0&&o=0},y.invoke=function(e,t){var r=u.call(arguments,2),n=y.isFunction(t);return y.map(e,function(e){var i=n?t:e[t];return null==i?i:i.apply(e,r)})},y.pluck=function(e,t){return y.map(e,y.property(t))},y.where=function(e,t){return y.filter(e,y.matcher(t))},y.findWhere=function(e,t){return y.find(e,y.matcher(t))},y.max=function(e,t,r){var n,i,o=-1/0,a=-1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;so&&(o=n);else t=v(t,r),y.each(e,function(e,r,n){((i=t(e,r,n))>a||i===-1/0&&o===-1/0)&&(o=e,a=i)});return o},y.min=function(e,t,r){var n,i,o=1/0,a=1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;sn||void 0===r)return 1;if(r0?0:i-1;o>=0&&o0?a=o>=0?o:Math.max(o+s,a):s=o>=0?Math.min(o+1,s):o+s+1;else if(r&&o&&s)return n[o=r(n,i)]===i?o:-1;if(i!=i)return(o=t(u.call(n,a,s),y.isNaN))>=0?o+a:-1;for(o=e>0?a:s-1;o>=0&&ot?(a&&(clearTimeout(a),a=null),s=c,o=e.apply(n,i),a||(n=i=null)):a||!1===r.trailing||(a=setTimeout(u,f)),o}},y.debounce=function(e,t,r){var n,i,o,a,s,u=function(){var c=y.now()-a;c=0?n=setTimeout(u,t-c):(n=null,r||(s=e.apply(o,i),n||(o=i=null)))};return function(){o=this,i=arguments,a=y.now();var c=r&&!n;return n||(n=setTimeout(u,t)),c&&(s=e.apply(o,i),o=i=null),s}},y.wrap=function(e,t){return y.partial(t,e)},y.negate=function(e){return function(){return!e.apply(this,arguments)}},y.compose=function(){var e=arguments,t=e.length-1;return function(){for(var r=t,n=e[t].apply(this,arguments);r--;)n=e[r].call(this,n);return n}},y.after=function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},y.before=function(e,t){var r;return function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=null),r}},y.once=y.partial(y.before,2);var j=!{toString:null}.propertyIsEnumerable("toString"),B=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];function P(e,t){var r=B.length,n=e.constructor,i=y.isFunction(n)&&n.prototype||o,a="constructor";for(y.has(e,a)&&!y.contains(t,a)&&t.push(a);r--;)(a=B[r])in e&&e[a]!==i[a]&&!y.contains(t,a)&&t.push(a)}y.keys=function(e){if(!y.isObject(e))return[];if(l)return l(e);var t=[];for(var r in e)y.has(e,r)&&t.push(r);return j&&P(e,t),t},y.allKeys=function(e){if(!y.isObject(e))return[];var t=[];for(var r in e)t.push(r);return j&&P(e,t),t},y.values=function(e){for(var t=y.keys(e),r=t.length,n=Array(r),i=0;i":">",'"':""","'":"'","`":"`"},R=y.invert(N),L=function(e){var t=function(t){return e[t]},r="(?:"+y.keys(e).join("|")+")",n=RegExp(r),i=RegExp(r,"g");return function(e){return e=null==e?"":""+e,n.test(e)?e.replace(i,t):e}};y.escape=L(N),y.unescape=L(R),y.result=function(e,t,r){var n=null==e?void 0:e[t];return void 0===n&&(n=r),y.isFunction(n)?n.call(e):n};var O=0;y.uniqueId=function(e){var t=++O+"";return e?e+t:t},y.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var D=/(.)^/,F={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},q=/\\|'|\r|\n|\u2028|\u2029/g,H=function(e){return"\\"+F[e]};y.template=function(e,t,r){!t&&r&&(t=r),t=y.defaults({},t,y.templateSettings);var n=RegExp([(t.escape||D).source,(t.interpolate||D).source,(t.evaluate||D).source].join("|")+"|$","g"),i=0,o="__p+='";e.replace(n,function(t,r,n,a,s){return o+=e.slice(i,s).replace(q,H),i=s+t.length,r?o+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":n?o+="'+\n((__t=("+n+"))==null?'':__t)+\n'":a&&(o+="';\n"+a+"\n__p+='"),t}),o+="';\n",t.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{var a=new Function(t.variable||"obj","_",o)}catch(e){throw e.source=o,e}var s=function(e){return a.call(this,e,y)},u=t.variable||"obj";return s.source="function("+u+"){\n"+o+"}",s},y.chain=function(e){var t=y(e);return t._chain=!0,t};var z=function(e,t){return e._chain?y(t).chain():t};y.mixin=function(e){y.each(y.functions(e),function(t){var r=y[t]=e[t];y.prototype[t]=function(){var e=[this._wrapped];return s.apply(e,arguments),z(this,r.apply(y,e))}})},y.mixin(y),y.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=i[e];y.prototype[e]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==e&&"splice"!==e||0!==r.length||delete r[0],z(this,r)}}),y.each(["concat","join","slice"],function(e){var t=i[e];y.prototype[e]=function(){return z(this,t.apply(this._wrapped,arguments))}}),y.prototype.value=function(){return this._wrapped},y.prototype.valueOf=y.prototype.toJSON=y.prototype.value,y.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return y})}).call(this)},{}],326:[function(e,t,r){t.exports=function(e,t){if(t){t=(t=t.trim().replace(/^(\?|#|&)/,""))?"?"+t:t;var r=e.split(/[\?\#]/),n=r[0];t&&/\:\/\/[^\/]*$/.test(n)&&(n+="/");var i=e.match(/(\#.*)$/);e=n+t,i&&(e+=i[0])}return e}},{}],327:[function(e,t,r){"use strict";var n=e("punycode"),i=e("./util");function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}r.parse=g,r.resolve=function(e,t){return g(e,!1,!0).resolve(t)},r.resolveObject=function(e,t){return e?g(e,!1,!0).resolveObject(t):t},r.format=function(e){i.isString(e)&&(e=g(e));return e instanceof o?e.format():o.prototype.format.call(e)},r.Url=o;var a=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=e("querystring");function g(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o127?P+="x":P+=B[C];if(!P.match(d)){var R=U.slice(0,M),L=U.slice(M+1),O=B.match(p);O&&(R.push(O[1]),L.unshift(O[2])),L.length&&(g="/"+L.join(".")+g),this.hostname=R.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),T||(this.hostname=n.toASCII(this.hostname));var D=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+D,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==g[0]&&(g="/"+g))}if(!b[A])for(M=0,j=f.length;M0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift());return r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!E.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var k=E.slice(-1)[0],S=(r.host||e.host||E.length>1)&&("."===k||".."===k)||""===k,M=0,I=E.length;I>=0;I--)"."===(k=E[I])?E.splice(I,1):".."===k?(E.splice(I,1),M++):M&&(E.splice(I,1),M--);if(!_&&!A)for(;M--;M)E.unshift("..");!_||""===E[0]||E[0]&&"/"===E[0].charAt(0)||E.unshift(""),S&&"/"!==E.join("/").substr(-1)&&E.push("");var T,U=""===E[0]||E[0]&&"/"===E[0].charAt(0);x&&(r.hostname=r.host=U?"":E.length?E.shift():"",(T=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift()));return(_=_||r.host&&E.length)&&!U&&E.unshift(""),E.length?r.pathname=E.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":328,punycode:265,querystring:269}],328:[function(e,t,r){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],329:[function(e,t,r){(function(e){!function(n){var i="object"==typeof r&&r,o="object"==typeof t&&t&&t.exports==i&&t,a="object"==typeof e&&e;a.global!==a&&a.window!==a||(n=a);var s,u,c,f=String.fromCharCode;function h(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i=55296&&e<=57343)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value")}function d(e,t){return f(e>>t&63|128)}function p(e){if(0==(4294967168&e))return f(e);var t="";return 0==(4294965248&e)?t=f(e>>6&31|192):0==(4294901760&e)?(l(e),t=f(e>>12&15|224),t+=d(e,6)):0==(4292870144&e)&&(t=f(e>>18&7|240),t+=d(e,12),t+=d(e,6)),t+=f(63&e|128)}function b(){if(c>=u)throw Error("Invalid byte index");var e=255&s[c];if(c++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function y(){var e,t;if(c>u)throw Error("Invalid byte index");if(c==u)return!1;if(e=255&s[c],c++,0==(128&e))return e;if(192==(224&e)){if((t=(31&e)<<6|b())>=128)return t;throw Error("Invalid continuation byte")}if(224==(240&e)){if((t=(15&e)<<12|b()<<6|b())>=2048)return l(t),t;throw Error("Invalid continuation byte")}if(240==(248&e)&&(t=(15&e)<<18|b()<<12|b()<<6|b())>=65536&&t<=1114111)return t;throw Error("Invalid UTF-8 detected")}var m={version:"2.0.0",encode:function(e){for(var t=h(e),r=t.length,n=-1,i="";++n65535&&(i+=f((t-=65536)>>>10&1023|55296),t=56320|1023&t),i+=f(t);return i}(r)}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return m});else if(i&&!i.nodeType)if(o)o.exports=m;else{var v={}.hasOwnProperty;for(var g in m)v.call(m,g)&&(i[g]=m[g])}else n.utf8=m}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],330:[function(e,t,r){(function(e){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],331:[function(e,t,r){arguments[4][180][0].apply(r,arguments)},{dup:180}],332:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],333:[function(e,t,r){(function(t,n){var i=/%[sdj%]/g;r.format=function(e){if(!m(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(t)?n.showHidden=t:t&&r._extend(n,t),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,e,n.depth)}function u(e,t){var r=s.styles[t];return r?"["+s.colors[r][0]+"m"+e+"["+s.colors[r][1]+"m":e}function c(e,t){return e}function f(e,t,n){if(e.customInspect&&t&&E(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return m(i)||(i=f(e,i,n)),i}var o=function(e,t){if(v(t))return e.stylize("undefined","undefined");if(m(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(y(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(b(t))return e.stylize("null","null")}(e,t);if(o)return o;var a=Object.keys(t),s=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),A(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return h(t);if(0===a.length){if(E(t)){var u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","special")}if(g(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(_(t))return e.stylize(Date.prototype.toString.call(t),"date");if(A(t))return h(t)}var c,w="",x=!1,k=["{","}"];(d(t)&&(x=!0,k=["[","]"]),E(t))&&(w=" [Function"+(t.name?": "+t.name:"")+"]");return g(t)&&(w=" "+RegExp.prototype.toString.call(t)),_(t)&&(w=" "+Date.prototype.toUTCString.call(t)),A(t)&&(w=" "+h(t)),0!==a.length||x&&0!=t.length?n<0?g(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=x?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(c,w,k)):k[0]+w+k[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),M(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=b(r)?f(e,u.value,null):f(e,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n")):s=e.stylize("[Circular]","special")),v(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function b(e){return null===e}function y(e){return"number"==typeof e}function m(e){return"string"==typeof e}function v(e){return void 0===e}function g(e){return w(e)&&"[object RegExp]"===x(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===x(e)}function A(e){return w(e)&&("[object Error]"===x(e)||e instanceof Error)}function E(e){return"function"==typeof e}function x(e){return Object.prototype.toString.call(e)}function k(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(v(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=t.pid;a[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else a[e]=function(){};return a[e]},r.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(e){return null==e},r.isNumber=y,r.isString=m,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=v,r.isRegExp=g,r.isObject=w,r.isDate=_,r.isError=A,r.isFunction=E,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[k(e.getHours()),k(e.getMinutes()),k(e.getSeconds())].join(":"),[e.getDate(),S[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":332,_process:257,inherits:331}],334:[function(require,module,exports){var indexOf=require("indexof"),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},c.prototype.getCall=function(e){return n.isFunction(this.call)?this.call(e):this.call},c.prototype.extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},c.prototype.validateArgs=function(e){if(e.length!==this.params)throw i.InvalidNumberOfParams(e.length,this.params,this.name)},c.prototype.formatInput=function(e){var t=this;return this.inputFormatter?this.inputFormatter.map(function(r,n){return r?r.call(t,e[n]):e[n]}):e},c.prototype.formatOutput=function(e){var t=this;return n.isArray(e)?e.map(function(e){return t.outputFormatter&&e?t.outputFormatter(e):e}):this.outputFormatter&&e?this.outputFormatter(e):e},c.prototype.toPayload=function(e){var t=this.getCall(e),r=this.extractCallback(e),n=this.formatInput(e);this.validateArgs(n);var i={method:t,params:n,callback:r};return this.transformPayload&&(i=this.transformPayload(i)),i},c.prototype._confirmTransaction=function(e,t,r){var i=this,f=!1,h=!0,l=0,d=0,p=null,b="",y=n.isObject(r.params[0])&&r.params[0].gas?r.params[0].gas:null,m=n.isObject(r.params[0])&&r.params[0].data&&r.params[0].from&&!r.params[0].to,v=[new c({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:o.outputTransactionReceiptFormatter}),new c({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[o.inputAddressFormatter,o.inputDefaultBlockNumberFormatter]}),new u({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:o.outputBlockFormatter}}})],g={};n.each(v,function(e){e.attachToObject(g),e.requestManager=i.requestManager});var w=function(r,n,o,u,c){if(!o)return c||(c={unsubscribe:function(){clearInterval(p)}}),(r?s.resolve(r):g.getTransactionReceipt(t)).catch(function(t){c.unsubscribe(),f=!0,a._fireError({message:"Failed to check for transaction receipt:",data:t},e.eventEmitter,e.reject)}).then(function(t){if(!t||!t.blockHash)throw new Error("Receipt missing or blockHash null");return i.extraFormatters&&i.extraFormatters.receiptFormatter&&(t=i.extraFormatters.receiptFormatter(t)),e.eventEmitter.listeners("confirmation").length>0&&(void 0!==r&&0===d||e.eventEmitter.emit("confirmation",d,t),h=!1,25===++d&&(c.unsubscribe(),e.eventEmitter.removeAllListeners())),t}).then(function(t){if(m&&!f){if(!t.contractAddress)return h&&(c.unsubscribe(),f=!0),void a._fireError(new Error("The transaction receipt didn't contain a contract address."),e.eventEmitter,e.reject);g.getCode(t.contractAddress,function(r,n){n&&(n.length>2?(e.eventEmitter.emit("receipt",t),i.extraFormatters&&i.extraFormatters.contractDeployFormatter?e.resolve(i.extraFormatters.contractDeployFormatter(t)):e.resolve(t),h&&e.eventEmitter.removeAllListeners()):a._fireError(new Error("The contract code couldn't be stored, please check your gas limit."),e.eventEmitter,e.reject),h&&c.unsubscribe(),f=!0)})}return t}).then(function(t){m||f||(t.outOfGas||y&&y===t.gasUsed||!0!==t.status&&"0x1"!==t.status&&void 0!==t.status?(b=JSON.stringify(t,null,2),!1===t.status||"0x0"===t.status?a._fireError(new Error("Transaction has been reverted by the EVM:\n"+b),e.eventEmitter,e.reject):a._fireError(new Error("Transaction ran out of gas. Please provide more gas:\n"+b),e.eventEmitter,e.reject)):(e.eventEmitter.emit("receipt",t),e.resolve(t),h&&e.eventEmitter.removeAllListeners()),h&&c.unsubscribe(),f=!0)}).catch(function(){l++,n?l-1>=750&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject)):l-1>=50&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject))});c.unsubscribe(),f=!0,a._fireError({message:"Failed to subscribe to new newBlockHeaders to confirm the transaction receipts.",data:o},e.eventEmitter,e.reject)},_=function(e){n.isFunction(this.requestManager.provider.on)?g.subscribe("newBlockHeaders",w.bind(null,e,!1)):p=setInterval(w.bind(null,e,!0),1e3)}.bind(this);g.getTransactionReceipt(t).then(function(t){t&&t.blockHash?(e.eventEmitter.listeners("confirmation").length>0&&_(t),w(t,!1)):f||_()}).catch(function(){f||_()})};var f=function(e,t){return n.isNumber(e)?t.wallet[e]:n.isObject(e)&&e.address&&e.privateKey?e:t.wallet[e.toLowerCase()]};c.prototype.buildCall=function(){var e=this,t="eth_sendTransaction"===e.call||"eth_sendRawTransaction"===e.call,r=function(){var r=s(!t),i=e.toPayload(Array.prototype.slice.call(arguments)),o=function(n,o){try{o=e.formatOutput(o)}catch(e){n=e}if(o instanceof Error&&(n=o),n)return n.error&&(n=n.error),a._fireError(n,r.eventEmitter,r.reject,i.callback);i.callback&&i.callback(null,o),t?(r.eventEmitter.emit("transactionHash",o),e._confirmTransaction(r,o,i)):n||r.resolve(o)},u=function(t){var r=n.extend({},i,{method:"eth_sendRawTransaction",params:[t.rawTransaction]});e.requestManager.send(r,o)},h=function(e,t){var i;if(t&&t.accounts&&t.accounts.wallet&&t.accounts.wallet.length)if("eth_sendTransaction"===e.method){var a=e.params[0];if((i=f(n.isObject(a)?a.from:null,t.accounts))&&i.privateKey)return t.accounts.signTransaction(n.omit(a,"from"),i.privateKey).then(u)}else if("eth_sign"===e.method){var s=e.params[1];if((i=f(e.params[0],t.accounts))&&i.privateKey){var c=t.accounts.sign(s,i.privateKey);return e.callback&&e.callback(null,c.signature),void r.resolve(c.signature)}}return t.requestManager.send(e,o)};t&&n.isObject(i.params[0])&&void 0===i.params[0].gasPrice?new c({name:"getGasPrice",call:"eth_gasPrice",params:0}).createFunction(e.requestManager)(function(t,r){r&&(i.params[0].gasPrice=r),h(i,e)}):h(i,e);return r.eventEmitter};return r.method=e,r.request=this.request.bind(this),r},c.prototype.request=function(){var e=this.toPayload(Array.prototype.slice.call(arguments));return e.format=this.formatOutput.bind(this),e},t.exports=c},{underscore:325,"web3-core-helpers":338,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-utils":403}],340:[function(e,t,r){"use strict";var n=e("eventemitter3"),i=e("any-promise"),o=function(e){var t,r,o=new i(function(){t=arguments[0],r=arguments[1]});if(e)return{resolve:t,reject:r,eventEmitter:o};var a=new n;return o._events=a._events,o.emit=a.emit,o.on=a.on,o.once=a.once,o.off=a.off,o.listeners=a.listeners,o.addListener=a.addListener,o.removeListener=a.removeListener,o.removeAllListeners=a.removeAllListeners,{resolve:t,reject:r,eventEmitter:o}};o.resolve=function(e){var t=o(!0);return t.resolve(e),t.eventEmitter},t.exports=o},{"any-promise":2,eventemitter3:156}],341:[function(e,t,r){"use strict";var n=e("./jsonrpc"),i=e("web3-core-helpers").errors,o=function(e){this.requestManager=e,this.requests=[]};o.prototype.add=function(e){this.requests.push(e)},o.prototype.execute=function(){var e=this.requests;this.requestManager.sendBatch(e,function(t,r){r=r||[],e.map(function(e,t){return r[t]||{}}).forEach(function(t,r){if(e[r].callback){if(t&&t.error)return e[r].callback(i.ErrorResponse(t));if(!n.isValidResponse(t))return e[r].callback(i.InvalidResponse(t));try{e[r].callback(null,e[r].format?e[r].format(t.result):t.result)}catch(t){e[r].callback(t)}}})})},t.exports=o},{"./jsonrpc":344,"web3-core-helpers":338}],342:[function(e,t,r){"use strict";var n=null,i=window;void 0!==i.ethereumProvider?n=i.ethereumProvider:void 0!==i.web3&&i.web3.currentProvider&&(i.web3.currentProvider.sendAsync&&(i.web3.currentProvider.send=i.web3.currentProvider.sendAsync,delete i.web3.currentProvider.sendAsync),!i.web3.currentProvider.on&&i.web3.currentProvider.connection&&"ipcProviderWrapper"===i.web3.currentProvider.connection.constructor.name&&(i.web3.currentProvider.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.connection.on("data",function(e){var r="";e=e.toString();try{r=JSON.parse(e)}catch(r){return t(new Error("Couldn't parse response data"+e))}r.id||-1===r.method.indexOf("_subscription")||t(null,r)});break;default:this.connection.on(e,t)}}),n=i.web3.currentProvider),t.exports=n},{}],343:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("./jsonrpc.js"),a=e("./batch.js"),s=e("./givenProvider.js"),u=function e(t){this.provider=null,this.providers=e.providers,this.setProvider(t),this.subscriptions={}};u.givenProvider=s,u.providers={WebsocketProvider:e("web3-providers-ws"),HttpProvider:e("web3-providers-http"),IpcProvider:e("web3-providers-ipc")},u.prototype.setProvider=function(e,t){var r=this;if(e&&"string"==typeof e&&this.providers)if(/^http(s)?:\/\//i.test(e))e=new this.providers.HttpProvider(e);else if(/^ws(s)?:\/\//i.test(e))e=new this.providers.WebsocketProvider(e);else if(e&&"object"==typeof t&&"function"==typeof t.connect)e=new this.providers.IpcProvider(e,t);else if(e)throw new Error("Can't autodetect provider for \""+e+'"');this.provider&&this.provider.connected&&this.clearSubscriptions(),this.provider=e||null,this.provider&&this.provider.on&&this.provider.on("data",function(e,t){(e=e||t).method&&r.subscriptions[e.params.subscription]&&r.subscriptions[e.params.subscription].callback&&r.subscriptions[e.params.subscription].callback(null,e.params.result)})},u.prototype.send=function(e,t){if(t=t||function(){},!this.provider)return t(i.InvalidProvider());var r=o.toPayload(e.method,e.params);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,n){return n&&n.id&&r.id!==n.id?t(new Error('Wrong response id "'+n.id+'" (expected: "'+r.id+'") in '+JSON.stringify(r))):e?t(e):n&&n.error?t(i.ErrorResponse(n)):o.isValidResponse(n)?void t(null,n.result):t(i.InvalidResponse(n))})},u.prototype.sendBatch=function(e,t){if(!this.provider)return t(i.InvalidProvider());var r=o.toBatchPayload(e);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,r){return e?t(e):n.isArray(r)?void t(null,r):t(i.InvalidResponse(r))})},u.prototype.addSubscription=function(e,t,r,n){if(!this.provider.on)throw new Error("The provider doesn't support subscriptions: "+this.provider.constructor.name);this.subscriptions[e]={callback:n,type:r,name:t}},u.prototype.removeSubscription=function(e,t){this.subscriptions[e]&&(this.send({method:this.subscriptions[e].type+"_unsubscribe",params:[e]},t),delete this.subscriptions[e])},u.prototype.clearSubscriptions=function(e){var t=this;Object.keys(this.subscriptions).forEach(function(r){e&&"syncing"===t.subscriptions[r].name||t.removeSubscription(r)}),this.provider.reset&&this.provider.reset()},t.exports={Manager:u,BatchManager:a}},{"./batch.js":341,"./givenProvider.js":342,"./jsonrpc.js":344,underscore:325,"web3-core-helpers":338,"web3-providers-http":398,"web3-providers-ipc":399,"web3-providers-ws":400}],344:[function(e,t,r){"use strict";var n={messageId:0,toPayload:function(e,t){if(!e)throw new Error('JSONRPC method should be specified for params: "'+JSON.stringify(t)+'"!');return n.messageId++,{jsonrpc:"2.0",id:n.messageId,method:e,params:t||[]}},isValidResponse:function(e){return Array.isArray(e)?e.every(t):t(e);function t(e){return!(!e||e.error||"2.0"!==e.jsonrpc||"number"!=typeof e.id&&"string"!=typeof e.id||void 0===e.result)}},toBatchPayload:function(e){return e.map(function(e){return n.toPayload(e.method,e.params)})}};t.exports=n},{}],345:[function(e,t,r){"use strict";var n=e("./subscription.js"),i=function(e){this.name=e.name,this.type=e.type,this.subscriptions=e.subscriptions||{},this.requestManager=null};i.prototype.setRequestManager=function(e){this.requestManager=e},i.prototype.attachToObject=function(e){var t=this.buildCall(),r=this.name.split(".");r.length>1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},i.prototype.buildCall=function(){var e=this;return function(){e.subscriptions[arguments[0]]||console.warn("Subscription "+JSON.stringify(arguments[0])+" doesn't exist. Subscribing anyway.");var t=new n({subscription:e.subscriptions[arguments[0]],requestManager:e.requestManager,type:e.type});return t.subscribe.apply(t,arguments)}},t.exports={subscriptions:i,subscription:n}},{"./subscription.js":346}],346:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("eventemitter3");function a(e){o.call(this),this.id=null,this.callback=n.identity,this.arguments=null,this._reconnectIntervalId=null,this.options={subscription:e.subscription,type:e.type,requestManager:e.requestManager}}a.prototype=Object.create(o.prototype),a.prototype.constructor=a,a.prototype._extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},a.prototype._validateArgs=function(e){var t=this.options.subscription;if(t||(t={}),t.params||(t.params=0),e.length!==t.params)throw i.InvalidNumberOfParams(e.length,t.params+1,e[0])},a.prototype._formatInput=function(e){var t=this.options.subscription;return t&&t.inputFormatter?t.inputFormatter.map(function(t,r){return t?t(e[r]):e[r]}):e},a.prototype._formatOutput=function(e){var t=this.options.subscription;return t&&t.outputFormatter&&e?t.outputFormatter(e):e},a.prototype._toPayload=function(e){var t=[];if(this.callback=this._extractCallback(e)||n.identity,this.subscriptionMethod||(this.subscriptionMethod=e.shift(),this.options.subscription.subscriptionName&&(this.subscriptionMethod=this.options.subscription.subscriptionName)),this.arguments||(this.arguments=this._formatInput(e),this._validateArgs(this.arguments),e=[]),t.push(this.subscriptionMethod),t=t.concat(this.arguments),e.length)throw new Error("Only a callback is allowed as parameter on an already instantiated subscription.");return{method:this.options.type+"_subscribe",params:t}},a.prototype.unsubscribe=function(e){this.options.requestManager.removeSubscription(this.id,e),this.id=null,this.removeAllListeners(),clearInterval(this._reconnectIntervalId)},a.prototype.subscribe=function(){var e=this,t=Array.prototype.slice.call(arguments),r=this._toPayload(t);if(!r)return this;if(!this.options.requestManager.provider){var i=new Error("No provider set.");return this.callback(i,null,this),this.emit("error",i),this}if(!this.options.requestManager.provider.on){var o=new Error("The current provider doesn't support subscriptions: "+this.options.requestManager.provider.constructor.name);return this.callback(o,null,this),this.emit("error",o),this}return this.id&&this.unsubscribe(),this.options.params=r.params[1],"logs"===r.params[0]&&n.isObject(r.params[1])&&r.params[1].hasOwnProperty("fromBlock")&&isFinite(r.params[1].fromBlock)&&this.options.requestManager.send({method:"eth_getLogs",params:[r.params[1]]},function(t,r){t?(e.callback(t,null,e),e.emit("error",t)):r.forEach(function(t){var r=e._formatOutput(t);e.callback(null,r,e),e.emit("data",r)})}),"object"==typeof r.params[1]&&delete r.params[1].fromBlock,this.options.requestManager.send(r,function(t,i){!t&&i?(e.id=i,e.options.requestManager.addSubscription(e.id,r.params[0],e.options.type,function(t,r){t?(e.options.requestManager.removeSubscription(e.id),e.options.requestManager.provider.once&&(e._reconnectIntervalId=setInterval(function(){e.options.requestManager.provider.reconnect&&e.options.requestManager.provider.reconnect()},500),e.options.requestManager.provider.once("connect",function(){clearInterval(e._reconnectIntervalId),e.subscribe(e.callback)})),e.emit("error",t),e.callback(t,null,e)):(n.isArray(r)||(r=[r]),r.forEach(function(t){var r=e._formatOutput(t);if(n.isFunction(e.options.subscription.subscriptionHandler))return e.options.subscription.subscriptionHandler.call(e,r);e.emit("data",r),e.callback(null,r,e)}))})):(e.callback(t,null,e),e.emit("error",t))}),this},t.exports=a},{eventemitter3:156,underscore:325,"web3-core-helpers":338}],347:[function(e,t,r){"use strict";var n=e("web3-core-helpers").formatters,i=e("web3-core-method"),o=e("web3-utils");t.exports=function(e){var t=function(t){var r;return t.property?(e[t.property]||(e[t.property]={}),r=e[t.property]):r=e,t.methods&&t.methods.forEach(function(t){t instanceof i||(t=new i(t)),t.attachToObject(r),t.setRequestManager(e._requestManager)}),e};return t.formatters=n,t.utils=o,t.Method=i,t}},{"web3-core-helpers":338,"web3-core-method":339,"web3-utils":403}],348:[function(e,t,r){"use strict";var n=e("web3-core-requestmanager"),i=e("./extend.js");t.exports={packageInit:function(e,t){if(t=Array.prototype.slice.call(t),!e)throw new Error('You need to instantiate using the "new" keyword.');Object.defineProperty(e,"currentProvider",{get:function(){return e._provider},set:function(t){return e.setProvider(t)},enumerable:!0,configurable:!0}),t[0]&&t[0]._requestManager?e._requestManager=new n.Manager(t[0].currentProvider):(e._requestManager=new n.Manager,e._requestManager.setProvider(t[0],t[1])),e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers,e._provider=e._requestManager.provider,e.setProvider||(e.setProvider=function(t,r){return e._requestManager.setProvider(t,r),e._provider=e._requestManager.provider,!0}),e.BatchRequest=n.BatchManager.bind(null,e._requestManager),e.extend=i(e)},addProviders:function(e){e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers}}},{"./extend.js":347,"web3-core-requestmanager":343}],349:[function(e,t,r){var n=e("underscore"),i=e("web3-utils"),o=new(0,e("ethers/utils/abi-coder").AbiCoder)(function(e,t){return!e.match(/^u?int/)||n.isArray(t)||n.isObject(t)&&"BN"===t.constructor.name?t:t.toString()});function a(){}var s=function(){};s.prototype.encodeFunctionSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e).slice(0,10)},s.prototype.encodeEventSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e)},s.prototype.encodeParameter=function(e,t){return this.encodeParameters([e],[t])},s.prototype.encodeParameters=function(e,t){return o.encode(this.mapTypes(e),t)},s.prototype.mapTypes=function(e){var t=this,r=[];return e.forEach(function(e){if(t.isSimplifiedStructFormat(e)){var n=Object.keys(e)[0];r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}else r.push(e)}),r},s.prototype.isSimplifiedStructFormat=function(e){return"object"==typeof e&&void 0===e.components&&void 0===e.name},s.prototype.mapStructNameAndType=function(e){var t="tuple";return e.indexOf("[]")>-1&&(t="tuple[]",e=e.slice(0,-2)),{type:t,name:e}},s.prototype.mapStructToCoderFormat=function(e){var t=this,r=[];return Object.keys(e).forEach(function(n){"object"!=typeof e[n]?r.push({name:n,type:e[n]}):r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}),r},s.prototype.encodeFunctionCall=function(e,t){return this.encodeFunctionSignature(e)+this.encodeParameters(e.inputs,t).replace("0x","")},s.prototype.decodeParameter=function(e,t){return this.decodeParameters([e],t)[0]},s.prototype.decodeParameters=function(e,t){if(!t||"0x"===t||"0X"===t)throw new Error("Returned values aren't valid, did it run Out of Gas?");var r=o.decode(this.mapTypes(e),"0x"+t.replace(/0x/i,"")),i=new a;return i.__length__=0,e.forEach(function(e,t){var o=r[i.__length__];o="0x"===o?null:o,i[t]=o,n.isObject(e)&&e.name&&(i[e.name]=o),i.__length__++}),i},s.prototype.decodeLog=function(e,t,r){var i=this;r=n.isArray(r)?r:[r],t=t||"";var o=[],s=[],u=0;e.forEach(function(e,t){e.indexed?(s[t]=["bool","int","uint","address","fixed","ufixed"].find(function(t){return-1!==e.type.indexOf(t)})?i.decodeParameter(e.type,r[u]):r[u],u++):o[t]=e});var c=t,f=c?this.decodeParameters(o,c):[],h=new a;return h.__length__=0,e.forEach(function(e,t){h[t]="string"===e.type?"":null,void 0!==f[t]&&(h[t]=f[t]),void 0!==s[t]&&(h[t]=s[t]),e.name&&(h[e.name]=h[t]),h.__length__++}),h};var u=new s;t.exports=u},{"ethers/utils/abi-coder":143,underscore:325,"web3-utils":403}],350:[function(e,t,r){(function(r){var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=e("./bytes"),o=e("./nat"),a=e("elliptic"),s=(e("./rlp"),new a.ec("secp256k1")),u=e("./hash"),c=u.keccak256,f=u.keccak256s,h=function(e){for(var t=f(e.slice(2)),r="0x",n=0;n<40;n++)r+=parseInt(t[n+2],16)>7?e[n+2].toUpperCase():e[n+2];return r},l=function(e){var t=new r(e.slice(2),"hex"),n="0x"+s.keyFromPrivate(t).getPublic(!1,"hex").slice(2),i=c(n);return{address:h("0x"+i.slice(-40)),privateKey:e}},d=function(e){var t=n(e,3),r=t[0],o=i.pad(32,t[1]),a=i.pad(32,t[2]);return i.flatten([o,a,r])},p=function(e){return[i.slice(64,i.length(e),e),i.slice(0,32,e),i.slice(32,64,e)]},b=function(e){return function(t,n){var a=s.keyFromPrivate(new r(n.slice(2),"hex")).sign(new r(t.slice(2),"hex"),{canonical:!0});return d([o.fromString(i.fromNumber(e+a.recoveryParam)),i.pad(32,i.fromNat("0x"+a.r.toString(16))),i.pad(32,i.fromNat("0x"+a.s.toString(16)))])}},y=b(27);t.exports={create:function(e){var t=c(i.concat(i.random(32),e||i.random(32))),r=i.concat(i.concat(i.random(32),t),i.random(32)),n=c(r);return l(n)},toChecksum:h,fromPrivate:l,sign:y,makeSigner:b,recover:function(e,t){var n=p(t),o={v:i.toNumber(n[0]),r:n[1].slice(2),s:n[2].slice(2)},a="0x"+s.recoverPubKey(new r(e.slice(2),"hex"),o,o.v<2?o.v:1-o.v%2).encode("hex",!1).slice(2),u=c(a);return h("0x"+u.slice(-40))},encodeSignature:d,decodeSignature:p}}).call(this,e("buffer").Buffer)},{"./bytes":352,"./hash":353,"./nat":354,"./rlp":355,buffer:84,elliptic:109}],351:[function(e,t,r){arguments[4][132][0].apply(r,arguments)},{dup:132}],352:[function(e,t,r){arguments[4][133][0].apply(r,arguments)},{"./array.js":351,dup:133}],353:[function(e,t,r){arguments[4][134][0].apply(r,arguments)},{dup:134}],354:[function(e,t,r){var n=e("bn.js"),i=e("./bytes"),o=function(e){return new n(e.slice(2),16)},a=function(e){var t="0x"+("0x"===e.slice(0,2)?new n(e.slice(2),16):new n(e,10)).toString("hex");return"0x0"===t?"0x":t},s=function(e){return"string"==typeof e?/^0x/.test(e)?e:"0x"+e:"0x"+new n(e).toString("hex")},u=function(e){return o(e).toNumber()},c=function(e){return function(t,r){return"0x"+o(t)[e](o(r)).toString("hex")}},f=c("add"),h=c("mul"),l=c("div"),d=c("sub");t.exports={toString:function(e){return o(e).toString(10)},fromString:a,toNumber:u,fromNumber:s,toEther:function(e){return u(l(e,a("10000000000")))/1e8},fromEther:function(e){return h(s(Math.floor(1e8*e)),a("10000000000"))},toUint256:function(e){return i.pad(32,e)},add:f,mul:h,div:l,sub:d}},{"./bytes":352,"bn.js":53}],355:[function(e,t,r){t.exports={encode:function(e){var t=function(e){return(t=e.toString(16)).length%2==0?t:"0"+t;var t},r=function(e,r){return e<56?t(r+e):t(r+t(e).length/2+55)+t(e)};return"0x"+function e(t){if("string"==typeof t){var n=t.slice(2);return(2!=n.length||n>="80"?r(n.length/2,128):"")+n}var i=t.map(e).join("");return r(i.length/2,192)+i}(e)},decode:function(e){var t=2,r=function(){if(t>=e.length)throw"";var r=e.slice(t,t+2);return r<"80"?(t+=2,"0x"+r):r<"c0"?i():o()},n=function(){var r=parseInt(e.slice(t,t+=2),16)%64;return r<56?r:parseInt(e.slice(t,t+=2*(r-55)),16)},i=function(){var r=n();return"0x"+e.slice(t,t+=2*r)},o=function(){for(var e=2*n()+t,i=[];t>>((3&t)<<3)&255;return i}}t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],357:[function(e,t,r){for(var n=e("./rng"),i=[],o={},a=0;a<256;a++)i[a]=(a+256).toString(16).substr(1),o[i[a]]=a;function s(e,t){var r=t||0,n=i;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var u=n(),c=[1|u[0],u[1],u[2],u[3],u[4],u[5]],f=16383&(u[6]<<8|u[7]),h=0,l=0;function d(e,t,r){var i=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||n)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var a=0;a<16;a++)t[i+a]=o[a];return t||s(o)}var p=d;p.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:f,a=void 0!==e.msecs?e.msecs:(new Date).getTime(),u=void 0!==e.nsecs?e.nsecs:l+1,d=a-h+(u-l)/1e4;if(d<0&&void 0===e.clockseq&&(o=o+1&16383),(d<0||a>h)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");h=a,l=u,f=o;var p=(1e4*(268435455&(a+=122192928e5))+u)%4294967296;i[n++]=p>>>24&255,i[n++]=p>>>16&255,i[n++]=p>>>8&255,i[n++]=255&p;var b=a/4294967296*1e4&268435455;i[n++]=b>>>8&255,i[n++]=255&b,i[n++]=b>>>24&15|16,i[n++]=b>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var y=e.node||c,m=0;m<6;m++)i[n+m]=y[m];return t||s(i)},p.v4=d,p.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=o[e])});i<16;)t[n+i++]=0;return t},p.unparse=s,t.exports=p},{"./rng":356}],358:[function(e,t,r){(function(r,n){"use strict";var i=e("underscore"),o=e("web3-core"),a=e("web3-core-method"),s=e("any-promise"),u=e("eth-lib/lib/account"),c=e("eth-lib/lib/hash"),f=e("eth-lib/lib/rlp"),h=e("eth-lib/lib/nat"),l=e("eth-lib/lib/bytes"),d=e(void 0===r?"crypto-browserify":"crypto"),p=e("scrypt.js"),b=e("uuid"),y=e("web3-utils"),m=e("web3-core-helpers"),v=function(e){return i.isUndefined(e)||i.isNull(e)},g=function(e){for(;e&&e.startsWith("0x0");)e="0x"+e.slice(3);return e},w=function(e){return e.length%2==1&&(e=e.replace("0x","0x0")),e},_=function(){var e=this;o.packageInit(this,arguments),delete this.BatchRequest,delete this.extend;var t=[new a({name:"getId",call:"net_version",params:0,outputFormatter:y.hexToNumber}),new a({name:"getGasPrice",call:"eth_gasPrice",params:0}),new a({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[function(e){if(y.isAddress(e))return e;throw new Error("Address "+e+' is not a valid address to get the "transactionCount".')},function(){return"latest"}]})];this._ethereumCall={},i.each(t,function(t){t.attachToObject(e._ethereumCall),t.setRequestManager(e._requestManager)}),this.wallet=new A(this)};function A(e){this._accounts=e,this.length=0,this.defaultKeyName="web3js_wallet"}_.prototype._addAccountFunctions=function(e){var t=this;return e.signTransaction=function(r,n){return t.signTransaction(r,e.privateKey,n)},e.sign=function(r){return t.sign(r,e.privateKey)},e.encrypt=function(r,n){return t.encrypt(e.privateKey,r,n)},e},_.prototype.create=function(e){return this._addAccountFunctions(u.create(e||y.randomHex(32)))},_.prototype.privateKeyToAccount=function(e){return this._addAccountFunctions(u.fromPrivate(e))},_.prototype.signTransaction=function(e,t,r){var n,o=!1;if(r=r||function(){},!e)return o=new Error("No transaction object given!"),r(o),s.reject(o);function a(e){if(e.gas||e.gasLimit||(o=new Error('"gas" is missing')),(e.nonce<0||e.gas<0||e.gasPrice<0||e.chainId<0)&&(o=new Error("Gas, gasPrice, nonce or chainId is lower than 0")),o)return r(o),s.reject(o);try{var i=e=m.formatters.inputCallFormatter(e);i.to=e.to||"0x",i.data=e.data||"0x",i.value=e.value||"0x",i.chainId=y.numberToHex(e.chainId);var a=f.encode([l.fromNat(i.nonce),l.fromNat(i.gasPrice),l.fromNat(i.gas),i.to.toLowerCase(),l.fromNat(i.value),i.data,l.fromNat(i.chainId||"0x1"),"0x","0x"]),d=c.keccak256(a),p=u.makeSigner(2*h.toNumber(i.chainId||"0x1")+35)(c.keccak256(a),t),b=f.decode(a).slice(0,6).concat(u.decodeSignature(p));b[6]=w(g(b[6])),b[7]=w(g(b[7])),b[8]=w(g(b[8]));var v=f.encode(b),_=f.decode(v);n={messageHash:d,v:g(_[6]),r:g(_[7]),s:g(_[8]),rawTransaction:v}}catch(e){return r(e),s.reject(e)}return r(null,n),n}return void 0!==e.nonce&&void 0!==e.chainId&&void 0!==e.gasPrice?s.resolve(a(e)):s.all([v(e.chainId)?this._ethereumCall.getId():e.chainId,v(e.gasPrice)?this._ethereumCall.getGasPrice():e.gasPrice,v(e.nonce)?this._ethereumCall.getTransactionCount(this.privateKeyToAccount(t).address):e.nonce]).then(function(t){if(v(t[0])||v(t[1])||v(t[2]))throw new Error('One of the values "chainId", "gasPrice", or "nonce" couldn\'t be fetched: '+JSON.stringify(t));return a(i.extend(e,{chainId:t[0],gasPrice:t[1],nonce:t[2]}))})},_.prototype.recoverTransaction=function(e){var t=f.decode(e),r=u.encodeSignature(t.slice(6,9)),n=l.toNumber(t[6]),i=n<35?[]:[l.fromNumber(n-35>>1),"0x","0x"],o=t.slice(0,6).concat(i),a=f.encode(o);return u.recover(c.keccak256(a),r)},_.prototype.hashMessage=function(e){var t=y.isHexStrict(e)?y.hexToBytes(e):e,r=n.from(t),i="Ethereum Signed Message:\n"+t.length,o=n.from(i),a=n.concat([o,r]);return c.keccak256s(a)},_.prototype.sign=function(e,t){var r=this.hashMessage(e),n=u.sign(r,t),i=u.decodeSignature(n);return{message:e,messageHash:r,v:i[0],r:i[1],s:i[2],signature:n}},_.prototype.recover=function(e,t,r){var n=[].slice.apply(arguments);return i.isObject(e)?this.recover(e.messageHash,u.encodeSignature([e.v,e.r,e.s]),!0):(r||(e=this.hashMessage(e)),n.length>=4?(r=n.slice(-1)[0],r=!!i.isBoolean(r)&&!!r,this.recover(e,u.encodeSignature(n.slice(1,4)),r)):u.recover(e,t))},_.prototype.decrypt=function(e,t,r){if(!i.isString(t))throw new Error("No password given.");var o,a,s=i.isObject(e)?e:JSON.parse(r?e.toLowerCase():e);if(3!==s.version)throw new Error("Not a valid V3 wallet");if("scrypt"===s.crypto.kdf)a=s.crypto.kdfparams,o=p(new n(t),new n(a.salt,"hex"),a.n,a.r,a.p,a.dklen);else{if("pbkdf2"!==s.crypto.kdf)throw new Error("Unsupported key derivation scheme");if("hmac-sha256"!==(a=s.crypto.kdfparams).prf)throw new Error("Unsupported parameters to PBKDF2");o=d.pbkdf2Sync(new n(t),new n(a.salt,"hex"),a.c,a.dklen,"sha256")}var u=new n(s.crypto.ciphertext,"hex");if(y.sha3(n.concat([o.slice(16,32),u])).replace("0x","")!==s.crypto.mac)throw new Error("Key derivation failed - possibly wrong password");var c=d.createDecipheriv(s.crypto.cipher,o.slice(0,16),new n(s.crypto.cipherparams.iv,"hex")),f="0x"+n.concat([c.update(u),c.final()]).toString("hex");return this.privateKeyToAccount(f)},_.prototype.encrypt=function(e,t,r){var i,o=this.privateKeyToAccount(e),a=(r=r||{}).salt||d.randomBytes(32),s=r.iv||d.randomBytes(16),u=r.kdf||"scrypt",c={dklen:r.dklen||32,salt:a.toString("hex")};if("pbkdf2"===u)c.c=r.c||262144,c.prf="hmac-sha256",i=d.pbkdf2Sync(new n(t),a,c.c,c.dklen,"sha256");else{if("scrypt"!==u)throw new Error("Unsupported kdf");c.n=r.n||8192,c.r=r.r||8,c.p=r.p||1,i=p(new n(t),a,c.n,c.r,c.p,c.dklen)}var f=d.createCipheriv(r.cipher||"aes-128-ctr",i.slice(0,16),s);if(!f)throw new Error("Unsupported cipher");var h=n.concat([f.update(new n(o.privateKey.replace("0x",""),"hex")),f.final()]),l=y.sha3(n.concat([i.slice(16,32),new n(h,"hex")])).replace("0x","");return{version:3,id:b.v4({random:r.uuid||d.randomBytes(16)}),address:o.address.toLowerCase().replace("0x",""),crypto:{ciphertext:h.toString("hex"),cipherparams:{iv:s.toString("hex")},cipher:r.cipher||"aes-128-ctr",kdf:u,kdfparams:c,mac:l.toString("hex")}}},A.prototype._findSafeIndex=function(e){return e=e||0,i.has(this,e)?this._findSafeIndex(e+1):e},A.prototype._currentIndexes=function(){return Object.keys(this).map(function(e){return parseInt(e)}).filter(function(e){return e<9e20})},A.prototype.create=function(e,t){for(var r=0;r=2?t.slice(2):t;var r=h.decodeParameters(e,t);return 1===r.__length__?r[0]:(delete r.__length__,r)},l.prototype.deploy=function(e,t){if((e=e||{}).arguments=e.arguments||[],!(e=this._getOrSetDefaultOptions(e)).data)return a._fireError(new Error('No "data" specified in neither the given options, nor the default options.'),null,null,t);var r=n.find(this.options.jsonInterface,function(e){return"constructor"===e.type})||{};return r.signature="constructor",this._createTxObject.apply({method:r,parent:this,deployData:e.data,_ethAccounts:this.constructor._ethAccounts},e.arguments)},l.prototype._generateEventOptions=function(){var e=Array.prototype.slice.call(arguments),t=this._getCallback(e),r=n.isObject(e[e.length-1])?e.pop():{},i=n.isString(e[0])?e[0]:"allevents";if(!(i="allevents"===i.toLowerCase()?{name:"ALLEVENTS",jsonInterface:this.options.jsonInterface}:this.options.jsonInterface.find(function(e){return"event"===e.type&&(e.name===i||e.signature==="0x"+i.replace("0x",""))})))throw new Error('Event "'+i.name+"\" doesn't exist in this contract.");if(!a.isAddress(this.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return{params:this._encodeEventABI(i,r),event:i,callback:t}},l.prototype.clone=function(){return new this.constructor(this.options.jsonInterface,this.options.address,this.options)},l.prototype.once=function(e,t,r){var i=Array.prototype.slice.call(arguments);if(!(r=this._getCallback(i)))throw new Error("Once requires a callback as the second parameter.");t&&delete t.fromBlock,this._on(e,t,function(e,t,i){i.unsubscribe(),n.isFunction(r)&&r(e,t,i)})},l.prototype._on=function(){var e=this._generateEventOptions.apply(this,arguments);this._checkListener("newListener",e.event.name,e.callback),this._checkListener("removeListener",e.event.name,e.callback);var t=new s({subscription:{params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event),subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},type:"eth",requestManager:this._requestManager});return t.subscribe("logs",e.params,e.callback||function(){}),t},l.prototype.getPastEvents=function(){var e=this._generateEventOptions.apply(this,arguments),t=new o({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event)});t.setRequestManager(this._requestManager);var r=t.buildCall();return t=null,r(e.params,e.callback)},l.prototype._createTxObject=function(){var e=Array.prototype.slice.call(arguments),t={};if("function"===this.method.type&&(t.call=this.parent._executeMethod.bind(t,"call"),t.call.request=this.parent._executeMethod.bind(t,"call",!0)),t.send=this.parent._executeMethod.bind(t,"send"),t.send.request=this.parent._executeMethod.bind(t,"send",!0),t.encodeABI=this.parent._encodeMethodABI.bind(t),t.estimateGas=this.parent._executeMethod.bind(t,"estimate"),e&&this.method.inputs&&e.length!==this.method.inputs.length){if(this.nextMethod)return this.nextMethod.apply(null,e);throw c.InvalidNumberOfParams(e.length,this.method.inputs.length,this.method.name)}return t.arguments=e||[],t._method=this.method,t._parent=this.parent,t._ethAccounts=this.parent.constructor._ethAccounts||this._ethAccounts,this.deployData&&(t._deployData=this.deployData),t},l.prototype._processExecuteArguments=function(e,t){var r={};if(r.type=e.shift(),r.callback=this._parent._getCallback(e),"call"===r.type&&!0!==e[e.length-1]&&(n.isString(e[e.length-1])||isFinite(e[e.length-1]))&&(r.defaultBlock=e.pop()),r.options=n.isObject(e[e.length-1])?e.pop():{},r.generateRequest=!0===e[e.length-1]&&e.pop(),r.options=this._parent._getOrSetDefaultOptions(r.options),r.options.data=this.encodeABI(),!this._deployData&&!a.isAddress(this._parent.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return this._deployData||(r.options.to=this._parent.options.address),r.options.data?r:a._fireError(new Error("Couldn't find a matching contract method, or the number of parameters is wrong."),t.eventEmitter,t.reject,r.callback)},l.prototype._executeMethod=function(){var e=this,t=this._parent._processExecuteArguments.call(this,Array.prototype.slice.call(arguments),r),r=f("send"!==t.type),i=e.constructor._ethAccounts||e._ethAccounts;if(t.generateRequest){var s={params:[u.inputCallFormatter.call(this._parent,t.options)],callback:t.callback};return"call"===t.type?(s.params.push(u.inputDefaultBlockNumberFormatter.call(this._parent,t.defaultBlock)),s.method="eth_call",s.format=this._parent._decodeMethodReturn.bind(null,this._method.outputs)):s.method="eth_sendTransaction",s}switch(t.type){case"estimate":return new o({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[u.inputCallFormatter],outputFormatter:a.hexToNumber,requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.callback);case"call":return new o({name:"call",call:"eth_call",params:2,inputFormatter:[u.inputCallFormatter,u.inputDefaultBlockNumberFormatter],outputFormatter:function(t){return e._parent._decodeMethodReturn(e._method.outputs,t)},requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.defaultBlock,t.callback);case"send":if(!a.isAddress(t.options.from))return a._fireError(new Error('No "from" address specified in neither the given options, nor the default options.'),r.eventEmitter,r.reject,t.callback);if(n.isBoolean(this._method.payable)&&!this._method.payable&&t.options.value&&t.options.value>0)return a._fireError(new Error("Can not send value to non-payable contract method or constructor"),r.eventEmitter,r.reject,t.callback);var c={receiptFormatter:function(t){if(n.isArray(t.logs)){var r=n.map(t.logs,function(t){return e._parent._decodeEventABI.call({name:"ALLEVENTS",jsonInterface:e._parent.options.jsonInterface},t)});t.events={};var i=0;r.forEach(function(e){e.event?t.events[e.event]?Array.isArray(t.events[e.event])?t.events[e.event].push(e):t.events[e.event]=[t.events[e.event],e]:t.events[e.event]=e:(t.events[i]=e,i++)}),delete t.logs}return t},contractDeployFormatter:function(t){var r=e._parent.clone();return r.options.address=t.contractAddress,r}};return new o({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[u.inputTransactionFormatter],requestManager:e._parent._requestManager,accounts:e.constructor._ethAccounts||e._ethAccounts,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock,extraFormatters:c}).createFunction()(t.options,t.callback)}},t.exports=l},{underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-utils":403}],360:[function(e,t,r){"use strict";var n=e("./config"),i=e("./contracts/Registry"),o=e("./lib/ResolverMethodHandler");function a(e){this.eth=e}Object.defineProperty(a.prototype,"registry",{get:function(){return new i(this)},enumerable:!0}),Object.defineProperty(a.prototype,"resolverMethodHandler",{get:function(){return new o(this.registry)},enumerable:!0}),a.prototype.resolver=function(e){return this.registry.resolver(e)},a.prototype.getAddress=function(e,t){return this.resolverMethodHandler.method(e,"addr",[]).call(t)},a.prototype.setAddress=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setAddr",[t]).send(r,n)},a.prototype.getPubkey=function(e,t){return this.resolverMethodHandler.method(e,"pubkey",[],t).call(t)},a.prototype.setPubkey=function(e,t,r,n,i){return this.resolverMethodHandler.method(e,"setPubkey",[t,r]).send(n,i)},a.prototype.getContent=function(e,t){return this.resolverMethodHandler.method(e,"content",[]).call(t)},a.prototype.setContent=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setContent",[t]).send(r,n)},a.prototype.getMultihash=function(e,t){return this.resolverMethodHandler.method(e,"multihash",[]).call(t)},a.prototype.setMultihash=function(e,t,r,n){return this.resolverMethodHandler.method(e,"multihash",[t]).send(r,n)},a.prototype.checkNetwork=function(){var e=this;return e.eth.getBlock("latest").then(function(t){var r=new Date/1e3-t.timestamp;if(r>3600)throw new Error("Network not synced; last block was "+r+" seconds ago");return e.eth.net.getNetworkType()}).then(function(e){var t=n.addresses[e];if(void 0===t)throw new Error("ENS is not supported on network "+e);return t})},t.exports=a},{"./config":361,"./contracts/Registry":362,"./lib/ResolverMethodHandler":364}],361:[function(e,t,r){"use strict";t.exports={addresses:{main:"0x314159265dD8dbb310642f98f50C066173C1259b",ropsten:"0x112234455c3a32fd11230c42e7bccd4a84e02010",rinkeby:"0xe7410170f87102df0055eb195163a03b7f2bff4a"}}},{}],362:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-eth-contract"),o=e("eth-ens-namehash"),a=e("web3-core-promievent"),s=e("../ressources/ABI/Registry"),u=e("../ressources/ABI/Resolver");function c(e){var t=this;this.ens=e,this.contract=e.checkNetwork().then(function(e){var r=new i(s,e);return r.setProvider(t.ens.eth.currentProvider),r})}c.prototype.owner=function(e,t){var r=new a(!0);return this.contract.then(function(i){i.methods.owner(o.hash(e)).call().then(function(e){r.resolve(e),n.isFunction(t)&&t(e)}).catch(function(e){r.reject(e),n.isFunction(t)&&t(e)})}),r.eventEmitter},c.prototype.resolver=function(e){var t=this;return this.contract.then(function(t){return t.methods.resolver(o.hash(e)).call()}).then(function(e){var r=new i(u,e);return r.setProvider(t.ens.eth.currentProvider),r})},t.exports=c},{"../ressources/ABI/Registry":365,"../ressources/ABI/Resolver":366,"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340,"web3-eth-contract":359}],363:[function(e,t,r){"use strict";var n=e("./ENS");t.exports=n},{"./ENS":360}],364:[function(e,t,r){"use strict";var n=e("web3-core-promievent"),i=e("eth-ens-namehash"),o=e("underscore");function a(e){this.registry=e}a.prototype.method=function(e,t,r,n){return{call:this.call.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this}),send:this.send.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this})}},a.prototype.call=function(e){var t=this,r=new n,i=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){t.parent.handleCall(r,n.methods[t.methodName],i,e)}).catch(function(e){r.reject(e)}),r.eventEmitter},a.prototype.send=function(e,t){var r=this,i=new n,o=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){r.parent.handleSend(i,n.methods[r.methodName],o,e,t)}).catch(function(e){i.reject(e)}),i.eventEmitter},a.prototype.handleCall=function(e,t,r,n){return t.apply(this,r).call().then(function(t){e.resolve(t),o.isFunction(n)&&n(t)}).catch(function(t){e.reject(t),o.isFunction(n)&&n(t)}),e},a.prototype.handleSend=function(e,t,r,n,i){return t.apply(this,r).send(n).on("transactionHash",function(t){e.eventEmitter.emit("transactionHash",t)}).on("confirmation",function(t,r){e.eventEmitter.emit("confirmation",t,r)}).on("receipt",function(t){e.eventEmitter.emit("receipt",t),e.resolve(t),o.isFunction(i)&&i(t)}).on("error",function(t){e.eventEmitter.emit("error",t),e.reject(t),o.isFunction(i)&&i(t)}),e},a.prototype.prepareArguments=function(e,t){var r=i.hash(e);return t.length>0?(t.unshift(r),t):[r]},t.exports=a},{"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340}],365:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"resolver",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"owner",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"label",type:"bytes32"},{name:"owner",type:"address"}],name:"setSubnodeOwner",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"ttl",type:"uint64"}],name:"setTTL",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"ttl",outputs:[{name:"",type:"uint64"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"resolver",type:"address"}],name:"setResolver",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"owner",type:"address"}],name:"setOwner",outputs:[],payable:!1,type:"function"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"label",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"NewOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"resolver",type:"address"}],name:"NewResolver",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"ttl",type:"uint64"}],name:"NewTTL",type:"event"}]},{}],366:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"interfaceID",type:"bytes4"}],name:"supportsInterface",outputs:[{name:"",type:"bool"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"},{name:"contentTypes",type:"uint256"}],name:"ABI",outputs:[{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes"}],name:"setMultihash",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"multihash",outputs:[{name:"",type:"bytes"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"setPubkey",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"content",outputs:[{name:"ret",type:"bytes32"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"addr",outputs:[{name:"ret",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],name:"setABI",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"name",outputs:[{name:"ret",type:"string"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"name",type:"string"}],name:"setName",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes32"}],name:"setContent",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"pubkey",outputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"addr",type:"address"}],name:"setAddr",outputs:[],payable:!1,type:"function"},{inputs:[{name:"ensAddr",type:"address"}],payable:!1,type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"a",type:"address"}],name:"AddrChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"hash",type:"bytes32"}],name:"ContentChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"name",type:"string"}],name:"NameChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"contentType",type:"uint256"}],name:"ABIChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"x",type:"bytes32"},{indexed:!1,name:"y",type:"bytes32"}],name:"PubkeyChanged",type:"event"}]},{}],367:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],368:[function(e,t,r){"use strict";var n=e("web3-utils"),i=e("bn.js"),o=function(e){var t="A".charCodeAt(0),r="Z".charCodeAt(0);return(e=(e=e.toUpperCase()).substr(4)+e.substr(0,4)).split("").map(function(e){var n=e.charCodeAt(0);return n>=t&&n<=r?n-t+10:e}).join("")},a=function(e){for(var t,r=e;r.length>2;)t=r.slice(0,9),r=parseInt(t,10)%97+r.slice(t.length);return parseInt(r,10)%97},s=function(e){this._iban=e};s.toAddress=function(e){if(!(e=new s(e)).isDirect())throw new Error("IBAN is indirect and can't be converted");return e.toAddress()},s.toIban=function(e){return s.fromAddress(e).toString()},s.fromAddress=function(e){if(!n.isAddress(e))throw new Error("Provided address is not a valid address: "+e);e=e.replace("0x","").replace("0X","");var t=function(e,t){for(var r=e;r.length<2*t;)r="0"+r;return r}(new i(e,16).toString(36),15);return s.fromBban(t.toUpperCase())},s.fromBban=function(e){var t=("0"+(98-a(o("XE00"+e)))).slice(-2);return new s("XE"+t+e)},s.createIndirect=function(e){return s.fromBban("ETH"+e.institution+e.identifier)},s.isValid=function(e){return new s(e).isValid()},s.prototype.isValid=function(){return/^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban)&&1===a(o(this._iban))},s.prototype.isDirect=function(){return 34===this._iban.length||35===this._iban.length},s.prototype.isIndirect=function(){return 20===this._iban.length},s.prototype.checksum=function(){return this._iban.substr(2,2)},s.prototype.institution=function(){return this.isIndirect()?this._iban.substr(7,4):""},s.prototype.client=function(){return this.isIndirect()?this._iban.substr(11):""},s.prototype.toAddress=function(){if(this.isDirect()){var e=this._iban.substr(4),t=new i(e,36);return n.toChecksumAddress(t.toString(16,20))}return""},s.prototype.toString=function(){return this._iban},t.exports=s},{"bn.js":367,"web3-utils":403}],369:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=e("web3-net"),s=e("web3-core-helpers").formatters,u=function(){var e=this;n.packageInit(this,arguments),this.net=new a(this.currentProvider);var t=null,r="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return t},set:function(e){return e&&(t=o.toChecksumAddress(s.inputAddressFormatter(e))),u.forEach(function(e){e.defaultAccount=t}),e},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return r},set:function(e){return r=e,u.forEach(function(e){e.defaultBlock=r}),e},enumerable:!0});var u=[new i({name:"getAccounts",call:"personal_listAccounts",params:0,outputFormatter:o.toChecksumAddress}),new i({name:"newAccount",call:"personal_newAccount",params:1,inputFormatter:[null],outputFormatter:o.toChecksumAddress}),new i({name:"unlockAccount",call:"personal_unlockAccount",params:3,inputFormatter:[s.inputAddressFormatter,null,null]}),new i({name:"lockAccount",call:"personal_lockAccount",params:1,inputFormatter:[s.inputAddressFormatter]}),new i({name:"importRawKey",call:"personal_importRawKey",params:2}),new i({name:"sendTransaction",call:"personal_sendTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"signTransaction",call:"personal_signTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"sign",call:"personal_sign",params:3,inputFormatter:[s.inputSignFormatter,s.inputAddressFormatter,null]}),new i({name:"ecRecover",call:"personal_ecRecover",params:2,inputFormatter:[s.inputSignFormatter,null]})];u.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};n.addProviders(u),t.exports=u},{"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-net":372,"web3-utils":403}],370:[function(e,t,r){"use strict";var n=e("underscore");t.exports=function(e){var t,r=this;return this.net.getId().then(function(e){return t=e,r.getBlock(0)}).then(function(r){var i="private";return"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"===r.hash&&1===t&&(i="main"),"0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303"===r.hash&&2===t&&(i="morden"),"0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"===r.hash&&3===t&&(i="ropsten"),"0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177"===r.hash&&4===t&&(i="rinkeby"),"0xa3c565fc15c7478862d50ccd6561e3c06b24cc509bf388941c25ea985ce32cb9"===r.hash&&42===t&&(i="kovan"),n.isFunction(e)&&e(null,i),i}).catch(function(t){if(!n.isFunction(e))throw t;e(t)})}},{underscore:325}],371:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core"),o=e("web3-core-helpers"),a=e("web3-core-subscriptions").subscriptions,s=e("web3-core-method"),u=e("web3-utils"),c=e("web3-net"),f=e("web3-eth-ens"),h=e("web3-eth-personal"),l=e("web3-eth-contract"),d=e("web3-eth-iban"),p=e("web3-eth-accounts"),b=e("web3-eth-abi"),y=e("./getNetworkType.js"),m=o.formatters,v=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},g=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},w=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},_=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},A=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"},E=function(){var e=this;i.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments),e.personal.setProvider.apply(e,arguments),e.accounts.setProvider.apply(e,arguments),e.Contract.setProvider(e.currentProvider,e.accounts)};var r=null,o="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return r},set:function(t){return t&&(r=u.toChecksumAddress(m.inputAddressFormatter(t))),e.Contract.defaultAccount=r,e.personal.defaultAccount=r,k.forEach(function(e){e.defaultAccount=r}),t},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return o},set:function(t){return o=t,e.Contract.defaultBlock=o,e.personal.defaultBlock=o,k.forEach(function(e){e.defaultBlock=o}),t},enumerable:!0}),this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new c(this.currentProvider),this.net.getNetworkType=y.bind(this),this.accounts=new p(this.currentProvider),this.personal=new h(this.currentProvider),this.personal.defaultAccount=this.defaultAccount;var E=this,x=function(){l.apply(this,arguments);var e=this,t=E.setProvider;E.setProvider=function(){t.apply(E,arguments),i.packageInit(e,[E.currentProvider])}};x.setProvider=function(){l.setProvider.apply(this,arguments)},(x.prototype=Object.create(l.prototype)).constructor=x,this.Contract=x,this.Contract.defaultAccount=this.defaultAccount,this.Contract.defaultBlock=this.defaultBlock,this.Contract.setProvider(this.currentProvider,this.accounts),this.Iban=d,this.abi=b,this.ens=new f(this);var k=[new s({name:"getNodeInfo",call:"web3_clientVersion"}),new s({name:"getProtocolVersion",call:"eth_protocolVersion",params:0}),new s({name:"getCoinbase",call:"eth_coinbase",params:0}),new s({name:"isMining",call:"eth_mining",params:0}),new s({name:"getHashrate",call:"eth_hashrate",params:0,outputFormatter:u.hexToNumber}),new s({name:"isSyncing",call:"eth_syncing",params:0,outputFormatter:m.outputSyncingFormatter}),new s({name:"getGasPrice",call:"eth_gasPrice",params:0,outputFormatter:m.outputBigNumberFormatter}),new s({name:"getAccounts",call:"eth_accounts",params:0,outputFormatter:u.toChecksumAddress}),new s({name:"getBlockNumber",call:"eth_blockNumber",params:0,outputFormatter:u.hexToNumber}),new s({name:"getBalance",call:"eth_getBalance",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:m.outputBigNumberFormatter}),new s({name:"getStorageAt",call:"eth_getStorageAt",params:3,inputFormatter:[m.inputAddressFormatter,u.numberToHex,m.inputDefaultBlockNumberFormatter]}),new s({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"getBlock",call:v,params:2,inputFormatter:[m.inputBlockNumberFormatter,function(e){return!!e}],outputFormatter:m.outputBlockFormatter}),new s({name:"getUncle",call:w,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputBlockFormatter}),new s({name:"getBlockTransactionCount",call:_,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getBlockUncleCount",call:A,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getTransaction",call:"eth_getTransactionByHash",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionFromBlock",call:g,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionReceiptFormatter}),new s({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"sendSignedTransaction",call:"eth_sendRawTransaction",params:1,inputFormatter:[null]}),new s({name:"signTransaction",call:"eth_signTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sign",call:"eth_sign",params:2,inputFormatter:[m.inputSignFormatter,m.inputAddressFormatter],transformPayload:function(e){return e.params.reverse(),e}}),new s({name:"call",call:"eth_call",params:2,inputFormatter:[m.inputCallFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[m.inputCallFormatter],outputFormatter:u.hexToNumber}),new s({name:"submitWork",call:"eth_submitWork",params:3}),new s({name:"getWork",call:"eth_getWork",params:0}),new s({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter}),new a({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:m.outputBlockFormatter},pendingTransactions:{subscriptionName:"newPendingTransactions",params:0},logs:{params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter,subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},syncing:{params:0,outputFormatter:m.outputSyncingFormatter,subscriptionHandler:function(e){var t=this;!0!==this._isSyncing?(this._isSyncing=!0,this.emit("changed",t._isSyncing),n.isFunction(this.callback)&&this.callback(null,t._isSyncing,this),setTimeout(function(){t.emit("data",e),n.isFunction(t.callback)&&t.callback(null,e,t)},0)):(this.emit("data",e),n.isFunction(t.callback)&&this.callback(null,e,this),clearTimeout(this._isSyncingTimeout),this._isSyncingTimeout=setTimeout(function(){e.currentBlock>e.highestBlock-200&&(t._isSyncing=!1,t.emit("changed",t._isSyncing),n.isFunction(t.callback)&&t.callback(null,t._isSyncing,t))},500))}}}})];k.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager,e.accounts),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};i.addProviders(E),t.exports=E},{"./getNetworkType.js":370,underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-eth-accounts":358,"web3-eth-contract":359,"web3-eth-ens":363,"web3-eth-iban":368,"web3-eth-personal":369,"web3-net":372,"web3-utils":403}],372:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=function(){var e=this;n.packageInit(this,arguments),[new i({name:"getId",call:"net_version",params:0,outputFormatter:o.hexToNumber}),new i({name:"isListening",call:"net_listening",params:0}),new i({name:"getPeerCount",call:"net_peerCount",params:0,outputFormatter:o.hexToNumber})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(a),t.exports=a},{"web3-core":348,"web3-core-method":339,"web3-utils":403}],373:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits,o=e("ethereumjs-util"),a=e("eth-block-tracker"),s=e("async/map"),u=e("async/eachSeries"),c=e("./util/stoplight.js");e("./util/rpc-cache-utils.js"),e("./util/create-payload.js");function f(e){const t=this;n.call(t),t.setMaxListeners(30),e=e||{};const r={sendAsync:t._handleAsync.bind(t)},i=e.blockTrackerProvider||r;t._blockTracker=e.blockTracker||new a({provider:i,pollingInterval:e.pollingInterval||4e3}),t._blockTracker.on("block",e=>{const r=function(e){return{number:o.toBuffer(e.number),hash:o.toBuffer(e.hash),parentHash:o.toBuffer(e.parentHash),nonce:o.toBuffer(e.nonce),mixHash:o.toBuffer(e.mixHash),sha3Uncles:o.toBuffer(e.sha3Uncles),logsBloom:o.toBuffer(e.logsBloom),transactionsRoot:o.toBuffer(e.transactionsRoot),stateRoot:o.toBuffer(e.stateRoot),receiptsRoot:o.toBuffer(e.receiptRoot||e.receiptsRoot),miner:o.toBuffer(e.miner),difficulty:o.toBuffer(e.difficulty),totalDifficulty:o.toBuffer(e.totalDifficulty),size:o.toBuffer(e.size),extraData:o.toBuffer(e.extraData),gasLimit:o.toBuffer(e.gasLimit),gasUsed:o.toBuffer(e.gasUsed),timestamp:o.toBuffer(e.timestamp),transactions:e.transactions}}(e);t._setCurrentBlock(r)}),t._blockTracker.on("block",t.emit.bind(t,"rawBlock")),t._blockTracker.on("sync",t.emit.bind(t,"sync")),t._blockTracker.on("latest",t.emit.bind(t,"latest")),t._ready=new c,t._blockTracker.once("block",()=>{t._ready.go()}),t.currentBlock=null,t._providers=[]}t.exports=f,i(f,n),f.prototype.start=function(e=function(){}){this._blockTracker.start().then(e).catch(e)},f.prototype.stop=function(){this._blockTracker.stop()},f.prototype.addProvider=function(e){this._providers.push(e),e.setEngine(this)},f.prototype.send=function(e){throw new Error("Web3ProviderEngine does not support synchronous requests.")},f.prototype.sendAsync=function(e,t){const r=this;r._ready.await(function(){Array.isArray(e)?s(e,r._handleAsync.bind(r),t):r._handleAsync(e,t)})},f.prototype._handleAsync=function(e,t){var r=this,n=-1,i=null,o=null,a=[];function s(r,n){o=r,i=n,u(a,function(e,t){e?e(o,i,t):t()},function(){var r={id:e.id,jsonrpc:e.jsonrpc,result:i};null!=o?(r.error={message:o.stack||o.message||o,code:-32e3},t(o,r)):t(null,r)})}!function t(i){n+=1;a.unshift(i);if(n>=r._providers.length)s(new Error('Request for method "'+e.method+'" not handled by any subprovider. Please check your subprovider configuration to ensure this method is handled.'));else try{var o=r._providers[n];o.handleRequest(e,t,s)}catch(e){s(e)}}()},f.prototype._setCurrentBlock=function(e){this.currentBlock=e,this.emit("block",e)}},{"./util/create-payload.js":391,"./util/rpc-cache-utils.js":394,"./util/stoplight.js":396,"async/eachSeries":25,"async/map":41,"eth-block-tracker":126,"ethereumjs-util":141,events:157,util:333}],374:[function(e,t,r){var n="undefined"!=typeof JSON?JSON:e("jsonify");t.exports=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var r=t.space||"";"number"==typeof r&&(r=Array(r+1).join(" "));var a,s="boolean"==typeof t.cycles&&t.cycles,u=t.replacer||function(e,t){return t},c=t.cmp&&(a=t.cmp,function(e){return function(t,r){var n={key:t,value:e[t]},i={key:r,value:e[r]};return a(n,i)}}),f=[];return function e(t,a,h,l){var d=r?"\n"+new Array(l+1).join(r):"",p=r?": ":":";if(h&&h.toJSON&&"function"==typeof h.toJSON&&(h=h.toJSON()),void 0!==(h=u.call(t,a,h))){if("object"!=typeof h||null===h)return n.stringify(h);if(i(h)){for(var b=[],y=0;y dist/ProviderEngine.js","bundle-zero":"browserify -s ZeroClientProvider -e zero.js -t [ babelify --presets [ es2015 ] ] > dist/ZeroClientProvider.js",prepublish:"npm run build && npm run bundle",test:"node test/index.js"},version:"14.1.0"}},{}],376:[function(e,t,r){const n=e("util").inherits,i=e("ethereumjs-util"),o=i.BN,a=e("clone"),s=e("../util/rpc-cache-utils.js"),u=e("../util/stoplight.js"),c=e("./subprovider.js");function f(e){e=e||{},this._ready=new u,this.strategies={perma:new l({eth_getTransactionByHash:p,eth_getTransactionReceipt:p}),block:new d(this),fork:new d(this)}}function h(){var e=this;e.cache={};var t=setInterval(function(){e.cache={}},6e5);t.unref&&t.unref()}function l(e){this.strategy=new h,this.conditionals=e}function d(){this.cache={}}function p(e){if(!e)return!1;if(!e.blockHash)return!1;var t;return(t=e.blockHash,new o(i.toBuffer(t))).gt(new o(0))}t.exports=f,n(f,c),f.prototype.setEngine=function(e){const t=this;function r(e){var r=t.currentBlock;t.currentBlock=e,r&&(t.strategies.block.cacheRollOff(r),t.strategies.fork.cacheRollOff(r))}t.engine=e,e.once("block",function(n){t.currentBlock=n,t._ready.go(),e.on("block",r)})},f.prototype.handleRequest=function(e,t,r){const n=this;return e.skipCache?t():"eth_getBlockByNumber"===e.method&&"latest"===e.params[0]?t():void n._ready.await(function(){n._handleRequest(e,t,r)})},f.prototype._handleRequest=function(e,t,r){const n=this;var o=s.cacheTypeForPayload(e),a=this.strategies[o];if(!a)return t();if(!a.canCache(e))return t();var u,c=s.blockTagForPayload(e);c||(c="latest"),u="earliest"===c?"0x00":"latest"===c?i.bufferToHex(n.currentBlock.number):c,a.hitCheck(e,u,r,function(){t(function(t,r,n){if(t)return n();a.cacheResult(e,r,u,n)})})},h.prototype.hitCheck=function(e,t,r,n){var i,o,u,c,f=s.cacheIdentifierForPayload(e),h=this.cache[f];return h&&(i=t,o=h.blockNumber,u=parseInt(i,16),c=parseInt(o,16),(u===c?0:u>c?1:-1)>=0)?r(null,a(h.result)):n()},h.prototype.cacheResult=function(e,t,r,n){var i=s.cacheIdentifierForPayload(e);if(t){var o=a(t);this.cache[i]={blockNumber:r,result:o}}n()},h.prototype.canCache=function(e){return s.canCache(e)},l.prototype.hitCheck=function(e,t,r,n){return this.strategy.hitCheck(e,t,r,n)},l.prototype.cacheResult=function(e,t,r,n){var i=this.conditionals[e.method];i?i(t)?this.strategy.cacheResult(e,t,r,n):n():this.strategy.cacheResult(e,t,r,n)},l.prototype.canCache=function(e){return this.strategy.canCache(e)},d.prototype.getBlockCacheForPayload=function(e,t){const r=Number.parseInt(t,16);let n=this.cache[r];if(!n){const e={};this.cache[r]=e,n=e}return n},d.prototype.hitCheck=function(e,t,r,n){var i=this.getBlockCacheForPayload(e,t);if(!i)return n();var o=i[s.cacheIdentifierForPayload(e)];return o?r(null,o):n()},d.prototype.cacheResult=function(e,t,r,n){t&&(this.getBlockCacheForPayload(e,r)[s.cacheIdentifierForPayload(e)]=t);n()},d.prototype.canCache=function(e){return!!s.canCache(e)&&"pending"!==s.blockTagForPayload(e)},d.prototype.cacheRollOff=function(e){const t=this,r=i.bufferToHex(e.number),n=Number.parseInt(r,16);Object.keys(t.cache).map(Number).filter(e=>e<=n).forEach(e=>delete t.cache[e])}},{"../util/rpc-cache-utils.js":394,"../util/stoplight.js":396,"./subprovider.js":387,clone:87,"ethereumjs-util":141,util:333}],377:[function(e,t,r){const n=e("util").inherits,i=e("xtend"),o=e("./fixture.js"),a=e("../package.json").version;function s(e){var t=i({web3_clientVersion:"ProviderEngine/v"+a+"/javascript",net_listening:!0,eth_hashrate:"0x00",eth_mining:!1},e=e||{});o.call(this,t)}t.exports=s,n(s,o)},{"../package.json":375,"./fixture.js":380,util:333,xtend:423}],378:[function(e,t,r){const n=e("cross-fetch"),i=e("util").inherits,o=e("async/retry"),a=e("async/waterfall"),s=e("async/asyncify"),u=e("json-rpc-error"),c=e("promise-to-callback"),f=e("../util/create-payload.js"),h=e("./subprovider.js"),l=["Gateway timeout","ETIMEDOUT","SyntaxError"];function d(e){this.rpcUrl=e.rpcUrl,this.originHttpHeaderKey=e.originHttpHeaderKey}function p(e){const t=e.toString();return l.some(e=>t.includes(e))}t.exports=d,i(d,h),d.prototype.handleRequest=function(e,t,r){const n=this,i=e.origin,a=f(e);delete a.origin;const s={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(a)};n.originHttpHeaderKey&&i&&(s.headers[n.originHttpHeaderKey]=i),o({times:5,interval:1e3,errorFilter:p},e=>n._submitRequest(s,e),(e,t)=>{if(e&&p(e)){const t=`FetchSubprovider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,n=new Error(t);return r(n)}return r(e,t)})},d.prototype._submitRequest=function(e,t){const r=this.rpcUrl;c(n(r,e))((e,r)=>{if(e)return t(e);a([function(e){switch(r.status){case 405:return e(new u.MethodNotFound);case 418:return e(function(){const e=new Error("Request is being rate limited.");return new u.InternalError(e)}());case 503:case 504:return e(function(){let e="Gateway timeout. The request took too long to process. ";const t=new Error(e+="This can happen when querying logs over too wide a block range.");return new u.InternalError(t)}());default:return e()}},e=>c(r.text())(e),s(e=>JSON.parse(e)),function(e,t){if(200!==r.status)return t(new u.InternalError(e));if(e.error)return t(new u.InternalError(e.error));t(null,e.result)}],t)})}},{"../util/create-payload.js":391,"./subprovider.js":387,"async/asyncify":20,"async/retry":43,"async/waterfall":44,"cross-fetch":96,"json-rpc-error":189,"promise-to-callback":258,util:333}],379:[function(e,t,r){const n=e("async"),i=e("util").inherits,o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/stoplight.js"),u=e("events").EventEmitter;function c(e){e=e||{};const t=this;t.filterIndex=0,t.filters={},t.filterDestroyHandlers={},t.asyncBlockHandlers={},t.asyncPendingBlockHandlers={},t._ready=new s,t._ready.setMaxListeners(e.maxFilters||25),t._ready.go(),t.pendingBlockTimeout=e.pendingBlockTimeout||4e3,t.checkForPendingBlocksActive=!1,setTimeout(function(){t.engine.on("block",function(e){t._ready.stop();var r=v(t.asyncBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,function(e){e&&console.error(e),t._ready.go()})})})}function f(e){u.apply(this),this.type="block",this.engine=e.engine,this.blockNumber=e.blockNumber,this.updates=[]}function h(e){u.apply(this),this.type="log",this.fromBlock=void 0!==e.fromBlock?e.fromBlock:"latest",this.toBlock=void 0!==e.toBlock?e.toBlock:"latest";var t=e.address&&(Array.isArray(e.address)?e.address:[e.address]);this.address=t&&t.map(d),this.topics=e.topics||[],this.updates=[],this.allResults=[]}function l(){u.apply(this),this.type="pendingTx",this.updates=[],this.allResults=[]}function d(e){return"0x"===e.slice(0,2)?e:"0x"+e}function p(e){return o.intToHex(e)}function b(e){return Number(e)}function y(e){return function(e){let t=o.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}(e.toString("hex"))}function m(e){return e&&-1===["earliest","latest","pending"].indexOf(e)}function v(e){return Object.keys(e).map(function(t){return e[t]})}t.exports=c,i(c,a),c.prototype.handleRequest=function(e,t,r){const n=this;switch(e.method){case"eth_newBlockFilter":return void n.newBlockFilter(r);case"eth_newPendingTransactionFilter":return n.newPendingTransactionFilter(r),void n.checkForPendingBlocks();case"eth_newFilter":return void n.newLogFilter(e.params[0],r);case"eth_getFilterChanges":return void n._ready.await(function(){n.getFilterChanges(e.params[0],r)});case"eth_getFilterLogs":return void n._ready.await(function(){n.getFilterLogs(e.params[0],r)});case"eth_uninstallFilter":return void n._ready.await(function(){n.uninstallFilter(e.params[0],r)});default:return void t()}},c.prototype.newBlockFilter=function(e){const t=this;t._getBlockNumber(function(r,n){if(r)return e(r);var i=new f({blockNumber:n}),o=i.update.bind(i);t.engine.on("block",o);t.filterIndex++,t.filters[t.filterIndex]=i,t.filterDestroyHandlers[t.filterIndex]=function(){t.engine.removeListener("block",o)};var a=p(t.filterIndex);e(null,a)})},c.prototype.newLogFilter=function(e,t){const r=this;r._getBlockNumber(function(n,i){if(n)return t(n);var o=new h(e),a=o.update.bind(o);r.filterIndex++,r.asyncBlockHandlers[r.filterIndex]=function(e,t){r._logsForBlock(e,function(e,r){if(e)return t(e);a(r),t()})},r.filters[r.filterIndex]=o;var s=p(r.filterIndex);t(null,s)})},c.prototype.newPendingTransactionFilter=function(e){const t=this;var r=new l,n=r.update.bind(r);t.filterIndex++,t.asyncPendingBlockHandlers[t.filterIndex]=function(e,r){t._txHashesForBlock(e,function(e,t){if(e)return r(e);n(t),r()})},t.filters[t.filterIndex]=r,e(null,p(t.filterIndex))},c.prototype.getFilterChanges=function(e,t){var r=Number.parseInt(e,16),n=this.filters[r];if(n||console.warn("FilterSubprovider - no filter with that id:",e),!n)return t(null,[]);var i=n.getChanges();n.clearChanges(),t(null,i)},c.prototype.getFilterLogs=function(e,t){const r=this;var n=Number.parseInt(e,16),i=r.filters[n];if(i||console.warn("FilterSubprovider - no filter with that id:",e),!i)return t(null,[]);if("log"===i.type)r.emitPayload({method:"eth_getLogs",params:[{fromBlock:i.fromBlock,toBlock:i.toBlock,address:i.address,topics:i.topics}]},function(e,r){if(e)return t(e);t(null,r.result)});else{t(null,[])}},c.prototype.uninstallFilter=function(e,t){var r=Number.parseInt(e,16);if(this.filters[r]){this.filters[r].removeAllListeners();var n=this.filterDestroyHandlers[r];delete this.filters[r],delete this.asyncBlockHandlers[r],delete this.asyncPendingBlockHandlers[r],delete this.filterDestroyHandlers[r],n&&n(),t(null,!0)}else t(null,!1)},c.prototype.checkForPendingBlocks=function(){const e=this;e.checkForPendingBlocksActive||!!Object.keys(e.asyncPendingBlockHandlers).length&&(e.checkForPendingBlocksActive=!0,e.emitPayload({method:"eth_getBlockByNumber",params:["pending",!0]},function(t,r){if(t)return e.checkForPendingBlocksActive=!1,void console.error(t);e.onNewPendingBlock(r.result,function(t){t&&console.error(t),e.checkForPendingBlocksActive=!1,setTimeout(e.checkForPendingBlocks.bind(e),e.pendingBlockTimeout)})}))},c.prototype.onNewPendingBlock=function(e,t){var r=v(this.asyncPendingBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,t)},c.prototype._getBlockNumber=function(e){e(null,y(this.engine.currentBlock.number))},c.prototype._logsForBlock=function(e,t){var r=y(e.number);this.emitPayload({method:"eth_getLogs",params:[{fromBlock:r,toBlock:r}]},function(e,r){return e?t(e):r.error?t(r.error):void t(null,r.result)})},c.prototype._txHashesForBlock=function(e,t){var r=e.transactions;if(0===r.length)return t(null,[]);"string"==typeof r[0]?t(null,r):t(null,r.map(e=>e.hash))},i(f,u),f.prototype.update=function(e){var t="0x"+e.hash.toString("hex");this.updates.push(t),this.emit("data",e)},f.prototype.getChanges=function(){return this.updates},f.prototype.clearChanges=function(){this.updates=[]},i(h,u),h.prototype.validateLog=function(e){return!(m(this.fromBlock)&&b(this.fromBlock)>=b(e.blockNumber))&&(!(m(this.toBlock)&&b(this.toBlock)<=b(e.blockNumber))&&(!(this.address&&!this.address.map(e=>e.toLowerCase()).includes(e.address.toLowerCase()))&&this.topics.reduce(function(t,r,n){if(!t)return!1;if(!r)return!0;var i=e.topics[n];return!!i&&(Array.isArray(r)?r:[r]).filter(function(e){return i.toLowerCase()===e.toLowerCase()}).length>0},!0)))},h.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateLog(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},h.prototype.getChanges=function(){return this.updates},h.prototype.getAllResults=function(){return this.allResults},h.prototype.clearChanges=function(){this.updates=[]},i(l,u),l.prototype.validateUnique=function(e){return-1===this.allResults.indexOf(e)},l.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateUnique(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},l.prototype.getChanges=function(){return this.updates},l.prototype.getAllResults=function(){return this.allResults},l.prototype.clearChanges=function(){this.updates=[]}},{"../util/stoplight.js":396,"./subprovider.js":387,async:21,"ethereumjs-util":141,events:157,util:333}],380:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){e=e||{},this.staticResponses=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){var n=this.staticResponses[e.method];"function"==typeof n?n(e,t,r):void 0!==n?setTimeout(()=>r(null,n)):t()}},{"./subprovider.js":387,util:333}],381:[function(e,t,r){const n=e("async/waterfall"),i=e("async/parallel"),o=e("util").inherits,a=e("ethereumjs-util"),s=e("eth-sig-util"),u=e("xtend"),c=e("semaphore"),f=e("./subprovider.js"),h=e("../util/estimate-gas.js"),l=/^[0-9A-Fa-f]+$/g;function d(e){this.nonceLock=c(1),e.getAccounts&&(this.getAccounts=e.getAccounts),e.processTransaction&&(this.processTransaction=e.processTransaction),e.processMessage&&(this.processMessage=e.processMessage),e.processPersonalMessage&&(this.processPersonalMessage=e.processPersonalMessage),e.processTypedMessage&&(this.processTypedMessage=e.processTypedMessage),this.approveTransaction=e.approveTransaction||this.autoApprove,this.approveMessage=e.approveMessage||this.autoApprove,this.approvePersonalMessage=e.approvePersonalMessage||this.autoApprove,this.approveTypedMessage=e.approveTypedMessage||this.autoApprove,e.signTransaction&&(this.signTransaction=e.signTransaction||y("signTransaction")),e.signMessage&&(this.signMessage=e.signMessage||y("signMessage")),e.signPersonalMessage&&(this.signPersonalMessage=e.signPersonalMessage||y("signPersonalMessage")),e.signTypedMessage&&(this.signTypedMessage=e.signTypedMessage||y("signTypedMessage")),e.recoverPersonalSignature&&(this.recoverPersonalSignature=e.recoverPersonalSignature),e.publishTransaction&&(this.publishTransaction=e.publishTransaction)}function p(e){return e.toLowerCase()}function b(e){return"string"==typeof e&&("0x"===e.slice(0,2)&&e.slice(2).match(l))}function y(e){return function(t,r){r(new Error('ProviderEngine - HookedWalletSubprovider - Must provide "'+e+'" fn in constructor options'))}}t.exports=d,o(d,f),d.prototype.handleRequest=function(e,t,r){const i=this;let o,s,c,f,h;switch(i._parityRequests={},i._parityRequestCount=0,e.method){case"eth_coinbase":return void i.getAccounts(function(e,t){if(e)return r(e);let n=t[0]||null;r(null,n)});case"eth_accounts":return void i.getAccounts(function(e,t){if(e)return r(e);r(null,t)});case"eth_sendTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processTransaction(o,e)],r);case"eth_signTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processSignTransaction(o,e)],r);case"eth_sign":return h=e.params[0],f=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateMessage(s,e),e=>i.processMessage(s,e)],r);case"personal_sign":const l=e.params[0];if(function(e){const t=a.addHexPrefix(e);return!a.isValidAddress(t)&&b(e)}(e.params[1])&&function(e){const t=a.addHexPrefix(e);return a.isValidAddress(t)}(l)){let t="The eth_personalSign method requires params ordered ";t+="[message, address]. This was previously handled incorrectly, ",t+="and has been corrected automatically. ",t+="Please switch this param order for smooth behavior in the future.",console.warn(t),h=e.params[0],f=e.params[1]}else f=e.params[0],h=e.params[1];return c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validatePersonalMessage(s,e),e=>i.processPersonalMessage(s,e)],r);case"personal_ecRecover":f=e.params[0];let d=e.params[1];return c=e.params[2]||{},s=u(c,{sig:d,data:f}),void i.recoverPersonalSignature(s,r);case"eth_signTypedData":return f=e.params[0],h=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateTypedMessage(s,e),e=>i.processTypedMessage(s,e)],r);case"parity_postTransaction":return o=e.params[0],void i.parityPostTransaction(o,r);case"parity_postSign":return h=e.params[0],f=e.params[1],void i.parityPostSign(h,f,r);case"parity_checkRequest":const p=e.params[0];return void i.parityCheckRequest(p,r);case"parity_defaultAccount":return void i.getAccounts(function(e,t){if(e)return r(e);const n=t[0]||null;r(null,n)});default:return void t()}},d.prototype.getAccounts=function(e){e(null,[])},d.prototype.processTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeAndSubmitTx(e,t)],t)},d.prototype.processSignTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeTx(e,t)],t)},d.prototype.processMessage=function(e,t){const r=this;n([t=>r.approveMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signMessage(e,t)],t)},d.prototype.processPersonalMessage=function(e,t){const r=this;n([t=>r.approvePersonalMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signPersonalMessage(e,t)],t)},d.prototype.processTypedMessage=function(e,t){const r=this;n([t=>r.approveTypedMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signTypedMessage(e,t)],t)},d.prototype.autoApprove=function(e,t){t(null,!0)},d.prototype.checkApproval=function(e,t,r){r(t?null:new Error("User denied "+e+" signature."))},d.prototype.parityPostTransaction=function(e,t){const r=this,n=`0x${r._parityRequestCount.toString(16)}`;r._parityRequestCount++,r.emitPayload({method:"eth_sendTransaction",params:[e]},function(e,t){if(e)return void(r._parityRequests[n]={error:e});const i=t.result;r._parityRequests[n]=i}),t(null,n)},d.prototype.parityPostSign=function(e,t,r){const n=this,i=`0x${n._parityRequestCount.toString(16)}`;n._parityRequestCount++,n.emitPayload({method:"eth_sign",params:[e,t]},function(e,t){if(e)return void(n._parityRequests[i]={error:e});const r=t.result;n._parityRequests[i]=r}),r(null,i)},d.prototype.parityCheckRequest=function(e,t){const r=this._parityRequests[e]||null;return r?r.error?t(r.error):void t(null,r):t(null,null)},d.prototype.recoverPersonalSignature=function(e,t){let r;try{r=s.recoverPersonalSignature(e)}catch(e){return t(e)}t(null,r)},d.prototype.validateTransaction=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign transaction."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign transaction for this address: "${e.from}"`))})},d.prototype.validateMessage=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign message."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validatePersonalMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign personal message.")):void 0===e.data?t(new Error("Undefined message - message required to sign personal message.")):b(e.data)?void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))}):t(new Error("HookedWalletSubprovider - validateMessage - message was not encoded as hex."))},d.prototype.validateTypedMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign typed data.")):void 0===e.data?t(new Error("Undefined data - message required to sign typed data.")):void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validateSender=function(e,t){if(!e)return t(null,!1);this.getAccounts(function(r,n){if(r)return t(r);const i=-1!==n.map(p).indexOf(e.toLowerCase());t(null,i)})},d.prototype.finalizeAndSubmitTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r),r.publishTransaction.bind(r)],function(e,n){if(r.nonceLock.leave(),e)return t(e);t(null,n)})})},d.prototype.finalizeTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r)],function(n,i){if(r.nonceLock.leave(),n)return t(n);t(null,{raw:i,tx:e})})})},d.prototype.publishTransaction=function(e,t){this.emitPayload({method:"eth_sendRawTransaction",params:[e]},function(e,r){if(e)return t(e);t(null,r.result)})},d.prototype.fillInTxExtras=function(e,t){const r=this,n=e.from,o={};void 0===e.gasPrice&&(o.gasPrice=r.emitPayload.bind(r,{method:"eth_gasPrice",params:[]})),void 0===e.nonce&&(o.nonce=r.emitPayload.bind(r,{method:"eth_getTransactionCount",params:[n,"pending"]})),void 0===e.gas&&(o.gas=h.bind(null,r.engine,function(e){return{from:e.from,to:e.to,value:e.value,data:e.data,gas:e.gas,gasPrice:e.gasPrice,nonce:e.nonce}}(e))),i(o,function(r,n){if(r)return t(r);const i={};n.gasPrice&&(i.gasPrice=n.gasPrice.result),n.nonce&&(i.nonce=n.nonce.result),n.gas&&(i.gas=n.gas),t(null,u(e,i))})}},{"../util/estimate-gas.js":392,"./subprovider.js":387,"async/parallel":42,"async/waterfall":44,"eth-sig-util":136,"ethereumjs-util":141,semaphore:301,util:333,xtend:423}],382:[function(e,t,r){const n=e("../util/rpc-cache-utils.js").cacheIdentifierForPayload,i=e("./subprovider.js");t.exports=class extends i{constructor(e){super(),this.inflightRequests={}}addEngine(e){this.engine=e}handleRequest(e,t,r){const i=n(e,{includeBlockRef:!0});if(!i)return t();let o=this.inflightRequests[i];o?o.push(r):(o=[],this.inflightRequests[i]=o,t((e,t,r)=>{delete this.inflightRequests[i],o.forEach(r=>r(e,t)),r(e,t)}))}}},{"../util/rpc-cache-utils.js":394,"./subprovider.js":387}],383:[function(e,t,r){const n=e("eth-json-rpc-infura/src/createProvider"),i=e("./provider.js");t.exports=class extends i{constructor(e={}){super(n(e))}}},{"./provider.js":385,"eth-json-rpc-infura/src/createProvider":129}],384:[function(e,t,r){(function(r){const n=e("util").inherits,i=e("ethereumjs-tx"),o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/rpc-cache-utils").blockTagForPayload;function u(e){this.nonceCache={}}t.exports=u,n(u,a),u.prototype.handleRequest=function(e,t,n){const a=this;switch(e.method){case"eth_getTransactionCount":var u=s(e),c=e.params[0].toLowerCase(),f=a.nonceCache[c];return void("pending"===u?f?n(null,f):t(function(e,t,r){if(e)return r();void 0===a.nonceCache[c]&&(a.nonceCache[c]=t),r()}):t());case"eth_sendRawTransaction":return void t(function(t,n,s){if(t)return s();var u=e.params[0],c=(o.stripHexPrefix(u),new r(o.stripHexPrefix(u),"hex"),new i(new r(o.stripHexPrefix(u),"hex"))),f="0x"+c.getSenderAddress().toString("hex").toLowerCase(),h=o.bufferToInt(c.nonce),l=(++h).toString(16);l.length%2&&(l="0"+l),l="0x"+l,a.nonceCache[f]=l,s()});default:return void t()}}}).call(this,e("buffer").Buffer)},{"../util/rpc-cache-utils":394,"./subprovider.js":387,buffer:84,"ethereumjs-tx":140,"ethereumjs-util":141,util:333}],385:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){if(!e)throw new Error("ProviderSubprovider - no provider specified");if(!e.sendAsync)throw new Error("ProviderSubprovider - specified provider does not have a sendAsync method");this.provider=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){this.provider.sendAsync(e,function(e,t){return e?r(e):t.error?r(new Error(t.error.message)):void r(null,t.result)})}},{"./subprovider.js":387,util:333}],386:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js"),o=(e("xtend"),e("ethereumjs-util"));function a(e){}t.exports=a,n(a,i),a.prototype.handleRequest=function(e,t,r){var n=e.params[0];if("object"==typeof n&&!Array.isArray(n)){var i=function(e){return s.reduce(function(t,r){return r in e&&(Array.isArray(e[r])?t[r]=e[r].map(function(e){return u(e)}):t[r]=u(e[r])),t},{})}(n);e.params[0]=i}t()};var s=["from","to","value","data","gas","gasPrice","nonce","fromBlock","toBlock","address","topics"];function u(e){switch(e){case"latest":case"pending":case"earliest":return e;default:return"string"==typeof e?o.addHexPrefix(e.toLowerCase()):e}}},{"./subprovider.js":387,"ethereumjs-util":141,util:333,xtend:423}],387:[function(e,t,r){const n=e("../util/create-payload.js");function i(){}t.exports=i,i.prototype.setEngine=function(e){const t=this;t.engine=e,e.on("block",function(e){t.currentBlock=e})},i.prototype.handleRequest=function(e,t,r){throw new Error("Subproviders should override `handleRequest`.")},i.prototype.emitPayload=function(e,t){this.engine.sendAsync(n(e),t)}},{"../util/create-payload.js":391}],388:[function(e,t,r){const n=e("events").EventEmitter,i=e("./filters.js"),o=e("../util/rpc-hex-encoding.js"),a=e("util").inherits,s=e("ethereumjs-util");function u(e){e=e||{},n.apply(this,Array.prototype.slice.call(arguments)),i.apply(this,[e]),this.subscriptions={}}a(u,i),Object.assign(u.prototype,n.prototype),u.prototype.constructor=u,u.prototype.eth_subscribe=function(e,t){const r=this;let n=()=>{},i=e.params[0];switch(i){case"logs":let o=e.params[1];n=r.newLogFilter.bind(r,o);break;case"newPendingTransactions":n=r.newPendingTransactionFilter.bind(r);break;case"newHeads":n=r.newBlockFilter.bind(r);break;case"syncing":default:return void t(new Error("unsupported subscription type"))}n(function(e,n){if(e)return t(e);const o=Number.parseInt(n,16);r.subscriptions[o]=i,r.filters[o].on("data",function(e){Array.isArray(e)||(e=[e]);var t=r._notificationHandler.bind(r,n,i);e.forEach(t),r.filters[o].clearChanges()}),"newPendingTransactions"===i&&r.checkForPendingBlocks(),t(null,n)})},u.prototype.eth_unsubscribe=function(e,t){const r=this;let n=e.params[0];const i=Number.parseInt(n,16);if(r.subscriptions[i]){r.subscriptions[i];r.uninstallFilter(n,function(e,n){delete r.subscriptions[i],t(e,n)})}else t(new Error(`Subscription ID ${n} not found.`))},u.prototype._notificationHandler=function(e,t,r){const n=this;"newHeads"===t&&(r=n._notificationResultFromBlock(r)),n.emit("data",null,{jsonrpc:"2.0",method:"eth_subscription",params:{subscription:e,result:r}})},u.prototype._notificationResultFromBlock=function(e){return{hash:s.bufferToHex(e.hash),parentHash:s.bufferToHex(e.parentHash),sha3Uncles:s.bufferToHex(e.sha3Uncles),miner:s.bufferToHex(e.miner),stateRoot:s.bufferToHex(e.stateRoot),transactionsRoot:s.bufferToHex(e.transactionsRoot),receiptsRoot:s.bufferToHex(e.receiptsRoot),logsBloom:s.bufferToHex(e.logsBloom),difficulty:o.intToQuantityHex(s.bufferToInt(e.difficulty)),number:o.intToQuantityHex(s.bufferToInt(e.number)),gasLimit:o.intToQuantityHex(s.bufferToInt(e.gasLimit)),gasUsed:o.intToQuantityHex(s.bufferToInt(e.gasUsed)),nonce:e.nonce?s.bufferToHex(e.nonce):null,mixHash:s.bufferToHex(e.mixHash),timestamp:o.intToQuantityHex(s.bufferToInt(e.timestamp)),extraData:s.bufferToHex(e.extraData)}},u.prototype.handleRequest=function(e,t,r){switch(e.method){case"eth_subscribe":this.eth_subscribe(e,r);break;case"eth_unsubscribe":this.eth_unsubscribe(e,r);break;default:i.prototype.handleRequest.apply(this,Array.prototype.slice.call(arguments))}},t.exports=u},{"../util/rpc-hex-encoding.js":395,"./filters.js":379,"ethereumjs-util":141,events:157,util:333}],389:[function(e,t,r){(function(r){const n=e("backoff"),i=e("events"),o=(e("util").inherits,r.WebSocket||e("ws")),a=e("./subprovider"),s=e("../util/create-payload");class u extends a{constructor({rpcUrl:e,debug:t,origin:r}){super(),i.call(this),Object.defineProperties(this,{_backoff:{value:n.exponential({randomisationFactor:.2,maxDelay:5e3})},_connectTime:{value:null,writable:!0},_log:{value:t?(...e)=>console.info.apply(console,["[WSProvider]",...e]):()=>{}},_origin:{value:r},_pendingRequests:{value:new Map},_socket:{value:null,writable:!0},_unhandledRequests:{value:[]},_url:{value:e}}),this._handleSocketClose=this._handleSocketClose.bind(this),this._handleSocketMessage=this._handleSocketMessage.bind(this),this._handleSocketOpen=this._handleSocketOpen.bind(this),this._backoff.on("ready",()=>{this._openSocket()}),this._openSocket()}handleRequest(e,t,r){if(!this._socket||this._socket.readyState!==o.OPEN)return this._unhandledRequests.push(Array.from(arguments)),void this._log("Socket not open. Request queued.");this._pendingRequests.set(e.id,[e,r]);const n=s(e);delete n.origin,this._socket.send(JSON.stringify(n)),this._log(`Sent: ${n.method} #${n.id}`)}_handleSocketClose({reason:e,code:t}){this._log(`Socket closed, code ${t} (${e||"no reason"})`),this._connectTime&&Date.now()-this._connectTime>5e3&&this._backoff.reset(),this._socket.removeEventListener("close",this._handleSocketClose),this._socket.removeEventListener("message",this._handleSocketMessage),this._socket.removeEventListener("open",this._handleSocketOpen),this._socket=null,this._backoff.backoff()}_handleSocketMessage(e){let t;try{t=JSON.parse(e.data)}catch(e){return void this._log("Received a message that is not valid JSON:",t)}if(void 0===t.id)return this.emit("data",null,t);if(!this._pendingRequests.has(t.id))return;const[r,n]=this._pendingRequests.get(t.id);if(this._pendingRequests.delete(t.id),this._log(`Received: ${r.method} #${t.id}`),t.error)return n(new Error(t.error.message));n(null,t.result)}_handleSocketOpen(){this._log("Socket open."),this._connectTime=Date.now(),this._pendingRequests.forEach(([e,t])=>{this._unhandledRequests.push([e,null,t])}),this._pendingRequests.clear(),this._unhandledRequests.splice(0,this._unhandledRequests.length).forEach(e=>{this.handleRequest.apply(this,e)})}_openSocket(){this._log("Opening socket..."),this._socket=new o(this._url,null,{origin:this._origin}),this._socket.addEventListener("close",this._handleSocketClose),this._socket.addEventListener("message",this._handleSocketMessage),this._socket.addEventListener("open",this._handleSocketOpen)}}Object.assign(u.prototype,i.prototype),t.exports=u}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util/create-payload":391,"./subprovider":387,backoff:45,events:157,util:333,ws:55}],390:[function(e,t,r){t.exports=function(e,t){if(!e)throw t||"Assertion failed"}},{}],391:[function(e,t,r){const n=e("./random-id.js"),i=e("xtend");t.exports=function(e){return i({id:n(),jsonrpc:"2.0",params:[]},e)}},{"./random-id.js":393,xtend:423}],392:[function(e,t,r){const n=e("./create-payload.js");t.exports=function(e,t,r){e.sendAsync(n({method:"eth_estimateGas",params:[t]}),function(e,t){if(e)return"no contract code at given address"===e.message?r(null,"0xcf08"):r(e);r(null,t.result)})}},{"./create-payload.js":391}],393:[function(e,t,r){const n=3;t.exports=function(){var e=(new Date).getTime()*Math.pow(10,n),t=Math.floor(Math.random()*Math.pow(10,n));return e+t}},{}],394:[function(e,t,r){const n=e("json-stable-stringify");function i(e){return"never"!==s(e)}function o(e){var t=a(e);return t>=e.params.length?e.params:"eth_getBlockByNumber"===e.method?e.params.slice(1):e.params.slice(0,t)}function a(e){switch(e.method){case"eth_getStorageAt":return 2;case"eth_getBalance":case"eth_getCode":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":return 1;case"eth_getBlockByNumber":return 0;default:return}}function s(e){switch(e.method){case"web3_clientVersion":case"web3_sha3":case"eth_protocolVersion":case"eth_getBlockTransactionCountByHash":case"eth_getUncleCountByBlockHash":case"eth_getCode":case"eth_getBlockByHash":case"eth_getTransactionByHash":case"eth_getTransactionByBlockHashAndIndex":case"eth_getTransactionReceipt":case"eth_getUncleByBlockHashAndIndex":case"eth_getCompilers":case"eth_compileLLL":case"eth_compileSolidity":case"eth_compileSerpent":case"shh_version":return"perma";case"eth_getBlockByNumber":case"eth_getBlockTransactionCountByNumber":case"eth_getUncleCountByBlockNumber":case"eth_getTransactionByBlockNumberAndIndex":case"eth_getUncleByBlockNumberAndIndex":return"fork";case"eth_gasPrice":case"eth_blockNumber":case"eth_getBalance":case"eth_getStorageAt":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":case"eth_getFilterLogs":case"eth_getLogs":case"net_peerCount":return"block";case"net_version":case"net_peerCount":case"net_listening":case"eth_syncing":case"eth_sign":case"eth_coinbase":case"eth_mining":case"eth_hashrate":case"eth_accounts":case"eth_sendTransaction":case"eth_sendRawTransaction":case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_getFilterChanges":case"eth_getWork":case"eth_submitWork":case"eth_submitHashrate":case"db_putString":case"db_getString":case"db_putHex":case"db_getHex":case"shh_post":case"shh_newIdentity":case"shh_hasIdentity":case"shh_newGroup":case"shh_addToGroup":case"shh_newFilter":case"shh_uninstallFilter":case"shh_getFilterChanges":case"shh_getMessages":return"never"}}t.exports={cacheIdentifierForPayload:function(e,t={}){if(!i(e))return null;const{includeBlockRef:r}=t,a=r?e.params:o(e);return e.method+":"+n(a)},canCache:i,blockTagForPayload:function(e){var t=a(e);if(t>=e.params.length)return null;return e.params[t]},paramsWithoutBlockTag:o,blockTagParamIndex:a,cacheTypeForPayload:s}},{"json-stable-stringify":374}],395:[function(e,t,r){(function(r){const n=e("ethereumjs-util"),i=e("./assert.js");t.exports={intToQuantityHex:function(e){i("number"==typeof e&&e===Math.floor(e),"intToQuantityHex arg must be an integer");var t=n.toBuffer(e).toString("hex");"0"===t[0]&&(t=t.substring(1));return n.addHexPrefix(t)},quantityHexToInt:function(e){i("string"==typeof e,"arg to quantityHexToInt must be a string");var t=n.stripHexPrefix(e);t.length%2!=0&&(t="0"+t);var o=new r(t,"hex");return n.bufferToInt(o)}}}).call(this,e("buffer").Buffer)},{"./assert.js":390,buffer:84,"ethereumjs-util":141}],396:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits;function o(){n.call(this),this.isLocked=!0}t.exports=o,i(o,n),o.prototype.go=function(){this.isLocked=!1,this.emit("unlock")},o.prototype.stop=function(){this.isLocked=!0,this.emit("lock")},o.prototype.await=function(e){const t=this;t.isLocked?t.once("unlock",e):setTimeout(e)}},{events:157,util:333}],397:[function(e,t,r){const n=e("./index.js"),i=e("./subproviders/default-fixture.js"),o=e("./subproviders/nonce-tracker.js"),a=e("./subproviders/cache.js"),s=e("./subproviders/filters.js"),u=e("./subproviders/subscriptions"),c=e("./subproviders/inflight-cache"),f=e("./subproviders/hooked-wallet.js"),h=e("./subproviders/sanitizer.js"),l=e("./subproviders/infura.js"),d=e("./subproviders/fetch.js"),p=e("./subproviders/websocket.js");t.exports=function(e={}){const t=function({rpcUrl:e}){if(!e)return;switch(e.split(":")[0].toLowerCase()){case"http":case"https":return"http";case"ws":case"wss":return"ws";default:throw new Error(`ProviderEngine - unrecognized protocol in "${e}"`)}}(e),r=new n(e.engineParams),b=new i(e.static);r.addProvider(b),r.addProvider(new o);const y=new h;r.addProvider(y);const m=new a;if(r.addProvider(m),"ws"===t){const e=new s;r.addProvider(e)}else{const e=new u;e.on("data",(e,t)=>{r.emit("data",e,t)}),r.addProvider(e)}const v=new c;r.addProvider(v);const g=new f({getAccounts:e.getAccounts,processTransaction:e.processTransaction,approveTransaction:e.approveTransaction,signTransaction:e.signTransaction,publishTransaction:e.publishTransaction,processMessage:e.processMessage,approveMessage:e.approveMessage,signMessage:e.signMessage,processPersonalMessage:e.processPersonalMessage,processTypedMessage:e.processTypedMessage,approvePersonalMessage:e.approvePersonalMessage,approveTypedMessage:e.approveTypedMessage,signPersonalMessage:e.signPersonalMessage,signTypedMessage:e.signTypedMessage,personalRecoverSigner:e.personalRecoverSigner});r.addProvider(g);const w=e.dataSubprovider||function(e,t){const{rpcUrl:r,debug:n}=t;if(!e)return new l;if("http"===e)return new d({rpcUrl:r,debug:n});if("ws"===e)return new p({rpcUrl:r,debug:n});throw new Error(`ProviderEngine - unrecognized connectionType "${e}"`)}(t,e);"ws"===t&&w.on("data",(e,t)=>{r.emit("data",e,t)});r.addProvider(w),e.stopped||r.start();return r}},{"./index.js":373,"./subproviders/cache.js":376,"./subproviders/default-fixture.js":377,"./subproviders/fetch.js":378,"./subproviders/filters.js":379,"./subproviders/hooked-wallet.js":381,"./subproviders/inflight-cache":382,"./subproviders/infura.js":383,"./subproviders/nonce-tracker.js":384,"./subproviders/sanitizer.js":386,"./subproviders/subscriptions":388,"./subproviders/websocket.js":389}],398:[function(e,t,r){var n=e("web3-core-helpers").errors,i=e("xhr2-cookies").XMLHttpRequest,o=e("http"),a=e("https"),s=function(e,t){t=t||{},this.host=e||"http://localhost:8545","https"===this.host.substring(0,5)?this.httpsAgent=new a.Agent({keepAlive:!0}):this.httpAgent=new o.Agent({keepAlive:!0}),this.timeout=t.timeout||0,this.headers=t.headers,this.connected=!1};s.prototype._prepareRequest=function(){var e=new i;return e.nodejsSet({httpsAgent:this.httpsAgent,httpAgent:this.httpAgent}),e.open("POST",this.host,!0),e.setRequestHeader("Content-Type","application/json"),e.timeout=this.timeout&&1!==this.timeout?this.timeout:0,e.withCredentials=!0,this.headers&&this.headers.forEach(function(t){e.setRequestHeader(t.name,t.value)}),e},s.prototype.send=function(e,t){var r=this,i=this._prepareRequest();i.onreadystatechange=function(){if(4===i.readyState&&1!==i.timeout){var e=i.responseText,o=null;try{e=JSON.parse(e)}catch(e){o=n.InvalidResponse(i.responseText)}r.connected=!0,t(o,e)}},i.ontimeout=function(){r.connected=!1,t(n.ConnectionTimeout(this.timeout))};try{i.send(JSON.stringify(e))}catch(e){this.connected=!1,t(n.InvalidConnection(this.host))}},s.prototype.disconnect=function(){},t.exports=s},{http:312,https:175,"web3-core-helpers":338,"xhr2-cookies":418}],399:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("oboe"),a=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],this.path=e,this.connected=!1,this.connection=t.connect({path:this.path}),this.addDefaultEvents();var i=function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,t||-1===e.method.indexOf("_subscription")?r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t]):r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)})};"Socket"===t.constructor.name?o(this.connection).done(i):this.connection.on("data",function(e){r._parseResponse(e.toString()).forEach(i)})};a.prototype.addDefaultEvents=function(){var e=this;this.connection.on("connect",function(){e.connected=!0}),this.connection.on("close",function(){e.connected=!1}),this.connection.on("error",function(){e._timeout()}),this.connection.on("end",function(){e._timeout()}),this.connection.on("timeout",function(){e._timeout()})},a.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},a.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n},a.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on IPC")),delete this.responseCallbacks[e])},a.prototype.reconnect=function(){this.connection.connect({path:this.path})},a.prototype.send=function(e,t){this.connection.writable||this.connection.connect({path:this.path}),this.connection.write(JSON.stringify(e)),this._addResponseCallback(e,t)},a.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;default:this.connection.on(e,t)}},a.prototype.once=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");this.connection.once(e,t)},a.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)});break;default:this.connection.removeListener(e,t)}},a.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;default:this.connection.removeAllListeners(e)}},a.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.connection.removeAllListeners("error"),this.connection.removeAllListeners("end"),this.connection.removeAllListeners("timeout"),this.addDefaultEvents()},t.exports=a},{oboe:239,underscore:325,"web3-core-helpers":338}],400:[function(e,t,r){(function(r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=null,a=null,s=null;if("undefined"!=typeof window&&void 0!==window.WebSocket)o=function(e,t){return new window.WebSocket(e,t)},a=btoa,s=function(e){return new URL(e)};else{o=e("websocket").w3cwebsocket,a=function(e){return r(e).toString("base64")};var u=e("url");if(u.URL){var c=u.URL;s=function(e){return new c(e)}}else s=e("url").parse}var f=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],t=t||{},this._customTimeout=t.timeout;var i=s(e),u=t.headers||{},c=t.protocol||void 0;i.username&&i.password&&(u.authorization="Basic "+a(i.username+":"+i.password));var f=t.clientConfig||void 0;i.auth&&(u.authorization="Basic "+a(i.auth)),this.connection=new o(e,c,void 0,u,void 0,f),this.addDefaultEvents(),this.connection.onmessage=function(e){var t="string"==typeof e.data?e.data:"";r._parseResponse(t).forEach(function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,!t&&e&&e.method&&-1!==e.method.indexOf("_subscription")?r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)}):r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t])})},Object.defineProperty(this,"connected",{get:function(){return this.connection&&this.connection.readyState===this.connection.OPEN},enumerable:!0})};f.prototype.addDefaultEvents=function(){var e=this;this.connection.onerror=function(){e._timeout()},this.connection.onclose=function(){e._timeout(),e.reset()}},f.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},f.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n;var o=this;this._customTimeout&&setTimeout(function(){o.responseCallbacks[r]&&(o.responseCallbacks[r](i.ConnectionTimeout(o._customTimeout)),delete o.responseCallbacks[r])},this._customTimeout)},f.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on WS")),delete this.responseCallbacks[e])},f.prototype.send=function(e,t){var r=this;if(this.connection.readyState!==this.connection.CONNECTING){if(this.connection.readyState!==this.connection.OPEN)return console.error("connection not open on send()"),"function"==typeof this.connection.onerror?this.connection.onerror(new Error("connection not open")):console.error("no error callback"),void t(new Error("connection not open"));this.connection.send(JSON.stringify(e)),this._addResponseCallback(e,t)}else setTimeout(function(){r.send(e,t)},10)},f.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;case"connect":this.connection.onopen=t;break;case"end":this.connection.onclose=t;break;case"error":this.connection.onerror=t}},f.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)})}},f.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;case"connect":this.connection.onopen=null;break;case"end":this.connection.onclose=null;break;case"error":this.connection.onerror=null}},f.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.addDefaultEvents()},f.prototype.disconnect=function(){this.connection&&this.connection.close()},t.exports=f}).call(this,e("buffer").Buffer)},{buffer:84,underscore:325,url:327,"web3-core-helpers":338,websocket:408}],401:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-subscriptions").subscriptions,o=e("web3-core-method"),a=e("web3-net"),s=function(){var e=this;n.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments)},this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new a(this.currentProvider),[new i({name:"subscribe",type:"shh",subscriptions:{messages:{params:1}}}),new o({name:"getVersion",call:"shh_version",params:0}),new o({name:"getInfo",call:"shh_info",params:0}),new o({name:"setMaxMessageSize",call:"shh_setMaxMessageSize",params:1}),new o({name:"setMinPoW",call:"shh_setMinPoW",params:1}),new o({name:"markTrustedPeer",call:"shh_markTrustedPeer",params:1}),new o({name:"newKeyPair",call:"shh_newKeyPair",params:0}),new o({name:"addPrivateKey",call:"shh_addPrivateKey",params:1}),new o({name:"deleteKeyPair",call:"shh_deleteKeyPair",params:1}),new o({name:"hasKeyPair",call:"shh_hasKeyPair",params:1}),new o({name:"getPublicKey",call:"shh_getPublicKey",params:1}),new o({name:"getPrivateKey",call:"shh_getPrivateKey",params:1}),new o({name:"newSymKey",call:"shh_newSymKey",params:0}),new o({name:"addSymKey",call:"shh_addSymKey",params:1}),new o({name:"generateSymKeyFromPassword",call:"shh_generateSymKeyFromPassword",params:1}),new o({name:"hasSymKey",call:"shh_hasSymKey",params:1}),new o({name:"getSymKey",call:"shh_getSymKey",params:1}),new o({name:"deleteSymKey",call:"shh_deleteSymKey",params:1}),new o({name:"newMessageFilter",call:"shh_newMessageFilter",params:1}),new o({name:"getFilterMessages",call:"shh_getFilterMessages",params:1}),new o({name:"deleteMessageFilter",call:"shh_deleteMessageFilter",params:1}),new o({name:"post",call:"shh_post",params:1,inputFormatter:[null]}),new o({name:"unsubscribe",call:"shh_unsubscribe",params:1})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(s),t.exports=s},{"web3-core":348,"web3-core-method":339,"web3-core-subscriptions":345,"web3-net":372}],402:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],403:[function(e,t,r){var n=e("underscore"),i=e("ethjs-unit"),o=e("./utils.js"),a=e("./soliditySha3.js"),s=e("randomhex"),u=function(e,t){var r=[];return t.forEach(function(t){if("object"==typeof t.components){if("tuple"!==t.type.substring(0,5))throw new Error("components found but type is not tuple; report on GitHub");var i="",o=t.type.indexOf("[");o>=0&&(i=t.type.substring(o));var a=u(e,t.components);n.isArray(a)&&e?r.push("tuple("+a.join(",")+")"+i):e?r.push("("+a+")"):r.push("("+a.join(",")+")"+i)}else r.push(t.type)}),r},c=function(e){if(!o.isHexStrict(e))throw new Error("The parameter must be a valid HEX string.");var t="",r=0,n=e.length;for("0x"===e.substring(0,2)&&(r=2);r7?r+=e[n].toUpperCase():r+=e[n];return r},toHex:o.toHex,toBN:o.toBN,bytesToHex:o.bytesToHex,hexToBytes:o.hexToBytes,hexToNumberString:o.hexToNumberString,hexToNumber:o.hexToNumber,toDecimal:o.hexToNumber,numberToHex:o.numberToHex,fromDecimal:o.numberToHex,hexToUtf8:o.hexToUtf8,hexToString:o.hexToUtf8,toUtf8:o.hexToUtf8,utf8ToHex:o.utf8ToHex,stringToHex:o.utf8ToHex,fromUtf8:o.utf8ToHex,hexToAscii:c,toAscii:c,asciiToHex:f,fromAscii:f,unitMap:i.unitMap,toWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.toWei(e,t):i.toWei(e,t).toString(10)},fromWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.fromWei(e,t):i.fromWei(e,t).toString(10)},padLeft:o.leftPad,leftPad:o.leftPad,padRight:o.rightPad,rightPad:o.rightPad,toTwosComplement:o.toTwosComplement}},{"./soliditySha3.js":404,"./utils.js":405,"ethjs-unit":153,randomhex:274,underscore:325}],404:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("./utils.js"),a=function(e){var t=typeof e;if("string"===t)return o.isHexStrict(e)?new i(e.replace(/0x/i,""),16):new i(e,10);if("number"===t)return new i(e);if(o.isBigNumber(e))return new i(e.toString(10));if(o.isBN(e))return e;throw new Error(e+" is not a number")},s=function(e,t,r){var n,s,u;if("bytes"===(e=(u=e).startsWith("int[")?"int256"+u.slice(3):"int"===u?"int256":u.startsWith("uint[")?"uint256"+u.slice(4):"uint"===u?"uint256":u.startsWith("fixed[")?"fixed128x128"+u.slice(5):"fixed"===u?"fixed128x128":u.startsWith("ufixed[")?"ufixed128x128"+u.slice(6):"ufixed"===u?"ufixed128x128":u)){if(t.replace(/^0x/i,"").length%2!=0)throw new Error("Invalid bytes characters "+t.length);return t}if("string"===e)return o.utf8ToHex(t);if("bool"===e)return t?"01":"00";if(e.startsWith("address")){if(n=r?64:40,!o.isAddress(t))throw new Error(t+" is not a valid address, or the checksum is invalid.");return o.leftPad(t.toLowerCase(),n)}if(n=function(e){var t=/^\D+(\d+).*$/.exec(e);return t?parseInt(t[1],10):null}(e),e.startsWith("bytes")){if(!n)throw new Error("bytes[] not yet supported in solidity");if(r&&(n=32),n<1||n>32||n256)throw new Error("Invalid uint"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied uint exceeds width: "+n+" vs "+s.bitLength());if(s.lt(new i(0)))throw new Error("Supplied uint "+s.toString()+" is negative");return n?o.leftPad(s.toString("hex"),n/8*2):s}if(e.startsWith("int")){if(n%8||n<8||n>256)throw new Error("Invalid int"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied int exceeds width: "+n+" vs "+s.bitLength());return s.lt(new i(0))?s.toTwos(n).toString("hex"):n?o.leftPad(s.toString("hex"),n/8*2):s}throw new Error("Unsupported or invalid type: "+e)},u=function(e){if(n.isArray(e))throw new Error("Autodetection of array types is not supported.");var t,r,a="";if(n.isObject(e)&&(e.hasOwnProperty("v")||e.hasOwnProperty("t")||e.hasOwnProperty("value")||e.hasOwnProperty("type"))?(t=e.hasOwnProperty("t")?e.t:e.type,a=e.hasOwnProperty("v")?e.v:e.value):(t=o.toHex(e,!0),a=o.toHex(e),t.startsWith("int")||t.startsWith("uint")||(t="bytes")),!t.startsWith("int")&&!t.startsWith("uint")||"string"!=typeof a||/^(-)?0x/i.test(a)||(a=new i(a)),n.isArray(a)){if((r=function(e){var t=/^\D+\d*\[(\d+)\]$/.exec(e);return t?parseInt(t[1],10):null}(t))&&a.length!==r)throw new Error(t+" is not matching the given array "+JSON.stringify(a));r=a.length}return n.isArray(a)?a.map(function(e){return s(t,e,r).toString("hex").replace("0x","")}).join(""):s(t,a,r).toString("hex").replace("0x","")};t.exports=function(){var e=Array.prototype.slice.call(arguments),t=n.map(e,u);return o.sha3("0x"+t.join(""))}},{"./utils.js":405,"bn.js":402,underscore:325}],405:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("number-to-bn"),a=e("utf8"),s=e("eth-lib/lib/hash"),u=function(e){return e instanceof i||e&&e.constructor&&"BN"===e.constructor.name},c=function(e){return e&&e.constructor&&"BigNumber"===e.constructor.name},f=function(e){try{return o.apply(null,arguments)}catch(t){throw new Error(t+' Given value: "'+e+'"')}},h=function(e){return!!/^(0x)?[0-9a-f]{40}$/i.test(e)&&(!(!/^(0x|0X)?[0-9a-f]{40}$/.test(e)&&!/^(0x|0X)?[0-9A-F]{40}$/.test(e))||l(e))},l=function(e){e=e.replace(/^0x/i,"");for(var t=m(e.toLowerCase()).replace(/^0x/i,""),r=0;r<40;r++)if(parseInt(t[r],16)>7&&e[r].toUpperCase()!==e[r]||parseInt(t[r],16)<=7&&e[r].toLowerCase()!==e[r])return!1;return!0},d=function(e){var t="";e=(e=(e=(e=(e=a.encode(e)).replace(/^(?:\u0000)*/,"")).split("").reverse().join("")).replace(/^(?:\u0000)*/,"")).split("").reverse().join("");for(var r=0;r>>4).toString(16)),t.push((15&e[r]).toString(16));return"0x"+t.join("")},isHex:function(e){return(n.isString(e)||n.isNumber(e))&&/^(-0x|0x)?[0-9a-f]*$/i.test(e)},isHexStrict:y,leftPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+new Array(i).join(r||"0")+e},rightPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+e+new Array(i).join(r||"0")},toTwosComplement:function(e){return"0x"+f(e).toTwos(256).toString(16,64)},sha3:m}},{"bn.js":402,"eth-lib/lib/hash":134,"number-to-bn":237,underscore:325,utf8:329}],406:[function(e,t,r){t.exports={_from:"web3@1.0.0-beta.36",_id:"web3@1.0.0-beta.36",_inBundle:!1,_integrity:"sha512-fZDunw1V0AQS27r5pUN3eOVP7u8YAvyo6vOapdgVRolAu5LgaweP7jncYyLINqIX9ZgWdS5A090bt+ymgaYHsw==",_location:"/web3",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"web3@1.0.0-beta.36",name:"web3",escapedName:"web3",rawSpec:"1.0.0-beta.36",saveSpec:null,fetchSpec:"1.0.0-beta.36"},_requiredBy:["#USER","/"],_resolved:"https://registry.npmjs.org/web3/-/web3-1.0.0-beta.36.tgz",_shasum:"2954da9e431124c88396025510d840ba731c8373",_spec:"web3@1.0.0-beta.36",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy",author:{name:"ethereum.org"},authors:[{name:"Fabian Vogelsteller",email:"fabian@ethereum.org",homepage:"http://frozeman.de"},{name:"Marek Kotewicz",email:"marek@parity.io",url:"https://github.com/debris"},{name:"Marian Oancea",url:"https://github.com/cubedro"},{name:"Gav Wood",email:"g@parity.io",homepage:"http://gavwood.com"},{name:"Jeffery Wilcke",email:"jeffrey.wilcke@ethereum.org",url:"https://github.com/obscuren"}],bugs:{url:"https://github.com/ethereum/web3.js/issues"},bundleDependencies:!1,dependencies:{"web3-bzz":"1.0.0-beta.36","web3-core":"1.0.0-beta.36","web3-eth":"1.0.0-beta.36","web3-eth-personal":"1.0.0-beta.36","web3-net":"1.0.0-beta.36","web3-shh":"1.0.0-beta.36","web3-utils":"1.0.0-beta.36"},deprecated:!1,description:"Ethereum JavaScript API",keywords:["Ethereum","JavaScript","API"],license:"LGPL-3.0",main:"src/index.js",name:"web3",namespace:"ethereum",repository:{type:"git",url:"https://github.com/ethereum/web3.js/tree/master/packages/web3"},version:"1.0.0-beta.36"}},{}],407:[function(e,t,r){"use strict";var n=e("../package.json").version,i=e("web3-core"),o=e("web3-eth"),a=e("web3-net"),s=e("web3-eth-personal"),u=e("web3-shh"),c=e("web3-bzz"),f=e("web3-utils"),h=function(){var e=this;i.packageInit(this,arguments),this.version=n,this.utils=f,this.eth=new o(this),this.shh=new u(this),this.bzz=new c(this);var t=this.setProvider;this.setProvider=function(r,n){return t.apply(e,arguments),this.eth.setProvider(r,n),this.shh.setProvider(r,n),this.bzz.setProvider(r),!0}};h.version=n,h.utils=f,h.modules={Eth:o,Net:a,Personal:s,Shh:u,Bzz:c},i.addProviders(h),t.exports=h},{"../package.json":406,"web3-bzz":335,"web3-core":348,"web3-eth":371,"web3-eth-personal":369,"web3-net":372,"web3-shh":401,"web3-utils":403}],408:[function(e,t,r){var n=function(){return this||{}}(),i=n.WebSocket||n.MozWebSocket,o=e("./version");function a(e,t){return t?new i(e,t):new i(e)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(e){Object.defineProperty(a,e,{get:function(){return i[e]}})}),t.exports={w3cwebsocket:i?a:null,version:o}},{"./version":409}],409:[function(e,t,r){t.exports=e("../package.json").version},{"../package.json":410}],410:[function(e,t,r){t.exports={_from:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_id:"websocket@1.0.26",_inBundle:!1,_integrity:"",_location:"/websocket",_phantomChildren:{},_requested:{type:"git",raw:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",name:"websocket",escapedName:"websocket",rawSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",saveSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",fetchSpec:"git://github.com/frozeman/WebSocket-Node.git",gitCommittish:"browserifyCompatible"},_requiredBy:["/web3-providers-ws"],_resolved:"git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",_spec:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy/node_modules/web3-providers-ws",author:{name:"Brian McKelvey",email:"brian@worlize.com",url:"https://www.worlize.com/"},browser:"lib/browser.js",bugs:{url:"https://github.com/theturtle32/WebSocket-Node/issues"},bundleDependencies:!1,config:{verbose:!1},contributors:[{name:"Iñaki Baz Castillo",email:"ibc@aliax.net",url:"http://dev.sipdoc.net"}],dependencies:{debug:"^2.2.0",nan:"^2.3.3","typedarray-to-buffer":"^3.1.2",yaeti:"^0.0.6"},deprecated:!1,description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",devDependencies:{"buffer-equal":"^1.0.0",faucet:"^0.0.1",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-jshint":"^2.0.4",jshint:"^2.0.0","jshint-stylish":"^2.2.1",tape:"^4.0.1"},directories:{lib:"./lib"},engines:{node:">=0.10.0"},homepage:"https://github.com/theturtle32/WebSocket-Node",keywords:["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],license:"Apache-2.0",main:"index",name:"websocket",repository:{type:"git",url:"git+https://github.com/theturtle32/WebSocket-Node.git"},scripts:{gulp:"gulp",install:"(node-gyp rebuild 2> builderror.log) || (exit 0)",test:"faucet test/unit"},version:"1.0.26"}},{}],411:[function(e,t,r){var n=e("xhr-request");t.exports=function(e,t){return new Promise(function(r,i){n(e,t,function(e,t){e?i(e):r(t)})})}},{"xhr-request":412}],412:[function(e,t,r){var n=e("query-string"),i=e("url-set-query"),o=e("object-assign"),a=e("./lib/ensure-header.js"),s=e("./lib/request.js"),u="application/json",c=function(){};t.exports=function(e,t,r){if(!e||"string"!=typeof e)throw new TypeError("must specify a URL");"function"==typeof t&&(r=t,t={});if(r&&"function"!=typeof r)throw new TypeError("expected cb to be undefined or a function");r=r||c;var f=(t=t||{}).json?"json":"text",h=(t=o({responseType:f},t)).headers||{},l=(t.method||"GET").toUpperCase(),d=t.query;d&&("string"!=typeof d&&(d=n.stringify(d)),e=i(e,d));"json"===t.responseType&&a(h,"Accept",u);t.json&&"GET"!==l&&"HEAD"!==l&&(a(h,"Content-Type",u),t.body=JSON.stringify(t.body));return t.method=l,t.url=e,t.headers=h,delete t.query,delete t.json,s(t,r)}},{"./lib/ensure-header.js":413,"./lib/request.js":415,"object-assign":238,"query-string":266,"url-set-query":326}],413:[function(e,t,r){t.exports=function(e,t,r){var n=t.toLowerCase();e[t]||e[n]||(e[t]=r)}},{}],414:[function(e,t,r){t.exports=function(e,t){return t?{statusCode:t.statusCode,headers:t.headers,method:e.method,url:e.url,rawRequest:t.rawRequest?t.rawRequest:t}:null}},{}],415:[function(e,t,r){var n=e("xhr"),i=e("./normalize-response"),o=function(){};t.exports=function(e,t){delete e.uri;var r=!1;"json"===e.responseType&&(e.responseType="text",r=!0);var a=n(e,function(n,a,s){if(r&&!n)try{var u=a.rawRequest.responseText;s=JSON.parse(u)}catch(e){n=e}a=i(e,a),t(n,n?null:s,a),t=o}),s=a.onabort;return a.onabort=function(){var e=s.apply(a,Array.prototype.slice.call(arguments));return t(new Error("XHR Aborted")),t=o,e},a}},{"./normalize-response":414,xhr:416}],416:[function(e,t,r){"use strict";var n=e("global/window"),i=e("is-function"),o=e("parse-headers"),a=e("xtend");function s(e,t,r){var n=e;return i(t)?(r=t,"string"==typeof e&&(n={uri:e})):n=a(t,{uri:e}),n.callback=r,n}function u(e,t,r){return c(t=s(e,t,r))}function c(e){if(void 0===e.callback)throw new Error("callback argument missing");var t=!1,r=function(r,n,i){t||(t=!0,e.callback(r,n,i))};function n(e){return clearTimeout(f),e instanceof Error||(e=new Error(""+(e||"Unknown XMLHttpRequest Error"))),e.statusCode=0,r(e,m)}function i(){if(!s){var t;clearTimeout(f),t=e.useXDR&&void 0===c.status?200:1223===c.status?204:c.status;var n=m,i=null;return 0!==t?(n={body:function(){var e=void 0;if(e=c.response?c.response:c.responseText||function(e){try{if("document"===e.responseType)return e.responseXML;var t=e.responseXML&&"parsererror"===e.responseXML.documentElement.nodeName;if(""===e.responseType&&!t)return e.responseXML}catch(e){}return null}(c),y)try{e=JSON.parse(e)}catch(e){}return e}(),statusCode:t,method:l,headers:{},url:h,rawRequest:c},c.getAllResponseHeaders&&(n.headers=o(c.getAllResponseHeaders()))):i=new Error("Internal XMLHttpRequest Error"),r(i,n,n.body)}}var a,s,c=e.xhr||null;c||(c=e.cors||e.useXDR?new u.XDomainRequest:new u.XMLHttpRequest);var f,h=c.url=e.uri||e.url,l=c.method=e.method||"GET",d=e.body||e.data,p=c.headers=e.headers||{},b=!!e.sync,y=!1,m={body:void 0,headers:{},statusCode:0,method:l,url:h,rawRequest:c};if("json"in e&&!1!==e.json&&(y=!0,p.accept||p.Accept||(p.Accept="application/json"),"GET"!==l&&"HEAD"!==l&&(p["content-type"]||p["Content-Type"]||(p["Content-Type"]="application/json"),d=JSON.stringify(!0===e.json?d:e.json))),c.onreadystatechange=function(){4===c.readyState&&setTimeout(i,0)},c.onload=i,c.onerror=n,c.onprogress=function(){},c.onabort=function(){s=!0},c.ontimeout=n,c.open(l,h,!b,e.username,e.password),b||(c.withCredentials=!!e.withCredentials),!b&&e.timeout>0&&(f=setTimeout(function(){if(!s){s=!0,c.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT",n(e)}},e.timeout)),c.setRequestHeader)for(a in p)p.hasOwnProperty(a)&&c.setRequestHeader(a,p[a]);else if(e.headers&&!function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}(e.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in e&&(c.responseType=e.responseType),"beforeSend"in e&&"function"==typeof e.beforeSend&&e.beforeSend(c),c.send(d||null),c}t.exports=u,t.exports.default=u,u.XMLHttpRequest=n.XMLHttpRequest||function(){},u.XDomainRequest="withCredentials"in new u.XMLHttpRequest?u.XMLHttpRequest:n.XDomainRequest,function(e,t){for(var r=0;r=0)return this._url=this._parseUrl(t.headers.location),this._method="GET",this._loweredHeaders["content-type"]&&(delete this._headers[this._loweredHeaders["content-type"]],delete this._loweredHeaders["content-type"]),null!=this._headers["Content-Type"]&&delete this._headers["Content-Type"],delete this._headers["Content-Length"],this.upload._reset(),this._finalizeHeaders(),void this._sendHxxpRequest();this._response=t,this._response.on("data",function(e){return n._onHttpResponseData(t,e)}),this._response.on("end",function(){return n._onHttpResponseEnd(t)}),this._response.on("close",function(){return n._onHttpResponseClose(t)}),this.responseUrl=this._url.href.split("#")[0],this.status=t.statusCode,this.statusText=s.STATUS_CODES[this.status],this._parseResponseHeaders(t);var i=this._responseHeaders["content-length"]||"";this._totalBytes=+i,this._lengthComputable=!!i,this._setReadyState(r.HEADERS_RECEIVED)}},r.prototype._onHttpResponseData=function(e,t){this._response===e&&(this._responseParts.push(new n(t)),this._loadedBytes+=t.length,this.readyState!==r.LOADING&&this._setReadyState(r.LOADING),this._dispatchProgress("progress"))},r.prototype._onHttpResponseEnd=function(e){this._response===e&&(this._parseResponse(),this._request=null,this._response=null,this._setReadyState(r.DONE),this._dispatchProgress("load"),this._dispatchProgress("loadend"))},r.prototype._onHttpResponseClose=function(e){if(this._response===e){var t=this._request;this._setError(),t.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend")}},r.prototype._onHttpTimeout=function(e){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("timeout"),this._dispatchProgress("loadend"))},r.prototype._onHttpRequestError=function(e,t){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend"))},r.prototype._dispatchProgress=function(e){var t=new r.ProgressEvent(e);t.lengthComputable=this._lengthComputable,t.loaded=this._loadedBytes,t.total=this._totalBytes,this.dispatchEvent(t)},r.prototype._setError=function(){this._request=null,this._response=null,this._responseHeaders=null,this._responseParts=null},r.prototype._parseUrl=function(e,t,r){var n=null==this.nodejsBaseUrl?e:f.resolve(this.nodejsBaseUrl,e),i=f.parse(n,!1,!0);i.hash=null;var o=(i.auth||"").split(":"),a=o[0],s=o[1];return(a||s||t||r)&&(i.auth=(t||a||"")+":"+(r||s||"")),i},r.prototype._parseResponseHeaders=function(e){for(var t in this._responseHeaders={},e.headers){var r=t.toLowerCase();this._privateHeaders[r]||(this._responseHeaders[r]=e.headers[t])}null!=this._mimeOverride&&(this._responseHeaders["content-type"]=this._mimeOverride)},r.prototype._parseResponse=function(){var e=n.concat(this._responseParts);switch(this._responseParts=null,this.responseType){case"json":this.responseText=null;try{this.response=JSON.parse(e.toString("utf-8"))}catch(e){this.response=null}return;case"buffer":return this.responseText=null,void(this.response=e);case"arraybuffer":this.responseText=null;for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),i=0;i BigUInt - /// Creates a checkpoint that can be used to query historical balances / totalSuppy + /// Creates a checkpoint that can be used to query historical balances / totalSupply func createCheckpoint(from: EthereumAddress) async throws -> WriteOperation /// gets length of investors array diff --git a/Sources/web3swift/Utils/EIP/EIP681.swift b/Sources/web3swift/Utils/EIP/EIP681.swift index 264dc5d37..9e2dbdb0d 100755 --- a/Sources/web3swift/Utils/EIP/EIP681.swift +++ b/Sources/web3swift/Utils/EIP/EIP681.swift @@ -62,8 +62,8 @@ extension Web3 { switch targetAddress { case .ethereumAddress(let ethereumAddress): address = ethereumAddress.address - case let .ensAddress(ensAdress): - address = ensAdress + case let .ensAddress(ensAddress): + address = ensAddress } var link = "ethereum:\(address)\(chainID != nil ? "@\(chainID!.description)" : "")" if let functionName = functionName, !functionName.isEmpty { @@ -431,14 +431,14 @@ extension Web3 { var nativeValueArray: [Any] = [] for value in rawValues { - let intermidiateValue = await parseFunctionArgument(type, + let intermediateValue = await parseFunctionArgument(type, value, chainID: chainID, inputNumber: inputNumber)? .parameter .value - if let intermidiateValue = intermidiateValue { - nativeValueArray.append(intermidiateValue) + if let intermediateValue = intermediateValue { + nativeValueArray.append(intermediateValue) } } nativeValue = nativeValueArray diff --git a/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift b/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift index a7082d731..5b7c2d5f4 100644 --- a/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift +++ b/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift @@ -64,7 +64,7 @@ public extension ENS { return expirity } - @available(*, message: "This function should not be used to check if a name can be registered by a user. To check if a name can be registered by a user, check name availablility via the controller") + @available(*, message: "This function should not be used to check if a name can be registered by a user. To check if a name can be registered by a user, check name availability via the controller") public func isNameAvailable(name: BigUInt) async throws -> Bool { guard let transaction = self.contract.createReadOperation("available", parameters: [name]) else { throw Web3Error.transactionSerializationError } diff --git a/Sources/web3swift/Web3/Web3+EIP1559.swift b/Sources/web3swift/Web3/Web3+EIP1559.swift index b7a5237f5..d49e2ea6c 100644 --- a/Sources/web3swift/Web3/Web3+EIP1559.swift +++ b/Sources/web3swift/Web3/Web3+EIP1559.swift @@ -138,7 +138,7 @@ public extension Web3 { /// Block number: 13_773_000 case ArrowGlacier - var mainNetFisrtBlockNumber: BigUInt { + var mainNetFirstBlockNumber: BigUInt { switch self { case .Byzantium: return 4_370_000 case .Constantinople: return 7_280_000 @@ -154,20 +154,20 @@ public extension Web3 { static func getChainVersion(of block: BigUInt) -> MainChainVersion { // Iterate given block number over each ChainVersion block numbers // to get the block's ChainVersion. - if block < MainChainVersion.Constantinople.mainNetFisrtBlockNumber { + if block < MainChainVersion.Constantinople.mainNetFirstBlockNumber { return .Byzantium // ~= means included in a given range - } else if MainChainVersion.Constantinople.mainNetFisrtBlockNumber..= MainChainVersion.ArrowGlacier.mainNetFisrtBlockNumber { + } else if block >= MainChainVersion.ArrowGlacier.mainNetFirstBlockNumber { // Pass to the default return. } return .ArrowGlacier @@ -175,7 +175,7 @@ public extension Web3 { } extension Web3.MainChainVersion: Comparable { - public static func < (lhs: Web3.MainChainVersion, rhs: Web3.MainChainVersion) -> Bool { return lhs.mainNetFisrtBlockNumber < rhs.mainNetFisrtBlockNumber } + public static func < (lhs: Web3.MainChainVersion, rhs: Web3.MainChainVersion) -> Bool { return lhs.mainNetFirstBlockNumber < rhs.mainNetFirstBlockNumber } } extension Block { From 7f5e70e98e628dd195149f3b45cd6634f2e99de7 Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Wed, 8 Mar 2023 23:58:19 +0000 Subject: [PATCH 150/210] revert change --- Sources/Web3Core/Structure/SECP256k1.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index 9ebcaa9cb..cd2c6f695 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -206,7 +206,7 @@ extension SECP256K1 { return recoverableSignature } - internal static func serializeSignature(recoverableSignature: input secp256k1_ecdsa_recoverable_signature) -> Data? { + internal static func serializeSignature(recoverableSignature: inout secp256k1_ecdsa_recoverable_signature) -> Data? { guard let context = context else { return nil } var serializedSignature = Data(repeating: 0x00, count: 64) var v: Int32 = 0 From c786c0f6c93fe9f9be38da17697563d538b396e4 Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Wed, 8 Mar 2023 23:58:29 +0000 Subject: [PATCH 151/210] revert change --- Sources/Web3Core/Structure/SECP256k1.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index cd2c6f695..76eba0bc8 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -124,7 +124,7 @@ extension SECP256K1 { return publicKey } - public static func serializePublicKey(publicKey: input secp256k1_pubkey, compressed: Bool = false) -> Data? { + public static func serializePublicKey(publicKey: inout secp256k1_pubkey, compressed: Bool = false) -> Data? { guard let context = context else { return nil } var keyLength = compressed ? 33 : 65 var serializedPubkey = Data(repeating: 0x00, count: keyLength) From 111885e235a25d548575250980325b0a291669d7 Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Wed, 8 Mar 2023 23:58:38 +0000 Subject: [PATCH 152/210] revert change --- Sources/Web3Core/Structure/SECP256k1.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index 76eba0bc8..d47c0577b 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -83,7 +83,7 @@ extension SECP256K1 { return serializedKey } - internal static func recoverPublicKey(hash: Data, recoverableSignature: input secp256k1_ecdsa_recoverable_signature) -> secp256k1_pubkey? { + internal static func recoverPublicKey(hash: Data, recoverableSignature: inout secp256k1_ecdsa_recoverable_signature) -> secp256k1_pubkey? { guard let context = context, hash.count == 32 else { return nil } var publicKey: secp256k1_pubkey = secp256k1_pubkey() let result = hash.withUnsafeBytes { (hashRawBufferPointer: UnsafeRawBufferPointer) -> Int32? in From 74b54ecef0639441a7cd6db8d786ec6fbef81921 Mon Sep 17 00:00:00 2001 From: Sara Tavares Date: Thu, 9 Mar 2023 00:03:33 +0000 Subject: [PATCH 153/210] revert changes --- Sources/web3swift/Browser/browser.js | 200 +++++++++++++-------------- 1 file changed, 100 insertions(+), 100 deletions(-) diff --git a/Sources/web3swift/Browser/browser.js b/Sources/web3swift/Browser/browser.js index f1ba2fff4..d85214d3d 100644 --- a/Sources/web3swift/Browser/browser.js +++ b/Sources/web3swift/Browser/browser.js @@ -137,7 +137,7 @@ * * 1. Previous registration * 2. global.Promise if node.js version >= 0.12 - * 3. Auto detected promise based on first successful require of + * 3. Auto detected promise based on first sucessful require of * known promise libraries. Note this is a last resort, as the * loaded library is non-deterministic. node.js >= 0.12 will * always use global.Promise over this priority list. @@ -1554,7 +1554,7 @@ // Long form var num = len & 0x7f; if (num > 4) - return buf.error('length octet is too long'); + return buf.error('length octect is too long'); len = 0; for (var i = 0; i < num; i++) { @@ -1706,7 +1706,7 @@ if (!this._isPrintstr(str)) { return this.reporter.error('Encoding of string type: printstr supports ' + 'only latin upper and lower case letters, ' + - 'digits, space, apostrophe, left and right ' + + 'digits, space, apostrophe, left and rigth ' + 'parenthesis, plus sign, comma, hyphen, ' + 'dot, slash, colon, equal sign, ' + 'question mark'); @@ -9326,7 +9326,7 @@ this.backoffNumber_++; }; - // Stops any backoff operation and resets the backoff delay to its initial value. + // Stops any backoff operation and resets the backoff delay to its inital value. Backoff.prototype.reset = function() { this.backoffNumber_ = 0; this.backoffStrategy_.reset(); @@ -13413,7 +13413,7 @@ },{"crypto":55}],55:[function(require,module,exports){ },{}],56:[function(require,module,exports){ - // based on the aes implementation in triple sec + // based on the aes implimentation in triple sec // https://github.com/keybase/triplesec // which is in turn based on the one from crypto-js // https://code.google.com/p/crypto-js/ @@ -13762,7 +13762,7 @@ module.exports = StreamCipher },{"./aes":56,"./ghash":61,"./incr32":62,"buffer-xor":83,"cipher-base":86,"inherits":180,"safe-buffer":290}],58:[function(require,module,exports){ - var ciphers = require('./encryptor') + var ciphers = require('./encrypter') var deciphers = require('./decrypter') var modes = require('./modes/list.json') @@ -13776,7 +13776,7 @@ exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv exports.listCiphers = exports.getCiphers = getCiphers - },{"./decrypter":59,"./encryptor":60,"./modes/list.json":70}],59:[function(require,module,exports){ + },{"./decrypter":59,"./encrypter":60,"./modes/list.json":70}],59:[function(require,module,exports){ var AuthCipher = require('./authCipher') var Buffer = require('safe-buffer').Buffer var MODES = require('./modes') @@ -14633,15 +14633,15 @@ var inherits = require('inherits') var modes = { - 'des-edge3-cbc': des.CBC.instantiate(des.EDGE), - 'des-edge3': des.EDGE, - 'des-edge-cbc': des.CBC.instantiate(des.EDGE), - 'des-edge': des.EDGE, + 'des-ede3-cbc': des.CBC.instantiate(des.EDE), + 'des-ede3': des.EDE, + 'des-ede-cbc': des.CBC.instantiate(des.EDE), + 'des-ede': des.EDE, 'des-cbc': des.CBC.instantiate(des.DES), 'des-ecb': des.DES } modes.des = modes['des-cbc'] - modes.des3 = modes['des-edge3-cbc'] + modes.des3 = modes['des-ede3-cbc'] module.exports = DES inherits(DES, CipherBase) function DES (opts) { @@ -14655,7 +14655,7 @@ type = 'encrypt' } var key = opts.key - if (modeName === 'des-edge' || modeName === 'des-edge-cbc') { + if (modeName === 'des-ede' || modeName === 'des-ede-cbc') { key = Buffer.concat([key, key.slice(0, 8)]) } var iv = opts.iv @@ -14682,19 +14682,19 @@ key: 8, iv: 8 } - exports['des-edge3-cbc'] = exports.des3 = { + exports['des-ede3-cbc'] = exports.des3 = { key: 24, iv: 8 } - exports['des-edge3'] = { + exports['des-ede3'] = { key: 24, iv: 0 } - exports['des-edge-cbc'] = { + exports['des-ede-cbc'] = { key: 16, iv: 8 } - exports['des-edge'] = { + exports['des-ede'] = { key: 16, iv: 0 } @@ -15406,7 +15406,7 @@ if (fill !== undefined) { // Only pay attention to encoding if it's a string. This // prevents accidentally sending in a number that would - // be interpreted as a start offset. + // be interpretted as a start offset. return typeof encoding === 'string' ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill) @@ -15689,7 +15689,7 @@ return '' } - // Force coercion to uint32. This will also coerce falsey/NaN values to 0. + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. end >>>= 0 start >>>= 0 @@ -18955,7 +18955,7 @@ exports.Cipher = require('./des/cipher'); exports.DES = require('./des/des'); exports.CBC = require('./des/cbc'); - exports.EDGE = require('./des/ede'); + exports.EDE = require('./des/ede'); },{"./des/cbc":100,"./des/cipher":101,"./des/des":102,"./des/ede":103,"./des/utils":104}],100:[function(require,module,exports){ 'use strict'; @@ -19322,7 +19322,7 @@ var Cipher = des.Cipher; var DES = des.DES; - function EDGEState(type, key) { + function EDEState(type, key) { assert.equal(key.length, 24, 'Invalid key length'); var k1 = key.slice(0, 8); @@ -19344,30 +19344,30 @@ } } - function EDGE(options) { + function EDE(options) { Cipher.call(this, options); - var state = new EDGEState(this.type, this.options.key); - this._edgeState = state; + var state = new EDEState(this.type, this.options.key); + this._edeState = state; } - inherits(EDGE, Cipher); + inherits(EDE, Cipher); - module.exports = EDGE; + module.exports = EDE; - EDGE.create = function create(options) { - return new EDGE(options); + EDE.create = function create(options) { + return new EDE(options); }; - EDGE.prototype._update = function _update(inp, inOff, out, outOff) { - var state = this._edgeState; + EDE.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._edeState; state.ciphers[0]._update(inp, inOff, out, outOff); state.ciphers[1]._update(out, outOff, out, outOff); state.ciphers[2]._update(out, outOff, out, outOff); }; - EDGE.prototype._pad = DES.prototype._pad; - EDGE.prototype._unpad = DES.prototype._unpad; + EDE.prototype._pad = DES.prototype._pad; + EDE.prototype._unpad = DES.prototype._unpad; },{"../des":99,"inherits":180,"minimalistic-assert":234}],104:[function(require,module,exports){ 'use strict'; @@ -22355,7 +22355,7 @@ var isYOdd = j & 1; var isSecondKey = j >> 1; if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) - throw new Error('Unable to find second key candidate'); + throw new Error('Unable to find sencond key candinate'); // 1.1. Let x = r + jn. if (isSecondKey) @@ -24751,7 +24751,7 @@ try { // attempt request await performFetch(network, req, res) - // request was successful + // request was succesful break } catch (err) { // an error was caught while performing the request @@ -25749,7 +25749,7 @@ }, "expGas": { "v": 10, - "d": "Once per EXP instruction." + "d": "Once per EXP instuction." }, "expByteGas": { "v": 10, @@ -25894,11 +25894,11 @@ }, "ommerReward": { "v": "625000000000000000", - "d": "The amount of wei a miner of an uncle block gets for being included in the blockchain" + "d": "The amount of wei a miner of an uncle block gets for being inculded in the blockchain" }, "niblingReward": { "v": "156250000000000000", - "d": "the amount a miner gets for including a uncle" + "d": "the amount a miner gets for inculding a uncle" }, "homeSteadForkNumber": { "v": 1150000, @@ -26526,7 +26526,7 @@ * var tx = new Transaction(rawTx); * * @class - * @param {Buffer | Array | Object} data a transaction can be initiailized with either a buffer containing the RLP serialized transaction or an array of buffers relating to each of the tx Properties, listed in order below in the example. + * @param {Buffer | Array | Object} data a transaction can be initiailized with either a buffer containing the RLP serialized transaction or an array of buffers relating to each of the tx Properties, listed in order below in the exmple. * * Or lastly an Object containing the Properties of the transaction like in the Usage example. * @@ -26643,7 +26643,7 @@ /** * Computes a sha3-256 hash of the serialized tx - * @param {Boolean} [includeSignature=true] whether or not to include the signature + * @param {Boolean} [includeSignature=true] whether or not to inculde the signature * @return {Buffer} */ @@ -27509,7 +27509,7 @@ } }); - // if the constructor is passed data + // if the constuctor is passed data if (data) { if (typeof data === 'string') { data = Buffer.from(exports.stripHexPrefix(data), 'hex'); @@ -28338,7 +28338,7 @@ else if (c === ')') { depth--; if (depth === -1) { - throw new Error('unbalanced parenthesis'); + throw new Error('unbalanced parenthsis'); } } } @@ -28613,7 +28613,7 @@ * BigNumber * * A wrapper around the BN.js object. We use the BN.js library - * because it is used by elliptic, so it is required regardless. + * because it is used by elliptic, so it is required regardles. * */ var bn_js_1 = __importDefault(require("bn.js")); @@ -28826,7 +28826,7 @@ if (typeof (value) === 'string') { var match = value.match(/^(0x)?[0-9a-fA-F]*$/); if (!match) { - errors.throwError('invalid hexadecimal string', errors.INVALID_ARGUMENT, { arg: 'value', value: value }); + errors.throwError('invalid hexidecimal string', errors.INVALID_ARGUMENT, { arg: 'value', value: value }); } if (match[1] !== '0x') { errors.throwError('hex string must have 0x prefix', errors.INVALID_ARGUMENT, { arg: 'value', value: value }); @@ -28929,7 +28929,7 @@ if (typeof (value) === 'string') { var match = value.match(/^(0x)?[0-9a-fA-F]*$/); if (!match) { - errors.throwError('invalid hexadecimal string', errors.INVALID_ARGUMENT, { arg: 'value', value: value }); + errors.throwError('invalid hexidecimal string', errors.INVALID_ARGUMENT, { arg: 'value', value: value }); } if (match[1] !== '0x') { errors.throwError('hex string must have 0x prefix', errors.INVALID_ARGUMENT, { arg: 'value', value: value }); @@ -29311,7 +29311,7 @@ else if (data[offset] >= 0x80) { var length = data[offset] - 0x80; if (offset + 1 + length > data.length) { - throw new Error('invalid rlp data'); + throw new Error('invlaid rlp data'); } var result = bytes_1.hexlify(data.slice(offset + 1, offset + 1 + length)); return { consumed: (1 + length), result: result }; @@ -33460,7 +33460,7 @@ * Register a new EventListener for the given event. * * @param {String} event Name of the event. - * @param {Function} fn Callback function. + * @param {Functon} fn Callback function. * @param {Mixed} context The context of the function. * @api public */ @@ -36311,7 +36311,7 @@ throw new Error("Failed to validate " + label); // 4. The label must not contain a U+002E ( . ) FULL STOP. - // this should never happen as label is chunked internally by this character + // this should nerver happen as label is chunked internally by this character /* istanbul ignore if */ if (label.includes('.')) throw new Error("Failed to validate " + label); @@ -37409,7 +37409,7 @@ case 'shake128': return new Shake(1344, 256, 0x1f, options) case 'shake256': return new Shake(1088, 512, 0x1f, options) - default: throw new Error('Invalid algorithm: ' + algorithm) + default: throw new Error('Invald algorithm: ' + algorithm) } } } @@ -42912,7 +42912,7 @@ var cachedSetTimeout; var cachedClearTimeout; - function defaultSetTimeout() { + function defaultSetTimout() { throw new Error('setTimeout has not been defined'); } function defaultClearTimeout () { @@ -42923,10 +42923,10 @@ if (typeof setTimeout === 'function') { cachedSetTimeout = setTimeout; } else { - cachedSetTimeout = defaultSetTimeout; + cachedSetTimeout = defaultSetTimout; } } catch (e) { - cachedSetTimeout = defaultSetTimeout; + cachedSetTimeout = defaultSetTimout; } try { if (typeof clearTimeout === 'function') { @@ -42940,23 +42940,23 @@ } ()) function runTimeout(fun) { if (cachedSetTimeout === setTimeout) { - //normal environments in sane situations + //normal enviroments in sane situations return setTimeout(fun, 0); } // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimeout || !cachedSetTimeout) && setTimeout) { + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { cachedSetTimeout = setTimeout; return setTimeout(fun, 0); } try { - // when when somebody has screwed with setTimeout but no I.E. madness + // when when somebody has screwed with setTimeout but no I.E. maddness return cachedSetTimeout(fun, 0); } catch(e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedSetTimeout.call(null, fun, 0); } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopefully our context correct otherwise it will throw a global error + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error return cachedSetTimeout.call(this, fun, 0); } } @@ -42965,7 +42965,7 @@ } function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { - //normal environments in sane situations + //normal enviroments in sane situations return clearTimeout(marker); } // if clearTimeout wasn't available but was latter defined @@ -42974,14 +42974,14 @@ return clearTimeout(marker); } try { - // when when somebody has screwed with setTimeout but no I.E. madness + // when when somebody has screwed with setTimeout but no I.E. maddness return cachedClearTimeout(marker); } catch (e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedClearTimeout.call(null, marker); } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopefully our context correct otherwise it will throw a global error. + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. // Some versions of I.E. have different rules for clearTimeout vs setTimeout return cachedClearTimeout.call(this, marker); } @@ -43047,7 +43047,7 @@ } }; - // v8 likes predictable objects + // v8 likes predictible objects function Item(fun, array) { this.fun = fun; this.array = array; @@ -47142,7 +47142,7 @@ /** * RLP Decoding based on: {@link https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-RLP|RLP} * @param {Buffer,String,Integer,Array} data - will be converted to buffer - * @returns {Array} - returns decode Array of Buffers containing the original message + * @returns {Array} - returns decode Array of Buffers containg the original message **/ exports.decode = function (input, stream) { if (!input || input.length === 0) { @@ -47460,7 +47460,7 @@ try { ReflectApply(handler, context, args) } catch (err) { - // throw error after timeout so as not to interrupt the stack + // throw error after timeout so as not to interupt the stack setTimeout(() => { throw err }) @@ -48037,7 +48037,7 @@ B32[i] |= (B[i * 4 + 1] & 0xff) << 8 B32[i] |= (B[i * 4 + 2] & 0xff) << 16 B32[i] |= (B[i * 4 + 3] & 0xff) << 24 - // B32[i] = B.readUInt32LE(i*4) <--- this is significantly slower even in Node.js + // B32[i] = B.readUInt32LE(i*4) <--- this is signficantly slower even in Node.js } arraycopy(B32, 0, x, 0, 16) @@ -48085,7 +48085,7 @@ B[bi + 1] = (B32[i] >> 8 & 0xff) B[bi + 2] = (B32[i] >> 16 & 0xff) B[bi + 3] = (B32[i] >> 24 & 0xff) - // B.writeInt32LE(B32[i], i*4) //<--- this is significantly slower even in Node.js + // B.writeInt32LE(B32[i], i*4) //<--- this is signficantly slower even in Node.js } } @@ -49728,18 +49728,18 @@ var Wi16l = W[i - 16 * 2 + 1] var Wil = (gamma0l + Wi7l) | 0 - var With = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0 + var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0 Wil = (Wil + gamma1l) | 0 - With = (With + gamma1 + getCarry(Wil, gamma1l)) | 0 + Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0 Wil = (Wil + Wi16l) | 0 - With = (With + Wi16h + getCarry(Wil, Wi16l)) | 0 + Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0 - W[i] = With + W[i] = Wih W[i + 1] = Wil } for (var j = 0; j < 160; j += 2) { - With = W[j] + Wih = W[j] Wil = W[j + 1] var majh = maj(ah, bh, ch) @@ -49764,7 +49764,7 @@ t1l = (t1l + Kil) | 0 t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0 t1l = (t1l + Wil) | 0 - t1h = (t1h + With + getCarry(t1l, Wil)) | 0 + t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0 // t2 = sigma0 + maj var t2l = (sigma0l + majl) | 0 @@ -50438,7 +50438,7 @@ 'host', 'keep-alive', 'origin', - 'referrer', + 'referer', 'te', 'trailer', 'transfer-encoding', @@ -51250,20 +51250,20 @@ return function (hash) { return downloadEntries(swarmUrl)(hash).then(function (entries) { var paths = Object.keys(entries); - var hashes = paths.map(function (path) { + var hashs = paths.map(function (path) { return entries[path].hash; }); var types = paths.map(function (path) { return entries[path].type; }); - var data = hashes.map(downloadData(swarmUrl)); - var files = function files(data) { - return data.map(function (data, i) { + var datas = hashs.map(downloadData(swarmUrl)); + var files = function files(datas) { + return datas.map(function (data, i) { return { type: types[i], data: data }; }); }; - return Promise.all(data).then(function (data) { - return toMap(paths)(files(data)); + return Promise.all(datas).then(function (datas) { + return toMap(paths)(files(datas)); }); }); }; @@ -51394,14 +51394,14 @@ return files.directoryTree(dirPath).then(function (fullPaths) { return Promise.all(fullPaths.map(function (path) { return fsp.readFile(path); - })).then(function (data) { + })).then(function (datas) { var paths = fullPaths.map(function (path) { return path.slice(dirPath.length); }); var types = fullPaths.map(function (path) { return mimetype.lookup(path) || "text/plain"; }); - return toMap(paths)(data.map(function (data, i) { + return toMap(paths)(datas.map(function (data, i) { return { type: types[i], data: data }; })); }); @@ -51605,7 +51605,7 @@ // String ~> Promise Bool // Returns true if Swarm is available on `url`. - // Performs a test upload to determine that. + // Perfoms a test upload to determine that. // TODO: improve this? var _isAvailable = function _isAvailable(swarmUrl) { var testFile = "test"; @@ -53211,7 +53211,7 @@ source += "';\n" + evaluate + "\n__p+='"; } - // Adobe VMs need the match returned to produce the correct offset. + // Adobe VMs need the match returned to produce the correct offest. return match; }); source += "';\n"; @@ -54544,7 +54544,7 @@ /** - * Echos the value of a value. Tries to print the value out + * Echos the value of a value. Trys to print the value out * in the best way possible given the different types. * * @param {Object} obj The object to print out. @@ -55703,7 +55703,7 @@ } else if (utils.isAddress(address)) { return '0x' + address.toLowerCase().replace('0x',''); } - throw new Error('Provided address "'+ address +'" is invalid, the capitalization checksum test failed, or its an indirect IBAN address which can\'t be converted.'); + throw new Error('Provided address "'+ address +'" is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can\'t be converted.'); }; @@ -56100,7 +56100,7 @@ defer.resolve(receipt); } - // need to remove listeners, as they aren't removed automatically when successful + // need to remove listeners, as they aren't removed automatically when succesfull if (canUnsubscribe) { defer.eventEmitter.removeAllListeners(); } @@ -56129,7 +56129,7 @@ defer.eventEmitter.emit('receipt', receipt); defer.resolve(receipt); - // need to remove listeners, as they aren't removed automatically when successful + // need to remove listeners, as they aren't removed automatically when succesfull if (canUnsubscribe) { defer.eventEmitter.removeAllListeners(); } @@ -56496,7 +56496,7 @@ * Should be called to add create new request to batch request * * @method add - * @param {Object} jsonrpc request object + * @param {Object} jsonrpc requet object */ Batch.prototype.add = function (request) { this.requests.push(request); @@ -58335,7 +58335,7 @@ // sets _requestmanager core.packageInit(this, arguments); - // remove unnecessary core functions + // remove unecessary core functions delete this.BatchRequest; delete this.extend; @@ -59431,7 +59431,7 @@ params: 1, inputFormatter: [formatters.inputLogFormatter], outputFormatter: this._decodeEventABI.bind(subOptions.event), - // DUPLICATE, also in web3-eth + // DUBLICATE, also in web3-eth subscriptionHandler: function (output) { if(output.removed) { this.emit('changed', output); @@ -59731,7 +59731,7 @@ /** * @file ENS.js * - * @author Samuel Further + * @author Samuel Furter * @date 2018 */ @@ -59935,7 +59935,7 @@ /** * @file Registry.js * - * @author Samuel Further + * @author Samuel Furter * @date 2018 */ @@ -60037,7 +60037,7 @@ /** * @file index.js * - * @author Samuel Further + * @author Samuel Furter * @date 2018 */ @@ -60064,7 +60064,7 @@ /** * @file ResolverMethodHandler.js * - * @author Samuel Further + * @author Samuel Furter * @date 2018 */ @@ -61697,7 +61697,7 @@ params: 1, inputFormatter: [formatter.inputLogFormatter], outputFormatter: formatter.outputLogFormatter, - // DUPLICATE, also in web3-eth-contract + // DUBLICATE, also in web3-eth-contract subscriptionHandler: function (output) { if(output.removed) { this.emit('changed', output); @@ -62419,7 +62419,7 @@ BlockCacheStrategy.prototype.getBlockCacheForPayload = function(payload, blockNumberHex) { const blockNumber = Number.parseInt(blockNumberHex, 16) let blockCache = this.cache[blockNumber] - // create new cache if necessary + // create new cache if necesary if (!blockCache) { const newCache = {} this.cache[blockNumber] = newCache @@ -62688,7 +62688,7 @@ self.pendingBlockTimeout = opts.pendingBlockTimeout || 4000 self.checkForPendingBlocksActive = false - // we dont have engine immediately + // we dont have engine immeditately setTimeout(function(){ // asyncBlockHandlers require locking provider until updates are completed self.engine.on('block', function(block){ @@ -65518,7 +65518,7 @@ Subscribes to provider events.provider @method on - @param {String} type 'notification', 'connect', 'error', 'end' or 'data' + @param {String} type 'notifcation', 'connect', 'error', 'end' or 'data' @param {Function} callback the callback to call */ WebsocketProvider.prototype.on = function (type, callback) { @@ -65555,7 +65555,7 @@ Removes event listener @method removeListener - @param {String} type 'notification', 'connect', 'error', 'end' or 'data' + @param {String} type 'notifcation', 'connect', 'error', 'end' or 'data' @param {Function} callback the callback to call */ WebsocketProvider.prototype.removeListener = function (type, callback) { @@ -65581,7 +65581,7 @@ Removes all event listeners @method removeAllListeners - @param {String} type 'notification', 'connect', 'error', 'end' or 'data' + @param {String} type 'notifcation', 'connect', 'error', 'end' or 'data' */ WebsocketProvider.prototype.removeAllListeners = function (type) { switch(type){ @@ -67433,7 +67433,7 @@ } function getBody() { - // Chrome with requestType=blob throws errors around when even testing access to responseText + // Chrome with requestType=blob throws errors arround when even testing access to responseText var body = undefined if (xhr.response) { @@ -67885,7 +67885,7 @@ host: true, 'keep-alive': true, origin: true, - referrer: true, + referer: true, te: true, trailer: true, 'transfer-encoding': true, @@ -68062,7 +68062,7 @@ } }; XMLHttpRequest.prototype._finalizeHeaders = function () { - this._headers = __assign({}, this._headers, { Connection: 'keep-alive', Host: this._url.host, 'User-Agent': this._userAgent }, this._anonymous ? { Referrer: 'about:blank' } : {}); + this._headers = __assign({}, this._headers, { Connection: 'keep-alive', Host: this._url.host, 'User-Agent': this._userAgent }, this._anonymous ? { Referer: 'about:blank' } : {}); this.upload._finalizeHeaders(this._headers, this._loweredHeaders); }; XMLHttpRequest.prototype._onHttpResponse = function (request, response) { From 77f0db9d36e0c6ab7955660edc53907e76af96d4 Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Thu, 9 Mar 2023 00:15:46 +0000 Subject: [PATCH 154/210] revert change --- Sources/web3swift/Browser/browser.min.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/web3swift/Browser/browser.min.js b/Sources/web3swift/Browser/browser.min.js index 6d75533da..f838d4a4b 100644 --- a/Sources/web3swift/Browser/browser.min.js +++ b/Sources/web3swift/Browser/browser.min.js @@ -1,2 +1,2 @@ -!function(){return function e(t,r,n){function i(a,s){if(!r[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var f=r[a]={exports:{}};t[a][0].call(f.exports,function(e){var r=t[a][1][e];return i(r||e)},f,f.exports,e,t,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a0&&(window.web3.eth.defaultAccount=t[0])})}window.ethereum=s}}},console.log("JS bridging rpc url access"),"undefined"!=typeof window&&window.bridge?window.bridge.post("getRPCurl",{},function(e,r){r&&t(r.description,null),t(null,e.rpcURL)}):(console.log("No bridge to native code is found"),t(!0,null))}()},{"./wk.bridge":424,web3:407,"web3-provider-engine/zero.js":397}],2:[function(e,t,r){t.exports=e("./register")().Promise},{"./register":4}],3:[function(e,t,r){"use strict";var n=null;t.exports=function(e,t){return function(r,i){r=r||null;var o=!1!==(i=i||{}).global;if(null===n&&o&&(n=e["@@any-promise/REGISTRATION"]||null),null!==n&&null!==r&&n.implementation!==r)throw new Error('any-promise already defined as "'+n.implementation+'". You can only register an implementation before the first call to require("any-promise") and an implementation cannot be changed');return null===n&&(n=null!==r&&void 0!==i.Promise?{Promise:i.Promise,implementation:r}:t(r),o&&(e["@@any-promise/REGISTRATION"]=n)),n}}},{}],4:[function(e,t,r){"use strict";t.exports=e("./loader")(window,function(){if(void 0===window.Promise)throw new Error("any-promise browser requires a polyfill or explicit registration e.g: require('any-promise/register/bluebird')");return{Promise:window.Promise,implementation:"window.Promise"}})},{"./loader":3}],5:[function(e,t,r){var n=r;n.bignum=e("bn.js"),n.define=e("./asn1/api").define,n.base=e("./asn1/base"),n.constants=e("./asn1/constants"),n.decoders=e("./asn1/decoders"),n.encoders=e("./asn1/encoders")},{"./asn1/api":6,"./asn1/base":8,"./asn1/constants":12,"./asn1/decoders":14,"./asn1/encoders":17,"bn.js":53}],6:[function(e,t,r){var n=e("../asn1"),i=e("inherits");function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}r.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(t){var r;try{r=e("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){r=function(e){this._initNamed(e)}}return i(r,t),r.prototype._initNamed=function(e){t.call(this,e)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(n.decoders[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(n.encoders[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},{"../asn1":5,inherits:180,vm:334}],7:[function(e,t,r){var n=e("inherits"),i=e("../base").Reporter,o=e("buffer").Buffer;function a(e,t){i.call(this,t),o.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function s(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return e instanceof s||(e=new s(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=o.byteLength(e);else{if(!o.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}n(a,i),r.DecoderBuffer=a,a.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},a.prototype.restore=function(e){var t=new a(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,i.prototype.restore.call(this,e.reporter),t},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},a.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new a(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},a.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},r.EncoderBuffer=s,s.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length?e:(Array.isArray(this.value)?this.value.forEach(function(r){r.join(e,t),t+=r.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):o.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},{"../base":8,buffer:84,inherits:180}],8:[function(e,t,r){var n=r;n.Reporter=e("./reporter").Reporter,n.DecoderBuffer=e("./buffer").DecoderBuffer,n.EncoderBuffer=e("./buffer").EncoderBuffer,n.Node=e("./node")},{"./buffer":7,"./node":9,"./reporter":10}],9:[function(e,t,r){var n=e("../base").Reporter,i=e("../base").EncoderBuffer,o=e("../base").DecoderBuffer,a=e("minimalistic-assert"),s=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],u=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function c(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}t.exports=c;var f=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){var e=this._baseState,t={};f.forEach(function(r){t[r]=e[r]});var r=new this.constructor(t.parent);return r._baseState=t,r},c.prototype._wrap=function(){var e=this._baseState;u.forEach(function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}},this)},c.prototype._init=function(e){var t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter(function(e){return e._baseState.parent===this},this),a.equal(t.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(e){var t=this._baseState,r=e.filter(function(e){return e instanceof this.constructor},this);e=e.filter(function(e){return!(e instanceof this.constructor)},this),0!==r.length&&(a(null===t.children),t.children=r,r.forEach(function(e){e._baseState.parent=this},this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map(function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach(function(r){r==(0|r)&&(r|=0);var n=e[r];t[n]=r}),t}))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(e){c.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}}),s.forEach(function(e){c.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(r),this}}),c.prototype.use=function(e){a(e);var t=this._baseState;return a(null===t.use),t.use=e,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(e){var t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},c.prototype.explicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},c.prototype.implicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},c.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},c.prototype.key=function(e){var t=this._baseState;return a(null===t.key),t.key=e,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(e){var t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map(function(t){return e[t]})),this},c.prototype.contains=function(e){var t=this._baseState;return a(null===t.use),t.contains=e,this},c.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var n,i=r.default,a=!0,s=null;if(null!==r.key&&(s=e.enterKey(r.key)),r.optional){var u=null;if(null!==r.explicit?u=r.explicit:null!==r.implicit?u=r.implicit:null!==r.tag&&(u=r.tag),null!==u||r.any){if(a=this._peekTag(e,u,r.any),e.isError(a))return a}else{var c=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(c)}}if(r.obj&&a&&(n=e.enterObject()),a){if(null!==r.explicit){var f=this._decodeTag(e,r.explicit);if(e.isError(f))return f;e=f}var h=e.offset;if(null===r.use&&null===r.choice){if(r.any)c=e.save();var l=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(l))return l;r.any?i=e.raw(c):e=l}if(t&&t.track&&null!==r.tag&&t.track(e.path(),h,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),i=r.any?i:null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),e.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach(function(r){r._decode(e,t)}),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var d=new o(i);i=this._getUse(r.contains,e._reporterState.obj)._decode(d,t)}}return r.obj&&a&&(i=e.leaveObject(n)),null===r.key||null===i&&!0!==a?null!==s&&e.exitKey(s):e.leaveKey(s,r.key,i),i},c.prototype._decodeGeneric=function(e,t,r){var n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},c.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},c.prototype._decodeChoice=function(e,t){var r=this._baseState,n=null,i=!1;return Object.keys(r.choice).some(function(o){var a=e.save(),s=r.choice[o];try{var u=s._decode(e,t);if(e.isError(u))return!1;n={type:o,value:u},i=!0}catch(t){return e.restore(a),!1}return!0},this),i?n:e.error("Choice not matched")},c.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},c.prototype._encode=function(e,t,r){var n=this._baseState;if(null===n.default||n.default!==e){var i=this._encodeValue(e,t,r);if(void 0!==i&&!this._skipDefault(i,t,r))return i}},c.prototype._encodeValue=function(e,t,r){var i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);var o=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}var a=null,s=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)a=this._getUse(i.contains,r)._encode(e,t),s=!0;else if(i.children)a=i.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i},this).filter(function(e){return e}),a=this._createEncoderBuffer(a);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var u=this.clone();u._baseState.implicit=null,a=this._createEncoderBuffer(e.map(function(r){var n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)},u))}else null!==i.use?o=this._getUse(i.use,r)._encode(e,t):(a=this._encodePrimitive(i.tag,e),s=!0);if(!i.any&&null===i.choice){var c=null!==i.implicit?i.implicit:i.tag,f=null===i.implicit?"universal":"context";null===c?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(c,s,f,a))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},c.prototype._encodeChoice=function(e,t){var r=this._baseState,n=r.choice[e.type];return n||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},c.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},c.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},c.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},{"../base":8,"minimalistic-assert":234}],10:[function(e,t,r){var n=e("inherits");function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}r.Reporter=i,i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,r){var n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){var t,r=this._reporterState,n=e instanceof o;if(t=n?e:new o(r.path.map(function(e){return"["+JSON.stringify(e)+"]"}).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},i.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},n(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{inherits:180}],11:[function(e,t,r){var n=e("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=n._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=n._reverse(r.tag)},{"../constants":12}],12:[function(e,t,r){var n=r;n._reverse=function(e){var t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r|=0);var n=e[r];t[n]=r}),t},n.der=e("./der")},{"./der":11}],13:[function(e,t,r){var n=e("inherits"),i=e("../../asn1"),o=i.base,a=i.bignum,s=i.constants.der;function u(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){o.Node.call(this,"der",e)}function f(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var n=s.tagClass[r>>6],i=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:s.tag[r]}}function h(e,t,r){var n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;var i=127&n;if(i>4)return e.error("length octet is too long");n=0;for(var o=0;o=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=s.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(n.length<128)return(o=new i(2))[0]=a,o[1]=n.length,this._createEncoderBuffer([o,n]);for(var u=1,c=n.length;c>=256;c>>=8)u++;(o=new i(2+u))[0]=a,o[1]=128|u;c=1+u;for(var f=n.length;f>0;c--,f>>=8)o[c]=255&f;return this._createEncoderBuffer([o,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new i(2*e.length),n=0;n=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var o=0;for(n=0;n=128;a>>=7)o++}var s=new i(o),u=s.length-1;for(n=e.length-1;n>=0;n--){a=e[n];for(s[u--]=127&a;(a>>=7)>0;)s[u--]=128|127&a}return this._createEncoderBuffer(s)},c.prototype._encodeTime=function(e,t){var r,n=new Date(e);return"gentime"===t?r=[f(n.getFullYear()),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[f(n.getFullYear()%100),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!i.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new i(r)}if(i.isBuffer(e)){var n=e.length;0===e.length&&n++;var o=new i(n);return e.copy(o),0===e.length&&(o[0]=0),this._createEncoderBuffer(o)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);n=1;for(var a=e;a>=256;a>>=8)n++;for(a=(o=new Array(n)).length-1;a>=0;a--)o[a]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new i(o))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){var n,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,r).join()),o.length!==i.defaultBuffer.length)return!1;for(n=0;n=0;c--)if(f[c]!==h[c])return!1;for(c=f.length-1;c>=0;c--)if(u=f[c],!v(e[u],t[u],r,n))return!1;return!0}(e,t,r,a))}return r?e===t:e==t}function g(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function w(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function _(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&y(i,r,"Missing expected exception"+n);var a="string"==typeof n,s=!e&&i&&!r;if((!e&&o.isError(i)&&a&&w(i,r)||s)&&y(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(i,r)||!e&&i)throw i}h.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=p(b((t=this).actual),128)+" "+t.operator+" "+p(b(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=d(r),a=i.indexOf("\n"+o);if(a>=0){var s=i.indexOf("\n",a+1);i=i.substring(s+1)}this.stack=i}}},o.inherits(h.AssertionError,Error),h.fail=y,h.ok=m,h.equal=function(e,t,r){e!=t&&y(e,t,r,"==",h.equal)},h.notEqual=function(e,t,r){e==t&&y(e,t,r,"!=",h.notEqual)},h.deepEqual=function(e,t,r){v(e,t,!1)||y(e,t,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(e,t,r){v(e,t,!0)||y(e,t,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(e,t,r){v(e,t,!1)&&y(e,t,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function e(t,r,n){v(t,r,!0)&&y(t,r,n,"notDeepStrictEqual",e)},h.strictEqual=function(e,t,r){e!==t&&y(e,t,r,"===",h.strictEqual)},h.notStrictEqual=function(e,t,r){e===t&&y(e,t,r,"!==",h.notStrictEqual)},h.throws=function(e,t,r){_(!0,e,t,r)},h.doesNotThrow=function(e,t,r){_(!1,e,t,r)},h.ifError=function(e){if(e)throw e};var A=Object.keys||function(e){var t=[];for(var r in e)a.call(e,r)&&t.push(r);return t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":333}],20:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){return(0,i.default)(function(t,r){var i;try{i=e.apply(this,t)}catch(e){return r(e)}(0,n.default)(i)&&"function"==typeof i.then?i.then(function(e){s(r,null,e)},function(e){s(r,e.message?e:new Error(e))}):r(null,i)})};var n=a(e("lodash/isObject")),i=a(e("./internal/initialParams")),o=a(e("./internal/setImmediate"));function a(e){return e&&e.__esModule?e:{default:e}}function s(e,t,r){try{e(t,r)}catch(e){(0,o.default)(u,e)}}function u(e){throw e}t.exports=r.default},{"./internal/initialParams":31,"./internal/setImmediate":37,"lodash/isObject":225}],21:[function(e,t,r){(function(e,n){!function(e,n){"object"==typeof r&&void 0!==t?n(r):"function"==typeof define&&define.amd?define(["exports"],n):n(e.async=e.async||{})}(this,function(r){"use strict";function i(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i-1&&e%1==0&&e<=L}function D(e){return null!=e&&O(e.length)&&!function(e){if(!s(e))return!1;var t=B(e);return t==C||t==N||t==P||t==R}(e)}var F={};function q(){}function H(e){return function(){if(null!==e){var t=e;e=null,t.apply(this,arguments)}}}var z="function"==typeof Symbol&&Symbol.iterator,K=function(e){return z&&e[z]&&e[z]()};function V(e){return null!=e&&"object"==typeof e}var G="[object Arguments]";function W(e){return V(e)&&B(e)==G}var Y=Object.prototype,X=Y.hasOwnProperty,Z=Y.propertyIsEnumerable,J=W(function(){return arguments}())?W:function(e){return V(e)&&X.call(e,"callee")&&!Z.call(e,"callee")},$=Array.isArray;var Q="object"==typeof r&&r&&!r.nodeType&&r,ee=Q&&"object"==typeof t&&t&&!t.nodeType&&t,te=ee&&ee.exports===Q?A.Buffer:void 0,re=(te?te.isBuffer:void 0)||function(){return!1},ne=9007199254740991,ie=/^(?:0|[1-9]\d*)$/;function oe(e,t){return!!(t=null==t?ne:t)&&("number"==typeof e||ie.test(e))&&e>-1&&e%1==0&&e2&&(n=i(arguments,1)),t){var c={};Fe(o,function(e,t){c[t]=e}),c[e]=n,s=!0,u=Object.create(null),r(t,c)}else o[e]=n,Le(u[e]||[],function(e){e()}),d()});a++;var c=v(t[t.length-1]);t.length>1?c(o,n):c(n)}(e,t)})}function d(){if(0===c.length&&0===a)return r(null,o);for(;c.length&&a=0&&r.push(n)}),r}Fe(e,function(t,r){if(!$(t))return l(r,[t]),void f.push(r);var n=t.slice(0,t.length-1),i=n.length;if(0===i)return l(r,t),void f.push(r);h[r]=i,Le(n,function(o){if(!e[o])throw new Error("async.auto task `"+r+"` has a non-existent dependency `"+o+"` in "+n.join(", "));!function(e,t){var r=u[e];r||(r=u[e]=[]);r.push(t)}(o,function(){0===--i&&l(r,t)})})}),function(){var e,t=0;for(;f.length;)e=f.pop(),t++,Le(p(e),function(e){0==--h[e]&&f.push(e)});if(t!==n)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),d()};function Ke(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r=n?e:function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n-1;);return r}(i,o),function(e,t){for(var r=e.length;r--&&He(t,e[r],0)>-1;);return r}(i,o)+1).join("")}var ht=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,lt=/,/,dt=/(=.+)?(\s*)$/,pt=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;function bt(e,t){var r={};Fe(e,function(e,t){var n,i,o=m(e),a=!o&&1===e.length||o&&0===e.length;if($(e))n=e.slice(0,-1),e=e[e.length-1],r[t]=n.concat(n.length>0?s:e);else if(a)r[t]=e;else{if(n=i=(i=(i=(i=(i=e).toString().replace(pt,"")).match(ht)[2].replace(" ",""))?i.split(lt):[]).map(function(e){return ft(e.replace(dt,""))}),0===e.length&&!o&&0===n.length)throw new Error("autoInject task functions require explicit parameters.");o||n.pop(),r[t]=n.concat(s)}function s(t,r){var i=Ke(n,function(e){return t[e]});i.push(r),v(e).apply(null,i)}}),ze(r,t)}function yt(){this.head=this.tail=null,this.length=0}function mt(e,t){e.length=1,e.head=e.tail=t}function vt(e,t,r){if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var n=v(e),i=0,o=[],a=!1;function s(e,t,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(f.started=!0,$(e)||(e=[e]),0===e.length&&f.idle())return l(function(){f.drain()});for(var n=0,i=e.length;n0&&o.splice(s,1),a.callback.apply(a,arguments),null!=t&&f.error(t,a.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()}}var c=!1,f={_tasks:new yt,concurrency:t,payload:r,saturated:q,unsaturated:q,buffer:t/4,empty:q,drain:q,error:q,started:!1,paused:!1,push:function(e,t){s(e,!1,t)},kill:function(){f.drain=q,f._tasks.empty()},unshift:function(e,t){s(e,!0,t)},remove:function(e){f._tasks.remove(e)},process:function(){if(!c){for(c=!0;!f.paused&&i2&&(o=i(arguments,1)),n[t]=o,r(e)})},function(e){r(e,n)})}function br(e,t){pr(Ie,e,t)}function yr(e,t,r){pr(Ee(t),e,r)}var mr=function(e,t){var r=v(e);return vt(function(e,t){r(e[0],t)},t,1)},vr=function(e,t){var r=mr(e,t);return r.push=function(e,t,n){if(null==n&&(n=q),"function"!=typeof n)throw new Error("task callback must be a function");if(r.started=!0,$(e)||(e=[e]),0===e.length)return l(function(){r.drain()});t=t||0;for(var i=r._tasks.head;i&&t>=i.priority;)i=i.next;for(var o=0,a=e.length;on?1:0}je(e,function(e,t){n(e,function(r,n){if(r)return t(r);t(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);r(null,Ke(t.sort(i),Zt("value")))})}function Nr(e,t,r){var n=v(e);return a(function(i,o){var a,s=!1;i.push(function(){s||(o.apply(null,arguments),clearTimeout(a))}),a=setTimeout(function(){var t=e.name||"anonymous",n=new Error('Callback function "'+t+'" timed out.');n.code="ETIMEDOUT",r&&(n.info=r),s=!0,o(n)},t),n.apply(null,i)})}var Rr=Math.ceil,Lr=Math.max;function Or(e,t,r,n){var i=v(r);Ce(function(e,t,r,n){for(var i=-1,o=Lr(Rr((t-e)/(r||1)),0),a=Array(o);o--;)a[n?o:++i]=e,e+=r;return a}(0,e,1),t,i,n)}var Dr=ke(Or,1/0),Fr=ke(Or,1);function qr(e,t,r,n){arguments.length<=3&&(n=r,r=t,t=$(e)?[]:{}),n=H(n||q);var i=v(r);Ie(e,function(e,r,n){i(t,e,r,n)},function(e){n(e,t)})}function Hr(e,t){var r,n=null;t=t||q,Kt(e,function(e,t){v(e)(function(e,o){r=arguments.length>2?i(arguments,1):o,n=e,t(!e)})},function(){t(n,r)})}function zr(e){return function(){return(e.unmemoized||e).apply(null,arguments)}}function Kr(e,t,r){r=Ae(r||q);var n=v(t);if(!e())return r(null);var o=function(t){if(t)return r(t);if(e())return n(o);var a=i(arguments,1);r.apply(null,[null].concat(a))};n(o)}function Vr(e,t,r){Kr(function(){return!e.apply(this,arguments)},t,r)}var Gr=function(e,t){if(t=H(t||q),!$(e))return t(new Error("First argument to waterfall must be an array of functions"));if(!e.length)return t();var r=0;function n(t){var n=v(e[r++]);t.push(Ae(o)),n.apply(null,t)}function o(o){if(o||r===e.length)return t.apply(null,arguments);n(i(arguments,1))}n([])},Wr={apply:o,applyEach:Be,applyEachSeries:Re,asyncify:d,auto:ze,autoInject:bt,cargo:gt,compose:Et,concat:St,concatLimit:kt,concatSeries:Mt,constant:It,detect:Bt,detectLimit:Pt,detectSeries:Ct,dir:Rt,doDuring:Lt,doUntil:Dt,doWhilst:Ot,during:Ft,each:Ht,eachLimit:zt,eachOf:Ie,eachOfLimit:xe,eachOfSeries:wt,eachSeries:Kt,ensureAsync:Vt,every:Wt,everyLimit:Yt,everySeries:Xt,filter:er,filterLimit:tr,filterSeries:rr,forever:nr,groupBy:or,groupByLimit:ir,groupBySeries:ar,log:sr,map:je,mapLimit:Ce,mapSeries:Ne,mapValues:cr,mapValuesLimit:ur,mapValuesSeries:fr,memoize:lr,nextTick:dr,parallel:br,parallelLimit:yr,priorityQueue:vr,queue:mr,race:gr,reduce:_t,reduceRight:wr,reflect:_r,reflectAll:Ar,reject:xr,rejectLimit:kr,rejectSeries:Sr,retry:Ir,retryable:Tr,seq:At,series:Ur,setImmediate:l,some:jr,someLimit:Br,someSeries:Pr,sortBy:Cr,timeout:Nr,times:Dr,timesLimit:Or,timesSeries:Fr,transform:qr,tryEach:Hr,unmemoize:zr,until:Vr,waterfall:Gr,whilst:Kr,all:Wt,allLimit:Yt,allSeries:Xt,any:jr,anyLimit:Br,anySeries:Pr,find:Bt,findLimit:Pt,findSeries:Ct,forEach:Ht,forEachSeries:Kt,forEachLimit:zt,forEachOf:Ie,forEachOfSeries:wt,forEachOfLimit:xe,inject:_t,foldl:_t,foldr:wr,select:er,selectLimit:tr,selectSeries:rr,wrapSync:d};r.default=Wr,r.apply=o,r.applyEach=Be,r.applyEachSeries=Re,r.asyncify=d,r.auto=ze,r.autoInject=bt,r.cargo=gt,r.compose=Et,r.concat=St,r.concatLimit=kt,r.concatSeries=Mt,r.constant=It,r.detect=Bt,r.detectLimit=Pt,r.detectSeries=Ct,r.dir=Rt,r.doDuring=Lt,r.doUntil=Dt,r.doWhilst=Ot,r.during=Ft,r.each=Ht,r.eachLimit=zt,r.eachOf=Ie,r.eachOfLimit=xe,r.eachOfSeries=wt,r.eachSeries=Kt,r.ensureAsync=Vt,r.every=Wt,r.everyLimit=Yt,r.everySeries=Xt,r.filter=er,r.filterLimit=tr,r.filterSeries=rr,r.forever=nr,r.groupBy=or,r.groupByLimit=ir,r.groupBySeries=ar,r.log=sr,r.map=je,r.mapLimit=Ce,r.mapSeries=Ne,r.mapValues=cr,r.mapValuesLimit=ur,r.mapValuesSeries=fr,r.memoize=lr,r.nextTick=dr,r.parallel=br,r.parallelLimit=yr,r.priorityQueue=vr,r.queue=mr,r.race=gr,r.reduce=_t,r.reduceRight=wr,r.reflect=_r,r.reflectAll=Ar,r.reject=xr,r.rejectLimit=kr,r.rejectSeries=Sr,r.retry=Ir,r.retryable=Tr,r.seq=At,r.series=Ur,r.setImmediate=l,r.some=jr,r.someLimit=Br,r.someSeries=Pr,r.sortBy=Cr,r.timeout=Nr,r.times=Dr,r.timesLimit=Or,r.timesSeries=Fr,r.transform=qr,r.tryEach=Hr,r.unmemoize=zr,r.until=Vr,r.waterfall=Gr,r.whilst=Kr,r.all=Wt,r.allLimit=Yt,r.allSeries=Xt,r.any=jr,r.anyLimit=Br,r.anySeries=Pr,r.find=Bt,r.findLimit=Pt,r.findSeries=Ct,r.forEach=Ht,r.forEachSeries=Kt,r.forEachLimit=zt,r.forEachOf=Ie,r.forEachOfSeries=wt,r.forEachOfLimit=xe,r.inject=_t,r.foldl=_t,r.foldr=wr,r.select=er,r.selectLimit=tr,r.selectSeries=rr,r.wrapSync=d,Object.defineProperty(r,"__esModule",{value:!0})})}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257}],22:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r,a){(0,n.default)(t)(e,(0,i.default)((0,o.default)(r)),a)};var n=a(e("./internal/eachOfLimit")),i=a(e("./internal/withoutIndex")),o=a(e("./internal/wrapAsync"));function a(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./internal/eachOfLimit":29,"./internal/withoutIndex":39,"./internal/wrapAsync":40}],23:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r){((0,n.default)(e)?l:d)(e,(0,f.default)(t),r)};var n=h(e("lodash/isArrayLike")),i=h(e("./internal/breakLoop")),o=h(e("./eachOfLimit")),a=h(e("./internal/doLimit")),s=h(e("lodash/noop")),u=h(e("./internal/once")),c=h(e("./internal/onlyOnce")),f=h(e("./internal/wrapAsync"));function h(e){return e&&e.__esModule?e:{default:e}}function l(e,t,r){r=(0,u.default)(r||s.default);var n=0,o=0,a=e.length;function f(e,t){e?r(e):++o!==a&&t!==i.default||r(null)}for(0===a&&r(null);n2&&(n=(0,o.default)(arguments,1)),s[t]=n,r(e)})},function(e){r(e,s)})};var n=s(e("lodash/noop")),i=s(e("lodash/isArrayLike")),o=s(e("./slice")),a=s(e("./wrapAsync"));function s(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./slice":38,"./wrapAsync":40,"lodash/isArrayLike":221,"lodash/noop":229}],37:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.hasNextTick=r.hasSetImmediate=void 0,r.fallback=c,r.wrap=f;var n,i=e("./slice"),o=(n=i)&&n.__esModule?n:{default:n};var a,s=r.hasSetImmediate="function"==typeof setImmediate&&setImmediate,u=r.hasNextTick="object"==typeof t&&"function"==typeof t.nextTick;function c(e){setTimeout(e,0)}function f(e){return function(t){var r=(0,o.default)(arguments,1);e(function(){t.apply(null,r)})}}a=s?setImmediate:u?t.nextTick:c,r.default=f(a)}).call(this,e("_process"))},{"./slice":38,_process:257}],38:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i0,"Expected a maximum number of retry greater than 0 but got %s.",e),this.maxNumberOfRetry_=e},o.prototype.backoff=function(e){i.checkState(-1===this.timeoutID_,"Backoff in progress."),this.backoffNumber_===this.maxNumberOfRetry_?(this.emit("fail",e),this.reset()):(this.backoffDelay_=this.backoffStrategy_.next(),this.timeoutID_=setTimeout(this.handlers.backoff,this.backoffDelay_),this.emit("backoff",this.backoffNumber_,this.backoffDelay_,e))},o.prototype.onBackoff_=function(){this.timeoutID_=-1,this.emit("ready",this.backoffNumber_,this.backoffDelay_),this.backoffNumber_++},o.prototype.reset=function(){this.backoffNumber_=0,this.backoffStrategy_.reset(),clearTimeout(this.timeoutID_),this.timeoutID_=-1},t.exports=o},{events:157,precond:253,util:333}],47:[function(e,t,r){var n=e("events"),i=e("precond"),o=e("util"),a=e("./backoff"),s=e("./strategy/fibonacci");function u(e,t,r){n.EventEmitter.call(this),i.checkIsFunction(e,"Expected fn to be a function."),i.checkIsArray(t,"Expected args to be an array."),i.checkIsFunction(r,"Expected callback to be a function."),this.function_=e,this.arguments_=t,this.callback_=r,this.lastResult_=[],this.numRetries_=0,this.backoff_=null,this.strategy_=null,this.failAfter_=-1,this.retryPredicate_=u.DEFAULT_RETRY_PREDICATE_,this.state_=u.State_.PENDING}o.inherits(u,n.EventEmitter),u.State_={PENDING:0,RUNNING:1,COMPLETED:2,ABORTED:3},u.DEFAULT_RETRY_PREDICATE_=function(e){return!0},u.prototype.isPending=function(){return this.state_==u.State_.PENDING},u.prototype.isRunning=function(){return this.state_==u.State_.RUNNING},u.prototype.isCompleted=function(){return this.state_==u.State_.COMPLETED},u.prototype.isAborted=function(){return this.state_==u.State_.ABORTED},u.prototype.setStrategy=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.strategy_=e,this},u.prototype.retryIf=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.retryPredicate_=e,this},u.prototype.getLastResult=function(){return this.lastResult_.concat()},u.prototype.getNumRetries=function(){return this.numRetries_},u.prototype.failAfter=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.failAfter_=e,this},u.prototype.abort=function(){this.isCompleted()||this.isAborted()||(this.isRunning()&&this.backoff_.reset(),this.state_=u.State_.ABORTED,this.lastResult_=[new Error("Backoff aborted.")],this.emit("abort"),this.doCallback_())},u.prototype.start=function(e){i.checkState(!this.isAborted(),"FunctionCall is aborted."),i.checkState(this.isPending(),"FunctionCall already started.");var t=this.strategy_||new s;this.backoff_=e?e(t):new a(t),this.backoff_.on("ready",this.doCall_.bind(this,!0)),this.backoff_.on("fail",this.doCallback_.bind(this)),this.backoff_.on("backoff",this.handleBackoff_.bind(this)),this.failAfter_>0&&this.backoff_.failAfter(this.failAfter_),this.state_=u.State_.RUNNING,this.doCall_(!1)},u.prototype.doCall_=function(e){e&&this.numRetries_++;var t=["call"].concat(this.arguments_);n.EventEmitter.prototype.emit.apply(this,t);var r=this.handleFunctionCallback_.bind(this);this.function_.apply(null,this.arguments_.concat(r))},u.prototype.doCallback_=function(){this.callback_.apply(null,this.lastResult_)},u.prototype.handleFunctionCallback_=function(){if(!this.isAborted()){var e=Array.prototype.slice.call(arguments);this.lastResult_=e,n.EventEmitter.prototype.emit.apply(this,["callback"].concat(e));var t=e[0];t&&this.retryPredicate_(t)?this.backoff_.backoff(t):(this.state_=u.State_.COMPLETED,this.doCallback_())}},u.prototype.handleBackoff_=function(e,t,r){this.emit("backoff",e,t,r)},t.exports=u},{"./backoff":46,"./strategy/fibonacci":49,events:157,precond:253,util:333}],48:[function(e,t,r){var n=e("util"),i=e("precond"),o=e("./strategy");function a(e){o.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay(),this.factor_=a.DEFAULT_FACTOR,e&&void 0!==e.factor&&(i.checkArgument(e.factor>1,"Exponential factor should be greater than 1 but got %s.",e.factor),this.factor_=e.factor)}n.inherits(a,o),a.DEFAULT_FACTOR=2,a.prototype.next_=function(){return this.backoffDelay_=Math.min(this.nextBackoffDelay_,this.getMaxDelay()),this.nextBackoffDelay_=this.backoffDelay_*this.factor_,this.backoffDelay_},a.prototype.reset_=function(){this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()},t.exports=a},{"./strategy":50,precond:253,util:333}],49:[function(e,t,r){var n=e("util"),i=e("./strategy");function o(e){i.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}n.inherits(o,i),o.prototype.next_=function(){var e=Math.min(this.nextBackoffDelay_,this.getMaxDelay());return this.nextBackoffDelay_+=this.backoffDelay_,this.backoffDelay_=e,e},o.prototype.reset_=function(){this.nextBackoffDelay_=this.getInitialDelay(),this.backoffDelay_=0},t.exports=o},{"./strategy":50,util:333}],50:[function(e,t,r){e("events"),e("util");function n(e){return null!=e}function i(e){if(n((e=e||{}).initialDelay)&&e.initialDelay<1)throw new Error("The initial timeout must be greater than 0.");if(n(e.maxDelay)&&e.maxDelay<1)throw new Error("The maximal timeout must be greater than 0.");if(this.initialDelay_=e.initialDelay||100,this.maxDelay_=e.maxDelay||1e4,this.maxDelay_<=this.initialDelay_)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");if(n(e.randomisationFactor)&&(e.randomisationFactor<0||e.randomisationFactor>1))throw new Error("The randomisation factor must be between 0 and 1.");this.randomisationFactor_=e.randomisationFactor||0}i.prototype.getMaxDelay=function(){return this.maxDelay_},i.prototype.getInitialDelay=function(){return this.initialDelay_},i.prototype.next=function(){var e=this.next_(),t=1+Math.random()*this.randomisationFactor_;return Math.round(e*t)},i.prototype.next_=function(){throw new Error("BackoffStrategy.next_() unimplemented.")},i.prototype.reset=function(){this.reset_()},i.prototype.reset_=function(){throw new Error("BackoffStrategy.reset_() unimplemented.")},t.exports=i},{events:157,util:333}],51:[function(e,t,r){"use strict";r.byteLength=function(e){return 3*e.length/4-c(e)},r.toByteArray=function(e){var t,r,n,a,s,u=e.length;a=c(e),s=new o(3*u/4-a),r=a>0?u-4:u;var f=0;for(t=0;t>16&255,s[f++]=n>>8&255,s[f++]=255&n;2===a?(n=i[e.charCodeAt(t)]<<2|i[e.charCodeAt(t+1)]>>4,s[f++]=255&n):1===a&&(n=i[e.charCodeAt(t)]<<10|i[e.charCodeAt(t+1)]<<4|i[e.charCodeAt(t+2)]>>2,s[f++]=n>>8&255,s[f++]=255&n);return s},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o="",a=[],s=0,u=r-i;su?u:s+16383));1===i?(t=e[r-1],o+=n[t>>2],o+=n[t<<4&63],o+="=="):2===i&&(t=(e[r-2]<<8)+e[r-1],o+=n[t>>10],o+=n[t>>4&63],o+=n[t<<2&63],o+="=");return a.push(o),a.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function f(e,t,r){for(var i,o,a=[],s=t;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],52:[function(e,t,r){var n=e("safe-buffer").Buffer;t.exports={check:function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))},decode:function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");var r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},encode:function(e,t){var r=e.length,i=t.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(i>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+r]=2,o[5+r]=t.length,t.copy(o,6+r),o}}},{"safe-buffer":290}],53:[function(e,t,r){!function(t,r){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var a;"object"==typeof t?t.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{a=e("buffer").Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:55}],54:[function(e,t,r){var n;function i(e){this.rand=e}if(t.exports=function(e){return n||(n=new i(null)),n.generate(e)},t.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^t[m++],a=c[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^t[m++],s=c[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^t[m++],u=c[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^t[m++],d=o,p=a,b=s,y=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^t[m++],a=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^t[m++],s=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[m++],u=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^t[m++],[o>>>=0,a>>>=0,s>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],u=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,u=0;u<256;++u){var c=s^s<<1^s<<2^s<<3^s<<4;c=c>>>8^255&c^99,r[a]=c,n[c]=a;var f=e[a],h=e[f],l=e[h],d=257*e[c]^16843008*c;i[0][a]=d<<24|d>>>8,i[1][a]=d<<16|d>>>16,i[2][a]=d<<8|d>>>24,i[3][a]=d,d=16843009*l^65537*h^257*f^16843008*a,o[0][c]=d<<24|d>>>8,o[1][c]=d<<16|d>>>16,o[2][c]=d<<8|d>>>24,o[3][c]=d,0===a?a=s=1:(a=f^e[e[e[l^f]]],s^=e[e[s]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(e){this._key=i(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a],a^=s[o/t|0]<<24):t>6&&o%t==4&&(a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a]),i[o]=i[o-t]^a}for(var c=[],f=0;f>>24]]^u.INV_SUB_MIX[1][u.SBOX[l>>>16&255]]^u.INV_SUB_MIX[2][u.SBOX[l>>>8&255]]^u.INV_SUB_MIX[3][u.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},c.prototype.encryptBlockRaw=function(e){return a(e=i(e),this._keySchedule,u.SUB_MIX,u.SBOX,this._nRounds)},c.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=n.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},c.prototype.decryptBlock=function(e){var t=(e=i(e))[1];e[1]=e[3],e[3]=t;var r=a(e,this._invKeySchedule,u.INV_SUB_MIX,u.INV_SBOX,this._nRounds),o=n.allocUnsafe(16);return o.writeUInt32BE(r[0],0),o.writeUInt32BE(r[3],4),o.writeUInt32BE(r[2],8),o.writeUInt32BE(r[1],12),o},c.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},t.exports.AES=c},{"safe-buffer":290}],57:[function(e,t,r){var n=e("./aes"),i=e("safe-buffer").Buffer,o=e("cipher-base"),a=e("inherits"),s=e("./ghash"),u=e("buffer-xor"),c=e("./incr32");function f(e,t,r,a){o.call(this);var u=i.alloc(4,0);this._cipher=new n.AES(t);var f=this._cipher.encryptBlock(u);this._ghash=new s(f),r=function(e,t,r){if(12===t.length)return e._finID=i.concat([t,i.from([0,0,0,1])]),i.concat([t,i.from([0,0,0,2])]);var n=new s(r),o=t.length,a=o%16;n.update(t),a&&(a=16-a,n.update(i.alloc(a,0))),n.update(i.alloc(8,0));var u=8*o,f=i.alloc(8);f.writeUIntBE(u,0,8),n.update(f),e._finID=n.state;var h=i.from(e._finID);return c(h),h}(this,r,f),this._prev=i.from(r),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=a,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}a(f,o),f.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=i.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},f.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=u(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var n=Math.min(e.length,t.length),i=0;i16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},h.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(e,t){var r=o[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(t,!1,r.key,r.iv);return l(e,n.key,n.iv)},r.createDecipheriv=l},{"./aes":56,"./authCipher":57,"./modes":69,"./streamCipher":72,"cipher-base":86,evp_bytestokey:158,inherits:180,"safe-buffer":290}],60:[function(e,t,r){var n=e("./modes"),i=e("./authCipher"),o=e("safe-buffer").Buffer,a=e("./streamCipher"),s=e("cipher-base"),u=e("./aes"),c=e("evp_bytestokey");function f(e,t,r){s.call(this),this._cache=new l,this._cipher=new u.AES(t),this._prev=o.from(r),this._mode=e,this._autopadding=!0}e("inherits")(f,s),f.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get();)r=this._mode.encrypt(this,t),n.push(r);return o.concat(n)};var h=o.alloc(16,16);function l(){this.cache=o.allocUnsafe(0)}function d(e,t,r){var s=n[e.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=o.from(t)),t.length!==s.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=o.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new a(s.module,t,r):"auth"===s.type?new i(s.module,t,r):new f(s.module,t,r)}f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(h))throw this._cipher.scrub(),new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},l.prototype.add=function(e){this.cache=o.concat([this.cache,e])},l.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},l.prototype.flush=function(){for(var e=16-this.cache.length,t=o.allocUnsafe(e),r=-1;++r>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function a(e){this.h=e,this.state=n.alloc(16,0),this.cache=n.allocUnsafe(0)}a.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=o(i)},a.prototype.update=function(e){var t;for(this.cache=n.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},a.prototype.final=function(e,t){return this.cache.length&&this.ghash(n.concat([this.cache,i],16)),this.ghash(o([0,e,0,t])),this.state},t.exports=a},{"safe-buffer":290}],62:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],63:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":83}],64:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("buffer-xor");function o(e,t,r){var o=t.length,a=i(t,e._cache);return e._cache=e._cache.slice(o),e._prev=n.concat([e._prev,r?t:a]),a}r.encrypt=function(e,t,r){for(var i,a=n.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=n.allocUnsafe(0)),!(e._cache.length<=t.length)){a=n.concat([a,o(e,t,r)]);break}i=e._cache.length,a=n.concat([a,o(e,t.slice(0,i),r)]),t=t.slice(i)}return a}},{"buffer-xor":83,"safe-buffer":290}],65:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t,r){for(var n,i,a=-1,s=0;++a<8;)n=t&1<<7-a?128:0,s+=(128&(i=e._cipher.encryptBlock(e._prev)[0]^n))>>a%8,e._prev=o(e._prev,r?n:i);return s}function o(e,t){var r=e.length,i=-1,o=n.allocUnsafe(e.length);for(e=n.concat([e,n.from([t])]);++i>7;return o}r.encrypt=function(e,t,r){for(var o=t.length,a=n.allocUnsafe(o),s=-1;++s=0||!r.umod(e.prime1)||!r.umod(e.prime2);)r=new n(i(t));return r}t.exports=o,o.getr=a}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84,randombytes:270}],77:[function(e,t,r){t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":78}],78:[function(e,t,r){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],79:[function(e,t,r){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],80:[function(e,t,r){(function(r){var n=e("create-hash"),i=e("stream"),o=e("inherits"),a=e("./sign"),s=e("./verify"),u=e("./algorithms.json");function c(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function f(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function h(e){return new c(e)}function l(e){return new f(e)}Object.keys(u).forEach(function(e){u[e].id=new r(u[e].id,"hex"),u[e.toLowerCase()]=u[e]}),o(c,i.Writable),c.prototype._write=function(e,t,r){this._hash.update(e),r()},c.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},c.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),n=a(r,e,this._hashType,this._signType,this._tag);return t?n.toString(t):n},o(f,i.Writable),f.prototype._write=function(e,t,r){this._hash.update(e),r()},f.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},f.prototype.verify=function(e,t,n){"string"==typeof t&&(t=new r(t,n)),this.end();var i=this._hash.digest();return s(t,i,e,this._signType,this._tag)},t.exports={Sign:h,Verify:l,createSign:h,createVerify:l}}).call(this,e("buffer").Buffer)},{"./algorithms.json":78,"./sign":81,"./verify":82,buffer:84,"create-hash":91,inherits:180,stream:311}],81:[function(e,t,r){(function(r){var n=e("create-hmac"),i=e("browserify-rsa"),o=e("elliptic").ec,a=e("bn.js"),s=e("parse-asn1"),u=e("./curves.json");function c(e,t,i,o){if((e=new r(e.toArray())).length0&&r.ishrn(n),r}function h(e,t,i){var o,a;do{for(o=new r(0);8*o.length=t)throw new Error("invalid sig")}t.exports=function(e,t,u,c,f){var h=o(u);if("ec"===h.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var n=a[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),s=r.data.subjectPrivateKey.data;return o.verify(t,e,s)}(e,t,h)}if("dsa"===h.type){if("dsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var i=r.data.p,a=r.data.q,u=r.data.g,c=r.data.pub_key,f=o.signature.decode(e,"der"),h=f.s,l=f.r;s(h,a),s(l,a);var d=n.mont(i),p=h.invm(a);return 0===u.toRed(d).redPow(new n(t).mul(p).mod(a)).fromRed().mul(c.toRed(d).redPow(l.mul(p).mod(a)).fromRed()).mod(i).mod(a).cmp(l)}(e,t,h)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");t=r.concat([f,t]);for(var l=h.modulus.byteLength(),d=[1],p=0;t.length+d.length+2o)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=s.prototype,t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(e)}return u(e,t,r)}function u(e,t,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return F(e)?function(e,t,r){if(t<0||e.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function d(e,t){if(s.isBuffer(e))return e.length;if(q(e)||F(e))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return O(e).length;default:if(n)return L(e).length;t=(""+t).toLowerCase(),n=!0}}function p(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var o,a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var f=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function x(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return x(this,t,r);case"ascii":return S(this,t,r);case"latin1":case"binary":return M(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},s.prototype.compare=function(e,t,r,n,i){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),u=Math.min(o,a),c=this.slice(n,i),f=e.slice(t,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return m(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return g(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function S(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,r,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function B(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function C(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,8),i.write(e,t,r,n,52,8),r+8}s.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},s.prototype.readUInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeFloatLE=function(e,t,r){return P(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return P(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return C(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return C(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(e){return n.toByteArray(function(e){if((e=e.trim().replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function F(e){return e instanceof ArrayBuffer||null!=e&&null!=e.constructor&&"ArrayBuffer"===e.constructor.name&&"number"==typeof e.byteLength}function q(e){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(e)}function H(e){return e!=e}},{"base64-js":51,ieee754:178}],85:[function(e,t,r){t.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],86:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("stream").Transform,o=e("string_decoder").StringDecoder;function a(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(a,i),a.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},a.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},a.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},a.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},t.exports=a},{inherits:180,"safe-buffer":290,stream:311,string_decoder:317}],87:[function(e,t,r){(function(e){var r=function(){"use strict";function t(e,t){return null!=t&&e instanceof t}var r,n,i;try{r=Map}catch(e){r=function(){}}try{n=Set}catch(e){n=function(){}}try{i=Promise}catch(e){i=function(){}}function o(a,u,c,f,h){"object"==typeof u&&(c=u.depth,f=u.prototype,h=u.includeNonEnumerable,u=u.circular);var l=[],d=[],p=void 0!==e;return void 0===u&&(u=!0),void 0===c&&(c=1/0),function a(c,b){if(null===c)return null;if(0===b)return c;var y,m;if("object"!=typeof c)return c;if(t(c,r))y=new r;else if(t(c,n))y=new n;else if(t(c,i))y=new i(function(e,t){c.then(function(t){e(a(t,b-1))},function(e){t(a(e,b-1))})});else if(o.__isArray(c))y=[];else if(o.__isRegExp(c))y=new RegExp(c.source,s(c)),c.lastIndex&&(y.lastIndex=c.lastIndex);else if(o.__isDate(c))y=new Date(c.getTime());else{if(p&&e.isBuffer(c))return y=e.allocUnsafe?e.allocUnsafe(c.length):new e(c.length),c.copy(y),y;t(c,Error)?y=Object.create(c):void 0===f?(m=Object.getPrototypeOf(c),y=Object.create(m)):(y=Object.create(f),m=f)}if(u){var v=l.indexOf(c);if(-1!=v)return d[v];l.push(c),d.push(y)}for(var g in t(c,r)&&c.forEach(function(e,t){var r=a(t,b-1),n=a(e,b-1);y.set(r,n)}),t(c,n)&&c.forEach(function(e){var t=a(e,b-1);y.add(t)}),c){var w;m&&(w=Object.getOwnPropertyDescriptor(m,g)),w&&null==w.set||(y[g]=a(c[g],b-1))}if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(c);for(g=0;g<_.length;g++){var A=_[g];(!(x=Object.getOwnPropertyDescriptor(c,A))||x.enumerable||h)&&(y[A]=a(c[A],b-1),x.enumerable||Object.defineProperty(y,A,{enumerable:!1}))}}if(h){var E=Object.getOwnPropertyNames(c);for(g=0;g>>2),a=0,s=0;a>5]|=128<>>9<<4)]=t;for(var r=1732584193,n=-271733879,i=-1732584194,o=271733878,h=0;h>>32-s,r);var a,s}function a(e,t,r,n,i,a,s){return o(t&r|~t&n,e,t,i,a,s)}function s(e,t,r,n,i,a,s){return o(t&n|r&~n,e,t,i,a,s)}function u(e,t,r,n,i,a,s){return o(t^r^n,e,t,i,a,s)}function c(e,t,r,n,i,a,s){return o(r^(t|~n),e,t,i,a,s)}function f(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}t.exports=function(e){return n(e,i)}},{"./make-hash":92}],94:[function(e,t,r){"use strict";var n=e("inherits"),i=e("./legacy"),o=e("cipher-base"),a=e("safe-buffer").Buffer,s=e("create-hash/md5"),u=e("ripemd160"),c=e("sha.js"),f=a.alloc(128);function h(e,t){o.call(this,"digest"),"string"==typeof t&&(t=a.from(t));var r="sha512"===e||"sha384"===e?128:64;(this._alg=e,this._key=t,t.length>r)?t=("rmd160"===e?new u:c(e)).update(t).digest():t.lengths?t=e(t):t.length-1};f.prototype.append=function(e,t){e=s(e),t=u(t);var r=this.map[e];this.map[e]=r?r+","+t:t},f.prototype.delete=function(e){delete this.map[s(e)]},f.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},f.prototype.set=function(e,t){this.map[s(e)]=u(t)},f.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},f.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),c(e)},f.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),c(e)},f.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),c(e)},t.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);var o=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},b.call(y.prototype),b.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:0,statusText:""});return e.type="error",e};var a=[301,302,303,307,308];v.redirect=function(e,t){if(-1===a.indexOf(t))throw new RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},e.Headers=f,e.Request=y,e.Response=v,e.fetch=function(e,r){return new Promise(function(n,i){var o=new y(e,r),a=new XMLHttpRequest;a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new v(i,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&t.blob&&(a.responseType="blob"),o.headers.forEach(function(e,t){a.setRequestHeader(t,e)}),a.send(void 0===o._bodyInit?null:o._bodyInit)})},e.fetch.polyfill=!0}function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function u(e){return"string"!=typeof e&&(e=String(e)),e}function c(e){var r={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t.iterable&&(r[Symbol.iterator]=function(){return r}),r}function f(e){this.map={},e instanceof f?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function h(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function l(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function d(e){var t=new FileReader,r=l(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(t.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(t.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(t.arrayBuffer&&t.blob&&n(e))this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!t.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(e)&&!i(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=p(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},t.blob&&(this.blob=function(){var e=h(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var e,t,r,n=h(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=l(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function v(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}}(void 0!==e?e:this)}).call(n,void 0);var i=n.fetch;i.Response=n.Response,i.Request=n.Request,i.Headers=n.Headers;"object"==typeof t&&t.exports&&(t.exports=i,t.exports.default=i)},{}],97:[function(e,t,r){"use strict";r.randomBytes=r.rng=r.pseudoRandomBytes=r.prng=e("randombytes"),r.createHash=r.Hash=e("create-hash"),r.createHmac=r.Hmac=e("create-hmac");var n=e("browserify-sign/algos"),i=Object.keys(n),o=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(i);r.getHashes=function(){return o};var a=e("pbkdf2");r.pbkdf2=a.pbkdf2,r.pbkdf2Sync=a.pbkdf2Sync;var s=e("browserify-cipher");r.Cipher=s.Cipher,r.createCipher=s.createCipher,r.Cipheriv=s.Cipheriv,r.createCipheriv=s.createCipheriv,r.Decipher=s.Decipher,r.createDecipher=s.createDecipher,r.Decipheriv=s.Decipheriv,r.createDecipheriv=s.createDecipheriv,r.getCiphers=s.getCiphers,r.listCiphers=s.listCiphers;var u=e("diffie-hellman");r.DiffieHellmanGroup=u.DiffieHellmanGroup,r.createDiffieHellmanGroup=u.createDiffieHellmanGroup,r.getDiffieHellman=u.getDiffieHellman,r.createDiffieHellman=u.createDiffieHellman,r.DiffieHellman=u.DiffieHellman;var c=e("browserify-sign");r.createSign=c.createSign,r.Sign=c.Sign,r.createVerify=c.createVerify,r.Verify=c.Verify,r.createECDH=e("create-ecdh");var f=e("public-encrypt");r.publicEncrypt=f.publicEncrypt,r.privateEncrypt=f.privateEncrypt,r.publicDecrypt=f.publicDecrypt,r.privateDecrypt=f.privateDecrypt;var h=e("randomfill");r.randomFill=h.randomFill,r.randomFillSync=h.randomFillSync,r.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))},r.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},{"browserify-cipher":73,"browserify-sign":80,"browserify-sign/algos":77,"create-ecdh":90,"create-hash":91,"create-hmac":94,"diffie-hellman":105,pbkdf2:247,"public-encrypt":259,randombytes:270,randomfill:271}],98:[function(e,t,r){"use strict";var n=new RegExp("%[a-f0-9]{2}","gi"),i=new RegExp("(%[a-f0-9]{2})+","gi");function o(e,t){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],o(r),o(n))}function a(e){try{return decodeURIComponent(e)}catch(i){for(var t=e.match(n),r=1;r0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];r=a.r28shl(r,s),i=a.r28shl(i,s),a.pc2(r,i,e.keys,o)}},u.prototype._update=function(e,t,r,n){var i=this._desState,o=a.readUInt32BE(e,t),s=a.readUInt32BE(e,t+4);a.ip(o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,s,i.tmp,0):this._decrypt(i,o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],a.writeUInt32BE(r,o,n),a.writeUInt32BE(r,s,n+4)},u.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,o=l}a.rip(s,o,n,i)},u.prototype._decrypt=function(e,t,r,n,i){for(var o=r,s=t,u=e.keys.length-2;u>=0;u-=2){var c=e.keys[u],f=e.keys[u+1];a.expand(o,e.tmp,0),c^=e.tmp[0],f^=e.tmp[1];var h=a.substitute(c,f),l=o;o=(s^a.permute(h))>>>0,s=l}a.rip(o,s,n,i)}},{"../des":99,inherits:180,"minimalistic-assert":234}],103:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits"),o=e("../des"),a=o.Cipher,s=o.DES;function u(e){a.call(this,e);var t=new function(e,t){n.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),i=t.slice(8,16),o=t.slice(16,24);this.ciphers="encrypt"===e?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edgeState=t}i(u,a),t.exports=u,u.create=function(e){return new u(e)},u.prototype._update=function(e,t,r,n){var i=this._edgeState;i.ciphers[0]._update(e,t,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},u.prototype._pad=s.prototype._pad,u.prototype._unpad=s.prototype._unpad},{"../des":99,inherits:180,"minimalistic-assert":234}],104:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,n){for(var i=0,o=0,a=6;a>=0;a-=2){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>>s+a&1}for(a=6;a>=0;a-=2){for(s=1;s<=25;s+=8)o<<=1,o|=t>>>s+a&1;for(s=1;s<=25;s+=8)o<<=1,o|=e>>>s+a&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(e,t,r,n){for(var i=0,o=0,a=0;a<4;a++)for(var s=24;s>=0;s-=8)i<<=1,i|=t>>>s+a&1,i<<=1,i|=e>>>s+a&1;for(a=4;a<8;a++)for(s=24;s>=0;s-=8)o<<=1,o|=t>>>s+a&1,o<<=1,o|=e>>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(e,t,r,n){for(var i=0,o=0,a=7;a>=5;a--){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+a&1}for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(a=1;a<=3;a++){for(s=0;s<=24;s+=8)o<<=1,o|=t>>s+a&1;for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1}for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,i){for(var o=0,a=0,s=n.length>>>1,u=0;u>>n[u]&1;for(u=s;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=a>>>0},r.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var n=e.toString(2);n.lengthe;)r.ishrn(1);if(r.isEven()&&r.iadd(s),r.testn(1)||r.iadd(u),t.cmp(u)){if(!t.cmp(c))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&m(p)&&m(r)&&a.test(p)&&a.test(r))return r}}},{"bn.js":53,"miller-rabin":233,randombytes:270}],108:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],109:[function(e,t,r){"use strict";var n=r;n.version=e("../package.json").version,n.utils=e("./elliptic/utils"),n.rand=e("brorand"),n.curve=e("./elliptic/curve"),n.curves=e("./elliptic/curves"),n.ec=e("./elliptic/ec"),n.eddsa=e("./elliptic/eddsa")},{"../package.json":124,"./elliptic/curve":112,"./elliptic/curves":115,"./elliptic/ec":116,"./elliptic/eddsa":119,"./elliptic/utils":123,brorand:54}],110:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.getNAF,a=i.getJSF,s=i.assert;function u(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){s(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=u;t--)c=(c<<1)+n[t];a.push(c)}for(var f=this.jpoint(null,null,null),h=this.jpoint(null,null,null),l=i;l>0;l--){for(u=0;u=0;c--){for(t=0;c>=0&&0===a[c];c--)t++;if(c>=0&&t++,u=u.dblp(t),c<0)break;var f=a[c];s(0!==f),u="affine"===e.type?f>0?u.mixedAdd(i[f-1>>1]):u.mixedAdd(i[-f-1>>1].neg()):f>0?u.add(i[f-1>>1]):u.add(i[-f-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){for(var s=this._wnafT1,u=this._wnafT2,c=this._wnafT3,f=0,h=0;h=1;h-=2){var d=h-1,p=h;if(1===s[d]&&1===s[p]){var b=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(b[1]=t[d].add(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].add(t[p].neg())):(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],m=a(r[d],r[p]);f=Math.max(m[0].length,f),c[d]=new Array(f),c[p]=new Array(f);for(var v=0;v=0;h--){for(var E=0;h>=0;){var x=!0;for(v=0;v=0&&E++,_=_.dblp(E),h<0)break;for(v=0;v0?k=u[v][S-1>>1]:S<0&&(k=u[v][-S-1>>1].neg()),_="affine"===k.type?_.mixedAdd(k):_.add(k))}}for(h=0;h=Math.ceil((e.bitLength()+1)/t.step)},c.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},f.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},f.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(r),s=n.redSub(t),u=i.redMul(a),c=o.redMul(s),f=i.redMul(s),h=a.redMul(o);return this.curve.point(u,c,h,f)},f.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var a=(c=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(a.redSub(this.curve.two)),t=a.redMul(c.redSub(o)),r=a.redSqr().redSub(a).redSub(a);else{var s=this.z.redSqr(),u=a.redSub(s).redISub(s);e=n.redSub(i).redISub(o).redMul(u),t=a.redMul(c.redSub(o)),r=a.redMul(u)}}else{var c=i.redAdd(o);s=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=c.redSub(s).redSub(s);e=this.curve._mulC(n.redISub(c)).redMul(u),t=this.curve._mulC(c).redMul(i.redISub(o)),r=c.redMul(u)}return this.curve.point(e,t,r)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},f.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=i.redSub(n),s=i.redAdd(n),u=r.redAdd(t),c=o.redMul(a),f=s.redMul(u),h=o.redMul(u),l=a.redMul(s);return this.curve.point(c,f,l,h)},f.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),c=i.redAdd(s),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),h=n.redMul(u).redMul(f);return this.curve.twisted?(t=n.redMul(c).redMul(a.redSub(this.curve._mulA(o))),r=u.redMul(c)):(t=n.redMul(c).redMul(a.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(h,t,r)},f.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},f.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},f.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},f.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},f.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()},f.prototype.getY=function(){return this.normalize(),this.y.fromRed()},f.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},f.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}return!1},f.prototype.toP=f.prototype.normalize,f.prototype.mixedAdd=f.prototype.add},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],112:[function(e,t,r){"use strict";var n=r;n.base=e("./base"),n.short=e("./short"),n.mont=e("./mont"),n.edwards=e("./edwards")},{"./base":110,"./edwards":111,"./mont":113,"./short":114}],113:[function(e,t,r){"use strict";var n=e("../curve"),i=e("bn.js"),o=e("inherits"),a=n.base,s=e("../../elliptic").utils;function u(e){a.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,r){a.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(u,a),t.exports=u,u.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},o(c,a.BasePoint),u.prototype.decodePoint=function(e,t){return this.point(s.toArray(e,t),1)},u.prototype.point=function(e,t){return new c(this,e,t)},u.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=i.redMul(n),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},c.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],114:[function(e,t,r){"use strict";var n=e("../curve"),i=e("../../elliptic"),o=e("bn.js"),a=e("inherits"),s=n.base,u=i.utils.assert;function c(e){s.call(this,"short",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function f(e,t,r,n){s.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new o(t,16),this.y=new o(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function h(e,t,r,n){s.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new o(0)):(this.x=new o(t,16),this.y=new o(r,16),this.z=new o(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}a(c,s),t.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new o(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new o(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?r=i[0]:(r=i[1],u(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new o(e.a,16),b:new o(e.b,16)}}):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:o.mont(e),r=new o(2).toRed(t).redInvm(),n=r.redNeg(),i=new o(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,r,n,i,a,s,u,c,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=e,d=this.n.clone(),p=new o(1),b=new o(0),y=new o(0),m=new o(1),v=0;0!==l.cmpn(0);){var g=d.div(l);c=d.sub(g.mul(l)),f=y.sub(g.mul(p));var w=m.sub(g.mul(b));if(!n&&c.cmp(h)<0)t=u.neg(),r=p,n=c.neg(),i=f;else if(n&&2==++v)break;u=c,d=l,l=c,y=p,p=f,m=b,b=w}a=c.neg(),s=f;var _=n.sqr().add(i.sqr());return a.sqr().add(s.sqr()).cmp(_)>=0&&(a=t,s=r),n.negative&&(n=n.neg(),i=i.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:n,b:i},{a:a,b:s}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(c).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},f.prototype.isInfinity=function(){return this.inf},f.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},f.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},f.prototype.getX=function(){return this.x.fromRed()},f.prototype.getY=function(){return this.y.fromRed()},f.prototype.mul=function(e){return e=new o(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},f.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},f.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},f.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},f.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},a(h,s.BasePoint),c.prototype.jpoint=function(e,t,r){return new h(this,e,t,r)},h.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},h.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},h.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),f=c.redMul(s),h=n.redMul(c),l=u.redSqr().redIAdd(f).redISub(h).redISub(h),d=u.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(l,d,p)},h.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),f=r.redMul(u),h=s.redSqr().redIAdd(c).redISub(f).redISub(f),l=s.redMul(f.redISub(h)).redISub(i.redMul(c)),d=this.z.redMul(a);return this.curve.jpoint(h,l,d)},h.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}return!1},h.prototype.inspect=function(){return this.isInfinity()?"":""},h.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],115:[function(e,t,r){"use strict";var n,i=r,o=e("hash.js"),a=e("../elliptic"),s=a.utils.assert;function u(e){"short"===e.type?this.curve=new a.curve.short(e):"edwards"===e.type?this.curve=new a.curve.edwards(e):this.curve=new a.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=e("./precomputed/secp256k1")}catch(e){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"../elliptic":109,"./precomputed/secp256k1":122,"hash.js":162}],116:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("hmac-drbg"),o=e("../../elliptic"),a=o.utils.assert,s=e("./key"),u=e("./signature");function c(e){if(!(this instanceof c))return new c(e);"string"==typeof e&&(a(o.curves.hasOwnProperty(e),"Unknown curve "+e),e=o.curves[e]),e instanceof o.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=c,c.prototype.keyPair=function(e){return new s(this,e)},c.prototype.keyFromPrivate=function(e,t){return s.fromPrivate(this,e,t)},c.prototype.keyFromPublic=function(e,t){return s.fromPublic(this,e,t)},c.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||o.rand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),a=this.n.sub(new n(2));;){var s=new n(t.generate(r));if(!(s.cmp(a)>0))return s.iaddn(1),this.keyFromPrivate(s)}},c.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},c.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),c=e.toArray("be",a),f=new i({hash:this.hash,entropy:s,nonce:c,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(f.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var m=d.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),v^=1),new u({r:y,s:m,recoveryParam:v})}}}}}},c.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new u(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,c=a.invm(this.n),f=c.mul(e).umod(this.n),h=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(f,r.getPublic(),h)).isInfinity()&&s.eqXToP(o):!(s=this.g.mulAdd(f,r.getPublic(),h)).isInfinity()&&0===s.getX().umod(this.n).cmp(o)},c.prototype.recoverPubKey=function(e,t,r,i){a((3&r)===r,"The recovery param is more than two bits"),t=new u(t,i);var o=this.n,s=new n(e),c=t.r,f=t.s,h=1&r,l=r>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find second key candidate");c=l?this.curve.pointFromX(c.add(this.curve.n),h):this.curve.pointFromX(c,h);var d=t.r.invm(o),p=o.sub(s).mul(d).umod(o),b=f.mul(d).umod(o);return this.g.mulAdd(p,c,b)},c.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new u(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":109,"./key":117,"./signature":118,"bn.js":53,"hmac-drbg":174}],117:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils.assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../../elliptic":109,"bn.js":53}],118:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new function(){this.place=0};if(48!==e[r.place++])return!1;if(s(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=s(e,r),a=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var u=s(e,r);if(e.length!==u+r.place)return!1;var c=e.slice(r.place,u+r.place);return 0===a[0]&&128&a[1]&&(a=a.slice(1)),0===c[0]&&128&c[1]&&(c=c.slice(1)),this.r=new n(a),this.s=new n(c),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=u(t),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),a=[48];return c(a,o.length),a=a.concat(o),i.encode(a,e)}},{"../../elliptic":109,"bn.js":53}],119:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("../../elliptic"),o=i.utils,a=o.assert,s=o.parseBytes,u=e("./key"),c=e("./signature");function f(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}t.exports=f,f.prototype.sign=function(e,t){e=s(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),u=n.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(e,t,r){e=s(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var s=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,c=t.andln(3)+i&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!=(s=e.andln(7)+n&7)&&5!==s||2!==c?u:-u,r[0].push(o),a=0==(1&c)?0:3!=(s=t.andln(7)+i&7)&&5!==s||2!==u?c:-c,r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},{"bn.js":53,"minimalistic-assert":234,"minimalistic-crypto-utils":235}],124:[function(e,t,r){t.exports={_from:"elliptic@^6.0.0",_id:"elliptic@6.4.0",_inBundle:!1,_integrity:"sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=",_location:"/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.0.0",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.0.0",saveSpec:null,fetchSpec:"^6.0.0"},_requiredBy:["/browserify-sign","/create-ecdh"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",_shasum:"cac9af8762c85836187003c8dfe193e5e2eae5df",_spec:"elliptic@^6.0.0",_where:"/Users/alexvlasov/Blockchain/web3swift_jsproxy/node_modules/browserify-sign",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.4.0"}},{}],125:[function(e,t,r){"use strict";const n=e("ethjs-util");function i(e){let t=n.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}t.exports={incrementHexNumber:function(e){return i(n.intToHex(parseInt(e,16)+1))},formatHex:i}},{"ethjs-util":155}],126:[function(e,t,r){const n=e("eth-query"),i=e("events"),o=e("pify"),a=e("./hexUtils"),s=a.incrementHexNumber,u=1e3,c=60*u;t.exports=class extends i{constructor(e={}){if(super(),!e.provider)throw new Error("RpcBlockTracker - no provider specified.");this._provider=e.provider,this._query=new n(e.provider),this._pollingInterval=e.pollingInterval||4*u,this._syncingTimeout=e.syncingTimeout||1*c,this._trackingBlock=null,this._trackingBlockTimestamp=null,this._currentBlock=null,this._isRunning=!1,this._performSync=this._performSync.bind(this),this._handleNewBlockNotification=this._handleNewBlockNotification.bind(this)}getTrackingBlock(){return this._trackingBlock}getCurrentBlock(){return this._currentBlock}async awaitCurrentBlock(){return this._currentBlock?this._currentBlock:(await new Promise(e=>this.once("latest",e)),this._currentBlock)}async start(e={}){this._isRunning||(this._isRunning=!0,e.fromBlock?await this._setTrackingBlock(await this._fetchBlockByNumber(e.fromBlock)):await this._setTrackingBlock(await this._fetchLatestBlock()),this._provider.on?await this._initSubscription():this._performSync().catch(e=>{e&&console.error(e)}))}async stop(){this._isRunning=!1,this._provider.on&&await this._removeSubscription()}async _setTrackingBlock(e){if(this._trackingBlock&&this._trackingBlock.hash===e.hash)return;const t=this._trackingBlockTimestamp,r=Date.now();t&&r-t>this._syncingTimeout?(this._trackingBlockTimestamp=null,await this._warpToLatest()):(this._trackingBlock=e,this._trackingBlockTimestamp=r,this.emit("block",e))}async _setCurrentBlock(e){if(this._currentBlock&&this._currentBlock.hash===e.hash)return;const t=this._currentBlock;this._currentBlock=e,this.emit("latest",e),this.emit("sync",{newBlock:e,oldBlock:t})}async _warpToLatest(){await this._setTrackingBlock(await this._fetchLatestBlock())}async _pollForNextBlock(){setTimeout(()=>this._performSync(),this._pollingInterval)}async _performSync(){if(!this._isRunning)return;const e=this.getTrackingBlock();if(!e)throw new Error("RpcBlockTracker - tracking block is missing");const t=s(e.number);try{const r=await this._fetchBlockByNumber(t);r?(await this._setTrackingBlock(r),this._performSync()):(await this._setCurrentBlock(e),this._pollForNextBlock())}catch(t){t.message.includes("index out of range")||t.message.includes("Couldn't find block by reference")?(await this._setCurrentBlock(e),this._pollForNextBlock()):(console.error(t),this._pollForNextBlock())}}async _handleNewBlockNotification(e,t){t.id==this._subscriptionId&&(e&&(this.emit("error",e),await this._removeSubscription()),await this._setTrackingBlock(await this._fetchBlockByNumber(t.result.number)))}async _initSubscription(){this._provider.on("data",this._handleNewBlockNotification);let e=await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_subscribe",params:["newHeads"]});this._subscriptionId=e.result}async _removeSubscription(){if(!this._subscriptionId)throw new Error("Not subscribed.");this._provider.removeListener("data",this._handleNewBlockNotification),await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_unsubscribe",params:[this._subscriptionId]}),delete this._subscriptionId}_fetchLatestBlock(){return o(this._query.getBlockByNumber).call(this._query,"latest",!0)}_fetchBlockByNumber(e){const t=a.formatHex(e);return o(this._query.getBlockByNumber).call(this._query,t,!0)}}},{"./hexUtils":125,"eth-query":135,events:157,pify:252}],127:[function(e,t,r){(function(t){var n=e("js-sha3").keccak_256,i=e("idna-uts46-hx");function o(e){return e?i.toUnicode(e,{useStd3ASCII:!0,transitional:!1}):e}r.hash=function(e){for(var r="",i=0;i<32;i++)r+="00";if(name=o(e),name){var a=name.split(".");for(i=a.length-1;i>=0;i--){var s=n(a[i]);r=n(new t(r+s,"hex"))}}return"0x"+r},r.normalize=o}).call(this,e("buffer").Buffer)},{buffer:84,"idna-uts46-hx":177,"js-sha3":128}],128:[function(e,t,r){(function(e,r){!function(){"use strict";var n="object"==typeof window?window:{};!n.JS_SHA3_NO_NODE_JS&&"object"==typeof e&&e.versions&&e.versions.node&&(n=r);for(var i=!n.JS_SHA3_NO_COMMON_JS&&"object"==typeof t&&t.exports,o="0123456789abcdef".split(""),a=[0,8,16,24],s=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],u=[224,256,384,512],c=["hex","buffer","arrayBuffer","array"],f=function(e,t,r){return function(n){return new _(e,t,e).update(n)[r]()}},h=function(e,t,r){return function(n,i){return new _(e,t,i).update(n)[r]()}},l=function(e,t){var r=f(e,t,"hex");r.create=function(){return new _(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}_.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,o=this.blocks,s=this.byteCount,u=this.blockCount,c=0,f=this.s;c>2]|=e[c]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(o[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=s){for(this.start=r-s,this.block=o[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+o[15&e]+o[e>>12&15]+o[e>>8&15]+o[e>>20&15]+o[e>>16&15]+o[e>>28&15]+o[e>>24&15];s%t==0&&(A(r),a=0)}return i&&(e=r[a],i>0&&(u+=o[e>>4&15]+o[15&e]),i>1&&(u+=o[e>>12&15]+o[e>>8&15]),i>2&&(u+=o[e>>20&15]+o[e>>16&15])),u},_.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&A(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var A=function(e){var t,r,n,i,o,a,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],a=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(a<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|a>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=a^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=s[n],e[1]^=s[n+1]};if(i)t.exports=p;else for(y=0;y{setTimeout(t,e)})}function c(e){const t=e.toString();return s.some(e=>t.includes(e))}async function f(e,t,r){const{fetchUrl:n,fetchParams:a}=h({network:e,req:t}),s=await o(n,a),u=await s.text();if(!s.ok)switch(s.status){case 405:throw new i.MethodNotFound;case 418:throw l("Request is being rate limited.");case 503:case 504:throw function(){let e="Gateway timeout. The request took too long to process. ";return e+="This can happen when querying logs over too wide a block range.",l("Gateway timeout. The request took too long to process. This can happen when querying logs over too wide a block range.")}();default:throw l(u)}if("eth_getBlockByNumber"===t.method&&"Not Found"===u)return void(r.result=null);const c=JSON.parse(u);r.result=c.result,r.error=c.error}function h({network:e,req:t}){const r=function(e){return{id:e.id,jsonrpc:e.jsonrpc,method:e.method,params:e.params}}(t),{method:n,params:i}=r,o={};let s=`https://api.infura.io/v1/jsonrpc/${e}`;if(a.includes(n))o.method="POST",o.headers={Accept:"application/json","Content-Type":"application/json"},o.body=JSON.stringify(r);else{o.method="GET",s+=`/${n}?params=${encodeURIComponent(JSON.stringify(i))}`}return{fetchUrl:s,fetchParams:o}}function l(e){const t=new Error(e);return new i.InternalError(t)}t.exports=function(e={}){const t=e.network||"mainnet",r=e.maxAttempts||5;if(!r)throw new Error(`Invalid value for 'maxAttempts': "${r}" (${typeof r})`);return n(async(e,n,i)=>{for(let i=1;i<=r;i++)try{await f(t,e,n);break}catch(e){if(!c(e))throw e;const t=r-i;if(!t){const t=`InfuraProvider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,r=new Error(t);throw r}await u(1e3)}})},t.exports.fetchConfigFromReq=h},{"cross-fetch":96,"json-rpc-engine/src/createAsyncMiddleware":187,"json-rpc-error":189}],131:[function(e,t,r){t.exports=function(e){return{sendAsync:e.handle.bind(e)}}},{}],132:[function(e,t,r){var n=function(e,t){for(var r=[],n=0;n>6|192);else{if(i>55295&&i<56320){if(++n==e.length)return null;var o=e.charCodeAt(n);if(o<56320||o>57343)return null;r+=t((i=65536+((1023&i)<<10)+(1023&o))>>18|240),r+=t(i>>12&63|128)}else r+=t(i>>12|224);r+=t(i>>6&63|128)}r+=t(63&i|128)}}return r},toString:function(e){for(var t="",r=0,o=i(e);r127){if(a>191&&a<224){if(r>=o)return null;a=(31&a)<<6|63&n(e,r)}else if(a>223&&a<240){if(r+1>=o)return null;a=(15&a)<<12|(63&n(e,r))<<6|63&n(e,++r)}else{if(!(a>239&&a<248))return null;if(r+2>=o)return null;a=(7&a)<<18|(63&n(e,r))<<12|(63&n(e,++r))<<6|63&n(e,++r)}++r}if(a<=65535)t+=String.fromCharCode(a);else{if(!(a<=1114111))return null;a-=65536,t+=String.fromCharCode(a>>10|55296),t+=String.fromCharCode(1023&a|56320)}}return t},fromNumber:function(e){var t=e.toString(16);return t.length%2==0?"0x"+t:"0x0"+t},toNumber:function(e){return parseInt(e.slice(2),16)},fromNat:function(e){return"0x0"===e?"0x":e.length%2==0?e:"0x0"+e.slice(2)},toNat:function(e){return"0"===e[2]?"0x"+e.slice(3):e},fromArray:a,toArray:o,fromUint8Array:function(e){return a([].slice.call(e,0))},toUint8Array:function(e){return new Uint8Array(o(e))}}},{"./array.js":132}],134:[function(e,t,r){var n="0123456789abcdef".split(""),i=[1,256,65536,16777216],o=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],s=function(e){var t,r,n,i,o,s,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=a[n],e[1]^=a[n+1]},u=function(e){return function(t){var r;if("0x"===t.slice(0,2)){r=[];for(var a=2,u=t.length;a>2]|=t[d]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|63&r)<=57344?(u[y>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<=c){for(e.start=y-c,e.block=u[f],y=0;y>2]|=i[3&y],e.lastByteIndex===c)for(u[0]=u[f],y=1;y>4&15]+n[15&p]+n[p>>12&15]+n[p>>8&15]+n[p>>20&15]+n[p>>16&15]+n[p>>28&15]+n[p>>24&15];m%f==0&&(s(l),y=0)}return"0x"+b}(function(e){return{blocks:[],reset:!0,block:0,start:0,blockCount:1600-(e<<1)>>5,outputBlocks:e>>5,s:(t=[0,0,0,0,0,0,0,0,0,0],[].concat(t,t,t,t,t))};var t}(e),r)}};t.exports={keccak256:u(256),keccak512:u(512),keccak256s:u(256),keccak512s:u(512)}},{}],135:[function(e,t,r){const n=e("xtend"),i=e("json-rpc-random-id")();function o(e){this.currentProvider=e}function a(e){return function(){var t=[].slice.call(arguments),r=t.pop();this.sendAsync({method:e,params:t},r)}}function s(e,t){return function(){var r=[].slice.call(arguments),n=r.pop();r.lengtho)throw new Error("Elements exceed array size: "+o);for(d in h=[],e=e.slice(0,e.lastIndexOf("[")),"string"==typeof t&&(t=JSON.parse(t)),t)h.push(l(e,t[d]));if("dynamic"===o){var p=l("uint256",t.length);h.unshift(p)}return r.concat(h)}if("bytes"===e)return t=new r(t),h=r.concat([l("uint256",t.length),t]),t.length%32!=0&&(h=r.concat([h,n.zeros(32-t.length%32)])),h;if(e.startsWith("bytes")){if((o=s(e))<1||o>32)throw new Error("Invalid bytes width: "+o);return n.setLengthRight(t,32)}if(e.startsWith("uint")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid uint width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied uint exceeds width: "+o+" vs "+a.bitLength());if(a<0)throw new Error("Supplied uint is negative");return a.toArrayLike(r,"be",32)}if(e.startsWith("int")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid int width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied int exceeds width: "+o+" vs "+a.bitLength());return a.toTwos(256).toArrayLike(r,"be",32)}if(e.startsWith("ufixed")){if(o=u(e),(a=f(t))<0)throw new Error("Supplied ufixed is negative");return l("uint256",a.mul(new i(2).pow(new i(o[1]))))}if(e.startsWith("fixed"))return o=u(e),l("int256",f(t).mul(new i(2).pow(new i(o[1]))));throw new Error("Unsupported or invalid type: "+e)}function d(e,t,n){var o,a,s,u;if("string"==typeof e&&(e=p(e)),"address"===e.name)return d(e.rawType,t,n).toArrayLike(r,"be",20).toString("hex");if("bool"===e.name)return d(e.rawType,t,n).toString()===new i(1).toString();if("string"===e.name){var c=d(e.rawType,t,n);return new r(c,"utf8").toString()}if(e.isArray){for(s=[],o=e.size,"dynamic"===e.size&&(o=d("uint256",t,n=d("uint256",t,n).toNumber()).toNumber(),n+=32),u=0;ue.size)throw new Error("Decoded int exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("int")){if((a=new i(t.slice(n,n+32),16,"be").fromTwos(256)).bitLength()>e.size)throw new Error("Decoded uint exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("ufixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("uint256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}if(e.name.startsWith("fixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("int256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}throw new Error("Unsupported or invalid type: "+e.name)}function p(e){var t,r,n;if(y(e)){t=c(e);var i=e.slice(0,e.lastIndexOf("["));return i=p(i),r={isArray:!0,name:e,size:t,memoryUsage:"dynamic"===t?32:i.memoryUsage*t,subArray:i}}switch(e){case"address":n="uint160";break;case"bool":n="uint8";break;case"string":n="bytes"}if(r={rawType:n,name:e,memoryUsage:32},e.startsWith("bytes")&&"bytes"!==e||e.startsWith("uint")||e.startsWith("int")?r.size=s(e):(e.startsWith("ufixed")||e.startsWith("fixed"))&&(r.size=u(e)),e.startsWith("bytes")&&"bytes"!==e&&(r.size<1||r.size>32))throw new Error("Invalid bytes width: "+r.size);if((e.startsWith("uint")||e.startsWith("int"))&&(r.size%8||r.size<8||r.size>256))throw new Error("Invalid int/uint width: "+r.size);return r}function b(e){return"string"===e||"bytes"===e||"dynamic"===c(e)}function y(e){return e.lastIndexOf("]")===e.length-1}function m(e,t){return e.startsWith("address")||e.startsWith("bytes")?"0x"+t.toString("hex"):t.toString()}o.eventID=function(e,t){var i=e+"("+t.map(a).join(",")+")";return n.sha3(new r(i))},o.methodID=function(e,t){return o.eventID(e,t).slice(0,4)},o.rawEncode=function(e,t){var n=[],i=[],o=0;e.forEach(function(e){if(y(e)){var t=c(e);o+="dynamic"!==t?32*t:32}else o+=32});for(var s=0;s32)throw new Error("Invalid bytes width: "+i);u.push(n.setLengthRight(l,i))}else if(h.startsWith("uint")){if((i=s(h))%8||i<8||i>256)throw new Error("Invalid uint width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied uint exceeds width: "+i+" vs "+o.bitLength());u.push(o.toArrayLike(r,"be",i/8))}else{if(!h.startsWith("int"))throw new Error("Unsupported or invalid type: "+h);if((i=s(h))%8||i<8||i>256)throw new Error("Invalid int width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied int exceeds width: "+i+" vs "+o.bitLength());u.push(o.toTwos(i).toArrayLike(r,"be",i/8))}}return r.concat(u)},o.soliditySHA3=function(e,t){return n.sha3(o.solidityPack(e,t))},o.soliditySHA256=function(e,t){return n.sha256(o.solidityPack(e,t))},o.solidityRIPEMD160=function(e,t){return n.ripemd160(o.solidityPack(e,t),!0)},o.fromSerpent=function(e){for(var t,r=[],n=0;n="0"&&t<="9");)o+=e[a]-"0",a++;n=a-1,r.push(o)}else if("i"===i)r.push("int256");else{if("a"!==i)throw new Error("Unsupported or invalid type: "+i);r.push("int256[]")}}return r},o.toSerpent=function(e){for(var t=[],r=0;r0){var r=this.raw.slice();this.v=this._chainId,this.r=0,this.s=0,t=this.raw,this.raw=r}else t=this.raw.slice(0,6);return n.rlphash(t)},e.prototype.getChainId=function(){return this._chainId},e.prototype.getSenderAddress=function(){if(this._from)return this._from;var e=this.getSenderPublicKey();return this._from=n.publicToAddress(e),this._from},e.prototype.getSenderPublicKey=function(){if(!(this._senderPubKey&&this._senderPubKey.length||this.verifySignature()))throw new Error("Invalid Signature");return this._senderPubKey},e.prototype.verifySignature=function(){var e=this.hash(!1);if(this._homestead&&1===new o(this.s).cmp(a))return!1;try{var t=n.bufferToInt(this.v);this._chainId>0&&(t-=2*this._chainId+8),this._senderPubKey=n.ecrecover(e,t,this.r,this.s)}catch(e){return!1}return!!this._senderPubKey},e.prototype.sign=function(e){var t=this.hash(!1),r=n.ecsign(t,e);this._chainId>0&&(r.v+=2*this._chainId+8),Object.assign(this,r)},e.prototype.getDataFee=function(){for(var e=this.raw[5],t=new o(0),r=0;r0&&t.push(["gas limit is too low. Need at least "+this.getBaseFee()]),void 0===e||!1===e?0===t.length:t.join(" ")},e}();t.exports=s}).call(this,e("buffer").Buffer)},{buffer:84,"ethereum-common/params.json":137,"ethereumjs-util":141}],141:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("keccak"),o=e("secp256k1"),a=e("assert"),s=e("rlp"),u=e("bn.js"),c=e("create-hash"),f=e("safe-buffer").Buffer;Object.assign(r,e("ethjs-util")),r.MAX_INTEGER=new u("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16),r.TWO_POW256=new u("10000000000000000000000000000000000000000000000000000000000000000",16),r.KECCAK256_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",r.SHA3_NULL_S=r.KECCAK256_NULL_S,r.KECCAK256_NULL=f.from(r.KECCAK256_NULL_S,"hex"),r.SHA3_NULL=r.KECCAK256_NULL,r.KECCAK256_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",r.SHA3_RLP_ARRAY_S=r.KECCAK256_RLP_ARRAY_S,r.KECCAK256_RLP_ARRAY=f.from(r.KECCAK256_RLP_ARRAY_S,"hex"),r.SHA3_RLP_ARRAY=r.KECCAK256_RLP_ARRAY,r.KECCAK256_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",r.SHA3_RLP_S=r.KECCAK256_RLP_S,r.KECCAK256_RLP=f.from(r.KECCAK256_RLP_S,"hex"),r.SHA3_RLP=r.KECCAK256_RLP,r.BN=u,r.rlp=s,r.secp256k1=o,r.zeros=function(e){return f.allocUnsafe(e).fill(0)},r.zeroAddress=function(){var e=r.zeros(20);return r.bufferToHex(e)},r.setLengthLeft=r.setLength=function(e,t,n){var i=r.zeros(t);return e=r.toBuffer(e),n?e.length0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e},r.toBuffer=function(e){if(!f.isBuffer(e))if(Array.isArray(e))e=f.from(e);else if("string"==typeof e)e=r.isHexString(e)?f.from(r.padToEven(r.stripHexPrefix(e)),"hex"):f.from(e);else if("number"==typeof e)e=r.intToBuffer(e);else if(null==e)e=f.allocUnsafe(0);else if(u.isBN(e))e=e.toArrayLike(f);else{if(!e.toArray)throw new Error("invalid type");e=f.from(e.toArray())}return e},r.bufferToInt=function(e){return new u(r.toBuffer(e)).toNumber()},r.bufferToHex=function(e){return"0x"+(e=r.toBuffer(e)).toString("hex")},r.fromSigned=function(e){return new u(e).fromTwos(256)},r.toUnsigned=function(e){return f.from(e.toTwos(256).toArray())},r.keccak=function(e,t){return e=r.toBuffer(e),t||(t=256),i("keccak"+t).update(e).digest()},r.keccak256=function(e){return r.keccak(e)},r.sha3=r.keccak,r.sha256=function(e){return e=r.toBuffer(e),c("sha256").update(e).digest()},r.ripemd160=function(e,t){e=r.toBuffer(e);var n=c("rmd160").update(e).digest();return!0===t?r.setLength(n,32):n},r.rlphash=function(e){return r.keccak(s.encode(e))},r.isValidPrivate=function(e){return o.privateKeyVerify(e)},r.isValidPublic=function(e,t){return 64===e.length?o.publicKeyVerify(f.concat([f.from([4]),e])):!!t&&o.publicKeyVerify(e)},r.pubToAddress=r.publicToAddress=function(e,t){return e=r.toBuffer(e),t&&64!==e.length&&(e=o.publicKeyConvert(e,!1).slice(1)),a(64===e.length),r.keccak(e).slice(-20)};var h=r.privateToPublic=function(e){return e=r.toBuffer(e),o.publicKeyCreate(e,!1).slice(1)};r.importPublic=function(e){return 64!==(e=r.toBuffer(e)).length&&(e=o.publicKeyConvert(e,!1).slice(1)),e},r.ecsign=function(e,t){var r=o.sign(e,t),n={};return n.r=r.signature.slice(0,32),n.s=r.signature.slice(32,64),n.v=r.recovery+27,n},r.hashPersonalMessage=function(e){var t=r.toBuffer("Ethereum Signed Message:\n"+e.length.toString());return r.keccak(f.concat([t,e]))},r.ecrecover=function(e,t,n,i){var a=f.concat([r.setLength(n,32),r.setLength(i,32)],64),s=t-27;if(0!==s&&1!==s)throw new Error("Invalid signature v value");var u=o.recover(e,a,s);return o.publicKeyConvert(u,!1).slice(1)},r.toRpcSig=function(e,t,n){if(27!==e&&28!==e)throw new Error("Invalid recovery id");return r.bufferToHex(f.concat([r.setLengthLeft(t,32),r.setLengthLeft(n,32),r.toBuffer(e-27)]))},r.fromRpcSig=function(e){if(65!==(e=r.toBuffer(e)).length)throw new Error("Invalid signature length");var t=e[64];return t<27&&(t+=27),{v:t,r:e.slice(0,32),s:e.slice(32,64)}},r.privateToAddress=function(e){return r.publicToAddress(h(e))},r.isValidAddress=function(e){return/^0x[0-9a-fA-F]{40}$/.test(e)},r.isZeroAddress=function(e){return r.zeroAddress()===r.addHexPrefix(e)},r.toChecksumAddress=function(e){e=r.stripHexPrefix(e).toLowerCase();for(var t=r.keccak(e).toString("hex"),n="0x",i=0;i=8?n+=e[i].toUpperCase():n+=e[i];return n},r.isValidChecksumAddress=function(e){return r.isValidAddress(e)&&r.toChecksumAddress(e)===e},r.generateAddress=function(e,t){return e=r.toBuffer(e),t=(t=new u(t)).isZero()?null:f.from(t.toArray()),r.rlphash([e,t]).slice(-20)},r.isPrecompiled=function(e){var t=r.unpad(e);return 1===t.length&&t[0]>=1&&t[0]<=8},r.addHexPrefix=function(e){return"string"!=typeof e?e:r.isHexPrefixed(e)?e:"0x"+e},r.isValidSignature=function(e,t,r,n){var i=new u("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16),o=new u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16);return 32===t.length&&32===r.length&&((27===e||28===e)&&(t=new u(t),r=new u(r),!(t.isZero()||t.gt(o)||r.isZero()||r.gt(o))&&(!1!==n||1!==new u(r).cmp(i))))},r.baToJSON=function(e){if(f.isBuffer(e))return"0x"+e.toString("hex");if(e instanceof Array){for(var t=[],n=0;n=i.length,"The field "+t.name+" must not have more "+t.length+" bytes")):t.allowZero&&0===i.length||!t.length||a(t.length===i.length,"The field "+t.name+" must have byte length of "+t.length),e.raw[n]=i}e._fields.push(t.name),Object.defineProperty(e,t.name,{enumerable:!0,configurable:!0,get:i,set:o}),t.default&&(e[t.name]=t.default),t.alias&&Object.defineProperty(e,t.alias,{enumerable:!1,configurable:!0,set:o,get:i})}),i)if("string"==typeof i&&(i=f.from(r.stripHexPrefix(i),"hex")),f.isBuffer(i)&&(i=s.decode(i)),Array.isArray(i)){if(i.length>e._fields.length)throw new Error("wrong number of fields in data");i.forEach(function(t,n){e[e._fields[n]]=r.toBuffer(t)})}else{if("object"!==(void 0===i?"undefined":n(i)))throw new Error("invalid data");var o=Object.keys(i);t.forEach(function(t){-1!==o.indexOf(t.name)&&(e[t.name]=i[t.name]),-1!==o.indexOf(t.alias)&&(e[t.alias]=i[t.alias])})}}},{assert:19,"bn.js":53,"create-hash":91,"ethjs-util":155,keccak:195,rlp:289,"safe-buffer":290,secp256k1:295}],142:[function(e,t,r){arguments[4][128][0].apply(r,arguments)},{_process:257,dup:128}],143:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var a=e("./address"),s=e("./bignumber"),u=e("./bytes"),c=e("./utf8"),f=e("./properties"),h=o(e("./errors")),l=new RegExp(/^bytes([0-9]*)$/),d=new RegExp(/^(u?int)([0-9]*)$/),p=new RegExp(/^(.*)\[([0-9]*)\]$/);r.defaultCoerceFunc=function(e,t){var r=e.match(d);return r&&parseInt(r[2])<=48?t.toNumber():t};var b=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"),y=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function m(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}function v(e,t){function r(t){throw new Error('unexpected character "'+e[t]+'" at position '+t+' in "'+e+'"')}for(var n={type:"",name:"",state:{allowType:!0}},i=n,o=0;o1){var i=r[1].match(b);if(""!=i[1].trim()||""!=i[3].trim())throw new Error("unexpected tokens");L(i[2]).forEach(function(e){t.outputs.push(v(e))})}return t}(e.trim()));throw new Error("unknown signature")};var w=function(){return function(e,t,r,n,i){this.coerceFunc=e,this.name=t,this.type=r,this.localName=n,this.dynamic=i}}(),_=function(e){function t(t){var r=e.call(this,t.coerceFunc,t.name,t.type,void 0,t.dynamic)||this;return f.defineReadOnly(r,"coder",t),r}return i(t,e),t.prototype.encode=function(e){return this.coder.encode(e)},t.prototype.decode=function(e,t){return this.coder.decode(e,t)},t}(w),A=function(e){function t(t,r){return e.call(this,t,"null","",r,!1)||this}return i(t,e),t.prototype.encode=function(e){return u.arrayify([])},t.prototype.decode=function(e,t){if(t>e.length)throw new Error("invalid null");return{consumed:0,value:this.coerceFunc("null",void 0)}},t}(w),E=function(e){function t(t,r,n,i){var o=this,a=(n?"int":"uint")+8*r;return(o=e.call(this,t,a,a,i,!1)||this).size=r,o.signed=n,o}return i(t,e),t.prototype.encode=function(e){try{var t=s.bigNumberify(e);return t=t.toTwos(8*this.size).maskn(8*this.size),this.signed&&(t=t.fromTwos(8*this.size).toTwos(256)),u.padZeros(u.arrayify(t),32)}catch(t){h.throwError("invalid number value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:e})}return null},t.prototype.decode=function(e,t){e.length32)throw new Error;t.set(r)}catch(t){h.throwError("invalid "+this.name+" value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:t.value||e})}return t},t.prototype.decode=function(e,t){return e.length=0?n:"")+"]",s=-1===n||r.dynamic;return(o=e.call(this,t,"array",a,i,s)||this).coder=r,o.length=n,o}return i(t,e),t.prototype.encode=function(e){Array.isArray(e)||h.throwError("expected array value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:"array",value:e});var t=this.length,r=new Uint8Array(0);-1===t&&(t=e.length,r=x.encode(t)),h.checkArgumentCount(t,e.length,"in coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i256||i%8!=0)&&h.throwError("invalid "+r[1]+" bit length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new E(e,i/8,"int"===r[1],t.name);if(r=t.type.match(l))return(0===(i=parseInt(r[1]))||i>32)&&h.throwError("invalid bytes length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new S(e,i,t.name);if(r=t.type.match(p)){var i=parseInt(r[2]||"-1");return(t=f.jsonCopy(t)).type=r[1],new N(e,D(e,t),i,t.name)}return"tuple"===t.type.substring(0,5)?function(e,t,r){t||(t=[]);var n=[];return t.forEach(function(t){n.push(D(e,t))}),new R(e,n,r)}(e,t.components,t.name):""===t.type?new A(e,t.name):(h.throwError("invalid type",h.INVALID_ARGUMENT,{arg:"type",value:t.type}),null)}var F=function(){function e(t){h.checkNew(this,e),t||(t=r.defaultCoerceFunc),f.defineReadOnly(this,"coerceFunc",t)}return e.prototype.encode=function(e,t){e.length!==t.length&&h.throwError("types/values length mismatch",h.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):e,r.push(D(this.coerceFunc,t))},this),u.hexlify(new R(this.coerceFunc,r,"_").encode(t))},e.prototype.decode=function(e,t){var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):f.jsonCopy(e),r.push(D(this.coerceFunc,t))},this),new R(this.coerceFunc,r,"_").decode(u.arrayify(t),0).value},e}();r.AbiCoder=F,r.defaultAbiCoder=new F},{"./address":144,"./bignumber":145,"./bytes":146,"./errors":147,"./properties":149,"./utf8":152}],144:[function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var i=n(e("bn.js")),o=e("./bytes"),a=e("./keccak256"),s=e("./rlp"),u=e("./errors");function c(e){"string"==typeof e&&e.match(/^0x[0-9A-Fa-f]{40}$/)||u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=o.arrayify(a.keccak256(r));for(var i=0;i<40;i+=2)r[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(15&r[i>>1])>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}for(var f={},h=0;h<10;h++)f[String(h)]=String(h);for(h=0;h<26;h++)f[String.fromCharCode(65+h)]=String(10+h);var l,d=Math.floor((l=9007199254740991,Math.log10?Math.log10(l):Math.log(l)/Math.LN10));function p(e){e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00";var t="";for(e.split("").forEach(function(e){t+=f[e]});t.length>=d;){var r=t.substring(0,d);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function b(e){var t=null;if("string"!=typeof e&&u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e}),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=c(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&u.throwError("bad address checksum",u.INVALID_ARGUMENT,{arg:"address",value:e});else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==p(e)&&u.throwError("bad icap checksum",u.INVALID_ARGUMENT,{arg:"address",value:e}),t=new i.default.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=c("0x"+t)}else u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});return t}r.getAddress=b,r.getIcapAddress=function(e){for(var t=new i.default.BN(b(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+p("XE00"+t)+t},r.getContractAddress=function(e){if(!e.from)throw new Error("missing from address");var t=e.nonce;return b("0x"+a.keccak256(s.encode([b(e.from),o.stripZeros(o.hexlify(t))])).substring(26))}},{"./bytes":146,"./errors":147,"./keccak256":148,"./rlp":150,"bn.js":53}],145:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=o(e("bn.js")),u=e("./bytes"),c=e("./properties"),f=e("./types"),h=a(e("./errors")),l=new s.default.BN(-1);function d(e){var t=e.toString(16);return"-"===t[0]?t.length%2==0?"-0x0"+t.substring(1):"-0x"+t.substring(1):t.length%2==1?"0x0"+t:"0x"+t}function p(e){return m(e)._bn}function b(e){return new y(d(e))}var y=function(e){function t(r){var n=e.call(this)||this;if(h.checkNew(n,t),"string"==typeof r)u.isHexString(r)?("0x"==r&&(r="0x0"),c.defineReadOnly(n,"_hex",r)):"-"===r[0]&&u.isHexString(r.substring(1))?c.defineReadOnly(n,"_hex",r):r.match(/^-?[0-9]*$/)?(""==r&&(r="0"),c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))):h.throwError("invalid BigNumber string value",h.INVALID_ARGUMENT,{arg:"value",value:r});else if("number"==typeof r){parseInt(String(r))!==r&&h.throwError("underflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"underflow",value:r,outputValue:parseInt(String(r))});try{c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}}else r instanceof t?c.defineReadOnly(n,"_hex",r._hex):r.toHexString?c.defineReadOnly(n,"_hex",d(p(r.toHexString()))):u.isArrayish(r)?c.defineReadOnly(n,"_hex",d(new s.default.BN(u.hexlify(r).substring(2),16))):h.throwError("invalid BigNumber value",h.INVALID_ARGUMENT,{arg:"value",value:r});return n}return i(t,e),Object.defineProperty(t.prototype,"_bn",{get:function(){return"-"===this._hex[0]?new s.default.BN(this._hex.substring(3),16).mul(l):new s.default.BN(this._hex.substring(2),16)},enumerable:!0,configurable:!0}),t.prototype.fromTwos=function(e){return b(this._bn.fromTwos(e))},t.prototype.toTwos=function(e){return b(this._bn.toTwos(e))},t.prototype.add=function(e){return b(this._bn.add(p(e)))},t.prototype.sub=function(e){return b(this._bn.sub(p(e)))},t.prototype.div=function(e){return m(e).isZero()&&h.throwError("division by zero",h.NUMERIC_FAULT,{operation:"divide",fault:"division by zero"}),b(this._bn.div(p(e)))},t.prototype.mul=function(e){return b(this._bn.mul(p(e)))},t.prototype.mod=function(e){return b(this._bn.mod(p(e)))},t.prototype.pow=function(e){return b(this._bn.pow(p(e)))},t.prototype.maskn=function(e){return b(this._bn.maskn(e))},t.prototype.eq=function(e){return this._bn.eq(p(e))},t.prototype.lt=function(e){return this._bn.lt(p(e))},t.prototype.lte=function(e){return this._bn.lte(p(e))},t.prototype.gt=function(e){return this._bn.gt(p(e))},t.prototype.gte=function(e){return this._bn.gte(p(e))},t.prototype.isZero=function(){return this._bn.isZero()},t.prototype.toNumber=function(){try{return this._bn.toNumber()}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}return null},t.prototype.toString=function(){return this._bn.toString(10)},t.prototype.toHexString=function(){return this._hex},t}(f.BigNumber);function m(e){return e instanceof y?e:new y(e)}r.bigNumberify=m,r.ConstantNegativeOne=m(-1),r.ConstantZero=m(0),r.ConstantOne=m(1),r.ConstantTwo=m(2),r.ConstantWeiPerEther=m("1000000000000000000")},{"./bytes":146,"./errors":147,"./properties":149,"./types":151,"bn.js":53}],146:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./errors");function i(e){return!!e._bn}function o(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return new Uint8Array(Array.prototype.slice.apply(e,t))},e)}function a(e){if(!e||parseInt(String(e.length))!=e.length||"string"==typeof e)return!1;for(var t=0;t=256||parseInt(String(r))!=r)return!1}return!0}function s(e){if(null==e&&n.throwError("cannot convert null value to array",n.INVALID_ARGUMENT,{arg:"value",value:e}),i(e)&&(e=e.toHexString()),"string"==typeof e){var t=e.match(/^(0x)?[0-9a-fA-F]*$/);t||n.throwError("invalid hexadecimal string",n.INVALID_ARGUMENT,{arg:"value",value:e}),"0x"!==t[1]&&n.throwError("hex string must have 0x prefix",n.INVALID_ARGUMENT,{arg:"value",value:e}),(e=e.substring(2)).length%2&&(e="0"+e);for(var r=[],s=0;s>4]+f[15&u])}return"0x"+o.join("")}return n.throwError("invalid hexlify value",null,{arg:"value",value:e}),"never"}function l(e,t){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length<2*t+2;)e="0x0"+e.substring(2);return e}function d(e){var t,r=0,i="0x",o="0x";if((t=e)&&null!=t.r&&null!=t.s){null==e.v&&null==e.recoveryParam&&n.throwError("at least on of recoveryParam or v must be specified",n.INVALID_ARGUMENT,{argument:"signature",value:e}),i=l(e.r,32),o=l(e.s,32),"string"==typeof(r=e.v)&&(r=parseInt(r,16));var a=e.recoveryParam;null==a&&null!=e.v&&(a=1-r%2),r=27+a}else{var u=s(e);if(65!==u.length)throw new Error("invalid signature");i=h(u.slice(0,32)),o=h(u.slice(32,64)),27!==(r=u[64])&&28!==r&&(r=27+r%2)}return{r:i,s:o,recoveryParam:r-27,v:r}}r.hexlify=h,r.hexDataLength=function(e){return c(e)&&e.length%2==0?(e.length-2)/2:null},r.hexDataSlice=function(e,t,r){return c(e)||n.throwError("invalid hex data",n.INVALID_ARGUMENT,{arg:"value",value:e}),e.length%2!=0&&n.throwError("hex data length must be even",n.INVALID_ARGUMENT,{arg:"value",value:e}),t=2+2*t,null!=r?"0x"+e.substring(t,t+2*r):"0x"+e.substring(t)},r.hexStripZeros=function(e){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length>3&&"0x0"===e.substring(0,3);)e="0x"+e.substring(3);return e},r.hexZeroPad=l,r.splitSignature=d,r.joinSignature=function(e){return h(u([(e=d(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}},{"./errors":147}],147:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.MISSING_NEW="MISSING_NEW",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.NUMERIC_FAULT="NUMERIC_FAULT",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION";var n=!1,i=!1;function o(e,t,n){if(i)throw new Error("unknown error");t||(t=r.UNKNOWN_ERROR),n||(n={});var o=[];Object.keys(n).forEach(function(e){try{o.push(e+"="+JSON.stringify(n[e]))}catch(t){o.push(e+"="+JSON.stringify(n[e].toString()))}});var a=e;o.length&&(e+=" ("+o.join(", ")+")");var s=new Error(e);throw s.reason=a,s.code=t,Object.keys(n).forEach(function(e){s[e]=n[e]}),s}r.throwError=o,r.checkNew=function(e,t){e instanceof t||o("missing new",r.MISSING_NEW,{name:t.name})},r.checkArgumentCount=function(e,t,n){n||(n=""),et&&o("too many arguments"+n,r.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})},r.setCensorship=function(e,t){n&&o("error censorship permanent",r.UNSUPPORTED_OPERATION,{operation:"setCersorship"}),i=!!e,n=!!t}},{}],148:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("js-sha3"),i=e("./bytes");r.keccak256=function(e){return"0x"+n.keccak_256(i.arrayify(e))}},{"./bytes":146,"js-sha3":142}],149:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defineReadOnly=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})},r.defineFrozen=function(e,t,r){var n=JSON.stringify(r);Object.defineProperty(e,t,{enumerable:!0,get:function(){return JSON.parse(n)}})},r.resolveProperties=function(e){var t={},r=[];return Object.keys(e).forEach(function(n){var i=e[n];i instanceof Promise?r.push(i.then(function(e){return t[n]=e,null})):t[n]=i}),Promise.all(r).then(function(){return t})},r.shallowCopy=function(e){var t={};for(var r in e)t[r]=e[r];return t},r.jsonCopy=function(e){return JSON.parse(JSON.stringify(e))}},{}],150:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./bytes");function i(e){for(var t=[];e;)t.unshift(255&e),e>>=8;return t}function o(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function s(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(r=e[t]-247)>e.length)throw new Error("too short");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("to short");return a(e,t,t+1+r,r+i)}if(e[t]>=192){if(t+1+(i=e[t]-192)>e.length)throw new Error("invalid rlp data");return a(e,t,t+1,i)}if(e[t]>=184){var r;if(t+1+(r=e[t]-183)>e.length)throw new Error("invalid rlp data");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("invalid rlp data");return{consumed:1+r+i,result:n.hexlify(e.slice(t+1+r,t+1+r+i))}}if(e[t]>=128){var i;if(t+1+(i=e[t]-128)>e.length)throw new Error("invalid rlp data");return{consumed:1+i,result:n.hexlify(e.slice(t+1,t+1+i))}}return{consumed:1,result:n.hexlify(e[t])}}r.encode=function(e){return n.hexlify(function e(t){if(Array.isArray(t)){var r=[];return t.forEach(function(t){r=r.concat(e(t))}),r.length<=55?(r.unshift(192+r.length),r):((o=i(r.length)).unshift(247+o.length),o.concat(r))}var o,a=Array.prototype.slice.call(n.arrayify(t));return 1===a.length&&a[0]<=127?a:a.length<=55?(a.unshift(128+a.length),a):((o=i(a.length)).unshift(183+o.length),o.concat(a))}(e))},r.decode=function(e){var t=n.arrayify(e),r=s(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}},{"./bytes":146}],151:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=function(){return function(){}}();r.BigNumber=n;var i=function(){return function(){}}();r.Indexed=i;var o=function(){return function(){}}();r.MinimalProvider=o;var a=function(){return function(){}}();r.Signer=a;var s=function(){return function(){}}();r.HDNode=s},{}],152:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,i=e("./bytes");!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(n=r.UnicodeNormalizationForm||(r.UnicodeNormalizationForm={})),r.toUtf8Bytes=function(e,t){void 0===t&&(t=n.current),t!=n.current&&(e=e.normalize(t));for(var r=[],o=0,a=0;a>6|192,r[o++]=63&s|128):55296==(64512&s)&&a+1>18|240,r[o++]=s>>12&63|128,r[o++]=s>>6&63|128,r[o++]=63&s|128):(r[o++]=s>>12|224,r[o++]=s>>6&63|128,r[o++]=63&s|128)}return i.arrayify(r)},r.toUtf8String=function(e){e=i.arrayify(e);for(var t="",r=0;r>7!=0){if(n>>6!=2){var o=null;if(n>>5==6)o=1;else if(n>>4==14)o=2;else if(n>>3==30)o=3;else if(n>>2==62)o=4;else{if(n>>1!=126)continue;o=5}if(r+o>e.length){for(;r>6==2;r++);if(r!=e.length)continue;return t}var a,s=n&(1<<8-o-1)-1;for(a=0;a>6!=2)break;s=s<<6|63&u}a==o?s<=65535?t+=String.fromCharCode(s):(s-=65536,t+=String.fromCharCode(55296+(s>>10&1023),56320+(1023&s))):r--}}else t+=String.fromCharCode(n)}return t}},{"./bytes":146}],153:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("number-to-bn"),o=new n(0),a=new n(-1),s={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",Gwei:"1000000000",shannon:"1000000000",nanoether:"1000000000",nano:"1000000000",szabo:"1000000000000",microether:"1000000000000",micro:"1000000000000",finney:"1000000000000000",milliether:"1000000000000000",milli:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"};function u(e){var t=e?e.toLowerCase():"ether",r=s[t];if("string"!=typeof r)throw new Error("[ethjs-unit] the unit provided "+e+" doesn't exists, please use the one of the following units "+JSON.stringify(s,null,2));return new n(r,10)}function c(e){if("string"==typeof e){if(!e.match(/^-?[0-9.]+$/))throw new Error("while converting number to string, invalid number value '"+e+"', should be a number matching (^-?[0-9.]+).");return e}if("number"==typeof e)return String(e);if("object"==typeof e&&e.toString&&(e.toTwos||e.dividedToIntegerBy))return e.toPrecision?String(e.toPrecision()):e.toString(10);throw new Error("while converting number to string, invalid number value '"+e+"' type "+typeof e+".")}t.exports={unitMap:s,numberToString:c,getValueOfUnit:u,fromWei:function(e,t,r){var n=i(e),c=n.lt(o),f=u(t),h=s[t].length-1||1,l=r||{};c&&(n=n.mul(a));for(var d=n.mod(f).toString(10);d.length2)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal points");var l=h[0],d=h[1];if(l||(l="0"),d||(d="0"),d.length>o)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal places");for(;d.length=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{}],155:[function(e,t,r){(function(r){"use strict";var n=e("is-hex-prefixed"),i=e("strip-hex-prefix");function o(e){var t=e;if("string"!=typeof t)throw new Error("[ethjs-util] while padding to even, value must be string, is currently "+typeof t+", while padToEven.");return t.length%2&&(t="0"+t),t}function a(e){return"0x"+e.toString(16)}t.exports={arrayContainsArray:function(e,t,r){if(!0!==Array.isArray(e))throw new Error("[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '"+typeof e+"'");if(!0!==Array.isArray(t))throw new Error("[ethjs-util] method arrayContainsArray requires input 'subset' to be an array got type '"+typeof t+"'");return t[Boolean(r)?"some":"every"](function(t){return e.indexOf(t)>=0})},intToBuffer:function(e){var t=a(e);return new r(o(t.slice(2)),"hex")},getBinarySize:function(e){if("string"!=typeof e)throw new Error("[ethjs-util] while getting binary size, method getBinarySize requires input 'str' to be type String, got '"+typeof e+"'.");return r.byteLength(e,"utf8")},isHexPrefixed:n,stripHexPrefix:i,padToEven:o,intToHex:a,fromAscii:function(e){for(var t="",r=0;r0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var r,n,a,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(r=this._events[e]).length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=a;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){n=s;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],158:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("md5.js");t.exports=function(e,t,r,o){if(n.isBuffer(e)||(e=n.from(e,"binary")),t&&(n.isBuffer(t)||(t=n.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var a=r/8,s=n.alloc(a),u=n.alloc(o||0),c=n.alloc(0);a>0||o>0;){var f=new i;f.update(c),f.update(e),t&&f.update(t),c=f.digest();var h=0;if(a>0){var l=s.length-a;h=Math.min(a,c.length),c.copy(s,l,0,h),a-=h}if(h0){var d=u.length-o,p=Math.min(o,c.length-h);c.copy(u,d,h,h+p),o-=p}}return c.fill(0),{key:s,iv:u}}},{"md5.js":231,"safe-buffer":290}],159:[function(e,t,r){"use strict";var n=e("is-callable"),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.exports=function(e,t,r){if(!n(t))throw new TypeError("iterator must be a function");var a;arguments.length>=3&&(a=r),"[object Array]"===i.call(e)?function(e,t,r){for(var n=0,i=e.length;n=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},i.prototype._update=function(e){throw new Error("_update is not implemented")},i.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();return void 0!==e&&(t=t.toString(e)),t},i.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=i}).call(this,e("buffer").Buffer)},{buffer:84,inherits:180,stream:311}],162:[function(e,t,r){var n=r;n.utils=e("./hash/utils"),n.common=e("./hash/common"),n.sha=e("./hash/sha"),n.ripemd=e("./hash/ripemd"),n.hmac=e("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":163,"./hash/hmac":164,"./hash/ripemd":165,"./hash/sha":166,"./hash/utils":173}],163:[function(e,t,r){"use strict";var n=e("./utils"),i=e("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},{"../utils":173}],173:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits");function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function s(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=i,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,a=255&i;o?r.push(o,a):r.push(a)}else for(n=0;n>>0}return a},r.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},r.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},r.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},r.sum64_lo=function(e,t,r,n){return t+n>>>0},r.sum64_4_hi=function(e,t,r,n,i,o,a,s){var u=0,c=t;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},r.sum64_5_hi=function(e,t,r,n,i,o,a,s,u,c){var f=0,h=t;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,n,i,o,a,s,u,c){return t+n+o+s+c>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:180,"minimalistic-assert":234}],174:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("minimalistic-crypto-utils"),o=e("minimalistic-assert");function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}t.exports=a,a.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},a.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length\\$%@ءؤة\"'^|~⦅⦆・ゥャ¢£¬¦¥₩│←↑→↓■○𐐨𐐩𐐪𐐫𐐬𐐭𐐮𐐯𐐰𐐱𐐲𐐳𐐴𐐵𐐶𐐷𐐸𐐹𐐺𐐻𐐼𐐽𐐾𐐿𐑀𐑁𐑂𐑃𐑄𐑅𐑆𐑇𐑈𐑉𐑊𐑋𐑌𐑍𐑎𐑏𐓘𐓙𐓚𐓛𐓜𐓝𐓞𐓟𐓠𐓡𐓢𐓣𐓤𐓥𐓦𐓧𐓨𐓩𐓪𐓫𐓬𐓭𐓮𐓯𐓰𐓱𐓲𐓳𐓴𐓵𐓶𐓷𐓸𐓹𐓺𐓻𐳀𐳁𐳂𐳃𐳄𐳅𐳆𐳇𐳈𐳉𐳊𐳋𐳌𐳍𐳎𐳏𐳐𐳑𐳒𐳓𐳔𐳕𐳖𐳗𐳘𐳙𐳚𐳛𐳜𐳝𐳞𐳟𐳠𐳡𐳢𐳣𐳤𐳥𐳦𐳧𐳨𐳩𐳪𐳫𐳬𐳭𐳮𐳯𐳰𐳱𐳲𑣀𑣁𑣂𑣃𑣄𑣅𑣆𑣇𑣈𑣉𑣊𑣋𑣌𑣍𑣎𑣏𑣐𑣑𑣒𑣓𑣔𑣕𑣖𑣗𑣘𑣙𑣚𑣛𑣜𑣝𑣞𑣟ıȷ∇∂𞤢𞤣𞤤𞤥𞤦𞤧𞤨𞤩𞤪𞤫𞤬𞤭𞤮𞤯𞤰𞤱𞤲𞤳𞤴𞤵𞤶𞤷𞤸𞤹𞤺𞤻𞤼𞤽𞤾𞤿𞥀𞥁𞥂𞥃ٮڡٯ字双多解交映無前後再新初終販声吹演投捕遊指禁空合満申割営配得可丽丸乁𠄢你侻倂偺備像㒞𠘺兔兤具𠔜㒹內𠕋冗冤仌冬𩇟刃㓟刻剆剷㔕包匆卉博即卽卿𠨬灰及叟𠭣叫叱吆咞吸呈周咢哶唐啓啣善喫喳嗂圖圗噑噴壮城埴堍型堲報墬𡓤売壷夆夢奢𡚨𡛪姬娛娧姘婦㛮嬈嬾𡧈寃寘寳𡬘寿将㞁屠峀岍𡷤嵃𡷦嵮嵫嵼巡巢㠯巽帨帽幩㡢𢆃㡼庰庳庶𪎒𢌱舁弢㣇𣊸𦇚形彫㣣徚忍志忹悁㤺㤜𢛔惇慈慌慺憲憤憯懞戛扝抱拔捐𢬌挽拼捨掃揤𢯱搢揅掩㨮摩摾撝摷㩬敬𣀊旣書晉㬙㬈㫤冒冕最暜肭䏙朡杞杓𣏃㭉柺枅桒𣑭梎栟椔楂榣槪檨𣚣櫛㰘次𣢧歔㱎歲殟殻𣪍𡴋𣫺汎𣲼沿泍汧洖派浩浸涅𣴞洴港湮㴳滇𣻑淹潮𣽞𣾎濆瀹瀛㶖灊災灷炭𠔥煅𤉣熜爨牐𤘈犀犕𤜵𤠔獺王㺬玥㺸瑇瑜璅瓊㼛甤𤰶甾𤲒𢆟瘐𤾡𤾸𥁄㿼䀈𥃳𥃲𥄙𥄳眞真瞋䁆䂖𥐝硎䃣𥘦𥚚𥛅秫䄯穊穏𥥼𥪧䈂𥮫篆築䈧𥲀糒䊠糨糣紀𥾆絣䌁緇縂繅䌴𦈨𦉇䍙𦋙罺𦌾羕翺𦓚𦔣聠𦖨聰𣍟䏕育脃䐋脾媵𦞧𦞵𣎓𣎜舄辞䑫芑芋芝劳花芳芽苦𦬼茝荣莭茣莽菧荓菊菌菜𦰶𦵫𦳕䔫蓱蓳蔖𧏊蕤𦼬䕝䕡𦾱𧃒䕫虐虧虩蚩蚈蜎蛢蜨蝫螆蟡蠁䗹衠𧙧裗裞䘵裺㒻𧢮𧥦䚾䛇誠𧲨貫賁贛起𧼯𠠄跋趼跰𠣞軔𨗒𨗭邔郱鄑𨜮鄛鈸鋗鋘鉼鏹鐕𨯺開䦕閷𨵷䧦雃嶲霣𩅅𩈚䩮䩶韠𩐊䪲𩒖頩𩖶飢䬳餩馧駂駾䯎𩬰鱀鳽䳎䳭鵧𪃎䳸𪄅𪈎𪊑䵖黾鼅鼏鼖𪘀",mapChar:function(r){return r>=196608?r>=917760&&r<=917999?18874368:0:e[t[r>>4]][15&r]}}},"function"==typeof define&&define.amd?define([],function(){return i()}):"object"==typeof r?t.exports=i():n.uts46_map=i()},{}],177:[function(e,t,r){var n,i;n=this,i=function(e,t){function r(r,n,i){for(var o=[],a=e.ucs2.decode(r),s=0;s>23,l=f>>21&3,d=f>>5&65535,p=31&f,b=t.mapStr.substr(d,p);if(0===l||n&&1&h)throw new Error("Illegal char "+c);1===l?o.push(b):2===l?o.push(i?b:c):3===l&&o.push(c)}return o.join("").normalize("NFC")}function n(t,n,o){void 0===o&&(o=!1);var a=r(t,o,n).split(".");return(a=a.map(function(t){return t.startsWith("xn--")?i(t=e.decode(t.substring(4)),o,!1):i(t,o,n),t})).join(".")}function i(e,n,i){if("-"===e[2]&&"-"===e[3])throw new Error("Failed to validate "+e);if(e.startsWith("-")||e.endsWith("-"))throw new Error("Failed to validate "+e);if(e.includes("."))throw new Error("Failed to validate "+e);if(r(e,n,i)!==e)throw new Error("Failed to validate "+e);var o=e.codePointAt(0);if(t.mapChar(o)&2<<23)throw new Error("Label contains illegal character: "+o)}return{toUnicode:function(e,t){return void 0===t&&(t={}),n(e,!1,"useStd3ASCII"in t&&t.useStd3ASCII)},toAscii:function(t,r){void 0===r&&(r={});var i,o=!("transitional"in r)||r.transitional,a="useStd3ASCII"in r&&r.useStd3ASCII,s="verifyDnsLength"in r&&r.verifyDnsLength,u=n(t,o,a).split(".").map(e.toASCII),c=u.join(".");if(s){if(c.length<1||c.length>253)throw new Error("DNS name has wrong length: "+c);for(i=0;i63)throw new Error("DNS label has wrong length: "+f)}}return c}}},"function"==typeof define&&define.amd?define(["punycode","./idna-map"],function(e,t){return i(e,t)}):"object"==typeof r?t.exports=i(e("punycode"),e("./idna-map")):n.uts46=i(n.punycode,n.idna_map)},{"./idna-map":176,punycode:265}],178:[function(e,t,r){r.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,f=-7,h=r?i-1:0,l=r?-1:1,d=e[t+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=s;f>0;o=256*o+e[t+h],h+=l,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+e[t+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=c}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var a,s,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(a++,u/=2),a+h>=f?(s=0,a=f):a+h>=1?(s=(t*u-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;e[r+d]=255&a,d+=p,a/=256,c-=8);e[r+d-p]|=128*b}},{}],179:[function(e,t,r){var n=[].indexOf;t.exports=function(e,t){if(n)return e.indexOf(t);for(var r=0;r-32e3)throw new Error("Invalid error code");if(!(this instanceof f))return new f(e);i.call(this,"Server error",e)};n(f,i),i.ParseError=o,i.InvalidRequest=a,i.MethodNotFound=s,i.InvalidParams=u,i.InternalError=c,i.ServerError=f,t.exports=i},{inherits:180}],191:[function(e,t,r){t.exports=function(e){var t=(e=e||{}).max||Number.MAX_SAFE_INTEGER,r=void 0!==e.start?e.start:Math.floor(Math.random()*t);return function(){return r%=t,r++}}},{}],192:[function(e,t,r){r.parse=e("./lib/parse"),r.stringify=e("./lib/stringify")},{"./lib/parse":193,"./lib/stringify":194}],193:[function(e,t,r){var n,i,o,a,s={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},u=function(e){throw{name:"SyntaxError",message:e,at:n,text:o}},c=function(e){return e&&e!==i&&u("Expected '"+e+"' instead of '"+i+"'"),i=o.charAt(n),n+=1,i},f=function(){var e,t="";for("-"===i&&(t="-",c("-"));i>="0"&&i<="9";)t+=i,c();if("."===i)for(t+=".";c()&&i>="0"&&i<="9";)t+=i;if("e"===i||"E"===i)for(t+=i,c(),"-"!==i&&"+"!==i||(t+=i,c());i>="0"&&i<="9";)t+=i,c();if(e=+t,isFinite(e))return e;u("Bad number")},h=function(){var e,t,r,n="";if('"'===i)for(;c();){if('"'===i)return c(),n;if("\\"===i)if(c(),"u"===i){for(r=0,t=0;t<4&&(e=parseInt(c(),16),isFinite(e));t+=1)r=16*r+e;n+=String.fromCharCode(r)}else{if("string"!=typeof s[i])break;n+=s[i]}else n+=i}u("Bad string")},l=function(){for(;i&&i<=" ";)c()};a=function(){switch(l(),i){case"{":return function(){var e,t={};if("{"===i){if(c("{"),l(),"}"===i)return c("}"),t;for(;i;){if(e=h(),l(),c(":"),Object.hasOwnProperty.call(t,e)&&u('Duplicate key "'+e+'"'),t[e]=a(),l(),"}"===i)return c("}"),t;c(","),l()}}u("Bad object")}();case"[":return function(){var e=[];if("["===i){if(c("["),l(),"]"===i)return c("]"),e;for(;i;){if(e.push(a()),l(),"]"===i)return c("]"),e;c(","),l()}}u("Bad array")}();case'"':return h();case"-":return f();default:return i>="0"&&i<="9"?f():function(){switch(i){case"t":return c("t"),c("r"),c("u"),c("e"),!0;case"f":return c("f"),c("a"),c("l"),c("s"),c("e"),!1;case"n":return c("n"),c("u"),c("l"),c("l"),null}u("Unexpected '"+i+"'")}()}},t.exports=function(e,t){var r;return o=e,n=0,i=" ",r=a(),l(),i&&u("Syntax error"),"function"==typeof t?function e(r,n){var i,o,a=r[n];if(a&&"object"==typeof a)for(i in a)Object.prototype.hasOwnProperty.call(a,i)&&(void 0!==(o=e(a,i))?a[i]=o:delete a[i]);return t.call(r,n,a)}({"":r},""):r}},{}],194:[function(e,t,r){var n,i,o,a=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,s={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function u(e){return a.lastIndex=0,a.test(e)?'"'+e.replace(a,function(e){var t=s[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}t.exports=function(e,t,r){var a;if(n="",i="","number"==typeof r)for(a=0;a>>31),p=l^(a<<1|o>>>31),b=e[0]^d,y=e[1]^p,m=e[10]^d,v=e[11]^p,g=e[20]^d,w=e[21]^p,_=e[30]^d,A=e[31]^p,E=e[40]^d,x=e[41]^p;d=r^(s<<1|u>>>31),p=i^(u<<1|s>>>31);var k=e[2]^d,S=e[3]^p,M=e[12]^d,I=e[13]^p,T=e[22]^d,U=e[23]^p,j=e[32]^d,B=e[33]^p,P=e[42]^d,C=e[43]^p;d=o^(c<<1|f>>>31),p=a^(f<<1|c>>>31);var N=e[4]^d,R=e[5]^p,L=e[14]^d,O=e[15]^p,D=e[24]^d,F=e[25]^p,q=e[34]^d,H=e[35]^p,z=e[44]^d,K=e[45]^p;d=s^(h<<1|l>>>31),p=u^(l<<1|h>>>31);var V=e[6]^d,G=e[7]^p,W=e[16]^d,Y=e[17]^p,X=e[26]^d,Z=e[27]^p,J=e[36]^d,$=e[37]^p,Q=e[46]^d,ee=e[47]^p;d=c^(r<<1|i>>>31),p=f^(i<<1|r>>>31);var te=e[8]^d,re=e[9]^p,ne=e[18]^d,ie=e[19]^p,oe=e[28]^d,ae=e[29]^p,se=e[38]^d,ue=e[39]^p,ce=e[48]^d,fe=e[49]^p,he=b,le=y,de=v<<4|m>>>28,pe=m<<4|v>>>28,be=g<<3|w>>>29,ye=w<<3|g>>>29,me=A<<9|_>>>23,ve=_<<9|A>>>23,ge=E<<18|x>>>14,we=x<<18|E>>>14,_e=k<<1|S>>>31,Ae=S<<1|k>>>31,Ee=I<<12|M>>>20,xe=M<<12|I>>>20,ke=T<<10|U>>>22,Se=U<<10|T>>>22,Me=B<<13|j>>>19,Ie=j<<13|B>>>19,Te=P<<2|C>>>30,Ue=C<<2|P>>>30,je=R<<30|N>>>2,Be=N<<30|R>>>2,Pe=L<<6|O>>>26,Ce=O<<6|L>>>26,Ne=F<<11|D>>>21,Re=D<<11|F>>>21,Le=q<<15|H>>>17,Oe=H<<15|q>>>17,De=K<<29|z>>>3,Fe=z<<29|K>>>3,qe=V<<28|G>>>4,He=G<<28|V>>>4,ze=Y<<23|W>>>9,Ke=W<<23|Y>>>9,Ve=X<<25|Z>>>7,Ge=Z<<25|X>>>7,We=J<<21|$>>>11,Ye=$<<21|J>>>11,Xe=ee<<24|Q>>>8,Ze=Q<<24|ee>>>8,Je=te<<27|re>>>5,$e=re<<27|te>>>5,Qe=ne<<20|ie>>>12,et=ie<<20|ne>>>12,tt=ae<<7|oe>>>25,rt=oe<<7|ae>>>25,nt=se<<8|ue>>>24,it=ue<<8|se>>>24,ot=ce<<14|fe>>>18,at=fe<<14|ce>>>18;e[0]=he^~Ee&Ne,e[1]=le^~xe&Re,e[10]=qe^~Qe&be,e[11]=He^~et&ye,e[20]=_e^~Pe&Ve,e[21]=Ae^~Ce&Ge,e[30]=Je^~de&ke,e[31]=$e^~pe&Se,e[40]=je^~ze&tt,e[41]=Be^~Ke&rt,e[2]=Ee^~Ne&We,e[3]=xe^~Re&Ye,e[12]=Qe^~be&Me,e[13]=et^~ye&Ie,e[22]=Pe^~Ve&nt,e[23]=Ce^~Ge&it,e[32]=de^~ke&Le,e[33]=pe^~Se&Oe,e[42]=ze^~tt&me,e[43]=Ke^~rt&ve,e[4]=Ne^~We&ot,e[5]=Re^~Ye&at,e[14]=be^~Me&De,e[15]=ye^~Ie&Fe,e[24]=Ve^~nt&ge,e[25]=Ge^~it&we,e[34]=ke^~Le&Xe,e[35]=Se^~Oe&Ze,e[44]=tt^~me&Te,e[45]=rt^~ve&Ue,e[6]=We^~ot&he,e[7]=Ye^~at&le,e[16]=Me^~De&qe,e[17]=Ie^~Fe&He,e[26]=nt^~ge&_e,e[27]=it^~we&Ae,e[36]=Le^~Xe&Je,e[37]=Oe^~Ze&$e,e[46]=me^~Te&je,e[47]=ve^~Ue&Be,e[8]=ot^~he&Ee,e[9]=at^~le&xe,e[18]=De^~qe&Qe,e[19]=Fe^~He&et,e[28]=ge^~_e&Pe,e[29]=we^~Ae&Ce,e[38]=Xe^~Je&de,e[39]=Ze^~$e&pe,e[48]=Te^~je&ze,e[49]=Ue^~Be&Ke,e[0]^=n[2*t],e[1]^=n[2*t+1]}}},{}],200:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("./keccak-state-unroll");function o(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}o.prototype.initialize=function(e,t){for(var r=0;r<50;++r)this.state[r]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},o.prototype.absorb=function(e){for(var t=0;t>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(i.p1600(this.state),this.count=0);return t},o.prototype.copy=function(e){for(var t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},t.exports=o},{"./keccak-state-unroll":199,"safe-buffer":290}],201:[function(e,t,r){var n=e("./_root").Symbol;t.exports=n},{"./_root":217}],202:[function(e,t,r){var n=e("./_baseTimes"),i=e("./isArguments"),o=e("./isArray"),a=e("./isBuffer"),s=e("./_isIndex"),u=e("./isTypedArray"),c=Object.prototype.hasOwnProperty;t.exports=function(e,t){var r=o(e),f=!r&&i(e),h=!r&&!f&&a(e),l=!r&&!f&&!h&&u(e),d=r||f||h||l,p=d?n(e.length,String):[],b=p.length;for(var y in e)!t&&!c.call(e,y)||d&&("length"==y||h&&("offset"==y||"parent"==y)||l&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||s(y,b))||p.push(y);return p}},{"./_baseTimes":207,"./_isIndex":211,"./isArguments":219,"./isArray":220,"./isBuffer":222,"./isTypedArray":227}],203:[function(e,t,r){var n=e("./_Symbol"),i=e("./_getRawTag"),o=e("./_objectToString"),a="[object Null]",s="[object Undefined]",u=n?n.toStringTag:void 0;t.exports=function(e){return null==e?void 0===e?s:a:u&&u in Object(e)?i(e):o(e)}},{"./_Symbol":201,"./_getRawTag":210,"./_objectToString":215}],204:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isObjectLike"),o="[object Arguments]";t.exports=function(e){return i(e)&&n(e)==o}},{"./_baseGetTag":203,"./isObjectLike":226}],205:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isLength"),o=e("./isObjectLike"),a={};a["[object Float32Array]"]=a["[object Float64Array]"]=a["[object Int8Array]"]=a["[object Int16Array]"]=a["[object Int32Array]"]=a["[object Uint8Array]"]=a["[object Uint8ClampedArray]"]=a["[object Uint16Array]"]=a["[object Uint32Array]"]=!0,a["[object Arguments]"]=a["[object Array]"]=a["[object ArrayBuffer]"]=a["[object Boolean]"]=a["[object DataView]"]=a["[object Date]"]=a["[object Error]"]=a["[object Function]"]=a["[object Map]"]=a["[object Number]"]=a["[object Object]"]=a["[object RegExp]"]=a["[object Set]"]=a["[object String]"]=a["[object WeakMap]"]=!1,t.exports=function(e){return o(e)&&i(e.length)&&!!a[n(e)]}},{"./_baseGetTag":203,"./isLength":224,"./isObjectLike":226}],206:[function(e,t,r){var n=e("./_isPrototype"),i=e("./_nativeKeys"),o=Object.prototype.hasOwnProperty;t.exports=function(e){if(!n(e))return i(e);var t=[];for(var r in Object(e))o.call(e,r)&&"constructor"!=r&&t.push(r);return t}},{"./_isPrototype":212,"./_nativeKeys":213}],207:[function(e,t,r){t.exports=function(e,t){for(var r=-1,n=Array(e);++r-1&&e%1==0&&e-1&&e%1==0&&e<=n}},{}],225:[function(e,t,r){t.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},{}],226:[function(e,t,r){t.exports=function(e){return null!=e&&"object"==typeof e}},{}],227:[function(e,t,r){var n=e("./_baseIsTypedArray"),i=e("./_baseUnary"),o=e("./_nodeUtil"),a=o&&o.isTypedArray,s=a?i(a):n;t.exports=s},{"./_baseIsTypedArray":205,"./_baseUnary":208,"./_nodeUtil":214}],228:[function(e,t,r){var n=e("./_arrayLikeKeys"),i=e("./_baseKeys"),o=e("./isArrayLike");t.exports=function(e){return o(e)?n(e):i(e)}},{"./_arrayLikeKeys":202,"./_baseKeys":206,"./isArrayLike":221}],229:[function(e,t,r){t.exports=function(){}},{}],230:[function(e,t,r){t.exports=function(){return!1}},{}],231:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base"),o=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function s(e,t){return e<>>32-t}function u(e,t,r,n,i,o,a){return s(e+(t&r|~t&n)+i+o|0,a)+t|0}function c(e,t,r,n,i,o,a){return s(e+(t&n|r&~n)+i+o|0,a)+t|0}function f(e,t,r,n,i,o,a){return s(e+(t^r^n)+i+o|0,a)+t|0}function h(e,t,r,n,i,o,a){return s(e+(r^(t|~n))+i+o|0,a)+t|0}n(a,i),a.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,a=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,a=u(a,r=u(r,n,i,a,e[0],3614090360,7),n,i,e[1],3905402710,12),r,n,e[2],606105819,17),a,r,e[3],3250441966,22),i=u(i,a=u(a,r=u(r,n,i,a,e[4],4118548399,7),n,i,e[5],1200080426,12),r,n,e[6],2821735955,17),a,r,e[7],4249261313,22),i=u(i,a=u(a,r=u(r,n,i,a,e[8],1770035416,7),n,i,e[9],2336552879,12),r,n,e[10],4294925233,17),a,r,e[11],2304563134,22),i=u(i,a=u(a,r=u(r,n,i,a,e[12],1804603682,7),n,i,e[13],4254626195,12),r,n,e[14],2792965006,17),a,r,e[15],1236535329,22),i=c(i,a=c(a,r=c(r,n,i,a,e[1],4129170786,5),n,i,e[6],3225465664,9),r,n,e[11],643717713,14),a,r,e[0],3921069994,20),i=c(i,a=c(a,r=c(r,n,i,a,e[5],3593408605,5),n,i,e[10],38016083,9),r,n,e[15],3634488961,14),a,r,e[4],3889429448,20),i=c(i,a=c(a,r=c(r,n,i,a,e[9],568446438,5),n,i,e[14],3275163606,9),r,n,e[3],4107603335,14),a,r,e[8],1163531501,20),i=c(i,a=c(a,r=c(r,n,i,a,e[13],2850285829,5),n,i,e[2],4243563512,9),r,n,e[7],1735328473,14),a,r,e[12],2368359562,20),i=f(i,a=f(a,r=f(r,n,i,a,e[5],4294588738,4),n,i,e[8],2272392833,11),r,n,e[11],1839030562,16),a,r,e[14],4259657740,23),i=f(i,a=f(a,r=f(r,n,i,a,e[1],2763975236,4),n,i,e[4],1272893353,11),r,n,e[7],4139469664,16),a,r,e[10],3200236656,23),i=f(i,a=f(a,r=f(r,n,i,a,e[13],681279174,4),n,i,e[0],3936430074,11),r,n,e[3],3572445317,16),a,r,e[6],76029189,23),i=f(i,a=f(a,r=f(r,n,i,a,e[9],3654602809,4),n,i,e[12],3873151461,11),r,n,e[15],530742520,16),a,r,e[2],3299628645,23),i=h(i,a=h(a,r=h(r,n,i,a,e[0],4096336452,6),n,i,e[7],1126891415,10),r,n,e[14],2878612391,15),a,r,e[5],4237533241,21),i=h(i,a=h(a,r=h(r,n,i,a,e[12],1700485571,6),n,i,e[3],2399980690,10),r,n,e[10],4293915773,15),a,r,e[1],2240044497,21),i=h(i,a=h(a,r=h(r,n,i,a,e[8],1873313359,6),n,i,e[15],4264355552,10),r,n,e[6],2734768916,15),a,r,e[13],1309151649,21),i=h(i,a=h(a,r=h(r,n,i,a,e[4],4149444226,6),n,i,e[11],3174756917,10),r,n,e[2],718787259,15),a,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+a|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=a}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":232,inherits:180}],232:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("stream").Transform;function o(e){i.call(this),this._block=n.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}e("inherits")(o,i),o.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},o.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},o.prototype.update=function(e,t){if(function(e,t){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");n.isBuffer(e)||(e=n.from(e,t));for(var r=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},{inherits:180,"safe-buffer":290,stream:311}],233:[function(e,t,r){var n=e("bn.js"),i=e("brorand");function o(e){this.rand=e||new i.Rand}t.exports=o,o.create=function(e){return new o(e)},o.prototype._randbelow=function(e){var t=e.bitLength(),r=Math.ceil(t/8);do{var i=new n(this.rand.generate(r))}while(i.cmp(e)>=0);return i},o.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},o.prototype.test=function(e,t,r){var i=e.bitLength(),o=n.mont(e),a=new n(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var s=e.subn(1),u=0;!s.testn(u);u++);for(var c=e.shrn(u),f=s.toRed(o);t>0;t--){var h=this._randrange(new n(2),s);r&&r(h);var l=h.toRed(o).redPow(c);if(0!==l.cmp(a)&&0!==l.cmp(f)){for(var d=1;d0;t--){var f=this._randrange(new n(2),a),h=e.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(u);if(0!==l.cmp(o)&&0!==l.cmp(c)){for(var d=1;d>8,a=255&i;o?r.push(o,a):r.push(a)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},{}],236:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],237:[function(e,t,r){var n=e("bn.js"),i=e("strip-hex-prefix");t.exports=function(e){if("string"==typeof e||"number"==typeof e){var t=new n(1),r=String(e).toLowerCase().trim(),o="0x"===r.substr(0,2)||"-0x"===r.substr(0,3),a=i(r);if("-"===a.substr(0,1)&&(a=i(a.slice(1)),t=new n(-1,10)),!(a=""===a?"0":a).match(/^-?[0-9]+$/)&&a.match(/^[0-9A-Fa-f]+$/)||a.match(/^[a-fA-F]+$/)||!0===o&&a.match(/^[0-9A-Fa-f]+$/))return new n(a,16).mul(t);if((a.match(/^-?[0-9]+$/)||""===a)&&!1===o)return new n(a,10).mul(t)}else if("object"==typeof e&&e.toString&&!e.pop&&!e.push&&e.toString(10).match(/^-?[0-9]+$/)&&(e.mul||e.dividedToIntegerBy))return new n(e.toString(10),10);throw new Error("[number-to-bn] while converting number "+JSON.stringify(e)+" to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.")}},{"bn.js":236,"strip-hex-prefix":318}],238:[function(e,t,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,a,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),u=1;u0;)if(q+=r,r=e.charAt(o++),4===H?(N+=String.fromCharCode(parseInt(q,16)),H=0,c=o-1):H++,!r)break e;if('"'===r&&!L){D=F.pop()||p,N+=e.substring(c,o-1);break}if(!("\\"!==r||L||(L=!0,N+=e.substring(c,o-1),r=e.charAt(o++))))break;if(L){if(L=!1,"n"===r?N+="\n":"r"===r?N+="\r":"t"===r?N+="\t":"f"===r?N+="\f":"b"===r?N+="\b":"u"===r?(H=1,q=""):N+=r,r=e.charAt(o++),c=o-1,r)continue;break}h.lastIndex=o;var l=h.exec(e);if(!l){o=e.length+1,N+=e.substring(c,o-1);break}if(o=l.index+1,!(r=e.charAt(l.index))){N+=e.substring(c,o-1);break}}continue;case A:if(!r)continue;if("r"!==r)return W("Invalid true started with t"+r);D=E;continue;case E:if(!r)continue;if("u"!==r)return W("Invalid true started with tr"+r);D=x;continue;case x:if(!r)continue;if("e"!==r)return W("Invalid true started with tru"+r);a(!0),u(),D=F.pop()||p;continue;case k:if(!r)continue;if("a"!==r)return W("Invalid false started with f"+r);D=S;continue;case S:if(!r)continue;if("l"!==r)return W("Invalid false started with fa"+r);D=M;continue;case M:if(!r)continue;if("s"!==r)return W("Invalid false started with fal"+r);D=I;continue;case I:if(!r)continue;if("e"!==r)return W("Invalid false started with fals"+r);a(!1),u(),D=F.pop()||p;continue;case T:if(!r)continue;if("u"!==r)return W("Invalid null started with n"+r);D=U;continue;case U:if(!r)continue;if("l"!==r)return W("Invalid null started with nu"+r);D=j;continue;case j:if(!r)continue;if("l"!==r)return W("Invalid null started with nul"+r);a(null),u(),D=F.pop()||p;continue;case B:if("."!==r)return W("Leading zero not followed by .");R+=r,D=P;continue;case P:if(-1!=="0123456789".indexOf(r))R+=r;else if("."===r){if(-1!==R.indexOf("."))return W("Invalid number has two dots");R+=r}else if("e"===r||"E"===r){if(-1!==R.indexOf("e")||-1!==R.indexOf("E"))return W("Invalid number has two exponential");R+=r}else if("+"===r||"-"===r){if("e"!==n&&"E"!==n)return W("Invalid symbol in number");R+=r}else R&&(a(parseFloat(R)),u(),R=""),o--,D=F.pop()||p;continue;default:return W("Unknown state: "+D)}K>=C&&(X=0,N!==s&&N.length>f&&(W("Max buffer length exceeded: textNode"),X=Math.max(X,N.length)),R.length>f&&(W("Max buffer length exceeded: numberNode"),X=Math.max(X,R.length)),C=f-X+K);var X}),e(ce).on(function(){if(D==d)return a({}),u(),void(O=!0);D===p&&0===z||W("Unexpected end");N!==s&&(a(N),u(),N=s);O=!0})}var C,N,R,L,O,D,F,q,H,z,K,V=(C=d(function(e){return e.unshift(/^/),(t=RegExp(e.map(f("source")).join(""))).exec.bind(t);var t}),L=C(N=/(\$?)/,/([\w-_]+|\*)/,R=/(?:{([\w ]*?)})?/),O=C(N,/\["([^"]+)"\]/,R),D=C(N,/\[(\d+|\*)\]/,R),F=C(N,/()/,/{([\w ]*?)}/),q=C(/\.\./),H=C(/\./),z=C(N,/!/),K=C(/$/),function(e){return e(h(L,O,D,F),q,H,z,K)});function G(e,t){return{key:e,node:t}}var W=f("key"),Y=f("node"),X={};function Z(e){var t=e(ee).emit,r=e(te).emit,n=e(ae).emit,o=e(oe).emit;function a(e,t,r){Y(x(e))[t]=r}function s(e,r,n){e&&a(e,r,n);var i=A(G(r,n),e);return t(i),i}var u={};return u[le]=function(e,t){if(!e)return n(t),s(e,X,t);var r=function(e,t){var r=Y(x(e));return m(i,r)?s(e,v(r),t):e}(e,t),o=k(r),u=W(x(r));return a(o,u,t),A(G(u,t),o)},u[de]=function(e){return r(e),k(e)||o(Y(x(e)))},u[he]=s,u}var J=V(function(e,t,r,n,i){var a=1,s=2,f=3,l=c(W,x),d=c(Y,x);function b(e,t){return!!t[a]?p(e,x):e}function m(e){if(e==y)return y;return p(function(e){return l(e)!=X},c(e,k))}function g(){return function(e){return l(e)==X}}function w(e,t,r,n,i){var o=e(r);if(o){var a=function(e,t,r){return U(function(e,t){return t(e,r)},t,e)}(t,n,o);return i(r.substr(v(o[0])),a)}}function A(e,t){return u(w,e,t)}var E=h(A(e,M(b,function(e,t){var r=t[f];return r?p(c(u(_,S(r.split(/\W+/))),d),e):e},function(e,t){var r=t[s];return p(r&&"*"!=r?function(e){return l(e)==r}:y,e)},m)),A(t,M(function(e){if(e==y)return y;var t=g(),r=e,n=m(function(e){return i(e)}),i=h(t,r,n);return i})),A(r,M()),A(n,M(b,g)),A(i,M(function(e){return function(t){var r=e(t);return!0===r?x(t):r}})),function(e){throw o('"'+e+'" could not be tokenised')});function I(e,t){return t}function T(e,t){return E(e,t,e?T:I)}return function(e){try{return T(e,y)}catch(t){throw o('Could not compile "'+e+'" because '+t.message)}}});function $(e,t,r){var n,i;function o(e){return function(t){return t.id==e}}return{on:function(r,o){var a={listener:r,id:o||r};return t&&t.emit(e,r,a.id),n=A(a,n),i=A(r,i),this},emit:function(){!function e(t,r){t&&(x(t).apply(null,r),e(k(t),r))}(i,arguments)},un:function(t){var a;n=j(n,o(t),function(e){a=e}),a&&(i=j(i,function(e){return e==a.listener}),r&&r.emit(e,a.listener,a.id))},listeners:function(){return i},hasListener:function(e){return w(function e(t,r){return r&&(t(x(r))?x(r):e(t,k(r)))}(e?o(e):y,n))}}}var Q=1,ee=Q++,te=Q++,re=Q++,ne=Q++,ie="fail",oe=Q++,ae=Q++,se="start",ue="data",ce="end",fe=Q++,he=Q++,le=Q++,de=Q++;function pe(e,t,r){try{var n=a.parse(t)}catch(e){}return{statusCode:e,body:t,jsonBody:n,thrown:r}}function be(e,t){var r={node:e(te),path:e(ee)};function n(t,r,n){var i=e(t).emit;r.on(function(e){var t=n(e);!1!==t&&function(e,t,r){var n=B(r);e(t,I(k(T(W,n))),I(T(Y,n)))}(i,Y(t),e)},t),e("removeListener").on(function(n){n==t&&(e(n).listeners()||r.un(t))})}e("newListener").on(function(e){var i=/(node|path):(.*)/.exec(e);if(i){var o=r[i[1]];o.hasListener(e)||n(e,o,t(i[2]))}})}function ye(e,t){var r,n=/^(node|path):./,i=e(oe),o=e(ne).emit,a=e(re).emit,s=d(function(t,i){if(r[t])l(i,r[t]);else{var o=e(t),a=i[0];n.test(t)?c(o,a):o.on(a)}return r});function c(e,t,n){n=n||t;var i=f(t);return e.on(function(){var t=!1;r.forget=function(){t=!0},l(arguments,i),delete r.forget,t&&e.un(n)},n),r}function f(e){return function(){try{return e.apply(r,arguments)}catch(e){setTimeout(function(){throw e})}}}function h(t,r,n){var i;i="node"==t?function(e){return function(){var t=e.apply(this,arguments);w(t)&&(t==ge.drop?o():a(t))}}(n):n,c(function(t,r){return e(t+":"+r)}(t,r),i,n)}function p(e,t,n){return g(t)?h(e,t,n):function(e,t){for(var r in t)h(e,r,t[r])}(e,t),r}return e(ae).on(function(e){var t;r.root=(t=e,function(){return t})}),e(se).on(function(e,t){r.header=function(e){return e?t[e]:t}}),r={on:s,addListener:s,removeListener:function(t,n,o){if("done"==t)i.un(n);else if("node"==t||"path"==t)e.un(t+":"+n,o);else{var a=n;e(t).un(a)}return r},emit:e.emit,node:u(p,"node"),path:u(p,"path"),done:u(c,i),start:u(function(t,n){return e(t).on(f(n),n),r},se),fail:e(ie).on,abort:e(fe).emit,header:b,root:b,source:t}}function me(t,r,n,i,o){var a=function(){var e={},t=n("newListener"),r=n("removeListener");function n(n){return e[n]=$(n,t,r)}function i(t){return e[t]||n(t)}return["emit","on","un"].forEach(function(e){i[e]=d(function(t,r){l(r,i(t)[e])})}),i}();return r&&function(t,r,n,i,o,a,c){"use strict";var f=t(ue).emit,h=t(ie).emit,l=0,d=!0;function p(){var e=r.responseText,t=e.substr(l);t&&f(t),l=v(e)}t(fe).on(function(){r.onreadystatechange=null,r.abort()}),"onprogress"in r&&(r.onprogress=p),r.onreadystatechange=function(){function e(){try{d&&t(se).emit(r.status,(e=r.getAllResponseHeaders(),n={},e&&e.split("\r\n").forEach(function(e){var t=e.indexOf(": ");n[e.substring(0,t)]=e.substring(t+2)}),n)),d=!1}catch(e){}var e,n}switch(r.readyState){case 2:case 3:return e();case 4:e(),2==String(r.status)[0]?(p(),t(ce).emit()):h(pe(r.status,r.responseText))}};try{for(var b in r.open(n,i,!0),a)r.setRequestHeader(b,a[b]);(function(e,t){function r(t){return t.port||{"http:":80,"https:":443}[t.protocol||e.protocol]}return!!(t.protocol&&t.protocol!=e.protocol||t.host&&t.host!=e.host||t.host&&r(t)!=r(e))})(e.location,function(e){var t=/(\w+:)?(?:\/\/)([\w.-]+)?(?::(\d+))?\/?/.exec(e)||[];return{protocol:t[1]||"",host:t[2]||"",port:t[3]||""}}(i))||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.withCredentials=c,r.send(o)}catch(t){e.setTimeout(u(h,pe(s,s,t)),0)}}(a,new XMLHttpRequest,t,r,n,i,o),P(a),function(e,t){"use strict";var r,n={};function i(e){return function(t){r=e(r,t)}}for(var o in t)e(o).on(i(t[o]),n);e(re).on(function(e){var t=x(r),n=W(t),i=k(r);i&&(Y(x(i))[n]=e)}),e(ne).on(function(){var e=x(r),t=W(e),n=k(r);n&&delete Y(x(n))[t]}),e(fe).on(function(){for(var r in t)e(r).un(n)})}(a,Z(a)),be(a,J),ye(a,r)}function ve(e,t,r,n,i,o,s){return i=i?a.parse(a.stringify(i)):{},n?g(n)||(n=a.stringify(n),i["Content-Type"]=i["Content-Type"]||"application/json"):n=null,e(r||"GET",function(e,t){return!1===t&&(-1==e.indexOf("?")?e+="?":e+="&",e+="_="+(new Date).getTime()),e}(t,s),n,i,o||!1)}function ge(e){var t=M("resume","pause","pipe"),r=u(_,t);return e?r(e)||g(e)?ve(me,e):ve(me,e.url,e.method,e.body,e.headers,e.withCredentials,e.cached):me()}ge.drop=function(){return ge.drop},"function"==typeof define&&define.amd?define("oboe",[],function(){return ge}):"object"==typeof r?t.exports=ge:e.oboe=ge}(function(){try{return window}catch(e){return self}}(),Object,Array,Error,JSON)},{}],240:[function(e,t,r){r.endianness=function(){return"LE"},r.hostname=function(){return"undefined"!=typeof location?location.hostname:""},r.loadavg=function(){return[]},r.uptime=function(){return 0},r.freemem=function(){return Number.MAX_VALUE},r.totalmem=function(){return Number.MAX_VALUE},r.cpus=function(){return[]},r.type=function(){return"Browser"},r.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},r.networkInterfaces=r.getNetworkInterfaces=function(){return{}},r.arch=function(){return"javascript"},r.platform=function(){return"browser"},r.tmpdir=r.tmpDir=function(){return"/tmp"},r.EOL="\n",r.homedir=function(){return"/"}},{}],241:[function(e,t,r){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],242:[function(e,t,r){"use strict";var n=e("asn1.js");r.certificate=e("./certificate");var i=n.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});r.RSAPrivateKey=i;var o=n.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});r.RSAPublicKey=o;var a=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())});r.PublicKey=a;var s=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),u=n.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(s),this.key("subjectPrivateKey").octstr())});r.PrivateKey=u;var c=n.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});r.EncryptedPrivateKey=c;var f=n.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});r.DSAPrivateKey=f,r.DSAparam=n.define("DSAparam",function(){this.int()});var h=n.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(l),this.key("publicKey").optional().explicit(1).bitstr())});r.ECPrivateKey=h;var l=n.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});r.signature=n.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},{"./certificate":243,"asn1.js":5}],243:[function(e,t,r){"use strict";var n=e("asn1.js"),i=n.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),o=n.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),a=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional())}),s=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())}),u=n.define("RelativeDistinguishedName",function(){this.setof(o)}),c=n.define("RDNSequence",function(){this.seqof(u)}),f=n.define("Name",function(){this.choice({rdnSequence:this.use(c)})}),h=n.define("Validity",function(){this.seq().obj(this.key("notBefore").use(i),this.key("notAfter").use(i))}),l=n.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),d=n.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int(),this.key("serialNumber").int(),this.key("signature").use(a),this.key("issuer").use(f),this.key("validity").use(h),this.key("subject").use(f),this.key("subjectPublicKeyInfo").use(s),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(l).optional())}),p=n.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(a),this.key("signatureValue").bitstr())});t.exports=p},{"asn1.js":5}],244:[function(e,t,r){(function(r){var n=/Proc-Type: 4,ENCRYPTED\n\r?DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\n\r?\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?/m,i=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n/m,o=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?-----END \1-----$/m,a=e("evp_bytestokey"),s=e("browserify-aes");t.exports=function(e,t){var u,c=e.toString(),f=c.match(n);if(f){var h="aes"+f[1],l=new r(f[2],"hex"),d=new r(f[3].replace(/\r?\n/g,""),"base64"),p=a(t,l.slice(0,8),parseInt(f[1],10)).key,b=[],y=s.createDecipheriv(h,p,l);b.push(y.update(d)),b.push(y.final()),u=r.concat(b)}else{var m=c.match(o);u=new r(m[2].replace(/\r?\n/g,""),"base64")}return{tag:c.match(i)[1],data:u}}}).call(this,e("buffer").Buffer)},{"browserify-aes":58,buffer:84,evp_bytestokey:158}],245:[function(e,t,r){(function(r){var n=e("./asn1"),i=e("./aesid.json"),o=e("./fixProc"),a=e("browserify-aes"),s=e("pbkdf2");function u(e){var t;"object"!=typeof e||r.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=new r(e));var u,c,f=o(e,t),h=f.tag,l=f.data;switch(h){case"CERTIFICATE":c=n.certificate.decode(l,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(c||(c=n.PublicKey.decode(l,"der")),u=c.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPublicKey.decode(c.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return c.subjectPrivateKey=c.subjectPublicKey,{type:"ec",data:c};case"1.2.840.10040.4.1":return c.algorithm.params.pub_key=n.DSAparam.decode(c.subjectPublicKey.data,"der"),{type:"dsa",data:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"ENCRYPTED PRIVATE KEY":l=function(e,t){var n=e.algorithm.decrypt.kde.kdeparams.salt,o=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),u=i[e.algorithm.decrypt.cipher.algo.join(".")],c=e.algorithm.decrypt.cipher.iv,f=e.subjectPrivateKey,h=parseInt(u.split("-")[1],10)/8,l=s.pbkdf2Sync(t,n,o,h),d=a.createDecipheriv(u,l,c),p=[];return p.push(d.update(f)),p.push(d.final()),r.concat(p)}(l=n.EncryptedPrivateKey.decode(l,"der"),t);case"PRIVATE KEY":switch(u=(c=n.PrivateKey.decode(l,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPrivateKey.decode(c.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:c.algorithm.curve,privateKey:n.ECPrivateKey.decode(c.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return c.algorithm.params.priv_key=n.DSAparam.decode(c.subjectPrivateKey,"der"),{type:"dsa",params:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"RSA PUBLIC KEY":return n.RSAPublicKey.decode(l,"der");case"RSA PRIVATE KEY":return n.RSAPrivateKey.decode(l,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:n.DSAPrivateKey.decode(l,"der")};case"EC PRIVATE KEY":return{curve:(l=n.ECPrivateKey.decode(l,"der")).parameters.value,privateKey:l.privateKey};default:throw new Error("unknown key type "+h)}}t.exports=u,u.signature=n.signature}).call(this,e("buffer").Buffer)},{"./aesid.json":241,"./asn1":242,"./fixProc":244,"browserify-aes":58,buffer:84,pbkdf2:247}],246:[function(e,t,r){var n=e("trim"),i=e("for-each");t.exports=function(e){if(!e)return{};var t={};return i(n(e).split("\n"),function(e){var r,i=e.indexOf(":"),o=n(e.slice(0,i)).toLowerCase(),a=n(e.slice(i+1));void 0===t[o]?t[o]=a:(r=t[o],"[object Array]"===Object.prototype.toString.call(r)?t[o].push(a):t[o]=[t[o],a])}),t}},{"for-each":159,trim:324}],247:[function(e,t,r){r.pbkdf2=e("./lib/async"),r.pbkdf2Sync=e("./lib/sync")},{"./lib/async":248,"./lib/sync":251}],248:[function(e,t,r){(function(r,n){var i,o=e("./precondition"),a=e("./default-encoding"),s=e("./sync"),u=e("safe-buffer").Buffer,c=n.crypto&&n.crypto.subtle,f={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},h=[];function l(e,t,r,n,i){return c.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then(function(e){return c.deriveBits({name:"PBKDF2",salt:t,iterations:r,hash:{name:i}},e,n<<3)}).then(function(e){return u.from(e)})}t.exports=function(e,t,d,p,b,y){if(u.isBuffer(e)||(e=u.from(e,a)),u.isBuffer(t)||(t=u.from(t,a)),o(d,p),"function"==typeof b&&(y=b,b=void 0),"function"!=typeof y)throw new Error("No callback provided to pbkdf2");var m=f[(b=b||"sha1").toLowerCase()];if(!m||"function"!=typeof n.Promise)return r.nextTick(function(){var r;try{r=s(e,t,d,p,b)}catch(e){return y(e)}y(null,r)});!function(e,t){e.then(function(e){r.nextTick(function(){t(null,e)})},function(e){r.nextTick(function(){t(e)})})}(function(e){if(n.process&&!n.process.browser)return Promise.resolve(!1);if(!c||!c.importKey||!c.deriveBits)return Promise.resolve(!1);if(void 0!==h[e])return h[e];var t=l(i=i||u.alloc(8),i,10,128,e).then(function(){return!0}).catch(function(){return!1});return h[e]=t,t}(m).then(function(r){return r?l(e,t,d,p,m):s(e,t,d,p,b)}),y)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-encoding":249,"./precondition":250,"./sync":251,_process:257,"safe-buffer":290}],249:[function(e,t,r){(function(e){var r;e.browser?r="utf-8":r=parseInt(e.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary";t.exports=r}).call(this,e("_process"))},{_process:257}],250:[function(e,t,r){var n=Math.pow(2,30)-1;t.exports=function(e,t){if("number"!=typeof e)throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if("number"!=typeof t)throw new TypeError("Key length not a number");if(t<0||t>n||t!=t)throw new TypeError("Bad key length")}},{}],251:[function(e,t,r){var n=e("create-hash/md5"),i=e("ripemd160"),o=e("sha.js"),a=e("./precondition"),s=e("./default-encoding"),u=e("safe-buffer").Buffer,c=u.alloc(128),f={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function h(e,t,r){var a=function(e){return"rmd160"===e||"ripemd160"===e?i:"md5"===e?n:function(t){return o(e).update(t).digest()}}(e),s="sha512"===e||"sha384"===e?128:64;t.length>s?t=a(t):t.length1)for(var r=1;rp||new a(t).cmp(d.modulus)>=0)throw new Error("decryption error");l=f?c(new a(t),d):s(t,d);var b=new r(p-l.length);if(b.fill(0),l=r.concat([b,l],p),4===h)return function(e,t){e.modulus;var n=e.modulus.byteLength(),a=(t.length,u("sha1").update(new r("")).digest()),s=a.length;if(0!==t[0])throw new Error("decryption error");var c=t.slice(1,s+1),f=t.slice(s+1),h=o(c,i(f,s)),l=o(f,i(h,n-s-1));if(function(e,t){e=new r(e),t=new r(t);var n=0,i=e.length;e.length!==t.length&&(n++,i=Math.min(e.length,t.length));var o=-1;for(;++o=t.length){o++;break}var a=t.slice(2,i-1);t.slice(i-1,i);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;a.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,l,f);if(3===h)return l;throw new Error("unknown padding")}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245}],262:[function(e,t,r){(function(r){var n=e("parse-asn1"),i=e("randombytes"),o=e("create-hash"),a=e("./mgf"),s=e("./xor"),u=e("bn.js"),c=e("./withPublic"),f=e("browserify-rsa");t.exports=function(e,t,h){var l;l=e.padding?e.padding:h?1:4;var d,p=n(e);if(4===l)d=function(e,t){var n=e.modulus.byteLength(),c=t.length,f=o("sha1").update(new r("")).digest(),h=f.length,l=2*h;if(c>n-l-2)throw new Error("message too long");var d=new r(n-c-l-2);d.fill(0);var p=n-h-1,b=i(h),y=s(r.concat([f,d,new r([1]),t],p),a(b,p)),m=s(b,a(y,h));return new u(r.concat([new r([0]),m,y],n))}(p,t);else if(1===l)d=function(e,t,n){var o,a=t.length,s=e.modulus.byteLength();if(a>s-11)throw new Error("message too long");n?(o=new r(s-a-3)).fill(255):o=function(e,t){var n,o=new r(e),a=0,s=i(2*e),u=0;for(;a=0)throw new Error("data too long for modulus")}return h?f(d,p):c(d,p)}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245,randombytes:270}],263:[function(e,t,r){(function(r){var n=e("bn.js");t.exports=function(e,t){return new r(e.toRed(n.mont(t.modulus)).redPow(new n(t.publicExponent)).fromRed().toArray())}}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84}],264:[function(e,t,r){t.exports=function(e,t){for(var r=e.length,n=-1;++n= 0x80 (not a basic code point)","invalid-input":"Invalid input"},A=f-h,E=Math.floor,x=String.fromCharCode;function k(e){throw new RangeError(_[e])}function S(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function M(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+S((e=e.replace(w,".")).split("."),t).join(".")}function I(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=x((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=x(e)}).join("")}function U(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function j(e,t,r){var n=0;for(e=r?E(e/p):e>>1,e+=E(e/t);e>A*l>>1;n+=f)e=E(e/A);return E(n+(A+1)*e/(e+d))}function B(e){var t,r,n,i,o,a,s,u,d,p,v,g=[],w=e.length,_=0,A=y,x=b;for((r=e.lastIndexOf(m))<0&&(r=0),n=0;n=128&&k("not-basic"),g.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=w&&k("invalid-input"),((u=(v=e.charCodeAt(i++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:f)>=f||u>E((c-_)/a))&&k("overflow"),_+=u*a,!(u<(d=s<=x?h:s>=x+l?l:s-x));s+=f)a>E(c/(p=f-d))&&k("overflow"),a*=p;x=j(_-o,t=g.length+1,0==o),E(_/t)>c-A&&k("overflow"),A+=E(_/t),_%=t,g.splice(_++,0,A)}return T(g)}function P(e){var t,r,n,i,o,a,s,u,d,p,v,g,w,_,A,S=[];for(g=(e=I(e)).length,t=y,r=0,o=b,a=0;a=t&&vE((c-r)/(w=n+1))&&k("overflow"),r+=(s-t)*w,t=s,a=0;ac&&k("overflow"),v==t){for(u=r,d=f;!(u<(p=d<=o?h:d>=o+l?l:d-o));d+=f)A=u-p,_=f-p,S.push(x(U(p+A%_,0))),u=E(A/_);S.push(x(U(u,0))),o=j(r,w,n==i),r=0,++n}++r,++t}return S.join("")}if(s={version:"1.4.1",ucs2:{decode:I,encode:T},decode:B,encode:P,toASCII:function(e){return M(e,function(e){return g.test(e)?"xn--"+P(e):e})},toUnicode:function(e){return M(e,function(e){return v.test(e)?B(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return s});else if(i&&o)if(t.exports==i)o.exports=s;else for(u in s)s.hasOwnProperty(u)&&(i[u]=s[u]);else n.punycode=s}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],266:[function(e,t,r){"use strict";var n=e("strict-uri-encode"),i=e("object-assign"),o=e("decode-uri-component");function a(e,t){return t.encode?t.strict?n(e):encodeURIComponent(e):e}function s(e){var t=e.indexOf("?");return-1===t?"":e.slice(t+1)}function u(e,t){var r=function(e){var t;switch(e.arrayFormat){case"index":return function(e,r,n){t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return function(e,r,n){t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};default:return function(e,t,r){void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t=i({arrayFormat:"none"},t)),n=Object.create(null);return"string"!=typeof e?n:(e=e.trim().replace(/^[?#&]/,""))?(e.split("&").forEach(function(e){var t=e.replace(/\+/g," ").split("="),i=t.shift(),a=t.length>0?t.join("="):void 0;a=void 0===a?null:o(a),r(o(i),a,n)}),Object.keys(n).sort().reduce(function(e,t){var r=n[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=function e(t){return Array.isArray(t)?t.sort():"object"==typeof t?e(Object.keys(t)).sort(function(e,t){return Number(e)-Number(t)}).map(function(e){return t[e]}):t}(r):e[t]=r,e},Object.create(null))):n}r.extract=s,r.parse=u,r.stringify=function(e,t){!1===(t=i({encode:!0,strict:!0,arrayFormat:"none"},t)).sort&&(t.sort=function(){});var r=function(e){switch(e.arrayFormat){case"index":return function(t,r,n){return null===r?[a(t,e),"[",n,"]"].join(""):[a(t,e),"[",a(n,e),"]=",a(r,e)].join("")};case"bracket":return function(t,r){return null===r?a(t,e):[a(t,e),"[]=",a(r,e)].join("")};default:return function(t,r){return null===r?a(t,e):[a(t,e),"=",a(r,e)].join("")}}}(t);return e?Object.keys(e).sort(t.sort).map(function(n){var i=e[n];if(void 0===i)return"";if(null===i)return a(n,t);if(Array.isArray(i)){var o=[];return i.slice().forEach(function(e){void 0!==e&&o.push(r(n,e,o.length))}),o.join("&")}return a(n,t)+"="+a(i,t)}).filter(function(e){return e.length>0}).join("&"):""},r.parseUrl=function(e,t){return{url:e.split("?")[0]||"",query:u(s(e),t)}}},{"decode-uri-component":98,"object-assign":238,"strict-uri-encode":316}],267:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&",r=r||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(a,d)?i(a[d])?a[d].push(p):a[d]=[a[d],p]:a[d]=p}return a};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],268:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,s){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),function(a){var s=encodeURIComponent(n(a))+r;return i(e[a])?o(e[a],function(e){return s+encodeURIComponent(n(e))}).join(t):s+encodeURIComponent(n(e[a]))}).join(t):s?encodeURIComponent(n(s))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n65536)throw new Error("requested too many random bytes");var a=new n.Uint8Array(e);e>0&&o.getRandomValues(a);var s=i.from(a.buffer);if("function"==typeof t)return r.nextTick(function(){t(null,s)});return s}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,"safe-buffer":290}],271:[function(e,t,r){(function(t,n){"use strict";function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=e("safe-buffer"),a=e("randombytes"),s=o.Buffer,u=o.kMaxLength,c=n.crypto||n.msCrypto,f=Math.pow(2,32)-1;function h(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>f||e<0)throw new TypeError("offset must be a uint32");if(e>u||e>t)throw new RangeError("offset out of range")}function l(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>f||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>u)throw new RangeError("buffer too small")}function d(e,r,n,i){if(t.browser){var o=e.buffer,s=new Uint8Array(o,r,n);return c.getRandomValues(s),i?void t.nextTick(function(){i(null,e)}):e}if(!i)return a(n).copy(e,r),e;a(n,function(t,n){if(t)return i(t);n.copy(e,r),i(null,e)})}c&&c.getRandomValues||!t.browser?(r.randomFill=function(e,t,r,i){if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)i=t,t=0,r=e.length;else if("function"==typeof r)i=r,r=e.length-t;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return h(t,e.length),l(r,t,e.length),d(e,t,r,i)},r.randomFillSync=function(e,t,r){void 0===t&&(t=0);if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');h(t,e.length),void 0===r&&(r=e.length-t);return l(r,t,e.length),d(e,t,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,randombytes:270,"safe-buffer":290}],272:[function(e,t,r){t.exports=window.crypto},{}],273:[function(e,t,r){t.exports=e("crypto")},{crypto:272}],274:[function(e,t,r){t.exports=function(t,r){var n=e("./crypto.js"),i="function"==typeof r;if(t>65536){if(!i)throw new Error("Requested too many random bytes.");r(new Error("Requested too many random bytes."))}if(void 0!==n&&n.randomBytes){if(!i)return"0x"+n.randomBytes(t).toString("hex");n.randomBytes(t,function(e,t){e?r(u):r(null,"0x"+t.toString("hex"))})}else{var o;if(void 0!==n?o=n:"undefined"!=typeof msCrypto&&(o=msCrypto),o&&o.getRandomValues){var a=o.getRandomValues(new Uint8Array(t)),s="0x"+Array.from(a).map(function(e){return e.toString(16)}).join("");if(!i)return s;r(null,s)}else{var u=new Error('No "crypto" object available. This Browser doesn\'t support generating secure random bytes.');if(!i)throw u;r(u)}}}},{"./crypto.js":273}],275:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":276}],276:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick,i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=h;var o=e("core-util-is");o.inherits=e("inherits");var a=e("./_stream_readable"),s=e("./_stream_writable");o.inherits(h,a);for(var u=i(s.prototype),c=0;c0?("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),n?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):_(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?_(e,a,t,!1):S(e,a)):_(e,a,t,!1))):n||(a.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=A?e=A:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(d("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i(k,e):k(e))}function k(e){d("emit readable"),e.emit("readable"),U(e)}function S(e,t){t.readingMore||(t.readingMore=!0,i(M,e,t))}function M(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=c.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,a),0===(e-=a)){a===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function B(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i(P,t,e))}function P(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function C(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return d("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?B(this):x(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&B(this),null;var n,i=t.needReadable;return d("need readable",i),(0===t.length||t.length-e0?j(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&B(this)),null!==n&&this.emit("data",n),n},g.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},g.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,d("pipe count=%d opts=%j",o.pipesCount,t);var u=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?f:g;function c(t,r){d("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,d("cleanup"),e.removeListener("close",m),e.removeListener("finish",v),e.removeListener("drain",h),e.removeListener("error",y),e.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",g),n.removeListener("data",b),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||h())}function f(){d("onend"),e.end()}o.endEmitted?i(u):n.once("end",u),e.on("unpipe",c);var h=function(e){return function(){var t=e._readableState;d("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,U(e))}}(n);e.on("drain",h);var l=!1;var p=!1;function b(t){d("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==C(o.pipes,e))&&!l&&(d("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(t){d("onerror",t),g(),e.removeListener("error",y),0===s(e,"error")&&e.emit("error",t)}function m(){e.removeListener("finish",v),g()}function v(){d("onfinish"),e.removeListener("close",m),g()}function g(){d("unpipe"),n.unpipe(e)}return n.on("data",b),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?a(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",y),e.once("close",m),e.once("finish",v),e.emit("pipe",n),o.flowing||(d("pipe resume"),n.resume()),e},g.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:i;m.WritableState=y;var u=e("core-util-is");u.inherits=e("inherits");var c={deprecate:e("util-deprecate")},f=e("./internal/streams/stream"),h=e("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=e("./internal/streams/destroy");function b(){}function y(t,r){a=a||e("./_stream_duplex"),t=t||{};var n=r instanceof a;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var u=t.highWaterMark,c=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=u||0===u?u:n&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===t.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,o=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,o){--t.pendingcb,r?(i(o,n),i(E,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(o(n),e._writableState.errorEmitted=!0,e.emit("error",n),E(e,t))}(e,r,n,t,o);else{var a=_(r);a||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),n?s(g,e,r,a,o):g(e,r,a,o)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function m(t){if(a=a||e("./_stream_duplex"),!(d.call(m,this)||this instanceof a))return new m(t);this._writableState=new y(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),f.call(this)}function v(e,t,r,n,i,o,a){t.writelen=n,t.writecb=a,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function g(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),E(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),a=t.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,v(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,h=r.callback;if(v(e,t,!1,t.objectMode?1:c.length,c,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function A(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),E(e,t)})}function E(e,t){var r=_(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,i(A,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}u.inherits(m,f),y.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(y.prototype,"buffer",{get:c.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===m&&(e&&e._writableState instanceof y)}})):d=function(e){return e instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(e,t,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=e,h.isBuffer(n)||n instanceof l);return s&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof r&&(r=b),o.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),i(t,r)}(this,r):(s||function(e,t,r,n){var o=!0,a=!1;return null===r?a=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),i(n,a),o=!1),o}(this,o,e,r))&&(o.pendingcb++,a=function(e,t,r,n,i,o){if(!r){var a=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,r));return t}(t,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=t.objectMode?1:n.length;t.length+=s;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},m.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,E(e,t),r&&(t.finished?i(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),m.prototype.destroy=p.destroy,m.prototype._undestroy=p.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":276,"./internal/streams/destroy":282,"./internal/streams/stream":283,_process:257,"core-util-is":89,inherits:180,"process-nextick-args":256,"safe-buffer":290,"util-deprecate":330}],281:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,i,o=n.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,r=o,i=s,t.copy(r,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":290,util:55}],282:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick;function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var r=this,o=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return o||a?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||n(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n(i,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":256}],283:[function(e,t,r){t.exports=e("events").EventEmitter},{events:157}],284:[function(e,t,r){t.exports=e("./readable").PassThrough},{"./readable":285}],285:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":276,"./lib/_stream_passthrough.js":277,"./lib/_stream_readable.js":278,"./lib/_stream_transform.js":279,"./lib/_stream_writable.js":280}],286:[function(e,t,r){t.exports=e("./readable").Transform},{"./readable":285}],287:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":280}],288:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base");function o(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function a(e,t){return e<>>32-t}function s(e,t,r,n,i,o,s,u){return a(e+(t^r^n)+o+s|0,u)+i|0}function u(e,t,r,n,i,o,s,u){return a(e+(t&r|~t&n)+o+s|0,u)+i|0}function c(e,t,r,n,i,o,s,u){return a(e+((t|~r)^n)+o+s|0,u)+i|0}function f(e,t,r,n,i,o,s,u){return a(e+(t&n|r&~n)+o+s|0,u)+i|0}function h(e,t,r,n,i,o,s,u){return a(e+(t^(r|~n))+o+s|0,u)+i|0}n(o,i),o.prototype._update=function(){for(var e=new Array(16),t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,o=this._d,l=this._e;l=s(l,r=s(r,n,i,o,l,e[0],0,11),n,i=a(i,10),o,e[1],0,14),n=s(n=a(n,10),i=s(i,o=s(o,l,r,n,i,e[2],0,15),l,r=a(r,10),n,e[3],0,12),o,l=a(l,10),r,e[4],0,5),o=s(o=a(o,10),l=s(l,r=s(r,n,i,o,l,e[5],0,8),n,i=a(i,10),o,e[6],0,7),r,n=a(n,10),i,e[7],0,9),r=s(r=a(r,10),n=s(n,i=s(i,o,l,r,n,e[8],0,11),o,l=a(l,10),r,e[9],0,13),i,o=a(o,10),l,e[10],0,14),i=s(i=a(i,10),o=s(o,l=s(l,r,n,i,o,e[11],0,15),r,n=a(n,10),i,e[12],0,6),l,r=a(r,10),n,e[13],0,7),l=u(l=a(l,10),r=s(r,n=s(n,i,o,l,r,e[14],0,9),i,o=a(o,10),l,e[15],0,8),n,i=a(i,10),o,e[7],1518500249,7),n=u(n=a(n,10),i=u(i,o=u(o,l,r,n,i,e[4],1518500249,6),l,r=a(r,10),n,e[13],1518500249,8),o,l=a(l,10),r,e[1],1518500249,13),o=u(o=a(o,10),l=u(l,r=u(r,n,i,o,l,e[10],1518500249,11),n,i=a(i,10),o,e[6],1518500249,9),r,n=a(n,10),i,e[15],1518500249,7),r=u(r=a(r,10),n=u(n,i=u(i,o,l,r,n,e[3],1518500249,15),o,l=a(l,10),r,e[12],1518500249,7),i,o=a(o,10),l,e[0],1518500249,12),i=u(i=a(i,10),o=u(o,l=u(l,r,n,i,o,e[9],1518500249,15),r,n=a(n,10),i,e[5],1518500249,9),l,r=a(r,10),n,e[2],1518500249,11),l=u(l=a(l,10),r=u(r,n=u(n,i,o,l,r,e[14],1518500249,7),i,o=a(o,10),l,e[11],1518500249,13),n,i=a(i,10),o,e[8],1518500249,12),n=c(n=a(n,10),i=c(i,o=c(o,l,r,n,i,e[3],1859775393,11),l,r=a(r,10),n,e[10],1859775393,13),o,l=a(l,10),r,e[14],1859775393,6),o=c(o=a(o,10),l=c(l,r=c(r,n,i,o,l,e[4],1859775393,7),n,i=a(i,10),o,e[9],1859775393,14),r,n=a(n,10),i,e[15],1859775393,9),r=c(r=a(r,10),n=c(n,i=c(i,o,l,r,n,e[8],1859775393,13),o,l=a(l,10),r,e[1],1859775393,15),i,o=a(o,10),l,e[2],1859775393,14),i=c(i=a(i,10),o=c(o,l=c(l,r,n,i,o,e[7],1859775393,8),r,n=a(n,10),i,e[0],1859775393,13),l,r=a(r,10),n,e[6],1859775393,6),l=c(l=a(l,10),r=c(r,n=c(n,i,o,l,r,e[13],1859775393,5),i,o=a(o,10),l,e[11],1859775393,12),n,i=a(i,10),o,e[5],1859775393,7),n=f(n=a(n,10),i=f(i,o=c(o,l,r,n,i,e[12],1859775393,5),l,r=a(r,10),n,e[1],2400959708,11),o,l=a(l,10),r,e[9],2400959708,12),o=f(o=a(o,10),l=f(l,r=f(r,n,i,o,l,e[11],2400959708,14),n,i=a(i,10),o,e[10],2400959708,15),r,n=a(n,10),i,e[0],2400959708,14),r=f(r=a(r,10),n=f(n,i=f(i,o,l,r,n,e[8],2400959708,15),o,l=a(l,10),r,e[12],2400959708,9),i,o=a(o,10),l,e[4],2400959708,8),i=f(i=a(i,10),o=f(o,l=f(l,r,n,i,o,e[13],2400959708,9),r,n=a(n,10),i,e[3],2400959708,14),l,r=a(r,10),n,e[7],2400959708,5),l=f(l=a(l,10),r=f(r,n=f(n,i,o,l,r,e[15],2400959708,6),i,o=a(o,10),l,e[14],2400959708,8),n,i=a(i,10),o,e[5],2400959708,6),n=h(n=a(n,10),i=f(i,o=f(o,l,r,n,i,e[6],2400959708,5),l,r=a(r,10),n,e[2],2400959708,12),o,l=a(l,10),r,e[4],2840853838,9),o=h(o=a(o,10),l=h(l,r=h(r,n,i,o,l,e[0],2840853838,15),n,i=a(i,10),o,e[5],2840853838,5),r,n=a(n,10),i,e[9],2840853838,11),r=h(r=a(r,10),n=h(n,i=h(i,o,l,r,n,e[7],2840853838,6),o,l=a(l,10),r,e[12],2840853838,8),i,o=a(o,10),l,e[2],2840853838,13),i=h(i=a(i,10),o=h(o,l=h(l,r,n,i,o,e[10],2840853838,12),r,n=a(n,10),i,e[14],2840853838,5),l,r=a(r,10),n,e[1],2840853838,12),l=h(l=a(l,10),r=h(r,n=h(n,i,o,l,r,e[3],2840853838,13),i,o=a(o,10),l,e[8],2840853838,14),n,i=a(i,10),o,e[11],2840853838,11),n=h(n=a(n,10),i=h(i,o=h(o,l,r,n,i,e[6],2840853838,8),l,r=a(r,10),n,e[15],2840853838,5),o,l=a(l,10),r,e[13],2840853838,6),o=a(o,10);var d=this._a,p=this._b,b=this._c,y=this._d,m=this._e;m=h(m,d=h(d,p,b,y,m,e[5],1352829926,8),p,b=a(b,10),y,e[14],1352829926,9),p=h(p=a(p,10),b=h(b,y=h(y,m,d,p,b,e[7],1352829926,9),m,d=a(d,10),p,e[0],1352829926,11),y,m=a(m,10),d,e[9],1352829926,13),y=h(y=a(y,10),m=h(m,d=h(d,p,b,y,m,e[2],1352829926,15),p,b=a(b,10),y,e[11],1352829926,15),d,p=a(p,10),b,e[4],1352829926,5),d=h(d=a(d,10),p=h(p,b=h(b,y,m,d,p,e[13],1352829926,7),y,m=a(m,10),d,e[6],1352829926,7),b,y=a(y,10),m,e[15],1352829926,8),b=h(b=a(b,10),y=h(y,m=h(m,d,p,b,y,e[8],1352829926,11),d,p=a(p,10),b,e[1],1352829926,14),m,d=a(d,10),p,e[10],1352829926,14),m=f(m=a(m,10),d=h(d,p=h(p,b,y,m,d,e[3],1352829926,12),b,y=a(y,10),m,e[12],1352829926,6),p,b=a(b,10),y,e[6],1548603684,9),p=f(p=a(p,10),b=f(b,y=f(y,m,d,p,b,e[11],1548603684,13),m,d=a(d,10),p,e[3],1548603684,15),y,m=a(m,10),d,e[7],1548603684,7),y=f(y=a(y,10),m=f(m,d=f(d,p,b,y,m,e[0],1548603684,12),p,b=a(b,10),y,e[13],1548603684,8),d,p=a(p,10),b,e[5],1548603684,9),d=f(d=a(d,10),p=f(p,b=f(b,y,m,d,p,e[10],1548603684,11),y,m=a(m,10),d,e[14],1548603684,7),b,y=a(y,10),m,e[15],1548603684,7),b=f(b=a(b,10),y=f(y,m=f(m,d,p,b,y,e[8],1548603684,12),d,p=a(p,10),b,e[12],1548603684,7),m,d=a(d,10),p,e[4],1548603684,6),m=f(m=a(m,10),d=f(d,p=f(p,b,y,m,d,e[9],1548603684,15),b,y=a(y,10),m,e[1],1548603684,13),p,b=a(b,10),y,e[2],1548603684,11),p=c(p=a(p,10),b=c(b,y=c(y,m,d,p,b,e[15],1836072691,9),m,d=a(d,10),p,e[5],1836072691,7),y,m=a(m,10),d,e[1],1836072691,15),y=c(y=a(y,10),m=c(m,d=c(d,p,b,y,m,e[3],1836072691,11),p,b=a(b,10),y,e[7],1836072691,8),d,p=a(p,10),b,e[14],1836072691,6),d=c(d=a(d,10),p=c(p,b=c(b,y,m,d,p,e[6],1836072691,6),y,m=a(m,10),d,e[9],1836072691,14),b,y=a(y,10),m,e[11],1836072691,12),b=c(b=a(b,10),y=c(y,m=c(m,d,p,b,y,e[8],1836072691,13),d,p=a(p,10),b,e[12],1836072691,5),m,d=a(d,10),p,e[2],1836072691,14),m=c(m=a(m,10),d=c(d,p=c(p,b,y,m,d,e[10],1836072691,13),b,y=a(y,10),m,e[0],1836072691,13),p,b=a(b,10),y,e[4],1836072691,7),p=u(p=a(p,10),b=u(b,y=c(y,m,d,p,b,e[13],1836072691,5),m,d=a(d,10),p,e[8],2053994217,15),y,m=a(m,10),d,e[6],2053994217,5),y=u(y=a(y,10),m=u(m,d=u(d,p,b,y,m,e[4],2053994217,8),p,b=a(b,10),y,e[1],2053994217,11),d,p=a(p,10),b,e[3],2053994217,14),d=u(d=a(d,10),p=u(p,b=u(b,y,m,d,p,e[11],2053994217,14),y,m=a(m,10),d,e[15],2053994217,6),b,y=a(y,10),m,e[0],2053994217,14),b=u(b=a(b,10),y=u(y,m=u(m,d,p,b,y,e[5],2053994217,6),d,p=a(p,10),b,e[12],2053994217,9),m,d=a(d,10),p,e[2],2053994217,12),m=u(m=a(m,10),d=u(d,p=u(p,b,y,m,d,e[13],2053994217,9),b,y=a(y,10),m,e[9],2053994217,12),p,b=a(b,10),y,e[7],2053994217,5),p=s(p=a(p,10),b=u(b,y=u(y,m,d,p,b,e[10],2053994217,15),m,d=a(d,10),p,e[14],2053994217,8),y,m=a(m,10),d,e[12],0,8),y=s(y=a(y,10),m=s(m,d=s(d,p,b,y,m,e[15],0,5),p,b=a(b,10),y,e[10],0,12),d,p=a(p,10),b,e[4],0,9),d=s(d=a(d,10),p=s(p,b=s(b,y,m,d,p,e[1],0,12),y,m=a(m,10),d,e[5],0,5),b,y=a(y,10),m,e[8],0,14),b=s(b=a(b,10),y=s(y,m=s(m,d,p,b,y,e[7],0,6),d,p=a(p,10),b,e[6],0,8),m,d=a(d,10),p,e[2],0,13),m=s(m=a(m,10),d=s(d,p=s(p,b,y,m,d,e[13],0,6),b,y=a(y,10),m,e[14],0,5),p,b=a(b,10),y,e[0],0,15),p=s(p=a(p,10),b=s(b,y=s(y,m,d,p,b,e[3],0,13),m,d=a(d,10),p,e[9],0,11),y,m=a(m,10),d,e[11],0,11),y=a(y,10);var v=this._b+i+y|0;this._b=this._c+o+m|0,this._c=this._d+l+d|0,this._d=this._e+r+p|0,this._e=this._a+n+b|0,this._a=v},o.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=o}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":161,inherits:180}],289:[function(e,t,r){const n=e("assert"),i=e("safe-buffer").Buffer;function o(e,t){if("00"===e.slice(0,2))throw new Error("invalid RLP: extra zeros");return parseInt(e,t)}function a(e,t){if(e<56)return i.from([e+t]);var r=u(e),n=u(t+55+r.length/2);return i.from(n+r,"hex")}function s(e){return"0x"===e.slice(0,2)}function u(e){var t=e.toString(16);return t.length%2&&(t="0"+t),t}function c(e){if(!i.isBuffer(e))if("string"==typeof e)e=s(e)?i.from(((r="string"!=typeof(n=e)?n:s(n)?n.slice(2):n).length%2&&(r="0"+r),r),"hex"):i.from(e);else if("number"==typeof e)e?(t=u(e),e=i.from(t,"hex")):e=i.from([]);else if(null==e)e=i.from([]);else{if(!e.toArray)throw new Error("invalid type");e=i.from(e.toArray())}var t,r,n;return e}r.encode=function(e){if(e instanceof Array){for(var t=[],n=0;nt.length)throw new Error("invalid rlp: total length is larger than the data");if(0===(s=t.slice(n,h)).length)throw new Error("invalid rlp, List has a invalid length");for(;s.length;)u=e(s),c.push(u.data),s=u.remainder;return{data:c,remainder:t.slice(h)}}(e=c(e));return t?r:(n.equal(r.remainder.length,0,"invalid remainder"),r.data)},r.getLength=function(e){if(!e||0===e.length)return i.from([]);var t=(e=c(e))[0];if(t<=127)return e.length;if(t<=183)return t-127;if(t<=191)return t-182;if(t<=247)return t-191;var r=t-246;return r+o(e.slice(1,r).toString("hex"),16)}},{assert:19,"safe-buffer":290}],290:[function(e,t,r){var n=e("buffer"),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function a(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,r),r.Buffer=a),o(i,a),a.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:84}],291:[function(e,t,r){const n=e("util"),i=e("events/");var o="object"==typeof Reflect?Reflect:null,a=o&&"function"==typeof o.apply?o.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};function s(){i.call(this)}function u(e,t,r){try{a(e,t,r)}catch(e){setTimeout(()=>{throw e})}}t.exports=s,n.inherits(s,i),s.prototype.emit=function(e){for(var t=[],r=1;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var s=i[e];if(void 0===s)return!1;if("function"==typeof s)u(s,this,t);else{var c=s.length,f=function(e,t){for(var r=new Array(t),n=0;n0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=function(){for(var e=[],t=0;t0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var c=u.length,f=p(u,c);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return l(this,e,!0)},s.prototype.rawListeners=function(e){return l(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},{}],293:[function(e,t,r){t.exports=e("scryptsy")},{scryptsy:294}],294:[function(e,t,r){(function(r){var n=e("pbkdf2").pbkdf2Sync,i=2147483647;function o(e,t,n,i,o){if(r.isBuffer(e)&&r.isBuffer(n))e.copy(n,i,t,t+o);else for(;o--;)n[i++]=e[t++]}t.exports=function(e,t,a,s,u,c,f){if(0===a||0!=(a&a-1))throw Error("N must be > 0 and a power of 2");if(a>i/128/s)throw Error("Parameter N is too large");if(s>i/128/u)throw Error("Parameter r is too large");var h,l=new r(256*s),d=new r(128*s*a),p=new Int32Array(16),b=new Int32Array(16),y=new r(64),m=n(e,t,1,128*u*s,"sha256");if(f){var v=u*a*2,g=0;h=function(){++g%1e3==0&&f({current:g,total:v,percent:g/v*100})}}for(var w=0;w>>32-t}function x(e){var t;for(t=0;t<16;t++)p[t]=(255&e[4*t+0])<<0,p[t]|=(255&e[4*t+1])<<8,p[t]|=(255&e[4*t+2])<<16,p[t]|=(255&e[4*t+3])<<24;for(o(p,0,b,0,16),t=8;t>0;t-=2)b[4]^=E(b[0]+b[12],7),b[8]^=E(b[4]+b[0],9),b[12]^=E(b[8]+b[4],13),b[0]^=E(b[12]+b[8],18),b[9]^=E(b[5]+b[1],7),b[13]^=E(b[9]+b[5],9),b[1]^=E(b[13]+b[9],13),b[5]^=E(b[1]+b[13],18),b[14]^=E(b[10]+b[6],7),b[2]^=E(b[14]+b[10],9),b[6]^=E(b[2]+b[14],13),b[10]^=E(b[6]+b[2],18),b[3]^=E(b[15]+b[11],7),b[7]^=E(b[3]+b[15],9),b[11]^=E(b[7]+b[3],13),b[15]^=E(b[11]+b[7],18),b[1]^=E(b[0]+b[3],7),b[2]^=E(b[1]+b[0],9),b[3]^=E(b[2]+b[1],13),b[0]^=E(b[3]+b[2],18),b[6]^=E(b[5]+b[4],7),b[7]^=E(b[6]+b[5],9),b[4]^=E(b[7]+b[6],13),b[5]^=E(b[4]+b[7],18),b[11]^=E(b[10]+b[9],7),b[8]^=E(b[11]+b[10],9),b[9]^=E(b[8]+b[11],13),b[10]^=E(b[9]+b[8],18),b[12]^=E(b[15]+b[14],7),b[13]^=E(b[12]+b[15],9),b[14]^=E(b[13]+b[12],13),b[15]^=E(b[14]+b[13],18);for(t=0;t<16;++t)p[t]=b[t]+p[t];for(t=0;t<16;t++){var r=4*t;e[r+0]=p[t]>>0&255,e[r+1]=p[t]>>8&255,e[r+2]=p[t]>>16&255,e[r+3]=p[t]>>24&255}}function k(e,t,r,n,i){for(var o=0;o=r)throw RangeError(n)}}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":181}],297:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("bip66"),o=n.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),a=n.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(e,t,r){var i=n.from(r?o:a);return e.copy(i,r?8:9),t.copy(i,r?181:214),i},r.privateKeyImport=function(e){var t=e.length,r=0;if(!(t2||t1?e[r+n-2]<<8:0);if(!(t<(r+=n)+i||t32||t1&&0===t[o]&&!(128&t[o+1]);--r,++o);for(var a=n.concat([n.from([0]),e.s]),s=33,u=0;s>1&&0===a[u]&&!(128&a[u+1]);--s,++u);return i.encode(t.slice(o),a.slice(u))},r.signatureImport=function(e){var t=n.alloc(32,0),r=n.alloc(32,0);try{var o=i.decode(e);if(33===o.r.length&&0===o.r[0]&&(o.r=o.r.slice(1)),o.r.length>32)throw new Error("R length is too long");if(33===o.s.length&&0===o.s[0]&&(o.s=o.s.slice(1)),o.s.length>32)throw new Error("S length is too long")}catch(e){return}return o.r.copy(t,32-o.r.length),o.s.copy(r,32-o.s.length),{r:t,s:r}},r.signatureImportLax=function(e){var t=n.alloc(32,0),r=n.alloc(32,0),i=e.length,o=0;if(48===e[o++]){var a=e[o++];if(!(128&a&&(o+=a-128)>i)&&2===e[o++]){var s=e[o++];if(128&s){if(o+(a=s-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(s=0;a>0;o+=1,a-=1)s=(s<<8)+e[o]}if(!(s>i-o)){var u=o;if(o+=s,2===e[o++]){var c=e[o++];if(128&c){if(o+(a=c-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(c=0;a>0;o+=1,a-=1)c=(c<<8)+e[o]}if(!(c>i-o)){var f=o;for(o+=c;s>0&&0===e[u];s-=1,u+=1);if(!(s>32)){var h=e.slice(u,u+s);for(h.copy(t,32-h.length);c>0&&0===e[f];c-=1,f+=1);if(!(c>32)){var l=e.slice(f,f+c);return l.copy(r,32-l.length),{r:t,s:r}}}}}}}}}},{bip66:52,"safe-buffer":290}],298:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("create-hash"),o=e("bn.js"),a=e("elliptic").ec,s=e("../messages.json"),u=new a("secp256k1"),c=u.curve;function f(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new o(t);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),u.keyPair({pub:{x:r,y:n}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new o(t),i=new o(r);if(n.cmp(c.p)>=0||i.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),i=i.toRed(c.red),(6===e||7===e)&&i.isOdd()!==(7===e))return null;var a=n.redSqr().redIMul(n);return i.redSqr().redISub(a.redIAdd(c.b)).isZero()?u.keyPair({pub:{x:n,y:i}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}r.privateKeyVerify=function(e){var t=new o(e);return t.cmp(c.n)<0&&!t.isZero()},r.privateKeyExport=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.privateKeyNegate=function(e){var t=new o(e);return t.isZero()?n.alloc(32):c.n.sub(t).umod(c.n).toArrayLike(n,"be",32)},r.privateKeyModInverse=function(e){var t=new o(e);if(t.cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(c.n).toArrayLike(n,"be",32)},r.privateKeyTweakAdd=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new o(e)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(n,"be",32)},r.privateKeyTweakMul=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new o(e)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(n,"be",32)},r.publicKeyCreate=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.publicKeyConvert=function(e,t){var r=f(e);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return n.from(r.getPublic(t,!0))},r.publicKeyVerify=function(e){return null!==f(e)},r.publicKeyTweakAdd=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return n.from(c.g.mul(t).add(i.pub).encode(!0,r))},r.publicKeyTweakMul=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return n.from(i.pub.mul(t).encode(!0,r))},r.publicKeyCombine=function(e,t){for(var r=new Array(e.length),i=0;i=0||r.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var i=n.from(e);return 1===r.cmp(u.nh)&&c.n.sub(r).toArrayLike(n,"be",32).copy(i,32),i},r.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new o(t).cmp(c.n)>=0||new o(r).cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},r.signatureImport=function(e){var t=new o(e.r);t.cmp(c.n)>=0&&(t=new o(0));var r=new o(e.s);return r.cmp(c.n)>=0&&(r=new o(0)),n.concat([t.toArrayLike(n,"be",32),r.toArrayLike(n,"be",32)])},r.sign=function(e,t,r,i){if("function"==typeof r){var a=r;r=function(r){var u=a(e,t,null,i,r);if(!n.isBuffer(u)||32!==u.length)throw new Error(s.ECDSA_SIGN_FAIL);return new o(u)}}var f=new o(t);if(f.cmp(c.n)>=0||f.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var h=u.sign(e,t,{canonical:!0,k:r,pers:i});return{signature:n.concat([h.r.toArrayLike(n,"be",32),h.s.toArrayLike(n,"be",32)]),recovery:h.recoveryParam}},r.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},i=new o(n.r),a=new o(n.s);if(i.cmp(c.n)>=0||a.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===a.cmp(u.nh)||i.isZero()||a.isZero())return!1;var h=f(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return u.verify(e,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(e,t,r,i){var a={r:t.slice(0,32),s:t.slice(32,64)},f=new o(a.r),h=new o(a.s);if(f.cmp(c.n)>=0||h.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(f.isZero()||h.isZero())throw new Error;var l=u.recoverPubKey(e,a,r);return n.from(l.encode(!0,i))}catch(e){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(e,t){var n=r.ecdhUnsafe(e,t,!0);return i("sha256").update(n).digest()},r.ecdhUnsafe=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var a=new o(t);if(a.cmp(c.n)>=0||a.isZero())throw new Error(s.ECDH_FAIL);return n.from(i.pub.mul(a).encode(!0,r))}},{"../messages.json":300,"bn.js":53,"create-hash":91,elliptic:109,"safe-buffer":290}],299:[function(e,t,r){"use strict";var n=e("./assert"),i=e("./der"),o=e("./messages.json");function a(e,t){return void 0===e?t:(n.isBoolean(e,o.COMPRESSED_TYPE_INVALID),e)}t.exports=function(e){return{privateKeyVerify:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0);var s=e.privateKeyExport(t,r);return i.privateKeyExport(t,s,r)},privateKeyImport:function(t){if(n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),(t=i.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakAdd(t,r,i)},publicKeyTweakMul:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakMul(t,r,i)},publicKeyCombine:function(t,r){n.isArray(t,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(t,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=2&&("function"==typeof arguments[1]?r.task=arguments[1]:r.n=arguments[1]);var n=r.task;if(r.task=function(){n(t.leave)},t.current+r.n-e>t.capacity)return 1===e&&(t.current--,t.firstHere=!1),t.queue.push(r);t.current+=r.n-e,r.task(t.leave),1===e&&(t.firstHere=!1)},leave:function(e){if(e=e||1,t.current-=e,t.queue.length){var r=t.queue[0];r.n+t.current>t.capacity||(t.queue.shift(),t.current+=r.n,i(r.task))}else if(t.current<0)throw new Error("leave called too many times.")},available:function(e){return e=e||1,t.current+e<=t.capacity}};return t}void 0!==e&&e&&"function"==typeof e.nextTick&&(i=e.nextTick),"object"==typeof r?t.exports=o:"function"==typeof define&&define.amd?define(function(){return o}):n.semaphore=o}(this)}).call(this,e("_process"))},{_process:257}],302:[function(e,t,r){"use strict";t.exports="function"==typeof setImmediate?setImmediate:function(){var e=[].slice.apply(arguments);e.splice(1,0,0),setTimeout.apply(null,e)}},{}],303:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t){this._block=n.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}i.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=n.from(e,t));for(var r=this._block,i=this._blockSize,o=e.length,a=this._len,s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},{"safe-buffer":290}],304:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":305,"./sha1":306,"./sha224":307,"./sha256":308,"./sha384":309,"./sha512":310}],305:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((t=n)<<5|t>>>27)+f(d,i,o,s)+u+r[l]+a[d];u=s,s=o,o=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],306:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function h(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=(t=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=c(n)+h(p,i,o,s)+u+r[d]+a[p]|0;u=s,s=o,o=f(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],307:[function(e,t,r){var n=e("inherits"),i=e("./sha256"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}n(u,i),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=u},{"./hash":303,"./sha256":308,inherits:180,"safe-buffer":290}],308:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function l(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(u,i),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,m=0;m<16;++m)r[m]=e.readInt32BE(4*m);for(;m<64;++m)r[m]=0|(((t=r[m-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[m-7]+d(r[m-15])+r[m-16];for(var v=0;v<64;++v){var g=y+l(u)+c(u,p,b)+a[v]+r[v]|0,w=h(n)+f(n,i,o)|0;y=b,b=p,p=u,u=s+g|0,s=o,o=i,i=n,n=g+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},u.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],309:[function(e,t,r){var n=e("inherits"),i=e("./sha512"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}n(u,i),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=u},{"./hash":303,"./sha512":310,inherits:180,"safe-buffer":290}],310:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function l(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function y(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function m(e,t){return e>>>0>>0?1:0}n(u,i),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,s=0|this._eh,u=0|this._fh,v=0|this._gh,g=0|this._hh,w=0|this._al,_=0|this._bl,A=0|this._cl,E=0|this._dl,x=0|this._el,k=0|this._fl,S=0|this._gl,M=0|this._hl,I=0;I<32;I+=2)t[I]=e.readInt32BE(4*I),t[I+1]=e.readInt32BE(4*I+4);for(;I<160;I+=2){var T=t[I-30],U=t[I-30+1],j=d(T,U),B=p(U,T),P=b(T=t[I-4],U=t[I-4+1]),C=y(U,T),N=t[I-14],R=t[I-14+1],L=t[I-32],O=t[I-32+1],D=B+R|0,F=j+N+m(D,B)|0;F=(F=F+P+m(D=D+C|0,C)|0)+L+m(D=D+O|0,O)|0,t[I]=F,t[I+1]=D}for(var q=0;q<160;q+=2){F=t[q],D=t[q+1];var H=f(r,n,i),z=f(w,_,A),K=h(r,w),V=h(w,r),G=l(s,x),W=l(x,s),Y=a[q],X=a[q+1],Z=c(s,u,v),J=c(x,k,S),$=M+W|0,Q=g+G+m($,M)|0;Q=(Q=(Q=Q+Z+m($=$+J|0,J)|0)+Y+m($=$+X|0,X)|0)+F+m($=$+D|0,D)|0;var ee=V+z|0,te=K+H+m(ee,V)|0;g=v,M=S,v=u,S=k,u=s,k=x,s=o+Q+m(x=E+$|0,E)|0,o=i,E=A,i=n,A=_,n=r,_=w,r=Q+te+m(w=$+ee|0,$)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+A|0,this._dl=this._dl+E|0,this._el=this._el+x|0,this._fl=this._fl+k|0,this._gl=this._gl+S|0,this._hl=this._hl+M|0,this._ah=this._ah+r+m(this._al,w)|0,this._bh=this._bh+n+m(this._bl,_)|0,this._ch=this._ch+i+m(this._cl,A)|0,this._dh=this._dh+o+m(this._dl,E)|0,this._eh=this._eh+s+m(this._el,x)|0,this._fh=this._fh+u+m(this._fl,k)|0,this._gh=this._gh+v+m(this._gl,S)|0,this._hh=this._hh+g+m(this._hl,M)|0},u.prototype._hash=function(){var e=o.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],311:[function(e,t,r){t.exports=i;var n=e("events").EventEmitter;function i(){n.call(this)}e("inherits")(i,n),i.Readable=e("readable-stream/readable.js"),i.Writable=e("readable-stream/writable.js"),i.Duplex=e("readable-stream/duplex.js"),i.Transform=e("readable-stream/transform.js"),i.PassThrough=e("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,e.end())}function u(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(f(),0===n.listenerCount(this,"error"))throw e}function f(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),e.removeListener("close",f)}return r.on("error",c),e.on("error",c),r.on("end",f),r.on("close",f),e.on("close",f),e.emit("pipe",r),e}},{events:157,inherits:180,"readable-stream/duplex.js":275,"readable-stream/passthrough.js":284,"readable-stream/readable.js":285,"readable-stream/transform.js":286,"readable-stream/writable.js":287}],312:[function(e,t,r){(function(t){var n=e("./lib/request"),i=e("./lib/response"),o=e("xtend"),a=e("builtin-status-codes"),s=e("url"),u=r;u.request=function(e,r){e="string"==typeof e?s.parse(e):o(e);var i=-1===t.location.protocol.search(/^https?:$/)?"http:":"",a=e.protocol||i,u=e.hostname||e.host,c=e.port,f=e.path||"/";u&&-1!==u.indexOf(":")&&(u="["+u+"]"),e.url=(u?a+"//"+u:"")+(c?":"+c:"")+f,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var h=new n(e);return r&&h.on("response",r),h},u.get=function(e,t){var r=u.request(e,t);return r.end(),r},u.ClientRequest=n,u.IncomingMessage=i,u.Agent=function(){},u.Agent.defaultMaxSockets=4,u.STATUS_CODES=a,u.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/request":314,"./lib/response":315,"builtin-status-codes":85,url:327,xtend:423}],313:[function(e,t,r){(function(e){r.fetch=s(e.fetch)&&s(e.ReadableStream),r.writableStream=s(e.WritableStream),r.abortController=s(e.AbortController),r.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),r.blobConstructor=!0}catch(e){}var t;function n(){if(void 0!==t)return t;if(e.XMLHttpRequest){t=new e.XMLHttpRequest;try{t.open("GET",e.XDomainRequest?"/":"https://example.com")}catch(e){t=null}}else t=null;return t}function i(e){var t=n();if(!t)return!1;try{return t.responseType=e,t.responseType===e}catch(e){}return!1}var o=void 0!==e.ArrayBuffer,a=o&&s(e.ArrayBuffer.prototype.slice);function s(e){return"function"==typeof e}r.arraybuffer=r.fetch||o&&i("arraybuffer"),r.msstream=!r.fetch&&a&&i("ms-stream"),r.mozchunkedarraybuffer=!r.fetch&&o&&i("moz-chunked-arraybuffer"),r.overrideMimeType=r.fetch||!!n()&&s(n().overrideMimeType),r.vbArray=s(e.VBArray),t=null}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],314:[function(e,t,r){(function(r,n,i){var o=e("./capability"),a=e("inherits"),s=e("./response"),u=e("readable-stream"),c=e("to-arraybuffer"),f=s.IncomingMessage,h=s.readyStates;var l=t.exports=function(e){var t,r=this;u.Writable.call(r),r._opts=e,r._body=[],r._headers={},e.auth&&r.setHeader("Authorization","Basic "+new i(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){r.setHeader(t,e.headers[t])});var n=!0;if("disable-fetch"===e.mode||"requestTimeout"in e&&!o.abortController)n=!1,t=!0;else if("prefer-streaming"===e.mode)t=!1;else if("allow-wrong-content-type"===e.mode)t=!o.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");t=!0}r._mode=function(e,t){return o.fetch&&t?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&e?"arraybuffer":o.vbArray&&e?"text:vbarray":"text"}(t,n),r.on("finish",function(){r._onFinish()})};a(l,u.Writable),l.prototype.setHeader=function(e,t){var r=e.toLowerCase();-1===d.indexOf(r)&&(this._headers[r]={name:e,value:t})},l.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},l.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},l.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,a=e._headers,s=null;"GET"!==t.method&&"HEAD"!==t.method&&(s=o.arraybuffer?c(i.concat(e._body)):o.blobConstructor?new n.Blob(e._body.map(function(e){return c(e)}),{type:(a["content-type"]||{}).value||""}):i.concat(e._body).toString());var u=[];if(Object.keys(a).forEach(function(e){var t=a[e].name,r=a[e].value;Array.isArray(r)?r.forEach(function(e){u.push([t,e])}):u.push([t,r])}),"fetch"===e._mode){var f=null;if(o.abortController){var l=new AbortController;f=l.signal,e._fetchAbortController=l,"requestTimeout"in t&&0!==t.requestTimeout&&n.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},t.requestTimeout)}n.fetch(e._opts.url,{method:e._opts.method,headers:u,body:s||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin",signal:f}).then(function(t){e._fetchResponse=t,e._connect()},function(t){e.emit("error",t)})}else{var d=e._xhr=new n.XMLHttpRequest;try{d.open(e._opts.method,e._opts.url,!0)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}"responseType"in d&&(d.responseType=e._mode.split(":")[0]),"withCredentials"in d&&(d.withCredentials=!!t.withCredentials),"text"===e._mode&&"overrideMimeType"in d&&d.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in t&&(d.timeout=t.requestTimeout,d.ontimeout=function(){e.emit("requestTimeout")}),u.forEach(function(e){d.setRequestHeader(e[0],e[1])}),e._response=null,d.onreadystatechange=function(){switch(d.readyState){case h.LOADING:case h.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(d.onprogress=function(){e._onXHRProgress()}),d.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{d.send(s)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}}}},l.prototype._onXHRProgress=function(){(function(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}})(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},l.prototype._connect=function(){var e=this;e._destroyed||(e._response=new f(e._xhr,e._fetchResponse,e._mode),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},l.prototype._write=function(e,t,r){this._body.push(e),r()},l.prototype.abort=l.prototype.destroy=function(){this._destroyed=!0,this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},l.prototype.end=function(e,t,r){"function"==typeof e&&(r=e,e=void 0),u.Writable.prototype.end.call(this,e,t,r)},l.prototype.flushHeaders=function(){},l.prototype.setTimeout=function(){},l.prototype.setNoDelay=function(){},l.prototype.setSocketKeepAlive=function(){};var d=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referrer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,"./response":315,_process:257,buffer:84,inherits:180,"readable-stream":285,"to-arraybuffer":323}],315:[function(e,t,r){(function(t,n,i){var o=e("./capability"),a=e("inherits"),s=e("readable-stream"),u=r.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},c=r.IncomingMessage=function(e,r,n){var a=this;if(s.Readable.call(a),a._mode=n,a.headers={},a.rawHeaders=[],a.trailers={},a.rawTrailers=[],a.on("end",function(){t.nextTick(function(){a.emit("close")})}),"fetch"===n){if(a._fetchResponse=r,a.url=r.url,a.statusCode=r.status,a.statusMessage=r.statusText,r.headers.forEach(function(e,t){a.headers[t.toLowerCase()]=e,a.rawHeaders.push(t,e)}),o.writableStream){var u=new WritableStream({write:function(e){return new Promise(function(t,r){a._destroyed||(a.push(new i(e))?t():a._resumeFetch=t)})},close:function(){a._destroyed||a.push(null)},abort:function(e){a._destroyed||a.emit("error",e)}});try{return void r.body.pipeTo(u)}catch(e){}}var c=r.body.getReader();!function e(){c.read().then(function(t){a._destroyed||(t.done?a.push(null):(a.push(new i(t.value)),e()))}).catch(function(e){a._destroyed||a.emit("error",e)})}()}else{if(a._xhr=e,a._pos=0,a.url=e.responseURL,a.statusCode=e.status,a.statusMessage=e.statusText,e.getAllResponseHeaders().split(/\r?\n/).forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var r=t[1].toLowerCase();"set-cookie"===r?(void 0===a.headers[r]&&(a.headers[r]=[]),a.headers[r].push(t[2])):void 0!==a.headers[r]?a.headers[r]+=", "+t[2]:a.headers[r]=t[2],a.rawHeaders.push(t[1],t[2])}}),a._charset="x-user-defined",!o.overrideMimeType){var f=a.rawHeaders["mime-type"];if(f){var h=f.match(/;\s*charset=([^;])(;|$)/);h&&(a._charset=h[1].toLowerCase())}a._charset||(a._charset="utf-8")}}};a(c,s.Readable),c.prototype._read=function(){var e=this._resumeFetch;e&&(this._resumeFetch=null,e())},c.prototype._onXHRProgress=function(){var e=this,t=e._xhr,r=null;switch(e._mode){case"text:vbarray":if(t.readyState!==u.DONE)break;try{r=new n.VBArray(t.responseBody).toArray()}catch(e){}if(null!==r){e.push(new i(r));break}case"text":try{r=t.responseText}catch(t){e._mode="text:vbarray";break}if(r.length>e._pos){var o=r.substr(e._pos);if("x-user-defined"===e._charset){for(var a=new i(o.length),s=0;se._pos&&(e.push(new i(new Uint8Array(c.result.slice(e._pos)))),e._pos=c.result.byteLength)},c.onload=function(){e.push(null)},c.readAsArrayBuffer(r)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,_process:257,buffer:84,inherits:180,"readable-stream":285}],316:[function(e,t,r){"use strict";t.exports=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}},{}],317:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=f,this.end=h,t=3;break;default:return this.write=l,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:-1}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�".repeat(r);if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�".repeat(r+1);if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�".repeat(r+2)}}(this,e,t);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function l(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}r.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":290}],318:[function(e,t,r){var n=e("is-hex-prefixed");t.exports=function(e){return"string"!=typeof e?e:n(e)?e.slice(2):e}},{"is-hex-prefixed":185}],319:[function(e,t,r){var n=function(){throw"This swarm.js function isn't available on the browser."},i={readFile:n},o={download:n,safeDownloadArchived:n,directoryTree:n},a={platform:n,arch:n},s={join:n,slice:n},u={spawn:n},c={lookup:n},f=e("xhr-request-promise"),h=e("eth-lib/lib/bytes"),l=e("./swarm-hash.js"),d=e("./pick.js"),p=e("./swarm");t.exports=p({fsp:i,files:o,os:a,path:s,child_process:u,defaultArchives:{},mimetype:c,request:f,downloadUrl:null,bytes:h,hash:l,pick:d})},{"./pick.js":320,"./swarm":322,"./swarm-hash.js":321,"eth-lib/lib/bytes":133,"xhr-request-promise":411}],320:[function(e,t,r){var n=function(e){return function(){return new Promise(function(t,r){var n=function(r){var n={},i=r.target.files.length,o=0;[].map.call(r.target.files,function(r){var a=new FileReader;a.onload=function(a){var s=new Uint8Array(a.target.result);if("directory"===e){var u=r.webkitRelativePath;n[u.slice(u.indexOf("/")+1)]={type:"text/plain",data:s},++o===i&&t(n)}else if("file"===e){var c=r.webkitRelativePath;t({type:mimetype.lookup(c),data:s})}else t(s)},a.readAsArrayBuffer(r)})},i=void 0;"directory"===e?((i=document.createElement("input")).addEventListener("change",n),i.type="file",i.webkitdirectory=!0,i.mozdirectory=!0,i.msdirectory=!0,i.odirectory=!0,i.directory=!0):((i=document.createElement("input")).addEventListener("change",n),i.type="file");var o=document.createEvent("MouseEvents");o.initEvent("click",!0,!1),i.dispatchEvent(o)})}};t.exports={data:n("data"),file:n("file"),directory:n("directory")}},{}],321:[function(e,t,r){var n=e("eth-lib/lib/hash").keccak256,i=e("eth-lib/lib/bytes"),o=function(e,t){var r=i.reverse(i.pad(6,i.fromNumber(e))),o=i.flatten([r,"0x0000",t]);return n(o).slice(2)};t.exports=function e(t){"string"==typeof t&&"0x"!==t.slice(0,2)?t=i.fromString(t):"string"!=typeof t&&void 0!==t.length&&(t=i.fromUint8Array(t));var r=i.length(t);if(r<=4096)return o(r,t);for(var n=4096;128*n0){var a=i.join(r,o);n.push(g(e)(t[o])(a))}return Promise.all(n).then(function(){return r})})}}},_=function(e){return function(t){return u(e+"/bzzr:/",{body:"string"==typeof t?L(t):t,method:"POST"})}},A=function(e){return function(t){return function(r){return function(n){return function i(o){var a="/"===r[0]?r:"/"+r,s=e+"/bzz:/"+t+a,c={method:"PUT",headers:{"Content-Type":n.type},body:n.data};return u(s,c).then(function(e){if(-1!==e.indexOf("error"))throw e;return e}).catch(function(e){return o>0&&i(o-1)})}(3)}}}},E=function(e){return function(t){return k(e)({"":t})}},x=function(e){return function(r){return t.readFile(r).then(function(t){return E(e)({type:a.lookup(r),data:t})})}},k=function(e){return function(t){return _(e)("{}").then(function(r){return Object.keys(t).reduce(function(r,n){return r.then(function(r){return function(n){return A(e)(n)(r)(t[r])}}(n))},Promise.resolve(r))})}},S=function(e){return function(r){return t.readFile(r).then(_(e))}},M=function(e){return function(n){return function(i){return r.directoryTree(i).then(function(e){return Promise.all(e.map(function(e){return t.readFile(e)})).then(function(t){var r=e.map(function(e){return e.slice(i.length)}),n=e.map(function(e){return a.lookup(e)||"text/plain"});return d(r)(t.map(function(e,t){return{type:n[t],data:e}}))})}).then(function(e){return(t=n?{"":e[n]}:{},function(e){var r={};for(var n in t)r[n]=t[n];for(var i in e)r[i]=e[i];return r})(e);var t}).then(k(e))}}},I=function(e){return function(t){if("data"===t.pick)return l.data().then(_(e));if("file"===t.pick)return l.file().then(E(e));if("directory"===t.pick)return l.directory().then(k(e));if(t.path)switch(t.kind){case"data":return S(e)(t.path);case"file":return x(e)(t.path);case"directory":return M(e)(t.defaultFile)(t.path)}else{if(t.length||"string"==typeof t)return _(e)(t);if(t instanceof Object)return k(e)(t)}return Promise.reject(new Error("Bad arguments"))}},T=function(e){return function(t){return function(r){return C(e)(t).then(function(n){return n?r?w(e)(t)(r):v(e)(t):r?g(e)(t)(r):b(e)(t)})}}},U=function(e,t){var i=n.platform().replace("win32","windows")+"-"+("x64"===n.arch()?"amd64":"386"),o=(t||s)[i],a=c+o.archive+".tar.gz",u=o.archiveMD5,f=o.binaryMD5;return r.safeDownloadArchived(a)(u)(f)(e)},j=function(e){return new Promise(function(t,r){var n=o.spawn,i=function(e){return function(t){return-1!==(""+t).indexOf(e)}},a=e.account,s=e.password,u=e.dataDir,c=e.ensApi,f=e.privateKey,h=0,l=n(e.binPath,["--bzzaccount",a||f,"--datadir",u,"--ens-api",c]),d=function(e){0===h&&i("Passphrase")(e)?setTimeout(function(){h=1,l.stdin.write(s+"\n")},500):i("Swarm http proxy started")(e)&&(h=2,clearTimeout(p),t(l))};l.stdout.on("data",d),l.stderr.on("data",d);var p=setTimeout(function(){return r(new Error("Couldn't start swarm process."))},2e4)})},B=function(e){return new Promise(function(t,r){e.stderr.removeAllListeners("data"),e.stdout.removeAllListeners("data"),e.stdin.removeAllListeners("error"),e.removeAllListeners("error"),e.removeAllListeners("exit"),e.kill("SIGINT");var n=setTimeout(function(){return e.kill("SIGKILL")},8e3);e.once("close",function(){clearTimeout(n),t()})})},P=function(e){return _(e)("test").then(function(e){return"c9a99c7d326dcc6316f32fe2625b311f6dc49a175e6877681ded93137d3569e7"===e}).catch(function(){return!1})},C=function(e){return function(t){return b(e)(t).then(function(e){try{return!!JSON.parse(R(e)).entries}catch(e){return!1}})}},N=function(e){return function(t,r,n,i,o){var a;return void 0!==t&&(a=e(t)),void 0!==r&&(a=e(r)),void 0!==n&&(a=e(n)),void 0!==i&&(a=e(i)),void 0!==o&&(a=e(o)),a}},R=function(e){return f.toString(f.fromUint8Array(e))},L=function(e){return f.toUint8Array(f.fromString(e))},O=function(e){return{download:function(t,r){return T(e)(t)(r)},downloadData:N(b(e)),downloadDataToDisk:N(g(e)),downloadDirectory:N(v(e)),downloadDirectoryToDisk:N(w(e)),downloadEntries:N(y(e)),downloadRoutes:N(m(e)),isAvailable:function(){return P(e)},upload:function(t){return I(e)(t)},uploadData:N(_(e)),uploadFile:N(E(e)),uploadFileFromDisk:N(E(e)),uploadDataFromDisk:N(S(e)),uploadDirectory:N(k(e)),uploadDirectoryFromDisk:N(M(e)),uploadToManifest:N(A(e)),pick:l,hash:h,fromString:L,toString:R}};return{at:O,local:function(e){return function(t){return P("http://localhost:8500").then(function(r){return r?t(O("http://localhost:8500")).then(function(){}):U(e.binPath,e.archives).onData(function(t){return(e.onProgress||function(){})(t.length)}).then(function(){return j(e)}).then(function(e){return t(O("http://localhost:8500")).then(function(){return e})}).then(B)})}},download:T,downloadBinary:U,downloadData:b,downloadDataToDisk:g,downloadDirectory:v,downloadDirectoryToDisk:w,downloadEntries:y,downloadRoutes:m,isAvailable:P,startProcess:j,stopProcess:B,upload:I,uploadData:_,uploadDataFromDisk:S,uploadFile:E,uploadFileFromDisk:x,uploadDirectory:k,uploadDirectoryFromDisk:M,uploadToManifest:A,pick:l,hash:h,fromString:L,toString:R}}},{}],323:[function(e,t,r){var n=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(n.isBuffer(e)){for(var t=new Uint8Array(e.length),r=e.length,i=0;i=0&&t<=A};function k(e){return function(t,r,n,i){r=m(r,i,4);var o=!x(t)&&y.keys(t),a=(o||t).length,s=e>0?0:a-1;return arguments.length<3&&(n=t[o?o[s]:s],s+=e),function(t,r,n,i,o,a){for(;o>=0&&o=0},y.invoke=function(e,t){var r=u.call(arguments,2),n=y.isFunction(t);return y.map(e,function(e){var i=n?t:e[t];return null==i?i:i.apply(e,r)})},y.pluck=function(e,t){return y.map(e,y.property(t))},y.where=function(e,t){return y.filter(e,y.matcher(t))},y.findWhere=function(e,t){return y.find(e,y.matcher(t))},y.max=function(e,t,r){var n,i,o=-1/0,a=-1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;so&&(o=n);else t=v(t,r),y.each(e,function(e,r,n){((i=t(e,r,n))>a||i===-1/0&&o===-1/0)&&(o=e,a=i)});return o},y.min=function(e,t,r){var n,i,o=1/0,a=1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;sn||void 0===r)return 1;if(r0?0:i-1;o>=0&&o0?a=o>=0?o:Math.max(o+s,a):s=o>=0?Math.min(o+1,s):o+s+1;else if(r&&o&&s)return n[o=r(n,i)]===i?o:-1;if(i!=i)return(o=t(u.call(n,a,s),y.isNaN))>=0?o+a:-1;for(o=e>0?a:s-1;o>=0&&ot?(a&&(clearTimeout(a),a=null),s=c,o=e.apply(n,i),a||(n=i=null)):a||!1===r.trailing||(a=setTimeout(u,f)),o}},y.debounce=function(e,t,r){var n,i,o,a,s,u=function(){var c=y.now()-a;c=0?n=setTimeout(u,t-c):(n=null,r||(s=e.apply(o,i),n||(o=i=null)))};return function(){o=this,i=arguments,a=y.now();var c=r&&!n;return n||(n=setTimeout(u,t)),c&&(s=e.apply(o,i),o=i=null),s}},y.wrap=function(e,t){return y.partial(t,e)},y.negate=function(e){return function(){return!e.apply(this,arguments)}},y.compose=function(){var e=arguments,t=e.length-1;return function(){for(var r=t,n=e[t].apply(this,arguments);r--;)n=e[r].call(this,n);return n}},y.after=function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},y.before=function(e,t){var r;return function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=null),r}},y.once=y.partial(y.before,2);var j=!{toString:null}.propertyIsEnumerable("toString"),B=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];function P(e,t){var r=B.length,n=e.constructor,i=y.isFunction(n)&&n.prototype||o,a="constructor";for(y.has(e,a)&&!y.contains(t,a)&&t.push(a);r--;)(a=B[r])in e&&e[a]!==i[a]&&!y.contains(t,a)&&t.push(a)}y.keys=function(e){if(!y.isObject(e))return[];if(l)return l(e);var t=[];for(var r in e)y.has(e,r)&&t.push(r);return j&&P(e,t),t},y.allKeys=function(e){if(!y.isObject(e))return[];var t=[];for(var r in e)t.push(r);return j&&P(e,t),t},y.values=function(e){for(var t=y.keys(e),r=t.length,n=Array(r),i=0;i":">",'"':""","'":"'","`":"`"},R=y.invert(N),L=function(e){var t=function(t){return e[t]},r="(?:"+y.keys(e).join("|")+")",n=RegExp(r),i=RegExp(r,"g");return function(e){return e=null==e?"":""+e,n.test(e)?e.replace(i,t):e}};y.escape=L(N),y.unescape=L(R),y.result=function(e,t,r){var n=null==e?void 0:e[t];return void 0===n&&(n=r),y.isFunction(n)?n.call(e):n};var O=0;y.uniqueId=function(e){var t=++O+"";return e?e+t:t},y.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var D=/(.)^/,F={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},q=/\\|'|\r|\n|\u2028|\u2029/g,H=function(e){return"\\"+F[e]};y.template=function(e,t,r){!t&&r&&(t=r),t=y.defaults({},t,y.templateSettings);var n=RegExp([(t.escape||D).source,(t.interpolate||D).source,(t.evaluate||D).source].join("|")+"|$","g"),i=0,o="__p+='";e.replace(n,function(t,r,n,a,s){return o+=e.slice(i,s).replace(q,H),i=s+t.length,r?o+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":n?o+="'+\n((__t=("+n+"))==null?'':__t)+\n'":a&&(o+="';\n"+a+"\n__p+='"),t}),o+="';\n",t.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{var a=new Function(t.variable||"obj","_",o)}catch(e){throw e.source=o,e}var s=function(e){return a.call(this,e,y)},u=t.variable||"obj";return s.source="function("+u+"){\n"+o+"}",s},y.chain=function(e){var t=y(e);return t._chain=!0,t};var z=function(e,t){return e._chain?y(t).chain():t};y.mixin=function(e){y.each(y.functions(e),function(t){var r=y[t]=e[t];y.prototype[t]=function(){var e=[this._wrapped];return s.apply(e,arguments),z(this,r.apply(y,e))}})},y.mixin(y),y.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=i[e];y.prototype[e]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==e&&"splice"!==e||0!==r.length||delete r[0],z(this,r)}}),y.each(["concat","join","slice"],function(e){var t=i[e];y.prototype[e]=function(){return z(this,t.apply(this._wrapped,arguments))}}),y.prototype.value=function(){return this._wrapped},y.prototype.valueOf=y.prototype.toJSON=y.prototype.value,y.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return y})}).call(this)},{}],326:[function(e,t,r){t.exports=function(e,t){if(t){t=(t=t.trim().replace(/^(\?|#|&)/,""))?"?"+t:t;var r=e.split(/[\?\#]/),n=r[0];t&&/\:\/\/[^\/]*$/.test(n)&&(n+="/");var i=e.match(/(\#.*)$/);e=n+t,i&&(e+=i[0])}return e}},{}],327:[function(e,t,r){"use strict";var n=e("punycode"),i=e("./util");function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}r.parse=g,r.resolve=function(e,t){return g(e,!1,!0).resolve(t)},r.resolveObject=function(e,t){return e?g(e,!1,!0).resolveObject(t):t},r.format=function(e){i.isString(e)&&(e=g(e));return e instanceof o?e.format():o.prototype.format.call(e)},r.Url=o;var a=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=e("querystring");function g(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o127?P+="x":P+=B[C];if(!P.match(d)){var R=U.slice(0,M),L=U.slice(M+1),O=B.match(p);O&&(R.push(O[1]),L.unshift(O[2])),L.length&&(g="/"+L.join(".")+g),this.hostname=R.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),T||(this.hostname=n.toASCII(this.hostname));var D=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+D,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==g[0]&&(g="/"+g))}if(!b[A])for(M=0,j=f.length;M0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift());return r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!E.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var k=E.slice(-1)[0],S=(r.host||e.host||E.length>1)&&("."===k||".."===k)||""===k,M=0,I=E.length;I>=0;I--)"."===(k=E[I])?E.splice(I,1):".."===k?(E.splice(I,1),M++):M&&(E.splice(I,1),M--);if(!_&&!A)for(;M--;M)E.unshift("..");!_||""===E[0]||E[0]&&"/"===E[0].charAt(0)||E.unshift(""),S&&"/"!==E.join("/").substr(-1)&&E.push("");var T,U=""===E[0]||E[0]&&"/"===E[0].charAt(0);x&&(r.hostname=r.host=U?"":E.length?E.shift():"",(T=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift()));return(_=_||r.host&&E.length)&&!U&&E.unshift(""),E.length?r.pathname=E.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":328,punycode:265,querystring:269}],328:[function(e,t,r){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],329:[function(e,t,r){(function(e){!function(n){var i="object"==typeof r&&r,o="object"==typeof t&&t&&t.exports==i&&t,a="object"==typeof e&&e;a.global!==a&&a.window!==a||(n=a);var s,u,c,f=String.fromCharCode;function h(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i=55296&&e<=57343)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value")}function d(e,t){return f(e>>t&63|128)}function p(e){if(0==(4294967168&e))return f(e);var t="";return 0==(4294965248&e)?t=f(e>>6&31|192):0==(4294901760&e)?(l(e),t=f(e>>12&15|224),t+=d(e,6)):0==(4292870144&e)&&(t=f(e>>18&7|240),t+=d(e,12),t+=d(e,6)),t+=f(63&e|128)}function b(){if(c>=u)throw Error("Invalid byte index");var e=255&s[c];if(c++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function y(){var e,t;if(c>u)throw Error("Invalid byte index");if(c==u)return!1;if(e=255&s[c],c++,0==(128&e))return e;if(192==(224&e)){if((t=(31&e)<<6|b())>=128)return t;throw Error("Invalid continuation byte")}if(224==(240&e)){if((t=(15&e)<<12|b()<<6|b())>=2048)return l(t),t;throw Error("Invalid continuation byte")}if(240==(248&e)&&(t=(15&e)<<18|b()<<12|b()<<6|b())>=65536&&t<=1114111)return t;throw Error("Invalid UTF-8 detected")}var m={version:"2.0.0",encode:function(e){for(var t=h(e),r=t.length,n=-1,i="";++n65535&&(i+=f((t-=65536)>>>10&1023|55296),t=56320|1023&t),i+=f(t);return i}(r)}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return m});else if(i&&!i.nodeType)if(o)o.exports=m;else{var v={}.hasOwnProperty;for(var g in m)v.call(m,g)&&(i[g]=m[g])}else n.utf8=m}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],330:[function(e,t,r){(function(e){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],331:[function(e,t,r){arguments[4][180][0].apply(r,arguments)},{dup:180}],332:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],333:[function(e,t,r){(function(t,n){var i=/%[sdj%]/g;r.format=function(e){if(!m(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(t)?n.showHidden=t:t&&r._extend(n,t),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,e,n.depth)}function u(e,t){var r=s.styles[t];return r?"["+s.colors[r][0]+"m"+e+"["+s.colors[r][1]+"m":e}function c(e,t){return e}function f(e,t,n){if(e.customInspect&&t&&E(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return m(i)||(i=f(e,i,n)),i}var o=function(e,t){if(v(t))return e.stylize("undefined","undefined");if(m(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(y(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(b(t))return e.stylize("null","null")}(e,t);if(o)return o;var a=Object.keys(t),s=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),A(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return h(t);if(0===a.length){if(E(t)){var u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","special")}if(g(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(_(t))return e.stylize(Date.prototype.toString.call(t),"date");if(A(t))return h(t)}var c,w="",x=!1,k=["{","}"];(d(t)&&(x=!0,k=["[","]"]),E(t))&&(w=" [Function"+(t.name?": "+t.name:"")+"]");return g(t)&&(w=" "+RegExp.prototype.toString.call(t)),_(t)&&(w=" "+Date.prototype.toUTCString.call(t)),A(t)&&(w=" "+h(t)),0!==a.length||x&&0!=t.length?n<0?g(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=x?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(c,w,k)):k[0]+w+k[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),M(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=b(r)?f(e,u.value,null):f(e,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n")):s=e.stylize("[Circular]","special")),v(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function b(e){return null===e}function y(e){return"number"==typeof e}function m(e){return"string"==typeof e}function v(e){return void 0===e}function g(e){return w(e)&&"[object RegExp]"===x(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===x(e)}function A(e){return w(e)&&("[object Error]"===x(e)||e instanceof Error)}function E(e){return"function"==typeof e}function x(e){return Object.prototype.toString.call(e)}function k(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(v(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=t.pid;a[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else a[e]=function(){};return a[e]},r.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(e){return null==e},r.isNumber=y,r.isString=m,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=v,r.isRegExp=g,r.isObject=w,r.isDate=_,r.isError=A,r.isFunction=E,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[k(e.getHours()),k(e.getMinutes()),k(e.getSeconds())].join(":"),[e.getDate(),S[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":332,_process:257,inherits:331}],334:[function(require,module,exports){var indexOf=require("indexof"),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},c.prototype.getCall=function(e){return n.isFunction(this.call)?this.call(e):this.call},c.prototype.extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},c.prototype.validateArgs=function(e){if(e.length!==this.params)throw i.InvalidNumberOfParams(e.length,this.params,this.name)},c.prototype.formatInput=function(e){var t=this;return this.inputFormatter?this.inputFormatter.map(function(r,n){return r?r.call(t,e[n]):e[n]}):e},c.prototype.formatOutput=function(e){var t=this;return n.isArray(e)?e.map(function(e){return t.outputFormatter&&e?t.outputFormatter(e):e}):this.outputFormatter&&e?this.outputFormatter(e):e},c.prototype.toPayload=function(e){var t=this.getCall(e),r=this.extractCallback(e),n=this.formatInput(e);this.validateArgs(n);var i={method:t,params:n,callback:r};return this.transformPayload&&(i=this.transformPayload(i)),i},c.prototype._confirmTransaction=function(e,t,r){var i=this,f=!1,h=!0,l=0,d=0,p=null,b="",y=n.isObject(r.params[0])&&r.params[0].gas?r.params[0].gas:null,m=n.isObject(r.params[0])&&r.params[0].data&&r.params[0].from&&!r.params[0].to,v=[new c({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:o.outputTransactionReceiptFormatter}),new c({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[o.inputAddressFormatter,o.inputDefaultBlockNumberFormatter]}),new u({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:o.outputBlockFormatter}}})],g={};n.each(v,function(e){e.attachToObject(g),e.requestManager=i.requestManager});var w=function(r,n,o,u,c){if(!o)return c||(c={unsubscribe:function(){clearInterval(p)}}),(r?s.resolve(r):g.getTransactionReceipt(t)).catch(function(t){c.unsubscribe(),f=!0,a._fireError({message:"Failed to check for transaction receipt:",data:t},e.eventEmitter,e.reject)}).then(function(t){if(!t||!t.blockHash)throw new Error("Receipt missing or blockHash null");return i.extraFormatters&&i.extraFormatters.receiptFormatter&&(t=i.extraFormatters.receiptFormatter(t)),e.eventEmitter.listeners("confirmation").length>0&&(void 0!==r&&0===d||e.eventEmitter.emit("confirmation",d,t),h=!1,25===++d&&(c.unsubscribe(),e.eventEmitter.removeAllListeners())),t}).then(function(t){if(m&&!f){if(!t.contractAddress)return h&&(c.unsubscribe(),f=!0),void a._fireError(new Error("The transaction receipt didn't contain a contract address."),e.eventEmitter,e.reject);g.getCode(t.contractAddress,function(r,n){n&&(n.length>2?(e.eventEmitter.emit("receipt",t),i.extraFormatters&&i.extraFormatters.contractDeployFormatter?e.resolve(i.extraFormatters.contractDeployFormatter(t)):e.resolve(t),h&&e.eventEmitter.removeAllListeners()):a._fireError(new Error("The contract code couldn't be stored, please check your gas limit."),e.eventEmitter,e.reject),h&&c.unsubscribe(),f=!0)})}return t}).then(function(t){m||f||(t.outOfGas||y&&y===t.gasUsed||!0!==t.status&&"0x1"!==t.status&&void 0!==t.status?(b=JSON.stringify(t,null,2),!1===t.status||"0x0"===t.status?a._fireError(new Error("Transaction has been reverted by the EVM:\n"+b),e.eventEmitter,e.reject):a._fireError(new Error("Transaction ran out of gas. Please provide more gas:\n"+b),e.eventEmitter,e.reject)):(e.eventEmitter.emit("receipt",t),e.resolve(t),h&&e.eventEmitter.removeAllListeners()),h&&c.unsubscribe(),f=!0)}).catch(function(){l++,n?l-1>=750&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject)):l-1>=50&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject))});c.unsubscribe(),f=!0,a._fireError({message:"Failed to subscribe to new newBlockHeaders to confirm the transaction receipts.",data:o},e.eventEmitter,e.reject)},_=function(e){n.isFunction(this.requestManager.provider.on)?g.subscribe("newBlockHeaders",w.bind(null,e,!1)):p=setInterval(w.bind(null,e,!0),1e3)}.bind(this);g.getTransactionReceipt(t).then(function(t){t&&t.blockHash?(e.eventEmitter.listeners("confirmation").length>0&&_(t),w(t,!1)):f||_()}).catch(function(){f||_()})};var f=function(e,t){return n.isNumber(e)?t.wallet[e]:n.isObject(e)&&e.address&&e.privateKey?e:t.wallet[e.toLowerCase()]};c.prototype.buildCall=function(){var e=this,t="eth_sendTransaction"===e.call||"eth_sendRawTransaction"===e.call,r=function(){var r=s(!t),i=e.toPayload(Array.prototype.slice.call(arguments)),o=function(n,o){try{o=e.formatOutput(o)}catch(e){n=e}if(o instanceof Error&&(n=o),n)return n.error&&(n=n.error),a._fireError(n,r.eventEmitter,r.reject,i.callback);i.callback&&i.callback(null,o),t?(r.eventEmitter.emit("transactionHash",o),e._confirmTransaction(r,o,i)):n||r.resolve(o)},u=function(t){var r=n.extend({},i,{method:"eth_sendRawTransaction",params:[t.rawTransaction]});e.requestManager.send(r,o)},h=function(e,t){var i;if(t&&t.accounts&&t.accounts.wallet&&t.accounts.wallet.length)if("eth_sendTransaction"===e.method){var a=e.params[0];if((i=f(n.isObject(a)?a.from:null,t.accounts))&&i.privateKey)return t.accounts.signTransaction(n.omit(a,"from"),i.privateKey).then(u)}else if("eth_sign"===e.method){var s=e.params[1];if((i=f(e.params[0],t.accounts))&&i.privateKey){var c=t.accounts.sign(s,i.privateKey);return e.callback&&e.callback(null,c.signature),void r.resolve(c.signature)}}return t.requestManager.send(e,o)};t&&n.isObject(i.params[0])&&void 0===i.params[0].gasPrice?new c({name:"getGasPrice",call:"eth_gasPrice",params:0}).createFunction(e.requestManager)(function(t,r){r&&(i.params[0].gasPrice=r),h(i,e)}):h(i,e);return r.eventEmitter};return r.method=e,r.request=this.request.bind(this),r},c.prototype.request=function(){var e=this.toPayload(Array.prototype.slice.call(arguments));return e.format=this.formatOutput.bind(this),e},t.exports=c},{underscore:325,"web3-core-helpers":338,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-utils":403}],340:[function(e,t,r){"use strict";var n=e("eventemitter3"),i=e("any-promise"),o=function(e){var t,r,o=new i(function(){t=arguments[0],r=arguments[1]});if(e)return{resolve:t,reject:r,eventEmitter:o};var a=new n;return o._events=a._events,o.emit=a.emit,o.on=a.on,o.once=a.once,o.off=a.off,o.listeners=a.listeners,o.addListener=a.addListener,o.removeListener=a.removeListener,o.removeAllListeners=a.removeAllListeners,{resolve:t,reject:r,eventEmitter:o}};o.resolve=function(e){var t=o(!0);return t.resolve(e),t.eventEmitter},t.exports=o},{"any-promise":2,eventemitter3:156}],341:[function(e,t,r){"use strict";var n=e("./jsonrpc"),i=e("web3-core-helpers").errors,o=function(e){this.requestManager=e,this.requests=[]};o.prototype.add=function(e){this.requests.push(e)},o.prototype.execute=function(){var e=this.requests;this.requestManager.sendBatch(e,function(t,r){r=r||[],e.map(function(e,t){return r[t]||{}}).forEach(function(t,r){if(e[r].callback){if(t&&t.error)return e[r].callback(i.ErrorResponse(t));if(!n.isValidResponse(t))return e[r].callback(i.InvalidResponse(t));try{e[r].callback(null,e[r].format?e[r].format(t.result):t.result)}catch(t){e[r].callback(t)}}})})},t.exports=o},{"./jsonrpc":344,"web3-core-helpers":338}],342:[function(e,t,r){"use strict";var n=null,i=window;void 0!==i.ethereumProvider?n=i.ethereumProvider:void 0!==i.web3&&i.web3.currentProvider&&(i.web3.currentProvider.sendAsync&&(i.web3.currentProvider.send=i.web3.currentProvider.sendAsync,delete i.web3.currentProvider.sendAsync),!i.web3.currentProvider.on&&i.web3.currentProvider.connection&&"ipcProviderWrapper"===i.web3.currentProvider.connection.constructor.name&&(i.web3.currentProvider.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.connection.on("data",function(e){var r="";e=e.toString();try{r=JSON.parse(e)}catch(r){return t(new Error("Couldn't parse response data"+e))}r.id||-1===r.method.indexOf("_subscription")||t(null,r)});break;default:this.connection.on(e,t)}}),n=i.web3.currentProvider),t.exports=n},{}],343:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("./jsonrpc.js"),a=e("./batch.js"),s=e("./givenProvider.js"),u=function e(t){this.provider=null,this.providers=e.providers,this.setProvider(t),this.subscriptions={}};u.givenProvider=s,u.providers={WebsocketProvider:e("web3-providers-ws"),HttpProvider:e("web3-providers-http"),IpcProvider:e("web3-providers-ipc")},u.prototype.setProvider=function(e,t){var r=this;if(e&&"string"==typeof e&&this.providers)if(/^http(s)?:\/\//i.test(e))e=new this.providers.HttpProvider(e);else if(/^ws(s)?:\/\//i.test(e))e=new this.providers.WebsocketProvider(e);else if(e&&"object"==typeof t&&"function"==typeof t.connect)e=new this.providers.IpcProvider(e,t);else if(e)throw new Error("Can't autodetect provider for \""+e+'"');this.provider&&this.provider.connected&&this.clearSubscriptions(),this.provider=e||null,this.provider&&this.provider.on&&this.provider.on("data",function(e,t){(e=e||t).method&&r.subscriptions[e.params.subscription]&&r.subscriptions[e.params.subscription].callback&&r.subscriptions[e.params.subscription].callback(null,e.params.result)})},u.prototype.send=function(e,t){if(t=t||function(){},!this.provider)return t(i.InvalidProvider());var r=o.toPayload(e.method,e.params);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,n){return n&&n.id&&r.id!==n.id?t(new Error('Wrong response id "'+n.id+'" (expected: "'+r.id+'") in '+JSON.stringify(r))):e?t(e):n&&n.error?t(i.ErrorResponse(n)):o.isValidResponse(n)?void t(null,n.result):t(i.InvalidResponse(n))})},u.prototype.sendBatch=function(e,t){if(!this.provider)return t(i.InvalidProvider());var r=o.toBatchPayload(e);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,r){return e?t(e):n.isArray(r)?void t(null,r):t(i.InvalidResponse(r))})},u.prototype.addSubscription=function(e,t,r,n){if(!this.provider.on)throw new Error("The provider doesn't support subscriptions: "+this.provider.constructor.name);this.subscriptions[e]={callback:n,type:r,name:t}},u.prototype.removeSubscription=function(e,t){this.subscriptions[e]&&(this.send({method:this.subscriptions[e].type+"_unsubscribe",params:[e]},t),delete this.subscriptions[e])},u.prototype.clearSubscriptions=function(e){var t=this;Object.keys(this.subscriptions).forEach(function(r){e&&"syncing"===t.subscriptions[r].name||t.removeSubscription(r)}),this.provider.reset&&this.provider.reset()},t.exports={Manager:u,BatchManager:a}},{"./batch.js":341,"./givenProvider.js":342,"./jsonrpc.js":344,underscore:325,"web3-core-helpers":338,"web3-providers-http":398,"web3-providers-ipc":399,"web3-providers-ws":400}],344:[function(e,t,r){"use strict";var n={messageId:0,toPayload:function(e,t){if(!e)throw new Error('JSONRPC method should be specified for params: "'+JSON.stringify(t)+'"!');return n.messageId++,{jsonrpc:"2.0",id:n.messageId,method:e,params:t||[]}},isValidResponse:function(e){return Array.isArray(e)?e.every(t):t(e);function t(e){return!(!e||e.error||"2.0"!==e.jsonrpc||"number"!=typeof e.id&&"string"!=typeof e.id||void 0===e.result)}},toBatchPayload:function(e){return e.map(function(e){return n.toPayload(e.method,e.params)})}};t.exports=n},{}],345:[function(e,t,r){"use strict";var n=e("./subscription.js"),i=function(e){this.name=e.name,this.type=e.type,this.subscriptions=e.subscriptions||{},this.requestManager=null};i.prototype.setRequestManager=function(e){this.requestManager=e},i.prototype.attachToObject=function(e){var t=this.buildCall(),r=this.name.split(".");r.length>1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},i.prototype.buildCall=function(){var e=this;return function(){e.subscriptions[arguments[0]]||console.warn("Subscription "+JSON.stringify(arguments[0])+" doesn't exist. Subscribing anyway.");var t=new n({subscription:e.subscriptions[arguments[0]],requestManager:e.requestManager,type:e.type});return t.subscribe.apply(t,arguments)}},t.exports={subscriptions:i,subscription:n}},{"./subscription.js":346}],346:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("eventemitter3");function a(e){o.call(this),this.id=null,this.callback=n.identity,this.arguments=null,this._reconnectIntervalId=null,this.options={subscription:e.subscription,type:e.type,requestManager:e.requestManager}}a.prototype=Object.create(o.prototype),a.prototype.constructor=a,a.prototype._extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},a.prototype._validateArgs=function(e){var t=this.options.subscription;if(t||(t={}),t.params||(t.params=0),e.length!==t.params)throw i.InvalidNumberOfParams(e.length,t.params+1,e[0])},a.prototype._formatInput=function(e){var t=this.options.subscription;return t&&t.inputFormatter?t.inputFormatter.map(function(t,r){return t?t(e[r]):e[r]}):e},a.prototype._formatOutput=function(e){var t=this.options.subscription;return t&&t.outputFormatter&&e?t.outputFormatter(e):e},a.prototype._toPayload=function(e){var t=[];if(this.callback=this._extractCallback(e)||n.identity,this.subscriptionMethod||(this.subscriptionMethod=e.shift(),this.options.subscription.subscriptionName&&(this.subscriptionMethod=this.options.subscription.subscriptionName)),this.arguments||(this.arguments=this._formatInput(e),this._validateArgs(this.arguments),e=[]),t.push(this.subscriptionMethod),t=t.concat(this.arguments),e.length)throw new Error("Only a callback is allowed as parameter on an already instantiated subscription.");return{method:this.options.type+"_subscribe",params:t}},a.prototype.unsubscribe=function(e){this.options.requestManager.removeSubscription(this.id,e),this.id=null,this.removeAllListeners(),clearInterval(this._reconnectIntervalId)},a.prototype.subscribe=function(){var e=this,t=Array.prototype.slice.call(arguments),r=this._toPayload(t);if(!r)return this;if(!this.options.requestManager.provider){var i=new Error("No provider set.");return this.callback(i,null,this),this.emit("error",i),this}if(!this.options.requestManager.provider.on){var o=new Error("The current provider doesn't support subscriptions: "+this.options.requestManager.provider.constructor.name);return this.callback(o,null,this),this.emit("error",o),this}return this.id&&this.unsubscribe(),this.options.params=r.params[1],"logs"===r.params[0]&&n.isObject(r.params[1])&&r.params[1].hasOwnProperty("fromBlock")&&isFinite(r.params[1].fromBlock)&&this.options.requestManager.send({method:"eth_getLogs",params:[r.params[1]]},function(t,r){t?(e.callback(t,null,e),e.emit("error",t)):r.forEach(function(t){var r=e._formatOutput(t);e.callback(null,r,e),e.emit("data",r)})}),"object"==typeof r.params[1]&&delete r.params[1].fromBlock,this.options.requestManager.send(r,function(t,i){!t&&i?(e.id=i,e.options.requestManager.addSubscription(e.id,r.params[0],e.options.type,function(t,r){t?(e.options.requestManager.removeSubscription(e.id),e.options.requestManager.provider.once&&(e._reconnectIntervalId=setInterval(function(){e.options.requestManager.provider.reconnect&&e.options.requestManager.provider.reconnect()},500),e.options.requestManager.provider.once("connect",function(){clearInterval(e._reconnectIntervalId),e.subscribe(e.callback)})),e.emit("error",t),e.callback(t,null,e)):(n.isArray(r)||(r=[r]),r.forEach(function(t){var r=e._formatOutput(t);if(n.isFunction(e.options.subscription.subscriptionHandler))return e.options.subscription.subscriptionHandler.call(e,r);e.emit("data",r),e.callback(null,r,e)}))})):(e.callback(t,null,e),e.emit("error",t))}),this},t.exports=a},{eventemitter3:156,underscore:325,"web3-core-helpers":338}],347:[function(e,t,r){"use strict";var n=e("web3-core-helpers").formatters,i=e("web3-core-method"),o=e("web3-utils");t.exports=function(e){var t=function(t){var r;return t.property?(e[t.property]||(e[t.property]={}),r=e[t.property]):r=e,t.methods&&t.methods.forEach(function(t){t instanceof i||(t=new i(t)),t.attachToObject(r),t.setRequestManager(e._requestManager)}),e};return t.formatters=n,t.utils=o,t.Method=i,t}},{"web3-core-helpers":338,"web3-core-method":339,"web3-utils":403}],348:[function(e,t,r){"use strict";var n=e("web3-core-requestmanager"),i=e("./extend.js");t.exports={packageInit:function(e,t){if(t=Array.prototype.slice.call(t),!e)throw new Error('You need to instantiate using the "new" keyword.');Object.defineProperty(e,"currentProvider",{get:function(){return e._provider},set:function(t){return e.setProvider(t)},enumerable:!0,configurable:!0}),t[0]&&t[0]._requestManager?e._requestManager=new n.Manager(t[0].currentProvider):(e._requestManager=new n.Manager,e._requestManager.setProvider(t[0],t[1])),e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers,e._provider=e._requestManager.provider,e.setProvider||(e.setProvider=function(t,r){return e._requestManager.setProvider(t,r),e._provider=e._requestManager.provider,!0}),e.BatchRequest=n.BatchManager.bind(null,e._requestManager),e.extend=i(e)},addProviders:function(e){e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers}}},{"./extend.js":347,"web3-core-requestmanager":343}],349:[function(e,t,r){var n=e("underscore"),i=e("web3-utils"),o=new(0,e("ethers/utils/abi-coder").AbiCoder)(function(e,t){return!e.match(/^u?int/)||n.isArray(t)||n.isObject(t)&&"BN"===t.constructor.name?t:t.toString()});function a(){}var s=function(){};s.prototype.encodeFunctionSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e).slice(0,10)},s.prototype.encodeEventSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e)},s.prototype.encodeParameter=function(e,t){return this.encodeParameters([e],[t])},s.prototype.encodeParameters=function(e,t){return o.encode(this.mapTypes(e),t)},s.prototype.mapTypes=function(e){var t=this,r=[];return e.forEach(function(e){if(t.isSimplifiedStructFormat(e)){var n=Object.keys(e)[0];r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}else r.push(e)}),r},s.prototype.isSimplifiedStructFormat=function(e){return"object"==typeof e&&void 0===e.components&&void 0===e.name},s.prototype.mapStructNameAndType=function(e){var t="tuple";return e.indexOf("[]")>-1&&(t="tuple[]",e=e.slice(0,-2)),{type:t,name:e}},s.prototype.mapStructToCoderFormat=function(e){var t=this,r=[];return Object.keys(e).forEach(function(n){"object"!=typeof e[n]?r.push({name:n,type:e[n]}):r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}),r},s.prototype.encodeFunctionCall=function(e,t){return this.encodeFunctionSignature(e)+this.encodeParameters(e.inputs,t).replace("0x","")},s.prototype.decodeParameter=function(e,t){return this.decodeParameters([e],t)[0]},s.prototype.decodeParameters=function(e,t){if(!t||"0x"===t||"0X"===t)throw new Error("Returned values aren't valid, did it run Out of Gas?");var r=o.decode(this.mapTypes(e),"0x"+t.replace(/0x/i,"")),i=new a;return i.__length__=0,e.forEach(function(e,t){var o=r[i.__length__];o="0x"===o?null:o,i[t]=o,n.isObject(e)&&e.name&&(i[e.name]=o),i.__length__++}),i},s.prototype.decodeLog=function(e,t,r){var i=this;r=n.isArray(r)?r:[r],t=t||"";var o=[],s=[],u=0;e.forEach(function(e,t){e.indexed?(s[t]=["bool","int","uint","address","fixed","ufixed"].find(function(t){return-1!==e.type.indexOf(t)})?i.decodeParameter(e.type,r[u]):r[u],u++):o[t]=e});var c=t,f=c?this.decodeParameters(o,c):[],h=new a;return h.__length__=0,e.forEach(function(e,t){h[t]="string"===e.type?"":null,void 0!==f[t]&&(h[t]=f[t]),void 0!==s[t]&&(h[t]=s[t]),e.name&&(h[e.name]=h[t]),h.__length__++}),h};var u=new s;t.exports=u},{"ethers/utils/abi-coder":143,underscore:325,"web3-utils":403}],350:[function(e,t,r){(function(r){var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=e("./bytes"),o=e("./nat"),a=e("elliptic"),s=(e("./rlp"),new a.ec("secp256k1")),u=e("./hash"),c=u.keccak256,f=u.keccak256s,h=function(e){for(var t=f(e.slice(2)),r="0x",n=0;n<40;n++)r+=parseInt(t[n+2],16)>7?e[n+2].toUpperCase():e[n+2];return r},l=function(e){var t=new r(e.slice(2),"hex"),n="0x"+s.keyFromPrivate(t).getPublic(!1,"hex").slice(2),i=c(n);return{address:h("0x"+i.slice(-40)),privateKey:e}},d=function(e){var t=n(e,3),r=t[0],o=i.pad(32,t[1]),a=i.pad(32,t[2]);return i.flatten([o,a,r])},p=function(e){return[i.slice(64,i.length(e),e),i.slice(0,32,e),i.slice(32,64,e)]},b=function(e){return function(t,n){var a=s.keyFromPrivate(new r(n.slice(2),"hex")).sign(new r(t.slice(2),"hex"),{canonical:!0});return d([o.fromString(i.fromNumber(e+a.recoveryParam)),i.pad(32,i.fromNat("0x"+a.r.toString(16))),i.pad(32,i.fromNat("0x"+a.s.toString(16)))])}},y=b(27);t.exports={create:function(e){var t=c(i.concat(i.random(32),e||i.random(32))),r=i.concat(i.concat(i.random(32),t),i.random(32)),n=c(r);return l(n)},toChecksum:h,fromPrivate:l,sign:y,makeSigner:b,recover:function(e,t){var n=p(t),o={v:i.toNumber(n[0]),r:n[1].slice(2),s:n[2].slice(2)},a="0x"+s.recoverPubKey(new r(e.slice(2),"hex"),o,o.v<2?o.v:1-o.v%2).encode("hex",!1).slice(2),u=c(a);return h("0x"+u.slice(-40))},encodeSignature:d,decodeSignature:p}}).call(this,e("buffer").Buffer)},{"./bytes":352,"./hash":353,"./nat":354,"./rlp":355,buffer:84,elliptic:109}],351:[function(e,t,r){arguments[4][132][0].apply(r,arguments)},{dup:132}],352:[function(e,t,r){arguments[4][133][0].apply(r,arguments)},{"./array.js":351,dup:133}],353:[function(e,t,r){arguments[4][134][0].apply(r,arguments)},{dup:134}],354:[function(e,t,r){var n=e("bn.js"),i=e("./bytes"),o=function(e){return new n(e.slice(2),16)},a=function(e){var t="0x"+("0x"===e.slice(0,2)?new n(e.slice(2),16):new n(e,10)).toString("hex");return"0x0"===t?"0x":t},s=function(e){return"string"==typeof e?/^0x/.test(e)?e:"0x"+e:"0x"+new n(e).toString("hex")},u=function(e){return o(e).toNumber()},c=function(e){return function(t,r){return"0x"+o(t)[e](o(r)).toString("hex")}},f=c("add"),h=c("mul"),l=c("div"),d=c("sub");t.exports={toString:function(e){return o(e).toString(10)},fromString:a,toNumber:u,fromNumber:s,toEther:function(e){return u(l(e,a("10000000000")))/1e8},fromEther:function(e){return h(s(Math.floor(1e8*e)),a("10000000000"))},toUint256:function(e){return i.pad(32,e)},add:f,mul:h,div:l,sub:d}},{"./bytes":352,"bn.js":53}],355:[function(e,t,r){t.exports={encode:function(e){var t=function(e){return(t=e.toString(16)).length%2==0?t:"0"+t;var t},r=function(e,r){return e<56?t(r+e):t(r+t(e).length/2+55)+t(e)};return"0x"+function e(t){if("string"==typeof t){var n=t.slice(2);return(2!=n.length||n>="80"?r(n.length/2,128):"")+n}var i=t.map(e).join("");return r(i.length/2,192)+i}(e)},decode:function(e){var t=2,r=function(){if(t>=e.length)throw"";var r=e.slice(t,t+2);return r<"80"?(t+=2,"0x"+r):r<"c0"?i():o()},n=function(){var r=parseInt(e.slice(t,t+=2),16)%64;return r<56?r:parseInt(e.slice(t,t+=2*(r-55)),16)},i=function(){var r=n();return"0x"+e.slice(t,t+=2*r)},o=function(){for(var e=2*n()+t,i=[];t>>((3&t)<<3)&255;return i}}t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],357:[function(e,t,r){for(var n=e("./rng"),i=[],o={},a=0;a<256;a++)i[a]=(a+256).toString(16).substr(1),o[i[a]]=a;function s(e,t){var r=t||0,n=i;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var u=n(),c=[1|u[0],u[1],u[2],u[3],u[4],u[5]],f=16383&(u[6]<<8|u[7]),h=0,l=0;function d(e,t,r){var i=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||n)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var a=0;a<16;a++)t[i+a]=o[a];return t||s(o)}var p=d;p.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:f,a=void 0!==e.msecs?e.msecs:(new Date).getTime(),u=void 0!==e.nsecs?e.nsecs:l+1,d=a-h+(u-l)/1e4;if(d<0&&void 0===e.clockseq&&(o=o+1&16383),(d<0||a>h)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");h=a,l=u,f=o;var p=(1e4*(268435455&(a+=122192928e5))+u)%4294967296;i[n++]=p>>>24&255,i[n++]=p>>>16&255,i[n++]=p>>>8&255,i[n++]=255&p;var b=a/4294967296*1e4&268435455;i[n++]=b>>>8&255,i[n++]=255&b,i[n++]=b>>>24&15|16,i[n++]=b>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var y=e.node||c,m=0;m<6;m++)i[n+m]=y[m];return t||s(i)},p.v4=d,p.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=o[e])});i<16;)t[n+i++]=0;return t},p.unparse=s,t.exports=p},{"./rng":356}],358:[function(e,t,r){(function(r,n){"use strict";var i=e("underscore"),o=e("web3-core"),a=e("web3-core-method"),s=e("any-promise"),u=e("eth-lib/lib/account"),c=e("eth-lib/lib/hash"),f=e("eth-lib/lib/rlp"),h=e("eth-lib/lib/nat"),l=e("eth-lib/lib/bytes"),d=e(void 0===r?"crypto-browserify":"crypto"),p=e("scrypt.js"),b=e("uuid"),y=e("web3-utils"),m=e("web3-core-helpers"),v=function(e){return i.isUndefined(e)||i.isNull(e)},g=function(e){for(;e&&e.startsWith("0x0");)e="0x"+e.slice(3);return e},w=function(e){return e.length%2==1&&(e=e.replace("0x","0x0")),e},_=function(){var e=this;o.packageInit(this,arguments),delete this.BatchRequest,delete this.extend;var t=[new a({name:"getId",call:"net_version",params:0,outputFormatter:y.hexToNumber}),new a({name:"getGasPrice",call:"eth_gasPrice",params:0}),new a({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[function(e){if(y.isAddress(e))return e;throw new Error("Address "+e+' is not a valid address to get the "transactionCount".')},function(){return"latest"}]})];this._ethereumCall={},i.each(t,function(t){t.attachToObject(e._ethereumCall),t.setRequestManager(e._requestManager)}),this.wallet=new A(this)};function A(e){this._accounts=e,this.length=0,this.defaultKeyName="web3js_wallet"}_.prototype._addAccountFunctions=function(e){var t=this;return e.signTransaction=function(r,n){return t.signTransaction(r,e.privateKey,n)},e.sign=function(r){return t.sign(r,e.privateKey)},e.encrypt=function(r,n){return t.encrypt(e.privateKey,r,n)},e},_.prototype.create=function(e){return this._addAccountFunctions(u.create(e||y.randomHex(32)))},_.prototype.privateKeyToAccount=function(e){return this._addAccountFunctions(u.fromPrivate(e))},_.prototype.signTransaction=function(e,t,r){var n,o=!1;if(r=r||function(){},!e)return o=new Error("No transaction object given!"),r(o),s.reject(o);function a(e){if(e.gas||e.gasLimit||(o=new Error('"gas" is missing')),(e.nonce<0||e.gas<0||e.gasPrice<0||e.chainId<0)&&(o=new Error("Gas, gasPrice, nonce or chainId is lower than 0")),o)return r(o),s.reject(o);try{var i=e=m.formatters.inputCallFormatter(e);i.to=e.to||"0x",i.data=e.data||"0x",i.value=e.value||"0x",i.chainId=y.numberToHex(e.chainId);var a=f.encode([l.fromNat(i.nonce),l.fromNat(i.gasPrice),l.fromNat(i.gas),i.to.toLowerCase(),l.fromNat(i.value),i.data,l.fromNat(i.chainId||"0x1"),"0x","0x"]),d=c.keccak256(a),p=u.makeSigner(2*h.toNumber(i.chainId||"0x1")+35)(c.keccak256(a),t),b=f.decode(a).slice(0,6).concat(u.decodeSignature(p));b[6]=w(g(b[6])),b[7]=w(g(b[7])),b[8]=w(g(b[8]));var v=f.encode(b),_=f.decode(v);n={messageHash:d,v:g(_[6]),r:g(_[7]),s:g(_[8]),rawTransaction:v}}catch(e){return r(e),s.reject(e)}return r(null,n),n}return void 0!==e.nonce&&void 0!==e.chainId&&void 0!==e.gasPrice?s.resolve(a(e)):s.all([v(e.chainId)?this._ethereumCall.getId():e.chainId,v(e.gasPrice)?this._ethereumCall.getGasPrice():e.gasPrice,v(e.nonce)?this._ethereumCall.getTransactionCount(this.privateKeyToAccount(t).address):e.nonce]).then(function(t){if(v(t[0])||v(t[1])||v(t[2]))throw new Error('One of the values "chainId", "gasPrice", or "nonce" couldn\'t be fetched: '+JSON.stringify(t));return a(i.extend(e,{chainId:t[0],gasPrice:t[1],nonce:t[2]}))})},_.prototype.recoverTransaction=function(e){var t=f.decode(e),r=u.encodeSignature(t.slice(6,9)),n=l.toNumber(t[6]),i=n<35?[]:[l.fromNumber(n-35>>1),"0x","0x"],o=t.slice(0,6).concat(i),a=f.encode(o);return u.recover(c.keccak256(a),r)},_.prototype.hashMessage=function(e){var t=y.isHexStrict(e)?y.hexToBytes(e):e,r=n.from(t),i="Ethereum Signed Message:\n"+t.length,o=n.from(i),a=n.concat([o,r]);return c.keccak256s(a)},_.prototype.sign=function(e,t){var r=this.hashMessage(e),n=u.sign(r,t),i=u.decodeSignature(n);return{message:e,messageHash:r,v:i[0],r:i[1],s:i[2],signature:n}},_.prototype.recover=function(e,t,r){var n=[].slice.apply(arguments);return i.isObject(e)?this.recover(e.messageHash,u.encodeSignature([e.v,e.r,e.s]),!0):(r||(e=this.hashMessage(e)),n.length>=4?(r=n.slice(-1)[0],r=!!i.isBoolean(r)&&!!r,this.recover(e,u.encodeSignature(n.slice(1,4)),r)):u.recover(e,t))},_.prototype.decrypt=function(e,t,r){if(!i.isString(t))throw new Error("No password given.");var o,a,s=i.isObject(e)?e:JSON.parse(r?e.toLowerCase():e);if(3!==s.version)throw new Error("Not a valid V3 wallet");if("scrypt"===s.crypto.kdf)a=s.crypto.kdfparams,o=p(new n(t),new n(a.salt,"hex"),a.n,a.r,a.p,a.dklen);else{if("pbkdf2"!==s.crypto.kdf)throw new Error("Unsupported key derivation scheme");if("hmac-sha256"!==(a=s.crypto.kdfparams).prf)throw new Error("Unsupported parameters to PBKDF2");o=d.pbkdf2Sync(new n(t),new n(a.salt,"hex"),a.c,a.dklen,"sha256")}var u=new n(s.crypto.ciphertext,"hex");if(y.sha3(n.concat([o.slice(16,32),u])).replace("0x","")!==s.crypto.mac)throw new Error("Key derivation failed - possibly wrong password");var c=d.createDecipheriv(s.crypto.cipher,o.slice(0,16),new n(s.crypto.cipherparams.iv,"hex")),f="0x"+n.concat([c.update(u),c.final()]).toString("hex");return this.privateKeyToAccount(f)},_.prototype.encrypt=function(e,t,r){var i,o=this.privateKeyToAccount(e),a=(r=r||{}).salt||d.randomBytes(32),s=r.iv||d.randomBytes(16),u=r.kdf||"scrypt",c={dklen:r.dklen||32,salt:a.toString("hex")};if("pbkdf2"===u)c.c=r.c||262144,c.prf="hmac-sha256",i=d.pbkdf2Sync(new n(t),a,c.c,c.dklen,"sha256");else{if("scrypt"!==u)throw new Error("Unsupported kdf");c.n=r.n||8192,c.r=r.r||8,c.p=r.p||1,i=p(new n(t),a,c.n,c.r,c.p,c.dklen)}var f=d.createCipheriv(r.cipher||"aes-128-ctr",i.slice(0,16),s);if(!f)throw new Error("Unsupported cipher");var h=n.concat([f.update(new n(o.privateKey.replace("0x",""),"hex")),f.final()]),l=y.sha3(n.concat([i.slice(16,32),new n(h,"hex")])).replace("0x","");return{version:3,id:b.v4({random:r.uuid||d.randomBytes(16)}),address:o.address.toLowerCase().replace("0x",""),crypto:{ciphertext:h.toString("hex"),cipherparams:{iv:s.toString("hex")},cipher:r.cipher||"aes-128-ctr",kdf:u,kdfparams:c,mac:l.toString("hex")}}},A.prototype._findSafeIndex=function(e){return e=e||0,i.has(this,e)?this._findSafeIndex(e+1):e},A.prototype._currentIndexes=function(){return Object.keys(this).map(function(e){return parseInt(e)}).filter(function(e){return e<9e20})},A.prototype.create=function(e,t){for(var r=0;r=2?t.slice(2):t;var r=h.decodeParameters(e,t);return 1===r.__length__?r[0]:(delete r.__length__,r)},l.prototype.deploy=function(e,t){if((e=e||{}).arguments=e.arguments||[],!(e=this._getOrSetDefaultOptions(e)).data)return a._fireError(new Error('No "data" specified in neither the given options, nor the default options.'),null,null,t);var r=n.find(this.options.jsonInterface,function(e){return"constructor"===e.type})||{};return r.signature="constructor",this._createTxObject.apply({method:r,parent:this,deployData:e.data,_ethAccounts:this.constructor._ethAccounts},e.arguments)},l.prototype._generateEventOptions=function(){var e=Array.prototype.slice.call(arguments),t=this._getCallback(e),r=n.isObject(e[e.length-1])?e.pop():{},i=n.isString(e[0])?e[0]:"allevents";if(!(i="allevents"===i.toLowerCase()?{name:"ALLEVENTS",jsonInterface:this.options.jsonInterface}:this.options.jsonInterface.find(function(e){return"event"===e.type&&(e.name===i||e.signature==="0x"+i.replace("0x",""))})))throw new Error('Event "'+i.name+"\" doesn't exist in this contract.");if(!a.isAddress(this.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return{params:this._encodeEventABI(i,r),event:i,callback:t}},l.prototype.clone=function(){return new this.constructor(this.options.jsonInterface,this.options.address,this.options)},l.prototype.once=function(e,t,r){var i=Array.prototype.slice.call(arguments);if(!(r=this._getCallback(i)))throw new Error("Once requires a callback as the second parameter.");t&&delete t.fromBlock,this._on(e,t,function(e,t,i){i.unsubscribe(),n.isFunction(r)&&r(e,t,i)})},l.prototype._on=function(){var e=this._generateEventOptions.apply(this,arguments);this._checkListener("newListener",e.event.name,e.callback),this._checkListener("removeListener",e.event.name,e.callback);var t=new s({subscription:{params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event),subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},type:"eth",requestManager:this._requestManager});return t.subscribe("logs",e.params,e.callback||function(){}),t},l.prototype.getPastEvents=function(){var e=this._generateEventOptions.apply(this,arguments),t=new o({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event)});t.setRequestManager(this._requestManager);var r=t.buildCall();return t=null,r(e.params,e.callback)},l.prototype._createTxObject=function(){var e=Array.prototype.slice.call(arguments),t={};if("function"===this.method.type&&(t.call=this.parent._executeMethod.bind(t,"call"),t.call.request=this.parent._executeMethod.bind(t,"call",!0)),t.send=this.parent._executeMethod.bind(t,"send"),t.send.request=this.parent._executeMethod.bind(t,"send",!0),t.encodeABI=this.parent._encodeMethodABI.bind(t),t.estimateGas=this.parent._executeMethod.bind(t,"estimate"),e&&this.method.inputs&&e.length!==this.method.inputs.length){if(this.nextMethod)return this.nextMethod.apply(null,e);throw c.InvalidNumberOfParams(e.length,this.method.inputs.length,this.method.name)}return t.arguments=e||[],t._method=this.method,t._parent=this.parent,t._ethAccounts=this.parent.constructor._ethAccounts||this._ethAccounts,this.deployData&&(t._deployData=this.deployData),t},l.prototype._processExecuteArguments=function(e,t){var r={};if(r.type=e.shift(),r.callback=this._parent._getCallback(e),"call"===r.type&&!0!==e[e.length-1]&&(n.isString(e[e.length-1])||isFinite(e[e.length-1]))&&(r.defaultBlock=e.pop()),r.options=n.isObject(e[e.length-1])?e.pop():{},r.generateRequest=!0===e[e.length-1]&&e.pop(),r.options=this._parent._getOrSetDefaultOptions(r.options),r.options.data=this.encodeABI(),!this._deployData&&!a.isAddress(this._parent.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return this._deployData||(r.options.to=this._parent.options.address),r.options.data?r:a._fireError(new Error("Couldn't find a matching contract method, or the number of parameters is wrong."),t.eventEmitter,t.reject,r.callback)},l.prototype._executeMethod=function(){var e=this,t=this._parent._processExecuteArguments.call(this,Array.prototype.slice.call(arguments),r),r=f("send"!==t.type),i=e.constructor._ethAccounts||e._ethAccounts;if(t.generateRequest){var s={params:[u.inputCallFormatter.call(this._parent,t.options)],callback:t.callback};return"call"===t.type?(s.params.push(u.inputDefaultBlockNumberFormatter.call(this._parent,t.defaultBlock)),s.method="eth_call",s.format=this._parent._decodeMethodReturn.bind(null,this._method.outputs)):s.method="eth_sendTransaction",s}switch(t.type){case"estimate":return new o({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[u.inputCallFormatter],outputFormatter:a.hexToNumber,requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.callback);case"call":return new o({name:"call",call:"eth_call",params:2,inputFormatter:[u.inputCallFormatter,u.inputDefaultBlockNumberFormatter],outputFormatter:function(t){return e._parent._decodeMethodReturn(e._method.outputs,t)},requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.defaultBlock,t.callback);case"send":if(!a.isAddress(t.options.from))return a._fireError(new Error('No "from" address specified in neither the given options, nor the default options.'),r.eventEmitter,r.reject,t.callback);if(n.isBoolean(this._method.payable)&&!this._method.payable&&t.options.value&&t.options.value>0)return a._fireError(new Error("Can not send value to non-payable contract method or constructor"),r.eventEmitter,r.reject,t.callback);var c={receiptFormatter:function(t){if(n.isArray(t.logs)){var r=n.map(t.logs,function(t){return e._parent._decodeEventABI.call({name:"ALLEVENTS",jsonInterface:e._parent.options.jsonInterface},t)});t.events={};var i=0;r.forEach(function(e){e.event?t.events[e.event]?Array.isArray(t.events[e.event])?t.events[e.event].push(e):t.events[e.event]=[t.events[e.event],e]:t.events[e.event]=e:(t.events[i]=e,i++)}),delete t.logs}return t},contractDeployFormatter:function(t){var r=e._parent.clone();return r.options.address=t.contractAddress,r}};return new o({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[u.inputTransactionFormatter],requestManager:e._parent._requestManager,accounts:e.constructor._ethAccounts||e._ethAccounts,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock,extraFormatters:c}).createFunction()(t.options,t.callback)}},t.exports=l},{underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-utils":403}],360:[function(e,t,r){"use strict";var n=e("./config"),i=e("./contracts/Registry"),o=e("./lib/ResolverMethodHandler");function a(e){this.eth=e}Object.defineProperty(a.prototype,"registry",{get:function(){return new i(this)},enumerable:!0}),Object.defineProperty(a.prototype,"resolverMethodHandler",{get:function(){return new o(this.registry)},enumerable:!0}),a.prototype.resolver=function(e){return this.registry.resolver(e)},a.prototype.getAddress=function(e,t){return this.resolverMethodHandler.method(e,"addr",[]).call(t)},a.prototype.setAddress=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setAddr",[t]).send(r,n)},a.prototype.getPubkey=function(e,t){return this.resolverMethodHandler.method(e,"pubkey",[],t).call(t)},a.prototype.setPubkey=function(e,t,r,n,i){return this.resolverMethodHandler.method(e,"setPubkey",[t,r]).send(n,i)},a.prototype.getContent=function(e,t){return this.resolverMethodHandler.method(e,"content",[]).call(t)},a.prototype.setContent=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setContent",[t]).send(r,n)},a.prototype.getMultihash=function(e,t){return this.resolverMethodHandler.method(e,"multihash",[]).call(t)},a.prototype.setMultihash=function(e,t,r,n){return this.resolverMethodHandler.method(e,"multihash",[t]).send(r,n)},a.prototype.checkNetwork=function(){var e=this;return e.eth.getBlock("latest").then(function(t){var r=new Date/1e3-t.timestamp;if(r>3600)throw new Error("Network not synced; last block was "+r+" seconds ago");return e.eth.net.getNetworkType()}).then(function(e){var t=n.addresses[e];if(void 0===t)throw new Error("ENS is not supported on network "+e);return t})},t.exports=a},{"./config":361,"./contracts/Registry":362,"./lib/ResolverMethodHandler":364}],361:[function(e,t,r){"use strict";t.exports={addresses:{main:"0x314159265dD8dbb310642f98f50C066173C1259b",ropsten:"0x112234455c3a32fd11230c42e7bccd4a84e02010",rinkeby:"0xe7410170f87102df0055eb195163a03b7f2bff4a"}}},{}],362:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-eth-contract"),o=e("eth-ens-namehash"),a=e("web3-core-promievent"),s=e("../ressources/ABI/Registry"),u=e("../ressources/ABI/Resolver");function c(e){var t=this;this.ens=e,this.contract=e.checkNetwork().then(function(e){var r=new i(s,e);return r.setProvider(t.ens.eth.currentProvider),r})}c.prototype.owner=function(e,t){var r=new a(!0);return this.contract.then(function(i){i.methods.owner(o.hash(e)).call().then(function(e){r.resolve(e),n.isFunction(t)&&t(e)}).catch(function(e){r.reject(e),n.isFunction(t)&&t(e)})}),r.eventEmitter},c.prototype.resolver=function(e){var t=this;return this.contract.then(function(t){return t.methods.resolver(o.hash(e)).call()}).then(function(e){var r=new i(u,e);return r.setProvider(t.ens.eth.currentProvider),r})},t.exports=c},{"../ressources/ABI/Registry":365,"../ressources/ABI/Resolver":366,"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340,"web3-eth-contract":359}],363:[function(e,t,r){"use strict";var n=e("./ENS");t.exports=n},{"./ENS":360}],364:[function(e,t,r){"use strict";var n=e("web3-core-promievent"),i=e("eth-ens-namehash"),o=e("underscore");function a(e){this.registry=e}a.prototype.method=function(e,t,r,n){return{call:this.call.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this}),send:this.send.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this})}},a.prototype.call=function(e){var t=this,r=new n,i=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){t.parent.handleCall(r,n.methods[t.methodName],i,e)}).catch(function(e){r.reject(e)}),r.eventEmitter},a.prototype.send=function(e,t){var r=this,i=new n,o=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){r.parent.handleSend(i,n.methods[r.methodName],o,e,t)}).catch(function(e){i.reject(e)}),i.eventEmitter},a.prototype.handleCall=function(e,t,r,n){return t.apply(this,r).call().then(function(t){e.resolve(t),o.isFunction(n)&&n(t)}).catch(function(t){e.reject(t),o.isFunction(n)&&n(t)}),e},a.prototype.handleSend=function(e,t,r,n,i){return t.apply(this,r).send(n).on("transactionHash",function(t){e.eventEmitter.emit("transactionHash",t)}).on("confirmation",function(t,r){e.eventEmitter.emit("confirmation",t,r)}).on("receipt",function(t){e.eventEmitter.emit("receipt",t),e.resolve(t),o.isFunction(i)&&i(t)}).on("error",function(t){e.eventEmitter.emit("error",t),e.reject(t),o.isFunction(i)&&i(t)}),e},a.prototype.prepareArguments=function(e,t){var r=i.hash(e);return t.length>0?(t.unshift(r),t):[r]},t.exports=a},{"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340}],365:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"resolver",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"owner",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"label",type:"bytes32"},{name:"owner",type:"address"}],name:"setSubnodeOwner",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"ttl",type:"uint64"}],name:"setTTL",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"ttl",outputs:[{name:"",type:"uint64"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"resolver",type:"address"}],name:"setResolver",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"owner",type:"address"}],name:"setOwner",outputs:[],payable:!1,type:"function"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"label",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"NewOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"resolver",type:"address"}],name:"NewResolver",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"ttl",type:"uint64"}],name:"NewTTL",type:"event"}]},{}],366:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"interfaceID",type:"bytes4"}],name:"supportsInterface",outputs:[{name:"",type:"bool"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"},{name:"contentTypes",type:"uint256"}],name:"ABI",outputs:[{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes"}],name:"setMultihash",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"multihash",outputs:[{name:"",type:"bytes"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"setPubkey",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"content",outputs:[{name:"ret",type:"bytes32"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"addr",outputs:[{name:"ret",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],name:"setABI",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"name",outputs:[{name:"ret",type:"string"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"name",type:"string"}],name:"setName",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes32"}],name:"setContent",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"pubkey",outputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"addr",type:"address"}],name:"setAddr",outputs:[],payable:!1,type:"function"},{inputs:[{name:"ensAddr",type:"address"}],payable:!1,type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"a",type:"address"}],name:"AddrChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"hash",type:"bytes32"}],name:"ContentChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"name",type:"string"}],name:"NameChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"contentType",type:"uint256"}],name:"ABIChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"x",type:"bytes32"},{indexed:!1,name:"y",type:"bytes32"}],name:"PubkeyChanged",type:"event"}]},{}],367:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],368:[function(e,t,r){"use strict";var n=e("web3-utils"),i=e("bn.js"),o=function(e){var t="A".charCodeAt(0),r="Z".charCodeAt(0);return(e=(e=e.toUpperCase()).substr(4)+e.substr(0,4)).split("").map(function(e){var n=e.charCodeAt(0);return n>=t&&n<=r?n-t+10:e}).join("")},a=function(e){for(var t,r=e;r.length>2;)t=r.slice(0,9),r=parseInt(t,10)%97+r.slice(t.length);return parseInt(r,10)%97},s=function(e){this._iban=e};s.toAddress=function(e){if(!(e=new s(e)).isDirect())throw new Error("IBAN is indirect and can't be converted");return e.toAddress()},s.toIban=function(e){return s.fromAddress(e).toString()},s.fromAddress=function(e){if(!n.isAddress(e))throw new Error("Provided address is not a valid address: "+e);e=e.replace("0x","").replace("0X","");var t=function(e,t){for(var r=e;r.length<2*t;)r="0"+r;return r}(new i(e,16).toString(36),15);return s.fromBban(t.toUpperCase())},s.fromBban=function(e){var t=("0"+(98-a(o("XE00"+e)))).slice(-2);return new s("XE"+t+e)},s.createIndirect=function(e){return s.fromBban("ETH"+e.institution+e.identifier)},s.isValid=function(e){return new s(e).isValid()},s.prototype.isValid=function(){return/^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban)&&1===a(o(this._iban))},s.prototype.isDirect=function(){return 34===this._iban.length||35===this._iban.length},s.prototype.isIndirect=function(){return 20===this._iban.length},s.prototype.checksum=function(){return this._iban.substr(2,2)},s.prototype.institution=function(){return this.isIndirect()?this._iban.substr(7,4):""},s.prototype.client=function(){return this.isIndirect()?this._iban.substr(11):""},s.prototype.toAddress=function(){if(this.isDirect()){var e=this._iban.substr(4),t=new i(e,36);return n.toChecksumAddress(t.toString(16,20))}return""},s.prototype.toString=function(){return this._iban},t.exports=s},{"bn.js":367,"web3-utils":403}],369:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=e("web3-net"),s=e("web3-core-helpers").formatters,u=function(){var e=this;n.packageInit(this,arguments),this.net=new a(this.currentProvider);var t=null,r="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return t},set:function(e){return e&&(t=o.toChecksumAddress(s.inputAddressFormatter(e))),u.forEach(function(e){e.defaultAccount=t}),e},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return r},set:function(e){return r=e,u.forEach(function(e){e.defaultBlock=r}),e},enumerable:!0});var u=[new i({name:"getAccounts",call:"personal_listAccounts",params:0,outputFormatter:o.toChecksumAddress}),new i({name:"newAccount",call:"personal_newAccount",params:1,inputFormatter:[null],outputFormatter:o.toChecksumAddress}),new i({name:"unlockAccount",call:"personal_unlockAccount",params:3,inputFormatter:[s.inputAddressFormatter,null,null]}),new i({name:"lockAccount",call:"personal_lockAccount",params:1,inputFormatter:[s.inputAddressFormatter]}),new i({name:"importRawKey",call:"personal_importRawKey",params:2}),new i({name:"sendTransaction",call:"personal_sendTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"signTransaction",call:"personal_signTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"sign",call:"personal_sign",params:3,inputFormatter:[s.inputSignFormatter,s.inputAddressFormatter,null]}),new i({name:"ecRecover",call:"personal_ecRecover",params:2,inputFormatter:[s.inputSignFormatter,null]})];u.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};n.addProviders(u),t.exports=u},{"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-net":372,"web3-utils":403}],370:[function(e,t,r){"use strict";var n=e("underscore");t.exports=function(e){var t,r=this;return this.net.getId().then(function(e){return t=e,r.getBlock(0)}).then(function(r){var i="private";return"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"===r.hash&&1===t&&(i="main"),"0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303"===r.hash&&2===t&&(i="morden"),"0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"===r.hash&&3===t&&(i="ropsten"),"0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177"===r.hash&&4===t&&(i="rinkeby"),"0xa3c565fc15c7478862d50ccd6561e3c06b24cc509bf388941c25ea985ce32cb9"===r.hash&&42===t&&(i="kovan"),n.isFunction(e)&&e(null,i),i}).catch(function(t){if(!n.isFunction(e))throw t;e(t)})}},{underscore:325}],371:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core"),o=e("web3-core-helpers"),a=e("web3-core-subscriptions").subscriptions,s=e("web3-core-method"),u=e("web3-utils"),c=e("web3-net"),f=e("web3-eth-ens"),h=e("web3-eth-personal"),l=e("web3-eth-contract"),d=e("web3-eth-iban"),p=e("web3-eth-accounts"),b=e("web3-eth-abi"),y=e("./getNetworkType.js"),m=o.formatters,v=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},g=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},w=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},_=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},A=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"},E=function(){var e=this;i.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments),e.personal.setProvider.apply(e,arguments),e.accounts.setProvider.apply(e,arguments),e.Contract.setProvider(e.currentProvider,e.accounts)};var r=null,o="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return r},set:function(t){return t&&(r=u.toChecksumAddress(m.inputAddressFormatter(t))),e.Contract.defaultAccount=r,e.personal.defaultAccount=r,k.forEach(function(e){e.defaultAccount=r}),t},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return o},set:function(t){return o=t,e.Contract.defaultBlock=o,e.personal.defaultBlock=o,k.forEach(function(e){e.defaultBlock=o}),t},enumerable:!0}),this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new c(this.currentProvider),this.net.getNetworkType=y.bind(this),this.accounts=new p(this.currentProvider),this.personal=new h(this.currentProvider),this.personal.defaultAccount=this.defaultAccount;var E=this,x=function(){l.apply(this,arguments);var e=this,t=E.setProvider;E.setProvider=function(){t.apply(E,arguments),i.packageInit(e,[E.currentProvider])}};x.setProvider=function(){l.setProvider.apply(this,arguments)},(x.prototype=Object.create(l.prototype)).constructor=x,this.Contract=x,this.Contract.defaultAccount=this.defaultAccount,this.Contract.defaultBlock=this.defaultBlock,this.Contract.setProvider(this.currentProvider,this.accounts),this.Iban=d,this.abi=b,this.ens=new f(this);var k=[new s({name:"getNodeInfo",call:"web3_clientVersion"}),new s({name:"getProtocolVersion",call:"eth_protocolVersion",params:0}),new s({name:"getCoinbase",call:"eth_coinbase",params:0}),new s({name:"isMining",call:"eth_mining",params:0}),new s({name:"getHashrate",call:"eth_hashrate",params:0,outputFormatter:u.hexToNumber}),new s({name:"isSyncing",call:"eth_syncing",params:0,outputFormatter:m.outputSyncingFormatter}),new s({name:"getGasPrice",call:"eth_gasPrice",params:0,outputFormatter:m.outputBigNumberFormatter}),new s({name:"getAccounts",call:"eth_accounts",params:0,outputFormatter:u.toChecksumAddress}),new s({name:"getBlockNumber",call:"eth_blockNumber",params:0,outputFormatter:u.hexToNumber}),new s({name:"getBalance",call:"eth_getBalance",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:m.outputBigNumberFormatter}),new s({name:"getStorageAt",call:"eth_getStorageAt",params:3,inputFormatter:[m.inputAddressFormatter,u.numberToHex,m.inputDefaultBlockNumberFormatter]}),new s({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"getBlock",call:v,params:2,inputFormatter:[m.inputBlockNumberFormatter,function(e){return!!e}],outputFormatter:m.outputBlockFormatter}),new s({name:"getUncle",call:w,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputBlockFormatter}),new s({name:"getBlockTransactionCount",call:_,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getBlockUncleCount",call:A,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getTransaction",call:"eth_getTransactionByHash",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionFromBlock",call:g,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionReceiptFormatter}),new s({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"sendSignedTransaction",call:"eth_sendRawTransaction",params:1,inputFormatter:[null]}),new s({name:"signTransaction",call:"eth_signTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sign",call:"eth_sign",params:2,inputFormatter:[m.inputSignFormatter,m.inputAddressFormatter],transformPayload:function(e){return e.params.reverse(),e}}),new s({name:"call",call:"eth_call",params:2,inputFormatter:[m.inputCallFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[m.inputCallFormatter],outputFormatter:u.hexToNumber}),new s({name:"submitWork",call:"eth_submitWork",params:3}),new s({name:"getWork",call:"eth_getWork",params:0}),new s({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter}),new a({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:m.outputBlockFormatter},pendingTransactions:{subscriptionName:"newPendingTransactions",params:0},logs:{params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter,subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},syncing:{params:0,outputFormatter:m.outputSyncingFormatter,subscriptionHandler:function(e){var t=this;!0!==this._isSyncing?(this._isSyncing=!0,this.emit("changed",t._isSyncing),n.isFunction(this.callback)&&this.callback(null,t._isSyncing,this),setTimeout(function(){t.emit("data",e),n.isFunction(t.callback)&&t.callback(null,e,t)},0)):(this.emit("data",e),n.isFunction(t.callback)&&this.callback(null,e,this),clearTimeout(this._isSyncingTimeout),this._isSyncingTimeout=setTimeout(function(){e.currentBlock>e.highestBlock-200&&(t._isSyncing=!1,t.emit("changed",t._isSyncing),n.isFunction(t.callback)&&t.callback(null,t._isSyncing,t))},500))}}}})];k.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager,e.accounts),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};i.addProviders(E),t.exports=E},{"./getNetworkType.js":370,underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-eth-accounts":358,"web3-eth-contract":359,"web3-eth-ens":363,"web3-eth-iban":368,"web3-eth-personal":369,"web3-net":372,"web3-utils":403}],372:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=function(){var e=this;n.packageInit(this,arguments),[new i({name:"getId",call:"net_version",params:0,outputFormatter:o.hexToNumber}),new i({name:"isListening",call:"net_listening",params:0}),new i({name:"getPeerCount",call:"net_peerCount",params:0,outputFormatter:o.hexToNumber})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(a),t.exports=a},{"web3-core":348,"web3-core-method":339,"web3-utils":403}],373:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits,o=e("ethereumjs-util"),a=e("eth-block-tracker"),s=e("async/map"),u=e("async/eachSeries"),c=e("./util/stoplight.js");e("./util/rpc-cache-utils.js"),e("./util/create-payload.js");function f(e){const t=this;n.call(t),t.setMaxListeners(30),e=e||{};const r={sendAsync:t._handleAsync.bind(t)},i=e.blockTrackerProvider||r;t._blockTracker=e.blockTracker||new a({provider:i,pollingInterval:e.pollingInterval||4e3}),t._blockTracker.on("block",e=>{const r=function(e){return{number:o.toBuffer(e.number),hash:o.toBuffer(e.hash),parentHash:o.toBuffer(e.parentHash),nonce:o.toBuffer(e.nonce),mixHash:o.toBuffer(e.mixHash),sha3Uncles:o.toBuffer(e.sha3Uncles),logsBloom:o.toBuffer(e.logsBloom),transactionsRoot:o.toBuffer(e.transactionsRoot),stateRoot:o.toBuffer(e.stateRoot),receiptsRoot:o.toBuffer(e.receiptRoot||e.receiptsRoot),miner:o.toBuffer(e.miner),difficulty:o.toBuffer(e.difficulty),totalDifficulty:o.toBuffer(e.totalDifficulty),size:o.toBuffer(e.size),extraData:o.toBuffer(e.extraData),gasLimit:o.toBuffer(e.gasLimit),gasUsed:o.toBuffer(e.gasUsed),timestamp:o.toBuffer(e.timestamp),transactions:e.transactions}}(e);t._setCurrentBlock(r)}),t._blockTracker.on("block",t.emit.bind(t,"rawBlock")),t._blockTracker.on("sync",t.emit.bind(t,"sync")),t._blockTracker.on("latest",t.emit.bind(t,"latest")),t._ready=new c,t._blockTracker.once("block",()=>{t._ready.go()}),t.currentBlock=null,t._providers=[]}t.exports=f,i(f,n),f.prototype.start=function(e=function(){}){this._blockTracker.start().then(e).catch(e)},f.prototype.stop=function(){this._blockTracker.stop()},f.prototype.addProvider=function(e){this._providers.push(e),e.setEngine(this)},f.prototype.send=function(e){throw new Error("Web3ProviderEngine does not support synchronous requests.")},f.prototype.sendAsync=function(e,t){const r=this;r._ready.await(function(){Array.isArray(e)?s(e,r._handleAsync.bind(r),t):r._handleAsync(e,t)})},f.prototype._handleAsync=function(e,t){var r=this,n=-1,i=null,o=null,a=[];function s(r,n){o=r,i=n,u(a,function(e,t){e?e(o,i,t):t()},function(){var r={id:e.id,jsonrpc:e.jsonrpc,result:i};null!=o?(r.error={message:o.stack||o.message||o,code:-32e3},t(o,r)):t(null,r)})}!function t(i){n+=1;a.unshift(i);if(n>=r._providers.length)s(new Error('Request for method "'+e.method+'" not handled by any subprovider. Please check your subprovider configuration to ensure this method is handled.'));else try{var o=r._providers[n];o.handleRequest(e,t,s)}catch(e){s(e)}}()},f.prototype._setCurrentBlock=function(e){this.currentBlock=e,this.emit("block",e)}},{"./util/create-payload.js":391,"./util/rpc-cache-utils.js":394,"./util/stoplight.js":396,"async/eachSeries":25,"async/map":41,"eth-block-tracker":126,"ethereumjs-util":141,events:157,util:333}],374:[function(e,t,r){var n="undefined"!=typeof JSON?JSON:e("jsonify");t.exports=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var r=t.space||"";"number"==typeof r&&(r=Array(r+1).join(" "));var a,s="boolean"==typeof t.cycles&&t.cycles,u=t.replacer||function(e,t){return t},c=t.cmp&&(a=t.cmp,function(e){return function(t,r){var n={key:t,value:e[t]},i={key:r,value:e[r]};return a(n,i)}}),f=[];return function e(t,a,h,l){var d=r?"\n"+new Array(l+1).join(r):"",p=r?": ":":";if(h&&h.toJSON&&"function"==typeof h.toJSON&&(h=h.toJSON()),void 0!==(h=u.call(t,a,h))){if("object"!=typeof h||null===h)return n.stringify(h);if(i(h)){for(var b=[],y=0;y dist/ProviderEngine.js","bundle-zero":"browserify -s ZeroClientProvider -e zero.js -t [ babelify --presets [ es2015 ] ] > dist/ZeroClientProvider.js",prepublish:"npm run build && npm run bundle",test:"node test/index.js"},version:"14.1.0"}},{}],376:[function(e,t,r){const n=e("util").inherits,i=e("ethereumjs-util"),o=i.BN,a=e("clone"),s=e("../util/rpc-cache-utils.js"),u=e("../util/stoplight.js"),c=e("./subprovider.js");function f(e){e=e||{},this._ready=new u,this.strategies={perma:new l({eth_getTransactionByHash:p,eth_getTransactionReceipt:p}),block:new d(this),fork:new d(this)}}function h(){var e=this;e.cache={};var t=setInterval(function(){e.cache={}},6e5);t.unref&&t.unref()}function l(e){this.strategy=new h,this.conditionals=e}function d(){this.cache={}}function p(e){if(!e)return!1;if(!e.blockHash)return!1;var t;return(t=e.blockHash,new o(i.toBuffer(t))).gt(new o(0))}t.exports=f,n(f,c),f.prototype.setEngine=function(e){const t=this;function r(e){var r=t.currentBlock;t.currentBlock=e,r&&(t.strategies.block.cacheRollOff(r),t.strategies.fork.cacheRollOff(r))}t.engine=e,e.once("block",function(n){t.currentBlock=n,t._ready.go(),e.on("block",r)})},f.prototype.handleRequest=function(e,t,r){const n=this;return e.skipCache?t():"eth_getBlockByNumber"===e.method&&"latest"===e.params[0]?t():void n._ready.await(function(){n._handleRequest(e,t,r)})},f.prototype._handleRequest=function(e,t,r){const n=this;var o=s.cacheTypeForPayload(e),a=this.strategies[o];if(!a)return t();if(!a.canCache(e))return t();var u,c=s.blockTagForPayload(e);c||(c="latest"),u="earliest"===c?"0x00":"latest"===c?i.bufferToHex(n.currentBlock.number):c,a.hitCheck(e,u,r,function(){t(function(t,r,n){if(t)return n();a.cacheResult(e,r,u,n)})})},h.prototype.hitCheck=function(e,t,r,n){var i,o,u,c,f=s.cacheIdentifierForPayload(e),h=this.cache[f];return h&&(i=t,o=h.blockNumber,u=parseInt(i,16),c=parseInt(o,16),(u===c?0:u>c?1:-1)>=0)?r(null,a(h.result)):n()},h.prototype.cacheResult=function(e,t,r,n){var i=s.cacheIdentifierForPayload(e);if(t){var o=a(t);this.cache[i]={blockNumber:r,result:o}}n()},h.prototype.canCache=function(e){return s.canCache(e)},l.prototype.hitCheck=function(e,t,r,n){return this.strategy.hitCheck(e,t,r,n)},l.prototype.cacheResult=function(e,t,r,n){var i=this.conditionals[e.method];i?i(t)?this.strategy.cacheResult(e,t,r,n):n():this.strategy.cacheResult(e,t,r,n)},l.prototype.canCache=function(e){return this.strategy.canCache(e)},d.prototype.getBlockCacheForPayload=function(e,t){const r=Number.parseInt(t,16);let n=this.cache[r];if(!n){const e={};this.cache[r]=e,n=e}return n},d.prototype.hitCheck=function(e,t,r,n){var i=this.getBlockCacheForPayload(e,t);if(!i)return n();var o=i[s.cacheIdentifierForPayload(e)];return o?r(null,o):n()},d.prototype.cacheResult=function(e,t,r,n){t&&(this.getBlockCacheForPayload(e,r)[s.cacheIdentifierForPayload(e)]=t);n()},d.prototype.canCache=function(e){return!!s.canCache(e)&&"pending"!==s.blockTagForPayload(e)},d.prototype.cacheRollOff=function(e){const t=this,r=i.bufferToHex(e.number),n=Number.parseInt(r,16);Object.keys(t.cache).map(Number).filter(e=>e<=n).forEach(e=>delete t.cache[e])}},{"../util/rpc-cache-utils.js":394,"../util/stoplight.js":396,"./subprovider.js":387,clone:87,"ethereumjs-util":141,util:333}],377:[function(e,t,r){const n=e("util").inherits,i=e("xtend"),o=e("./fixture.js"),a=e("../package.json").version;function s(e){var t=i({web3_clientVersion:"ProviderEngine/v"+a+"/javascript",net_listening:!0,eth_hashrate:"0x00",eth_mining:!1},e=e||{});o.call(this,t)}t.exports=s,n(s,o)},{"../package.json":375,"./fixture.js":380,util:333,xtend:423}],378:[function(e,t,r){const n=e("cross-fetch"),i=e("util").inherits,o=e("async/retry"),a=e("async/waterfall"),s=e("async/asyncify"),u=e("json-rpc-error"),c=e("promise-to-callback"),f=e("../util/create-payload.js"),h=e("./subprovider.js"),l=["Gateway timeout","ETIMEDOUT","SyntaxError"];function d(e){this.rpcUrl=e.rpcUrl,this.originHttpHeaderKey=e.originHttpHeaderKey}function p(e){const t=e.toString();return l.some(e=>t.includes(e))}t.exports=d,i(d,h),d.prototype.handleRequest=function(e,t,r){const n=this,i=e.origin,a=f(e);delete a.origin;const s={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(a)};n.originHttpHeaderKey&&i&&(s.headers[n.originHttpHeaderKey]=i),o({times:5,interval:1e3,errorFilter:p},e=>n._submitRequest(s,e),(e,t)=>{if(e&&p(e)){const t=`FetchSubprovider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,n=new Error(t);return r(n)}return r(e,t)})},d.prototype._submitRequest=function(e,t){const r=this.rpcUrl;c(n(r,e))((e,r)=>{if(e)return t(e);a([function(e){switch(r.status){case 405:return e(new u.MethodNotFound);case 418:return e(function(){const e=new Error("Request is being rate limited.");return new u.InternalError(e)}());case 503:case 504:return e(function(){let e="Gateway timeout. The request took too long to process. ";const t=new Error(e+="This can happen when querying logs over too wide a block range.");return new u.InternalError(t)}());default:return e()}},e=>c(r.text())(e),s(e=>JSON.parse(e)),function(e,t){if(200!==r.status)return t(new u.InternalError(e));if(e.error)return t(new u.InternalError(e.error));t(null,e.result)}],t)})}},{"../util/create-payload.js":391,"./subprovider.js":387,"async/asyncify":20,"async/retry":43,"async/waterfall":44,"cross-fetch":96,"json-rpc-error":189,"promise-to-callback":258,util:333}],379:[function(e,t,r){const n=e("async"),i=e("util").inherits,o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/stoplight.js"),u=e("events").EventEmitter;function c(e){e=e||{};const t=this;t.filterIndex=0,t.filters={},t.filterDestroyHandlers={},t.asyncBlockHandlers={},t.asyncPendingBlockHandlers={},t._ready=new s,t._ready.setMaxListeners(e.maxFilters||25),t._ready.go(),t.pendingBlockTimeout=e.pendingBlockTimeout||4e3,t.checkForPendingBlocksActive=!1,setTimeout(function(){t.engine.on("block",function(e){t._ready.stop();var r=v(t.asyncBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,function(e){e&&console.error(e),t._ready.go()})})})}function f(e){u.apply(this),this.type="block",this.engine=e.engine,this.blockNumber=e.blockNumber,this.updates=[]}function h(e){u.apply(this),this.type="log",this.fromBlock=void 0!==e.fromBlock?e.fromBlock:"latest",this.toBlock=void 0!==e.toBlock?e.toBlock:"latest";var t=e.address&&(Array.isArray(e.address)?e.address:[e.address]);this.address=t&&t.map(d),this.topics=e.topics||[],this.updates=[],this.allResults=[]}function l(){u.apply(this),this.type="pendingTx",this.updates=[],this.allResults=[]}function d(e){return"0x"===e.slice(0,2)?e:"0x"+e}function p(e){return o.intToHex(e)}function b(e){return Number(e)}function y(e){return function(e){let t=o.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}(e.toString("hex"))}function m(e){return e&&-1===["earliest","latest","pending"].indexOf(e)}function v(e){return Object.keys(e).map(function(t){return e[t]})}t.exports=c,i(c,a),c.prototype.handleRequest=function(e,t,r){const n=this;switch(e.method){case"eth_newBlockFilter":return void n.newBlockFilter(r);case"eth_newPendingTransactionFilter":return n.newPendingTransactionFilter(r),void n.checkForPendingBlocks();case"eth_newFilter":return void n.newLogFilter(e.params[0],r);case"eth_getFilterChanges":return void n._ready.await(function(){n.getFilterChanges(e.params[0],r)});case"eth_getFilterLogs":return void n._ready.await(function(){n.getFilterLogs(e.params[0],r)});case"eth_uninstallFilter":return void n._ready.await(function(){n.uninstallFilter(e.params[0],r)});default:return void t()}},c.prototype.newBlockFilter=function(e){const t=this;t._getBlockNumber(function(r,n){if(r)return e(r);var i=new f({blockNumber:n}),o=i.update.bind(i);t.engine.on("block",o);t.filterIndex++,t.filters[t.filterIndex]=i,t.filterDestroyHandlers[t.filterIndex]=function(){t.engine.removeListener("block",o)};var a=p(t.filterIndex);e(null,a)})},c.prototype.newLogFilter=function(e,t){const r=this;r._getBlockNumber(function(n,i){if(n)return t(n);var o=new h(e),a=o.update.bind(o);r.filterIndex++,r.asyncBlockHandlers[r.filterIndex]=function(e,t){r._logsForBlock(e,function(e,r){if(e)return t(e);a(r),t()})},r.filters[r.filterIndex]=o;var s=p(r.filterIndex);t(null,s)})},c.prototype.newPendingTransactionFilter=function(e){const t=this;var r=new l,n=r.update.bind(r);t.filterIndex++,t.asyncPendingBlockHandlers[t.filterIndex]=function(e,r){t._txHashesForBlock(e,function(e,t){if(e)return r(e);n(t),r()})},t.filters[t.filterIndex]=r,e(null,p(t.filterIndex))},c.prototype.getFilterChanges=function(e,t){var r=Number.parseInt(e,16),n=this.filters[r];if(n||console.warn("FilterSubprovider - no filter with that id:",e),!n)return t(null,[]);var i=n.getChanges();n.clearChanges(),t(null,i)},c.prototype.getFilterLogs=function(e,t){const r=this;var n=Number.parseInt(e,16),i=r.filters[n];if(i||console.warn("FilterSubprovider - no filter with that id:",e),!i)return t(null,[]);if("log"===i.type)r.emitPayload({method:"eth_getLogs",params:[{fromBlock:i.fromBlock,toBlock:i.toBlock,address:i.address,topics:i.topics}]},function(e,r){if(e)return t(e);t(null,r.result)});else{t(null,[])}},c.prototype.uninstallFilter=function(e,t){var r=Number.parseInt(e,16);if(this.filters[r]){this.filters[r].removeAllListeners();var n=this.filterDestroyHandlers[r];delete this.filters[r],delete this.asyncBlockHandlers[r],delete this.asyncPendingBlockHandlers[r],delete this.filterDestroyHandlers[r],n&&n(),t(null,!0)}else t(null,!1)},c.prototype.checkForPendingBlocks=function(){const e=this;e.checkForPendingBlocksActive||!!Object.keys(e.asyncPendingBlockHandlers).length&&(e.checkForPendingBlocksActive=!0,e.emitPayload({method:"eth_getBlockByNumber",params:["pending",!0]},function(t,r){if(t)return e.checkForPendingBlocksActive=!1,void console.error(t);e.onNewPendingBlock(r.result,function(t){t&&console.error(t),e.checkForPendingBlocksActive=!1,setTimeout(e.checkForPendingBlocks.bind(e),e.pendingBlockTimeout)})}))},c.prototype.onNewPendingBlock=function(e,t){var r=v(this.asyncPendingBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,t)},c.prototype._getBlockNumber=function(e){e(null,y(this.engine.currentBlock.number))},c.prototype._logsForBlock=function(e,t){var r=y(e.number);this.emitPayload({method:"eth_getLogs",params:[{fromBlock:r,toBlock:r}]},function(e,r){return e?t(e):r.error?t(r.error):void t(null,r.result)})},c.prototype._txHashesForBlock=function(e,t){var r=e.transactions;if(0===r.length)return t(null,[]);"string"==typeof r[0]?t(null,r):t(null,r.map(e=>e.hash))},i(f,u),f.prototype.update=function(e){var t="0x"+e.hash.toString("hex");this.updates.push(t),this.emit("data",e)},f.prototype.getChanges=function(){return this.updates},f.prototype.clearChanges=function(){this.updates=[]},i(h,u),h.prototype.validateLog=function(e){return!(m(this.fromBlock)&&b(this.fromBlock)>=b(e.blockNumber))&&(!(m(this.toBlock)&&b(this.toBlock)<=b(e.blockNumber))&&(!(this.address&&!this.address.map(e=>e.toLowerCase()).includes(e.address.toLowerCase()))&&this.topics.reduce(function(t,r,n){if(!t)return!1;if(!r)return!0;var i=e.topics[n];return!!i&&(Array.isArray(r)?r:[r]).filter(function(e){return i.toLowerCase()===e.toLowerCase()}).length>0},!0)))},h.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateLog(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},h.prototype.getChanges=function(){return this.updates},h.prototype.getAllResults=function(){return this.allResults},h.prototype.clearChanges=function(){this.updates=[]},i(l,u),l.prototype.validateUnique=function(e){return-1===this.allResults.indexOf(e)},l.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateUnique(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},l.prototype.getChanges=function(){return this.updates},l.prototype.getAllResults=function(){return this.allResults},l.prototype.clearChanges=function(){this.updates=[]}},{"../util/stoplight.js":396,"./subprovider.js":387,async:21,"ethereumjs-util":141,events:157,util:333}],380:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){e=e||{},this.staticResponses=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){var n=this.staticResponses[e.method];"function"==typeof n?n(e,t,r):void 0!==n?setTimeout(()=>r(null,n)):t()}},{"./subprovider.js":387,util:333}],381:[function(e,t,r){const n=e("async/waterfall"),i=e("async/parallel"),o=e("util").inherits,a=e("ethereumjs-util"),s=e("eth-sig-util"),u=e("xtend"),c=e("semaphore"),f=e("./subprovider.js"),h=e("../util/estimate-gas.js"),l=/^[0-9A-Fa-f]+$/g;function d(e){this.nonceLock=c(1),e.getAccounts&&(this.getAccounts=e.getAccounts),e.processTransaction&&(this.processTransaction=e.processTransaction),e.processMessage&&(this.processMessage=e.processMessage),e.processPersonalMessage&&(this.processPersonalMessage=e.processPersonalMessage),e.processTypedMessage&&(this.processTypedMessage=e.processTypedMessage),this.approveTransaction=e.approveTransaction||this.autoApprove,this.approveMessage=e.approveMessage||this.autoApprove,this.approvePersonalMessage=e.approvePersonalMessage||this.autoApprove,this.approveTypedMessage=e.approveTypedMessage||this.autoApprove,e.signTransaction&&(this.signTransaction=e.signTransaction||y("signTransaction")),e.signMessage&&(this.signMessage=e.signMessage||y("signMessage")),e.signPersonalMessage&&(this.signPersonalMessage=e.signPersonalMessage||y("signPersonalMessage")),e.signTypedMessage&&(this.signTypedMessage=e.signTypedMessage||y("signTypedMessage")),e.recoverPersonalSignature&&(this.recoverPersonalSignature=e.recoverPersonalSignature),e.publishTransaction&&(this.publishTransaction=e.publishTransaction)}function p(e){return e.toLowerCase()}function b(e){return"string"==typeof e&&("0x"===e.slice(0,2)&&e.slice(2).match(l))}function y(e){return function(t,r){r(new Error('ProviderEngine - HookedWalletSubprovider - Must provide "'+e+'" fn in constructor options'))}}t.exports=d,o(d,f),d.prototype.handleRequest=function(e,t,r){const i=this;let o,s,c,f,h;switch(i._parityRequests={},i._parityRequestCount=0,e.method){case"eth_coinbase":return void i.getAccounts(function(e,t){if(e)return r(e);let n=t[0]||null;r(null,n)});case"eth_accounts":return void i.getAccounts(function(e,t){if(e)return r(e);r(null,t)});case"eth_sendTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processTransaction(o,e)],r);case"eth_signTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processSignTransaction(o,e)],r);case"eth_sign":return h=e.params[0],f=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateMessage(s,e),e=>i.processMessage(s,e)],r);case"personal_sign":const l=e.params[0];if(function(e){const t=a.addHexPrefix(e);return!a.isValidAddress(t)&&b(e)}(e.params[1])&&function(e){const t=a.addHexPrefix(e);return a.isValidAddress(t)}(l)){let t="The eth_personalSign method requires params ordered ";t+="[message, address]. This was previously handled incorrectly, ",t+="and has been corrected automatically. ",t+="Please switch this param order for smooth behavior in the future.",console.warn(t),h=e.params[0],f=e.params[1]}else f=e.params[0],h=e.params[1];return c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validatePersonalMessage(s,e),e=>i.processPersonalMessage(s,e)],r);case"personal_ecRecover":f=e.params[0];let d=e.params[1];return c=e.params[2]||{},s=u(c,{sig:d,data:f}),void i.recoverPersonalSignature(s,r);case"eth_signTypedData":return f=e.params[0],h=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateTypedMessage(s,e),e=>i.processTypedMessage(s,e)],r);case"parity_postTransaction":return o=e.params[0],void i.parityPostTransaction(o,r);case"parity_postSign":return h=e.params[0],f=e.params[1],void i.parityPostSign(h,f,r);case"parity_checkRequest":const p=e.params[0];return void i.parityCheckRequest(p,r);case"parity_defaultAccount":return void i.getAccounts(function(e,t){if(e)return r(e);const n=t[0]||null;r(null,n)});default:return void t()}},d.prototype.getAccounts=function(e){e(null,[])},d.prototype.processTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeAndSubmitTx(e,t)],t)},d.prototype.processSignTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeTx(e,t)],t)},d.prototype.processMessage=function(e,t){const r=this;n([t=>r.approveMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signMessage(e,t)],t)},d.prototype.processPersonalMessage=function(e,t){const r=this;n([t=>r.approvePersonalMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signPersonalMessage(e,t)],t)},d.prototype.processTypedMessage=function(e,t){const r=this;n([t=>r.approveTypedMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signTypedMessage(e,t)],t)},d.prototype.autoApprove=function(e,t){t(null,!0)},d.prototype.checkApproval=function(e,t,r){r(t?null:new Error("User denied "+e+" signature."))},d.prototype.parityPostTransaction=function(e,t){const r=this,n=`0x${r._parityRequestCount.toString(16)}`;r._parityRequestCount++,r.emitPayload({method:"eth_sendTransaction",params:[e]},function(e,t){if(e)return void(r._parityRequests[n]={error:e});const i=t.result;r._parityRequests[n]=i}),t(null,n)},d.prototype.parityPostSign=function(e,t,r){const n=this,i=`0x${n._parityRequestCount.toString(16)}`;n._parityRequestCount++,n.emitPayload({method:"eth_sign",params:[e,t]},function(e,t){if(e)return void(n._parityRequests[i]={error:e});const r=t.result;n._parityRequests[i]=r}),r(null,i)},d.prototype.parityCheckRequest=function(e,t){const r=this._parityRequests[e]||null;return r?r.error?t(r.error):void t(null,r):t(null,null)},d.prototype.recoverPersonalSignature=function(e,t){let r;try{r=s.recoverPersonalSignature(e)}catch(e){return t(e)}t(null,r)},d.prototype.validateTransaction=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign transaction."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign transaction for this address: "${e.from}"`))})},d.prototype.validateMessage=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign message."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validatePersonalMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign personal message.")):void 0===e.data?t(new Error("Undefined message - message required to sign personal message.")):b(e.data)?void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))}):t(new Error("HookedWalletSubprovider - validateMessage - message was not encoded as hex."))},d.prototype.validateTypedMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign typed data.")):void 0===e.data?t(new Error("Undefined data - message required to sign typed data.")):void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validateSender=function(e,t){if(!e)return t(null,!1);this.getAccounts(function(r,n){if(r)return t(r);const i=-1!==n.map(p).indexOf(e.toLowerCase());t(null,i)})},d.prototype.finalizeAndSubmitTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r),r.publishTransaction.bind(r)],function(e,n){if(r.nonceLock.leave(),e)return t(e);t(null,n)})})},d.prototype.finalizeTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r)],function(n,i){if(r.nonceLock.leave(),n)return t(n);t(null,{raw:i,tx:e})})})},d.prototype.publishTransaction=function(e,t){this.emitPayload({method:"eth_sendRawTransaction",params:[e]},function(e,r){if(e)return t(e);t(null,r.result)})},d.prototype.fillInTxExtras=function(e,t){const r=this,n=e.from,o={};void 0===e.gasPrice&&(o.gasPrice=r.emitPayload.bind(r,{method:"eth_gasPrice",params:[]})),void 0===e.nonce&&(o.nonce=r.emitPayload.bind(r,{method:"eth_getTransactionCount",params:[n,"pending"]})),void 0===e.gas&&(o.gas=h.bind(null,r.engine,function(e){return{from:e.from,to:e.to,value:e.value,data:e.data,gas:e.gas,gasPrice:e.gasPrice,nonce:e.nonce}}(e))),i(o,function(r,n){if(r)return t(r);const i={};n.gasPrice&&(i.gasPrice=n.gasPrice.result),n.nonce&&(i.nonce=n.nonce.result),n.gas&&(i.gas=n.gas),t(null,u(e,i))})}},{"../util/estimate-gas.js":392,"./subprovider.js":387,"async/parallel":42,"async/waterfall":44,"eth-sig-util":136,"ethereumjs-util":141,semaphore:301,util:333,xtend:423}],382:[function(e,t,r){const n=e("../util/rpc-cache-utils.js").cacheIdentifierForPayload,i=e("./subprovider.js");t.exports=class extends i{constructor(e){super(),this.inflightRequests={}}addEngine(e){this.engine=e}handleRequest(e,t,r){const i=n(e,{includeBlockRef:!0});if(!i)return t();let o=this.inflightRequests[i];o?o.push(r):(o=[],this.inflightRequests[i]=o,t((e,t,r)=>{delete this.inflightRequests[i],o.forEach(r=>r(e,t)),r(e,t)}))}}},{"../util/rpc-cache-utils.js":394,"./subprovider.js":387}],383:[function(e,t,r){const n=e("eth-json-rpc-infura/src/createProvider"),i=e("./provider.js");t.exports=class extends i{constructor(e={}){super(n(e))}}},{"./provider.js":385,"eth-json-rpc-infura/src/createProvider":129}],384:[function(e,t,r){(function(r){const n=e("util").inherits,i=e("ethereumjs-tx"),o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/rpc-cache-utils").blockTagForPayload;function u(e){this.nonceCache={}}t.exports=u,n(u,a),u.prototype.handleRequest=function(e,t,n){const a=this;switch(e.method){case"eth_getTransactionCount":var u=s(e),c=e.params[0].toLowerCase(),f=a.nonceCache[c];return void("pending"===u?f?n(null,f):t(function(e,t,r){if(e)return r();void 0===a.nonceCache[c]&&(a.nonceCache[c]=t),r()}):t());case"eth_sendRawTransaction":return void t(function(t,n,s){if(t)return s();var u=e.params[0],c=(o.stripHexPrefix(u),new r(o.stripHexPrefix(u),"hex"),new i(new r(o.stripHexPrefix(u),"hex"))),f="0x"+c.getSenderAddress().toString("hex").toLowerCase(),h=o.bufferToInt(c.nonce),l=(++h).toString(16);l.length%2&&(l="0"+l),l="0x"+l,a.nonceCache[f]=l,s()});default:return void t()}}}).call(this,e("buffer").Buffer)},{"../util/rpc-cache-utils":394,"./subprovider.js":387,buffer:84,"ethereumjs-tx":140,"ethereumjs-util":141,util:333}],385:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){if(!e)throw new Error("ProviderSubprovider - no provider specified");if(!e.sendAsync)throw new Error("ProviderSubprovider - specified provider does not have a sendAsync method");this.provider=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){this.provider.sendAsync(e,function(e,t){return e?r(e):t.error?r(new Error(t.error.message)):void r(null,t.result)})}},{"./subprovider.js":387,util:333}],386:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js"),o=(e("xtend"),e("ethereumjs-util"));function a(e){}t.exports=a,n(a,i),a.prototype.handleRequest=function(e,t,r){var n=e.params[0];if("object"==typeof n&&!Array.isArray(n)){var i=function(e){return s.reduce(function(t,r){return r in e&&(Array.isArray(e[r])?t[r]=e[r].map(function(e){return u(e)}):t[r]=u(e[r])),t},{})}(n);e.params[0]=i}t()};var s=["from","to","value","data","gas","gasPrice","nonce","fromBlock","toBlock","address","topics"];function u(e){switch(e){case"latest":case"pending":case"earliest":return e;default:return"string"==typeof e?o.addHexPrefix(e.toLowerCase()):e}}},{"./subprovider.js":387,"ethereumjs-util":141,util:333,xtend:423}],387:[function(e,t,r){const n=e("../util/create-payload.js");function i(){}t.exports=i,i.prototype.setEngine=function(e){const t=this;t.engine=e,e.on("block",function(e){t.currentBlock=e})},i.prototype.handleRequest=function(e,t,r){throw new Error("Subproviders should override `handleRequest`.")},i.prototype.emitPayload=function(e,t){this.engine.sendAsync(n(e),t)}},{"../util/create-payload.js":391}],388:[function(e,t,r){const n=e("events").EventEmitter,i=e("./filters.js"),o=e("../util/rpc-hex-encoding.js"),a=e("util").inherits,s=e("ethereumjs-util");function u(e){e=e||{},n.apply(this,Array.prototype.slice.call(arguments)),i.apply(this,[e]),this.subscriptions={}}a(u,i),Object.assign(u.prototype,n.prototype),u.prototype.constructor=u,u.prototype.eth_subscribe=function(e,t){const r=this;let n=()=>{},i=e.params[0];switch(i){case"logs":let o=e.params[1];n=r.newLogFilter.bind(r,o);break;case"newPendingTransactions":n=r.newPendingTransactionFilter.bind(r);break;case"newHeads":n=r.newBlockFilter.bind(r);break;case"syncing":default:return void t(new Error("unsupported subscription type"))}n(function(e,n){if(e)return t(e);const o=Number.parseInt(n,16);r.subscriptions[o]=i,r.filters[o].on("data",function(e){Array.isArray(e)||(e=[e]);var t=r._notificationHandler.bind(r,n,i);e.forEach(t),r.filters[o].clearChanges()}),"newPendingTransactions"===i&&r.checkForPendingBlocks(),t(null,n)})},u.prototype.eth_unsubscribe=function(e,t){const r=this;let n=e.params[0];const i=Number.parseInt(n,16);if(r.subscriptions[i]){r.subscriptions[i];r.uninstallFilter(n,function(e,n){delete r.subscriptions[i],t(e,n)})}else t(new Error(`Subscription ID ${n} not found.`))},u.prototype._notificationHandler=function(e,t,r){const n=this;"newHeads"===t&&(r=n._notificationResultFromBlock(r)),n.emit("data",null,{jsonrpc:"2.0",method:"eth_subscription",params:{subscription:e,result:r}})},u.prototype._notificationResultFromBlock=function(e){return{hash:s.bufferToHex(e.hash),parentHash:s.bufferToHex(e.parentHash),sha3Uncles:s.bufferToHex(e.sha3Uncles),miner:s.bufferToHex(e.miner),stateRoot:s.bufferToHex(e.stateRoot),transactionsRoot:s.bufferToHex(e.transactionsRoot),receiptsRoot:s.bufferToHex(e.receiptsRoot),logsBloom:s.bufferToHex(e.logsBloom),difficulty:o.intToQuantityHex(s.bufferToInt(e.difficulty)),number:o.intToQuantityHex(s.bufferToInt(e.number)),gasLimit:o.intToQuantityHex(s.bufferToInt(e.gasLimit)),gasUsed:o.intToQuantityHex(s.bufferToInt(e.gasUsed)),nonce:e.nonce?s.bufferToHex(e.nonce):null,mixHash:s.bufferToHex(e.mixHash),timestamp:o.intToQuantityHex(s.bufferToInt(e.timestamp)),extraData:s.bufferToHex(e.extraData)}},u.prototype.handleRequest=function(e,t,r){switch(e.method){case"eth_subscribe":this.eth_subscribe(e,r);break;case"eth_unsubscribe":this.eth_unsubscribe(e,r);break;default:i.prototype.handleRequest.apply(this,Array.prototype.slice.call(arguments))}},t.exports=u},{"../util/rpc-hex-encoding.js":395,"./filters.js":379,"ethereumjs-util":141,events:157,util:333}],389:[function(e,t,r){(function(r){const n=e("backoff"),i=e("events"),o=(e("util").inherits,r.WebSocket||e("ws")),a=e("./subprovider"),s=e("../util/create-payload");class u extends a{constructor({rpcUrl:e,debug:t,origin:r}){super(),i.call(this),Object.defineProperties(this,{_backoff:{value:n.exponential({randomisationFactor:.2,maxDelay:5e3})},_connectTime:{value:null,writable:!0},_log:{value:t?(...e)=>console.info.apply(console,["[WSProvider]",...e]):()=>{}},_origin:{value:r},_pendingRequests:{value:new Map},_socket:{value:null,writable:!0},_unhandledRequests:{value:[]},_url:{value:e}}),this._handleSocketClose=this._handleSocketClose.bind(this),this._handleSocketMessage=this._handleSocketMessage.bind(this),this._handleSocketOpen=this._handleSocketOpen.bind(this),this._backoff.on("ready",()=>{this._openSocket()}),this._openSocket()}handleRequest(e,t,r){if(!this._socket||this._socket.readyState!==o.OPEN)return this._unhandledRequests.push(Array.from(arguments)),void this._log("Socket not open. Request queued.");this._pendingRequests.set(e.id,[e,r]);const n=s(e);delete n.origin,this._socket.send(JSON.stringify(n)),this._log(`Sent: ${n.method} #${n.id}`)}_handleSocketClose({reason:e,code:t}){this._log(`Socket closed, code ${t} (${e||"no reason"})`),this._connectTime&&Date.now()-this._connectTime>5e3&&this._backoff.reset(),this._socket.removeEventListener("close",this._handleSocketClose),this._socket.removeEventListener("message",this._handleSocketMessage),this._socket.removeEventListener("open",this._handleSocketOpen),this._socket=null,this._backoff.backoff()}_handleSocketMessage(e){let t;try{t=JSON.parse(e.data)}catch(e){return void this._log("Received a message that is not valid JSON:",t)}if(void 0===t.id)return this.emit("data",null,t);if(!this._pendingRequests.has(t.id))return;const[r,n]=this._pendingRequests.get(t.id);if(this._pendingRequests.delete(t.id),this._log(`Received: ${r.method} #${t.id}`),t.error)return n(new Error(t.error.message));n(null,t.result)}_handleSocketOpen(){this._log("Socket open."),this._connectTime=Date.now(),this._pendingRequests.forEach(([e,t])=>{this._unhandledRequests.push([e,null,t])}),this._pendingRequests.clear(),this._unhandledRequests.splice(0,this._unhandledRequests.length).forEach(e=>{this.handleRequest.apply(this,e)})}_openSocket(){this._log("Opening socket..."),this._socket=new o(this._url,null,{origin:this._origin}),this._socket.addEventListener("close",this._handleSocketClose),this._socket.addEventListener("message",this._handleSocketMessage),this._socket.addEventListener("open",this._handleSocketOpen)}}Object.assign(u.prototype,i.prototype),t.exports=u}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util/create-payload":391,"./subprovider":387,backoff:45,events:157,util:333,ws:55}],390:[function(e,t,r){t.exports=function(e,t){if(!e)throw t||"Assertion failed"}},{}],391:[function(e,t,r){const n=e("./random-id.js"),i=e("xtend");t.exports=function(e){return i({id:n(),jsonrpc:"2.0",params:[]},e)}},{"./random-id.js":393,xtend:423}],392:[function(e,t,r){const n=e("./create-payload.js");t.exports=function(e,t,r){e.sendAsync(n({method:"eth_estimateGas",params:[t]}),function(e,t){if(e)return"no contract code at given address"===e.message?r(null,"0xcf08"):r(e);r(null,t.result)})}},{"./create-payload.js":391}],393:[function(e,t,r){const n=3;t.exports=function(){var e=(new Date).getTime()*Math.pow(10,n),t=Math.floor(Math.random()*Math.pow(10,n));return e+t}},{}],394:[function(e,t,r){const n=e("json-stable-stringify");function i(e){return"never"!==s(e)}function o(e){var t=a(e);return t>=e.params.length?e.params:"eth_getBlockByNumber"===e.method?e.params.slice(1):e.params.slice(0,t)}function a(e){switch(e.method){case"eth_getStorageAt":return 2;case"eth_getBalance":case"eth_getCode":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":return 1;case"eth_getBlockByNumber":return 0;default:return}}function s(e){switch(e.method){case"web3_clientVersion":case"web3_sha3":case"eth_protocolVersion":case"eth_getBlockTransactionCountByHash":case"eth_getUncleCountByBlockHash":case"eth_getCode":case"eth_getBlockByHash":case"eth_getTransactionByHash":case"eth_getTransactionByBlockHashAndIndex":case"eth_getTransactionReceipt":case"eth_getUncleByBlockHashAndIndex":case"eth_getCompilers":case"eth_compileLLL":case"eth_compileSolidity":case"eth_compileSerpent":case"shh_version":return"perma";case"eth_getBlockByNumber":case"eth_getBlockTransactionCountByNumber":case"eth_getUncleCountByBlockNumber":case"eth_getTransactionByBlockNumberAndIndex":case"eth_getUncleByBlockNumberAndIndex":return"fork";case"eth_gasPrice":case"eth_blockNumber":case"eth_getBalance":case"eth_getStorageAt":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":case"eth_getFilterLogs":case"eth_getLogs":case"net_peerCount":return"block";case"net_version":case"net_peerCount":case"net_listening":case"eth_syncing":case"eth_sign":case"eth_coinbase":case"eth_mining":case"eth_hashrate":case"eth_accounts":case"eth_sendTransaction":case"eth_sendRawTransaction":case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_getFilterChanges":case"eth_getWork":case"eth_submitWork":case"eth_submitHashrate":case"db_putString":case"db_getString":case"db_putHex":case"db_getHex":case"shh_post":case"shh_newIdentity":case"shh_hasIdentity":case"shh_newGroup":case"shh_addToGroup":case"shh_newFilter":case"shh_uninstallFilter":case"shh_getFilterChanges":case"shh_getMessages":return"never"}}t.exports={cacheIdentifierForPayload:function(e,t={}){if(!i(e))return null;const{includeBlockRef:r}=t,a=r?e.params:o(e);return e.method+":"+n(a)},canCache:i,blockTagForPayload:function(e){var t=a(e);if(t>=e.params.length)return null;return e.params[t]},paramsWithoutBlockTag:o,blockTagParamIndex:a,cacheTypeForPayload:s}},{"json-stable-stringify":374}],395:[function(e,t,r){(function(r){const n=e("ethereumjs-util"),i=e("./assert.js");t.exports={intToQuantityHex:function(e){i("number"==typeof e&&e===Math.floor(e),"intToQuantityHex arg must be an integer");var t=n.toBuffer(e).toString("hex");"0"===t[0]&&(t=t.substring(1));return n.addHexPrefix(t)},quantityHexToInt:function(e){i("string"==typeof e,"arg to quantityHexToInt must be a string");var t=n.stripHexPrefix(e);t.length%2!=0&&(t="0"+t);var o=new r(t,"hex");return n.bufferToInt(o)}}}).call(this,e("buffer").Buffer)},{"./assert.js":390,buffer:84,"ethereumjs-util":141}],396:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits;function o(){n.call(this),this.isLocked=!0}t.exports=o,i(o,n),o.prototype.go=function(){this.isLocked=!1,this.emit("unlock")},o.prototype.stop=function(){this.isLocked=!0,this.emit("lock")},o.prototype.await=function(e){const t=this;t.isLocked?t.once("unlock",e):setTimeout(e)}},{events:157,util:333}],397:[function(e,t,r){const n=e("./index.js"),i=e("./subproviders/default-fixture.js"),o=e("./subproviders/nonce-tracker.js"),a=e("./subproviders/cache.js"),s=e("./subproviders/filters.js"),u=e("./subproviders/subscriptions"),c=e("./subproviders/inflight-cache"),f=e("./subproviders/hooked-wallet.js"),h=e("./subproviders/sanitizer.js"),l=e("./subproviders/infura.js"),d=e("./subproviders/fetch.js"),p=e("./subproviders/websocket.js");t.exports=function(e={}){const t=function({rpcUrl:e}){if(!e)return;switch(e.split(":")[0].toLowerCase()){case"http":case"https":return"http";case"ws":case"wss":return"ws";default:throw new Error(`ProviderEngine - unrecognized protocol in "${e}"`)}}(e),r=new n(e.engineParams),b=new i(e.static);r.addProvider(b),r.addProvider(new o);const y=new h;r.addProvider(y);const m=new a;if(r.addProvider(m),"ws"===t){const e=new s;r.addProvider(e)}else{const e=new u;e.on("data",(e,t)=>{r.emit("data",e,t)}),r.addProvider(e)}const v=new c;r.addProvider(v);const g=new f({getAccounts:e.getAccounts,processTransaction:e.processTransaction,approveTransaction:e.approveTransaction,signTransaction:e.signTransaction,publishTransaction:e.publishTransaction,processMessage:e.processMessage,approveMessage:e.approveMessage,signMessage:e.signMessage,processPersonalMessage:e.processPersonalMessage,processTypedMessage:e.processTypedMessage,approvePersonalMessage:e.approvePersonalMessage,approveTypedMessage:e.approveTypedMessage,signPersonalMessage:e.signPersonalMessage,signTypedMessage:e.signTypedMessage,personalRecoverSigner:e.personalRecoverSigner});r.addProvider(g);const w=e.dataSubprovider||function(e,t){const{rpcUrl:r,debug:n}=t;if(!e)return new l;if("http"===e)return new d({rpcUrl:r,debug:n});if("ws"===e)return new p({rpcUrl:r,debug:n});throw new Error(`ProviderEngine - unrecognized connectionType "${e}"`)}(t,e);"ws"===t&&w.on("data",(e,t)=>{r.emit("data",e,t)});r.addProvider(w),e.stopped||r.start();return r}},{"./index.js":373,"./subproviders/cache.js":376,"./subproviders/default-fixture.js":377,"./subproviders/fetch.js":378,"./subproviders/filters.js":379,"./subproviders/hooked-wallet.js":381,"./subproviders/inflight-cache":382,"./subproviders/infura.js":383,"./subproviders/nonce-tracker.js":384,"./subproviders/sanitizer.js":386,"./subproviders/subscriptions":388,"./subproviders/websocket.js":389}],398:[function(e,t,r){var n=e("web3-core-helpers").errors,i=e("xhr2-cookies").XMLHttpRequest,o=e("http"),a=e("https"),s=function(e,t){t=t||{},this.host=e||"http://localhost:8545","https"===this.host.substring(0,5)?this.httpsAgent=new a.Agent({keepAlive:!0}):this.httpAgent=new o.Agent({keepAlive:!0}),this.timeout=t.timeout||0,this.headers=t.headers,this.connected=!1};s.prototype._prepareRequest=function(){var e=new i;return e.nodejsSet({httpsAgent:this.httpsAgent,httpAgent:this.httpAgent}),e.open("POST",this.host,!0),e.setRequestHeader("Content-Type","application/json"),e.timeout=this.timeout&&1!==this.timeout?this.timeout:0,e.withCredentials=!0,this.headers&&this.headers.forEach(function(t){e.setRequestHeader(t.name,t.value)}),e},s.prototype.send=function(e,t){var r=this,i=this._prepareRequest();i.onreadystatechange=function(){if(4===i.readyState&&1!==i.timeout){var e=i.responseText,o=null;try{e=JSON.parse(e)}catch(e){o=n.InvalidResponse(i.responseText)}r.connected=!0,t(o,e)}},i.ontimeout=function(){r.connected=!1,t(n.ConnectionTimeout(this.timeout))};try{i.send(JSON.stringify(e))}catch(e){this.connected=!1,t(n.InvalidConnection(this.host))}},s.prototype.disconnect=function(){},t.exports=s},{http:312,https:175,"web3-core-helpers":338,"xhr2-cookies":418}],399:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("oboe"),a=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],this.path=e,this.connected=!1,this.connection=t.connect({path:this.path}),this.addDefaultEvents();var i=function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,t||-1===e.method.indexOf("_subscription")?r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t]):r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)})};"Socket"===t.constructor.name?o(this.connection).done(i):this.connection.on("data",function(e){r._parseResponse(e.toString()).forEach(i)})};a.prototype.addDefaultEvents=function(){var e=this;this.connection.on("connect",function(){e.connected=!0}),this.connection.on("close",function(){e.connected=!1}),this.connection.on("error",function(){e._timeout()}),this.connection.on("end",function(){e._timeout()}),this.connection.on("timeout",function(){e._timeout()})},a.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},a.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n},a.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on IPC")),delete this.responseCallbacks[e])},a.prototype.reconnect=function(){this.connection.connect({path:this.path})},a.prototype.send=function(e,t){this.connection.writable||this.connection.connect({path:this.path}),this.connection.write(JSON.stringify(e)),this._addResponseCallback(e,t)},a.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;default:this.connection.on(e,t)}},a.prototype.once=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");this.connection.once(e,t)},a.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)});break;default:this.connection.removeListener(e,t)}},a.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;default:this.connection.removeAllListeners(e)}},a.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.connection.removeAllListeners("error"),this.connection.removeAllListeners("end"),this.connection.removeAllListeners("timeout"),this.addDefaultEvents()},t.exports=a},{oboe:239,underscore:325,"web3-core-helpers":338}],400:[function(e,t,r){(function(r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=null,a=null,s=null;if("undefined"!=typeof window&&void 0!==window.WebSocket)o=function(e,t){return new window.WebSocket(e,t)},a=btoa,s=function(e){return new URL(e)};else{o=e("websocket").w3cwebsocket,a=function(e){return r(e).toString("base64")};var u=e("url");if(u.URL){var c=u.URL;s=function(e){return new c(e)}}else s=e("url").parse}var f=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],t=t||{},this._customTimeout=t.timeout;var i=s(e),u=t.headers||{},c=t.protocol||void 0;i.username&&i.password&&(u.authorization="Basic "+a(i.username+":"+i.password));var f=t.clientConfig||void 0;i.auth&&(u.authorization="Basic "+a(i.auth)),this.connection=new o(e,c,void 0,u,void 0,f),this.addDefaultEvents(),this.connection.onmessage=function(e){var t="string"==typeof e.data?e.data:"";r._parseResponse(t).forEach(function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,!t&&e&&e.method&&-1!==e.method.indexOf("_subscription")?r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)}):r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t])})},Object.defineProperty(this,"connected",{get:function(){return this.connection&&this.connection.readyState===this.connection.OPEN},enumerable:!0})};f.prototype.addDefaultEvents=function(){var e=this;this.connection.onerror=function(){e._timeout()},this.connection.onclose=function(){e._timeout(),e.reset()}},f.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},f.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n;var o=this;this._customTimeout&&setTimeout(function(){o.responseCallbacks[r]&&(o.responseCallbacks[r](i.ConnectionTimeout(o._customTimeout)),delete o.responseCallbacks[r])},this._customTimeout)},f.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on WS")),delete this.responseCallbacks[e])},f.prototype.send=function(e,t){var r=this;if(this.connection.readyState!==this.connection.CONNECTING){if(this.connection.readyState!==this.connection.OPEN)return console.error("connection not open on send()"),"function"==typeof this.connection.onerror?this.connection.onerror(new Error("connection not open")):console.error("no error callback"),void t(new Error("connection not open"));this.connection.send(JSON.stringify(e)),this._addResponseCallback(e,t)}else setTimeout(function(){r.send(e,t)},10)},f.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;case"connect":this.connection.onopen=t;break;case"end":this.connection.onclose=t;break;case"error":this.connection.onerror=t}},f.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)})}},f.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;case"connect":this.connection.onopen=null;break;case"end":this.connection.onclose=null;break;case"error":this.connection.onerror=null}},f.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.addDefaultEvents()},f.prototype.disconnect=function(){this.connection&&this.connection.close()},t.exports=f}).call(this,e("buffer").Buffer)},{buffer:84,underscore:325,url:327,"web3-core-helpers":338,websocket:408}],401:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-subscriptions").subscriptions,o=e("web3-core-method"),a=e("web3-net"),s=function(){var e=this;n.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments)},this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new a(this.currentProvider),[new i({name:"subscribe",type:"shh",subscriptions:{messages:{params:1}}}),new o({name:"getVersion",call:"shh_version",params:0}),new o({name:"getInfo",call:"shh_info",params:0}),new o({name:"setMaxMessageSize",call:"shh_setMaxMessageSize",params:1}),new o({name:"setMinPoW",call:"shh_setMinPoW",params:1}),new o({name:"markTrustedPeer",call:"shh_markTrustedPeer",params:1}),new o({name:"newKeyPair",call:"shh_newKeyPair",params:0}),new o({name:"addPrivateKey",call:"shh_addPrivateKey",params:1}),new o({name:"deleteKeyPair",call:"shh_deleteKeyPair",params:1}),new o({name:"hasKeyPair",call:"shh_hasKeyPair",params:1}),new o({name:"getPublicKey",call:"shh_getPublicKey",params:1}),new o({name:"getPrivateKey",call:"shh_getPrivateKey",params:1}),new o({name:"newSymKey",call:"shh_newSymKey",params:0}),new o({name:"addSymKey",call:"shh_addSymKey",params:1}),new o({name:"generateSymKeyFromPassword",call:"shh_generateSymKeyFromPassword",params:1}),new o({name:"hasSymKey",call:"shh_hasSymKey",params:1}),new o({name:"getSymKey",call:"shh_getSymKey",params:1}),new o({name:"deleteSymKey",call:"shh_deleteSymKey",params:1}),new o({name:"newMessageFilter",call:"shh_newMessageFilter",params:1}),new o({name:"getFilterMessages",call:"shh_getFilterMessages",params:1}),new o({name:"deleteMessageFilter",call:"shh_deleteMessageFilter",params:1}),new o({name:"post",call:"shh_post",params:1,inputFormatter:[null]}),new o({name:"unsubscribe",call:"shh_unsubscribe",params:1})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(s),t.exports=s},{"web3-core":348,"web3-core-method":339,"web3-core-subscriptions":345,"web3-net":372}],402:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],403:[function(e,t,r){var n=e("underscore"),i=e("ethjs-unit"),o=e("./utils.js"),a=e("./soliditySha3.js"),s=e("randomhex"),u=function(e,t){var r=[];return t.forEach(function(t){if("object"==typeof t.components){if("tuple"!==t.type.substring(0,5))throw new Error("components found but type is not tuple; report on GitHub");var i="",o=t.type.indexOf("[");o>=0&&(i=t.type.substring(o));var a=u(e,t.components);n.isArray(a)&&e?r.push("tuple("+a.join(",")+")"+i):e?r.push("("+a+")"):r.push("("+a.join(",")+")"+i)}else r.push(t.type)}),r},c=function(e){if(!o.isHexStrict(e))throw new Error("The parameter must be a valid HEX string.");var t="",r=0,n=e.length;for("0x"===e.substring(0,2)&&(r=2);r7?r+=e[n].toUpperCase():r+=e[n];return r},toHex:o.toHex,toBN:o.toBN,bytesToHex:o.bytesToHex,hexToBytes:o.hexToBytes,hexToNumberString:o.hexToNumberString,hexToNumber:o.hexToNumber,toDecimal:o.hexToNumber,numberToHex:o.numberToHex,fromDecimal:o.numberToHex,hexToUtf8:o.hexToUtf8,hexToString:o.hexToUtf8,toUtf8:o.hexToUtf8,utf8ToHex:o.utf8ToHex,stringToHex:o.utf8ToHex,fromUtf8:o.utf8ToHex,hexToAscii:c,toAscii:c,asciiToHex:f,fromAscii:f,unitMap:i.unitMap,toWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.toWei(e,t):i.toWei(e,t).toString(10)},fromWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.fromWei(e,t):i.fromWei(e,t).toString(10)},padLeft:o.leftPad,leftPad:o.leftPad,padRight:o.rightPad,rightPad:o.rightPad,toTwosComplement:o.toTwosComplement}},{"./soliditySha3.js":404,"./utils.js":405,"ethjs-unit":153,randomhex:274,underscore:325}],404:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("./utils.js"),a=function(e){var t=typeof e;if("string"===t)return o.isHexStrict(e)?new i(e.replace(/0x/i,""),16):new i(e,10);if("number"===t)return new i(e);if(o.isBigNumber(e))return new i(e.toString(10));if(o.isBN(e))return e;throw new Error(e+" is not a number")},s=function(e,t,r){var n,s,u;if("bytes"===(e=(u=e).startsWith("int[")?"int256"+u.slice(3):"int"===u?"int256":u.startsWith("uint[")?"uint256"+u.slice(4):"uint"===u?"uint256":u.startsWith("fixed[")?"fixed128x128"+u.slice(5):"fixed"===u?"fixed128x128":u.startsWith("ufixed[")?"ufixed128x128"+u.slice(6):"ufixed"===u?"ufixed128x128":u)){if(t.replace(/^0x/i,"").length%2!=0)throw new Error("Invalid bytes characters "+t.length);return t}if("string"===e)return o.utf8ToHex(t);if("bool"===e)return t?"01":"00";if(e.startsWith("address")){if(n=r?64:40,!o.isAddress(t))throw new Error(t+" is not a valid address, or the checksum is invalid.");return o.leftPad(t.toLowerCase(),n)}if(n=function(e){var t=/^\D+(\d+).*$/.exec(e);return t?parseInt(t[1],10):null}(e),e.startsWith("bytes")){if(!n)throw new Error("bytes[] not yet supported in solidity");if(r&&(n=32),n<1||n>32||n256)throw new Error("Invalid uint"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied uint exceeds width: "+n+" vs "+s.bitLength());if(s.lt(new i(0)))throw new Error("Supplied uint "+s.toString()+" is negative");return n?o.leftPad(s.toString("hex"),n/8*2):s}if(e.startsWith("int")){if(n%8||n<8||n>256)throw new Error("Invalid int"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied int exceeds width: "+n+" vs "+s.bitLength());return s.lt(new i(0))?s.toTwos(n).toString("hex"):n?o.leftPad(s.toString("hex"),n/8*2):s}throw new Error("Unsupported or invalid type: "+e)},u=function(e){if(n.isArray(e))throw new Error("Autodetection of array types is not supported.");var t,r,a="";if(n.isObject(e)&&(e.hasOwnProperty("v")||e.hasOwnProperty("t")||e.hasOwnProperty("value")||e.hasOwnProperty("type"))?(t=e.hasOwnProperty("t")?e.t:e.type,a=e.hasOwnProperty("v")?e.v:e.value):(t=o.toHex(e,!0),a=o.toHex(e),t.startsWith("int")||t.startsWith("uint")||(t="bytes")),!t.startsWith("int")&&!t.startsWith("uint")||"string"!=typeof a||/^(-)?0x/i.test(a)||(a=new i(a)),n.isArray(a)){if((r=function(e){var t=/^\D+\d*\[(\d+)\]$/.exec(e);return t?parseInt(t[1],10):null}(t))&&a.length!==r)throw new Error(t+" is not matching the given array "+JSON.stringify(a));r=a.length}return n.isArray(a)?a.map(function(e){return s(t,e,r).toString("hex").replace("0x","")}).join(""):s(t,a,r).toString("hex").replace("0x","")};t.exports=function(){var e=Array.prototype.slice.call(arguments),t=n.map(e,u);return o.sha3("0x"+t.join(""))}},{"./utils.js":405,"bn.js":402,underscore:325}],405:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("number-to-bn"),a=e("utf8"),s=e("eth-lib/lib/hash"),u=function(e){return e instanceof i||e&&e.constructor&&"BN"===e.constructor.name},c=function(e){return e&&e.constructor&&"BigNumber"===e.constructor.name},f=function(e){try{return o.apply(null,arguments)}catch(t){throw new Error(t+' Given value: "'+e+'"')}},h=function(e){return!!/^(0x)?[0-9a-f]{40}$/i.test(e)&&(!(!/^(0x|0X)?[0-9a-f]{40}$/.test(e)&&!/^(0x|0X)?[0-9A-F]{40}$/.test(e))||l(e))},l=function(e){e=e.replace(/^0x/i,"");for(var t=m(e.toLowerCase()).replace(/^0x/i,""),r=0;r<40;r++)if(parseInt(t[r],16)>7&&e[r].toUpperCase()!==e[r]||parseInt(t[r],16)<=7&&e[r].toLowerCase()!==e[r])return!1;return!0},d=function(e){var t="";e=(e=(e=(e=(e=a.encode(e)).replace(/^(?:\u0000)*/,"")).split("").reverse().join("")).replace(/^(?:\u0000)*/,"")).split("").reverse().join("");for(var r=0;r>>4).toString(16)),t.push((15&e[r]).toString(16));return"0x"+t.join("")},isHex:function(e){return(n.isString(e)||n.isNumber(e))&&/^(-0x|0x)?[0-9a-f]*$/i.test(e)},isHexStrict:y,leftPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+new Array(i).join(r||"0")+e},rightPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+e+new Array(i).join(r||"0")},toTwosComplement:function(e){return"0x"+f(e).toTwos(256).toString(16,64)},sha3:m}},{"bn.js":402,"eth-lib/lib/hash":134,"number-to-bn":237,underscore:325,utf8:329}],406:[function(e,t,r){t.exports={_from:"web3@1.0.0-beta.36",_id:"web3@1.0.0-beta.36",_inBundle:!1,_integrity:"sha512-fZDunw1V0AQS27r5pUN3eOVP7u8YAvyo6vOapdgVRolAu5LgaweP7jncYyLINqIX9ZgWdS5A090bt+ymgaYHsw==",_location:"/web3",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"web3@1.0.0-beta.36",name:"web3",escapedName:"web3",rawSpec:"1.0.0-beta.36",saveSpec:null,fetchSpec:"1.0.0-beta.36"},_requiredBy:["#USER","/"],_resolved:"https://registry.npmjs.org/web3/-/web3-1.0.0-beta.36.tgz",_shasum:"2954da9e431124c88396025510d840ba731c8373",_spec:"web3@1.0.0-beta.36",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy",author:{name:"ethereum.org"},authors:[{name:"Fabian Vogelsteller",email:"fabian@ethereum.org",homepage:"http://frozeman.de"},{name:"Marek Kotewicz",email:"marek@parity.io",url:"https://github.com/debris"},{name:"Marian Oancea",url:"https://github.com/cubedro"},{name:"Gav Wood",email:"g@parity.io",homepage:"http://gavwood.com"},{name:"Jeffery Wilcke",email:"jeffrey.wilcke@ethereum.org",url:"https://github.com/obscuren"}],bugs:{url:"https://github.com/ethereum/web3.js/issues"},bundleDependencies:!1,dependencies:{"web3-bzz":"1.0.0-beta.36","web3-core":"1.0.0-beta.36","web3-eth":"1.0.0-beta.36","web3-eth-personal":"1.0.0-beta.36","web3-net":"1.0.0-beta.36","web3-shh":"1.0.0-beta.36","web3-utils":"1.0.0-beta.36"},deprecated:!1,description:"Ethereum JavaScript API",keywords:["Ethereum","JavaScript","API"],license:"LGPL-3.0",main:"src/index.js",name:"web3",namespace:"ethereum",repository:{type:"git",url:"https://github.com/ethereum/web3.js/tree/master/packages/web3"},version:"1.0.0-beta.36"}},{}],407:[function(e,t,r){"use strict";var n=e("../package.json").version,i=e("web3-core"),o=e("web3-eth"),a=e("web3-net"),s=e("web3-eth-personal"),u=e("web3-shh"),c=e("web3-bzz"),f=e("web3-utils"),h=function(){var e=this;i.packageInit(this,arguments),this.version=n,this.utils=f,this.eth=new o(this),this.shh=new u(this),this.bzz=new c(this);var t=this.setProvider;this.setProvider=function(r,n){return t.apply(e,arguments),this.eth.setProvider(r,n),this.shh.setProvider(r,n),this.bzz.setProvider(r),!0}};h.version=n,h.utils=f,h.modules={Eth:o,Net:a,Personal:s,Shh:u,Bzz:c},i.addProviders(h),t.exports=h},{"../package.json":406,"web3-bzz":335,"web3-core":348,"web3-eth":371,"web3-eth-personal":369,"web3-net":372,"web3-shh":401,"web3-utils":403}],408:[function(e,t,r){var n=function(){return this||{}}(),i=n.WebSocket||n.MozWebSocket,o=e("./version");function a(e,t){return t?new i(e,t):new i(e)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(e){Object.defineProperty(a,e,{get:function(){return i[e]}})}),t.exports={w3cwebsocket:i?a:null,version:o}},{"./version":409}],409:[function(e,t,r){t.exports=e("../package.json").version},{"../package.json":410}],410:[function(e,t,r){t.exports={_from:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_id:"websocket@1.0.26",_inBundle:!1,_integrity:"",_location:"/websocket",_phantomChildren:{},_requested:{type:"git",raw:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",name:"websocket",escapedName:"websocket",rawSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",saveSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",fetchSpec:"git://github.com/frozeman/WebSocket-Node.git",gitCommittish:"browserifyCompatible"},_requiredBy:["/web3-providers-ws"],_resolved:"git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",_spec:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy/node_modules/web3-providers-ws",author:{name:"Brian McKelvey",email:"brian@worlize.com",url:"https://www.worlize.com/"},browser:"lib/browser.js",bugs:{url:"https://github.com/theturtle32/WebSocket-Node/issues"},bundleDependencies:!1,config:{verbose:!1},contributors:[{name:"Iñaki Baz Castillo",email:"ibc@aliax.net",url:"http://dev.sipdoc.net"}],dependencies:{debug:"^2.2.0",nan:"^2.3.3","typedarray-to-buffer":"^3.1.2",yaeti:"^0.0.6"},deprecated:!1,description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",devDependencies:{"buffer-equal":"^1.0.0",faucet:"^0.0.1",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-jshint":"^2.0.4",jshint:"^2.0.0","jshint-stylish":"^2.2.1",tape:"^4.0.1"},directories:{lib:"./lib"},engines:{node:">=0.10.0"},homepage:"https://github.com/theturtle32/WebSocket-Node",keywords:["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],license:"Apache-2.0",main:"index",name:"websocket",repository:{type:"git",url:"git+https://github.com/theturtle32/WebSocket-Node.git"},scripts:{gulp:"gulp",install:"(node-gyp rebuild 2> builderror.log) || (exit 0)",test:"faucet test/unit"},version:"1.0.26"}},{}],411:[function(e,t,r){var n=e("xhr-request");t.exports=function(e,t){return new Promise(function(r,i){n(e,t,function(e,t){e?i(e):r(t)})})}},{"xhr-request":412}],412:[function(e,t,r){var n=e("query-string"),i=e("url-set-query"),o=e("object-assign"),a=e("./lib/ensure-header.js"),s=e("./lib/request.js"),u="application/json",c=function(){};t.exports=function(e,t,r){if(!e||"string"!=typeof e)throw new TypeError("must specify a URL");"function"==typeof t&&(r=t,t={});if(r&&"function"!=typeof r)throw new TypeError("expected cb to be undefined or a function");r=r||c;var f=(t=t||{}).json?"json":"text",h=(t=o({responseType:f},t)).headers||{},l=(t.method||"GET").toUpperCase(),d=t.query;d&&("string"!=typeof d&&(d=n.stringify(d)),e=i(e,d));"json"===t.responseType&&a(h,"Accept",u);t.json&&"GET"!==l&&"HEAD"!==l&&(a(h,"Content-Type",u),t.body=JSON.stringify(t.body));return t.method=l,t.url=e,t.headers=h,delete t.query,delete t.json,s(t,r)}},{"./lib/ensure-header.js":413,"./lib/request.js":415,"object-assign":238,"query-string":266,"url-set-query":326}],413:[function(e,t,r){t.exports=function(e,t,r){var n=t.toLowerCase();e[t]||e[n]||(e[t]=r)}},{}],414:[function(e,t,r){t.exports=function(e,t){return t?{statusCode:t.statusCode,headers:t.headers,method:e.method,url:e.url,rawRequest:t.rawRequest?t.rawRequest:t}:null}},{}],415:[function(e,t,r){var n=e("xhr"),i=e("./normalize-response"),o=function(){};t.exports=function(e,t){delete e.uri;var r=!1;"json"===e.responseType&&(e.responseType="text",r=!0);var a=n(e,function(n,a,s){if(r&&!n)try{var u=a.rawRequest.responseText;s=JSON.parse(u)}catch(e){n=e}a=i(e,a),t(n,n?null:s,a),t=o}),s=a.onabort;return a.onabort=function(){var e=s.apply(a,Array.prototype.slice.call(arguments));return t(new Error("XHR Aborted")),t=o,e},a}},{"./normalize-response":414,xhr:416}],416:[function(e,t,r){"use strict";var n=e("global/window"),i=e("is-function"),o=e("parse-headers"),a=e("xtend");function s(e,t,r){var n=e;return i(t)?(r=t,"string"==typeof e&&(n={uri:e})):n=a(t,{uri:e}),n.callback=r,n}function u(e,t,r){return c(t=s(e,t,r))}function c(e){if(void 0===e.callback)throw new Error("callback argument missing");var t=!1,r=function(r,n,i){t||(t=!0,e.callback(r,n,i))};function n(e){return clearTimeout(f),e instanceof Error||(e=new Error(""+(e||"Unknown XMLHttpRequest Error"))),e.statusCode=0,r(e,m)}function i(){if(!s){var t;clearTimeout(f),t=e.useXDR&&void 0===c.status?200:1223===c.status?204:c.status;var n=m,i=null;return 0!==t?(n={body:function(){var e=void 0;if(e=c.response?c.response:c.responseText||function(e){try{if("document"===e.responseType)return e.responseXML;var t=e.responseXML&&"parsererror"===e.responseXML.documentElement.nodeName;if(""===e.responseType&&!t)return e.responseXML}catch(e){}return null}(c),y)try{e=JSON.parse(e)}catch(e){}return e}(),statusCode:t,method:l,headers:{},url:h,rawRequest:c},c.getAllResponseHeaders&&(n.headers=o(c.getAllResponseHeaders()))):i=new Error("Internal XMLHttpRequest Error"),r(i,n,n.body)}}var a,s,c=e.xhr||null;c||(c=e.cors||e.useXDR?new u.XDomainRequest:new u.XMLHttpRequest);var f,h=c.url=e.uri||e.url,l=c.method=e.method||"GET",d=e.body||e.data,p=c.headers=e.headers||{},b=!!e.sync,y=!1,m={body:void 0,headers:{},statusCode:0,method:l,url:h,rawRequest:c};if("json"in e&&!1!==e.json&&(y=!0,p.accept||p.Accept||(p.Accept="application/json"),"GET"!==l&&"HEAD"!==l&&(p["content-type"]||p["Content-Type"]||(p["Content-Type"]="application/json"),d=JSON.stringify(!0===e.json?d:e.json))),c.onreadystatechange=function(){4===c.readyState&&setTimeout(i,0)},c.onload=i,c.onerror=n,c.onprogress=function(){},c.onabort=function(){s=!0},c.ontimeout=n,c.open(l,h,!b,e.username,e.password),b||(c.withCredentials=!!e.withCredentials),!b&&e.timeout>0&&(f=setTimeout(function(){if(!s){s=!0,c.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT",n(e)}},e.timeout)),c.setRequestHeader)for(a in p)p.hasOwnProperty(a)&&c.setRequestHeader(a,p[a]);else if(e.headers&&!function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}(e.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in e&&(c.responseType=e.responseType),"beforeSend"in e&&"function"==typeof e.beforeSend&&e.beforeSend(c),c.send(d||null),c}t.exports=u,t.exports.default=u,u.XMLHttpRequest=n.XMLHttpRequest||function(){},u.XDomainRequest="withCredentials"in new u.XMLHttpRequest?u.XMLHttpRequest:n.XDomainRequest,function(e,t){for(var r=0;r=0)return this._url=this._parseUrl(t.headers.location),this._method="GET",this._loweredHeaders["content-type"]&&(delete this._headers[this._loweredHeaders["content-type"]],delete this._loweredHeaders["content-type"]),null!=this._headers["Content-Type"]&&delete this._headers["Content-Type"],delete this._headers["Content-Length"],this.upload._reset(),this._finalizeHeaders(),void this._sendHxxpRequest();this._response=t,this._response.on("data",function(e){return n._onHttpResponseData(t,e)}),this._response.on("end",function(){return n._onHttpResponseEnd(t)}),this._response.on("close",function(){return n._onHttpResponseClose(t)}),this.responseUrl=this._url.href.split("#")[0],this.status=t.statusCode,this.statusText=s.STATUS_CODES[this.status],this._parseResponseHeaders(t);var i=this._responseHeaders["content-length"]||"";this._totalBytes=+i,this._lengthComputable=!!i,this._setReadyState(r.HEADERS_RECEIVED)}},r.prototype._onHttpResponseData=function(e,t){this._response===e&&(this._responseParts.push(new n(t)),this._loadedBytes+=t.length,this.readyState!==r.LOADING&&this._setReadyState(r.LOADING),this._dispatchProgress("progress"))},r.prototype._onHttpResponseEnd=function(e){this._response===e&&(this._parseResponse(),this._request=null,this._response=null,this._setReadyState(r.DONE),this._dispatchProgress("load"),this._dispatchProgress("loadend"))},r.prototype._onHttpResponseClose=function(e){if(this._response===e){var t=this._request;this._setError(),t.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend")}},r.prototype._onHttpTimeout=function(e){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("timeout"),this._dispatchProgress("loadend"))},r.prototype._onHttpRequestError=function(e,t){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend"))},r.prototype._dispatchProgress=function(e){var t=new r.ProgressEvent(e);t.lengthComputable=this._lengthComputable,t.loaded=this._loadedBytes,t.total=this._totalBytes,this.dispatchEvent(t)},r.prototype._setError=function(){this._request=null,this._response=null,this._responseHeaders=null,this._responseParts=null},r.prototype._parseUrl=function(e,t,r){var n=null==this.nodejsBaseUrl?e:f.resolve(this.nodejsBaseUrl,e),i=f.parse(n,!1,!0);i.hash=null;var o=(i.auth||"").split(":"),a=o[0],s=o[1];return(a||s||t||r)&&(i.auth=(t||a||"")+":"+(r||s||"")),i},r.prototype._parseResponseHeaders=function(e){for(var t in this._responseHeaders={},e.headers){var r=t.toLowerCase();this._privateHeaders[r]||(this._responseHeaders[r]=e.headers[t])}null!=this._mimeOverride&&(this._responseHeaders["content-type"]=this._mimeOverride)},r.prototype._parseResponse=function(){var e=n.concat(this._responseParts);switch(this._responseParts=null,this.responseType){case"json":this.responseText=null;try{this.response=JSON.parse(e.toString("utf-8"))}catch(e){this.response=null}return;case"buffer":return this.responseText=null,void(this.response=e);case"arraybuffer":this.responseText=null;for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),i=0;i0&&(window.web3.eth.defaultAccount=t[0])})}window.ethereum=s}}},console.log("JS bridging rpc url access"),"undefined"!=typeof window&&window.bridge?window.bridge.post("getRPCurl",{},function(e,r){r&&t(r.description,null),t(null,e.rpcURL)}):(console.log("No bridge to native code is found"),t(!0,null))}()},{"./wk.bridge":424,web3:407,"web3-provider-engine/zero.js":397}],2:[function(e,t,r){t.exports=e("./register")().Promise},{"./register":4}],3:[function(e,t,r){"use strict";var n=null;t.exports=function(e,t){return function(r,i){r=r||null;var o=!1!==(i=i||{}).global;if(null===n&&o&&(n=e["@@any-promise/REGISTRATION"]||null),null!==n&&null!==r&&n.implementation!==r)throw new Error('any-promise already defined as "'+n.implementation+'". You can only register an implementation before the first call to require("any-promise") and an implementation cannot be changed');return null===n&&(n=null!==r&&void 0!==i.Promise?{Promise:i.Promise,implementation:r}:t(r),o&&(e["@@any-promise/REGISTRATION"]=n)),n}}},{}],4:[function(e,t,r){"use strict";t.exports=e("./loader")(window,function(){if(void 0===window.Promise)throw new Error("any-promise browser requires a polyfill or explicit registration e.g: require('any-promise/register/bluebird')");return{Promise:window.Promise,implementation:"window.Promise"}})},{"./loader":3}],5:[function(e,t,r){var n=r;n.bignum=e("bn.js"),n.define=e("./asn1/api").define,n.base=e("./asn1/base"),n.constants=e("./asn1/constants"),n.decoders=e("./asn1/decoders"),n.encoders=e("./asn1/encoders")},{"./asn1/api":6,"./asn1/base":8,"./asn1/constants":12,"./asn1/decoders":14,"./asn1/encoders":17,"bn.js":53}],6:[function(e,t,r){var n=e("../asn1"),i=e("inherits");function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}r.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(t){var r;try{r=e("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){r=function(e){this._initNamed(e)}}return i(r,t),r.prototype._initNamed=function(e){t.call(this,e)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(n.decoders[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(n.encoders[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},{"../asn1":5,inherits:180,vm:334}],7:[function(e,t,r){var n=e("inherits"),i=e("../base").Reporter,o=e("buffer").Buffer;function a(e,t){i.call(this,t),o.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function s(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return e instanceof s||(e=new s(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=o.byteLength(e);else{if(!o.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}n(a,i),r.DecoderBuffer=a,a.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},a.prototype.restore=function(e){var t=new a(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,i.prototype.restore.call(this,e.reporter),t},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},a.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new a(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},a.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},r.EncoderBuffer=s,s.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length?e:(Array.isArray(this.value)?this.value.forEach(function(r){r.join(e,t),t+=r.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):o.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},{"../base":8,buffer:84,inherits:180}],8:[function(e,t,r){var n=r;n.Reporter=e("./reporter").Reporter,n.DecoderBuffer=e("./buffer").DecoderBuffer,n.EncoderBuffer=e("./buffer").EncoderBuffer,n.Node=e("./node")},{"./buffer":7,"./node":9,"./reporter":10}],9:[function(e,t,r){var n=e("../base").Reporter,i=e("../base").EncoderBuffer,o=e("../base").DecoderBuffer,a=e("minimalistic-assert"),s=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],u=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function c(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}t.exports=c;var f=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){var e=this._baseState,t={};f.forEach(function(r){t[r]=e[r]});var r=new this.constructor(t.parent);return r._baseState=t,r},c.prototype._wrap=function(){var e=this._baseState;u.forEach(function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}},this)},c.prototype._init=function(e){var t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter(function(e){return e._baseState.parent===this},this),a.equal(t.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(e){var t=this._baseState,r=e.filter(function(e){return e instanceof this.constructor},this);e=e.filter(function(e){return!(e instanceof this.constructor)},this),0!==r.length&&(a(null===t.children),t.children=r,r.forEach(function(e){e._baseState.parent=this},this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map(function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach(function(r){r==(0|r)&&(r|=0);var n=e[r];t[n]=r}),t}))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(e){c.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}}),s.forEach(function(e){c.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(r),this}}),c.prototype.use=function(e){a(e);var t=this._baseState;return a(null===t.use),t.use=e,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(e){var t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},c.prototype.explicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},c.prototype.implicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},c.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},c.prototype.key=function(e){var t=this._baseState;return a(null===t.key),t.key=e,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(e){var t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map(function(t){return e[t]})),this},c.prototype.contains=function(e){var t=this._baseState;return a(null===t.use),t.contains=e,this},c.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var n,i=r.default,a=!0,s=null;if(null!==r.key&&(s=e.enterKey(r.key)),r.optional){var u=null;if(null!==r.explicit?u=r.explicit:null!==r.implicit?u=r.implicit:null!==r.tag&&(u=r.tag),null!==u||r.any){if(a=this._peekTag(e,u,r.any),e.isError(a))return a}else{var c=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(c)}}if(r.obj&&a&&(n=e.enterObject()),a){if(null!==r.explicit){var f=this._decodeTag(e,r.explicit);if(e.isError(f))return f;e=f}var h=e.offset;if(null===r.use&&null===r.choice){if(r.any)c=e.save();var l=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(l))return l;r.any?i=e.raw(c):e=l}if(t&&t.track&&null!==r.tag&&t.track(e.path(),h,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),i=r.any?i:null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),e.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach(function(r){r._decode(e,t)}),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var d=new o(i);i=this._getUse(r.contains,e._reporterState.obj)._decode(d,t)}}return r.obj&&a&&(i=e.leaveObject(n)),null===r.key||null===i&&!0!==a?null!==s&&e.exitKey(s):e.leaveKey(s,r.key,i),i},c.prototype._decodeGeneric=function(e,t,r){var n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},c.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},c.prototype._decodeChoice=function(e,t){var r=this._baseState,n=null,i=!1;return Object.keys(r.choice).some(function(o){var a=e.save(),s=r.choice[o];try{var u=s._decode(e,t);if(e.isError(u))return!1;n={type:o,value:u},i=!0}catch(t){return e.restore(a),!1}return!0},this),i?n:e.error("Choice not matched")},c.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},c.prototype._encode=function(e,t,r){var n=this._baseState;if(null===n.default||n.default!==e){var i=this._encodeValue(e,t,r);if(void 0!==i&&!this._skipDefault(i,t,r))return i}},c.prototype._encodeValue=function(e,t,r){var i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);var o=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}var a=null,s=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)a=this._getUse(i.contains,r)._encode(e,t),s=!0;else if(i.children)a=i.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i},this).filter(function(e){return e}),a=this._createEncoderBuffer(a);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var u=this.clone();u._baseState.implicit=null,a=this._createEncoderBuffer(e.map(function(r){var n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)},u))}else null!==i.use?o=this._getUse(i.use,r)._encode(e,t):(a=this._encodePrimitive(i.tag,e),s=!0);if(!i.any&&null===i.choice){var c=null!==i.implicit?i.implicit:i.tag,f=null===i.implicit?"universal":"context";null===c?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(c,s,f,a))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},c.prototype._encodeChoice=function(e,t){var r=this._baseState,n=r.choice[e.type];return n||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},c.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},c.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},c.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},{"../base":8,"minimalistic-assert":234}],10:[function(e,t,r){var n=e("inherits");function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}r.Reporter=i,i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,r){var n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){var t,r=this._reporterState,n=e instanceof o;if(t=n?e:new o(r.path.map(function(e){return"["+JSON.stringify(e)+"]"}).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},i.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},n(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{inherits:180}],11:[function(e,t,r){var n=e("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=n._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=n._reverse(r.tag)},{"../constants":12}],12:[function(e,t,r){var n=r;n._reverse=function(e){var t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r|=0);var n=e[r];t[n]=r}),t},n.der=e("./der")},{"./der":11}],13:[function(e,t,r){var n=e("inherits"),i=e("../../asn1"),o=i.base,a=i.bignum,s=i.constants.der;function u(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){o.Node.call(this,"der",e)}function f(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var n=s.tagClass[r>>6],i=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:s.tag[r]}}function h(e,t,r){var n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;var i=127&n;if(i>4)return e.error("length octet is too long");n=0;for(var o=0;o=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=s.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(n.length<128)return(o=new i(2))[0]=a,o[1]=n.length,this._createEncoderBuffer([o,n]);for(var u=1,c=n.length;c>=256;c>>=8)u++;(o=new i(2+u))[0]=a,o[1]=128|u;c=1+u;for(var f=n.length;f>0;c--,f>>=8)o[c]=255&f;return this._createEncoderBuffer([o,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new i(2*e.length),n=0;n=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var o=0;for(n=0;n=128;a>>=7)o++}var s=new i(o),u=s.length-1;for(n=e.length-1;n>=0;n--){a=e[n];for(s[u--]=127&a;(a>>=7)>0;)s[u--]=128|127&a}return this._createEncoderBuffer(s)},c.prototype._encodeTime=function(e,t){var r,n=new Date(e);return"gentime"===t?r=[f(n.getFullYear()),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[f(n.getFullYear()%100),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!i.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new i(r)}if(i.isBuffer(e)){var n=e.length;0===e.length&&n++;var o=new i(n);return e.copy(o),0===e.length&&(o[0]=0),this._createEncoderBuffer(o)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);n=1;for(var a=e;a>=256;a>>=8)n++;for(a=(o=new Array(n)).length-1;a>=0;a--)o[a]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new i(o))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){var n,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,r).join()),o.length!==i.defaultBuffer.length)return!1;for(n=0;n=0;c--)if(f[c]!==h[c])return!1;for(c=f.length-1;c>=0;c--)if(u=f[c],!v(e[u],t[u],r,n))return!1;return!0}(e,t,r,a))}return r?e===t:e==t}function g(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function w(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function _(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&y(i,r,"Missing expected exception"+n);var a="string"==typeof n,s=!e&&i&&!r;if((!e&&o.isError(i)&&a&&w(i,r)||s)&&y(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(i,r)||!e&&i)throw i}h.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=p(b((t=this).actual),128)+" "+t.operator+" "+p(b(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=d(r),a=i.indexOf("\n"+o);if(a>=0){var s=i.indexOf("\n",a+1);i=i.substring(s+1)}this.stack=i}}},o.inherits(h.AssertionError,Error),h.fail=y,h.ok=m,h.equal=function(e,t,r){e!=t&&y(e,t,r,"==",h.equal)},h.notEqual=function(e,t,r){e==t&&y(e,t,r,"!=",h.notEqual)},h.deepEqual=function(e,t,r){v(e,t,!1)||y(e,t,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(e,t,r){v(e,t,!0)||y(e,t,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(e,t,r){v(e,t,!1)&&y(e,t,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function e(t,r,n){v(t,r,!0)&&y(t,r,n,"notDeepStrictEqual",e)},h.strictEqual=function(e,t,r){e!==t&&y(e,t,r,"===",h.strictEqual)},h.notStrictEqual=function(e,t,r){e===t&&y(e,t,r,"!==",h.notStrictEqual)},h.throws=function(e,t,r){_(!0,e,t,r)},h.doesNotThrow=function(e,t,r){_(!1,e,t,r)},h.ifError=function(e){if(e)throw e};var A=Object.keys||function(e){var t=[];for(var r in e)a.call(e,r)&&t.push(r);return t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":333}],20:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){return(0,i.default)(function(t,r){var i;try{i=e.apply(this,t)}catch(e){return r(e)}(0,n.default)(i)&&"function"==typeof i.then?i.then(function(e){s(r,null,e)},function(e){s(r,e.message?e:new Error(e))}):r(null,i)})};var n=a(e("lodash/isObject")),i=a(e("./internal/initialParams")),o=a(e("./internal/setImmediate"));function a(e){return e&&e.__esModule?e:{default:e}}function s(e,t,r){try{e(t,r)}catch(e){(0,o.default)(u,e)}}function u(e){throw e}t.exports=r.default},{"./internal/initialParams":31,"./internal/setImmediate":37,"lodash/isObject":225}],21:[function(e,t,r){(function(e,n){!function(e,n){"object"==typeof r&&void 0!==t?n(r):"function"==typeof define&&define.amd?define(["exports"],n):n(e.async=e.async||{})}(this,function(r){"use strict";function i(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i-1&&e%1==0&&e<=L}function D(e){return null!=e&&O(e.length)&&!function(e){if(!s(e))return!1;var t=B(e);return t==C||t==N||t==P||t==R}(e)}var F={};function q(){}function H(e){return function(){if(null!==e){var t=e;e=null,t.apply(this,arguments)}}}var z="function"==typeof Symbol&&Symbol.iterator,K=function(e){return z&&e[z]&&e[z]()};function V(e){return null!=e&&"object"==typeof e}var G="[object Arguments]";function W(e){return V(e)&&B(e)==G}var Y=Object.prototype,X=Y.hasOwnProperty,Z=Y.propertyIsEnumerable,J=W(function(){return arguments}())?W:function(e){return V(e)&&X.call(e,"callee")&&!Z.call(e,"callee")},$=Array.isArray;var Q="object"==typeof r&&r&&!r.nodeType&&r,ee=Q&&"object"==typeof t&&t&&!t.nodeType&&t,te=ee&&ee.exports===Q?A.Buffer:void 0,re=(te?te.isBuffer:void 0)||function(){return!1},ne=9007199254740991,ie=/^(?:0|[1-9]\d*)$/;function oe(e,t){return!!(t=null==t?ne:t)&&("number"==typeof e||ie.test(e))&&e>-1&&e%1==0&&e2&&(n=i(arguments,1)),t){var c={};Fe(o,function(e,t){c[t]=e}),c[e]=n,s=!0,u=Object.create(null),r(t,c)}else o[e]=n,Le(u[e]||[],function(e){e()}),d()});a++;var c=v(t[t.length-1]);t.length>1?c(o,n):c(n)}(e,t)})}function d(){if(0===c.length&&0===a)return r(null,o);for(;c.length&&a=0&&r.push(n)}),r}Fe(e,function(t,r){if(!$(t))return l(r,[t]),void f.push(r);var n=t.slice(0,t.length-1),i=n.length;if(0===i)return l(r,t),void f.push(r);h[r]=i,Le(n,function(o){if(!e[o])throw new Error("async.auto task `"+r+"` has a non-existent dependency `"+o+"` in "+n.join(", "));!function(e,t){var r=u[e];r||(r=u[e]=[]);r.push(t)}(o,function(){0===--i&&l(r,t)})})}),function(){var e,t=0;for(;f.length;)e=f.pop(),t++,Le(p(e),function(e){0==--h[e]&&f.push(e)});if(t!==n)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),d()};function Ke(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r=n?e:function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n-1;);return r}(i,o),function(e,t){for(var r=e.length;r--&&He(t,e[r],0)>-1;);return r}(i,o)+1).join("")}var ht=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,lt=/,/,dt=/(=.+)?(\s*)$/,pt=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;function bt(e,t){var r={};Fe(e,function(e,t){var n,i,o=m(e),a=!o&&1===e.length||o&&0===e.length;if($(e))n=e.slice(0,-1),e=e[e.length-1],r[t]=n.concat(n.length>0?s:e);else if(a)r[t]=e;else{if(n=i=(i=(i=(i=(i=e).toString().replace(pt,"")).match(ht)[2].replace(" ",""))?i.split(lt):[]).map(function(e){return ft(e.replace(dt,""))}),0===e.length&&!o&&0===n.length)throw new Error("autoInject task functions require explicit parameters.");o||n.pop(),r[t]=n.concat(s)}function s(t,r){var i=Ke(n,function(e){return t[e]});i.push(r),v(e).apply(null,i)}}),ze(r,t)}function yt(){this.head=this.tail=null,this.length=0}function mt(e,t){e.length=1,e.head=e.tail=t}function vt(e,t,r){if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var n=v(e),i=0,o=[],a=!1;function s(e,t,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(f.started=!0,$(e)||(e=[e]),0===e.length&&f.idle())return l(function(){f.drain()});for(var n=0,i=e.length;n0&&o.splice(s,1),a.callback.apply(a,arguments),null!=t&&f.error(t,a.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()}}var c=!1,f={_tasks:new yt,concurrency:t,payload:r,saturated:q,unsaturated:q,buffer:t/4,empty:q,drain:q,error:q,started:!1,paused:!1,push:function(e,t){s(e,!1,t)},kill:function(){f.drain=q,f._tasks.empty()},unshift:function(e,t){s(e,!0,t)},remove:function(e){f._tasks.remove(e)},process:function(){if(!c){for(c=!0;!f.paused&&i2&&(o=i(arguments,1)),n[t]=o,r(e)})},function(e){r(e,n)})}function br(e,t){pr(Ie,e,t)}function yr(e,t,r){pr(Ee(t),e,r)}var mr=function(e,t){var r=v(e);return vt(function(e,t){r(e[0],t)},t,1)},vr=function(e,t){var r=mr(e,t);return r.push=function(e,t,n){if(null==n&&(n=q),"function"!=typeof n)throw new Error("task callback must be a function");if(r.started=!0,$(e)||(e=[e]),0===e.length)return l(function(){r.drain()});t=t||0;for(var i=r._tasks.head;i&&t>=i.priority;)i=i.next;for(var o=0,a=e.length;on?1:0}je(e,function(e,t){n(e,function(r,n){if(r)return t(r);t(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);r(null,Ke(t.sort(i),Zt("value")))})}function Nr(e,t,r){var n=v(e);return a(function(i,o){var a,s=!1;i.push(function(){s||(o.apply(null,arguments),clearTimeout(a))}),a=setTimeout(function(){var t=e.name||"anonymous",n=new Error('Callback function "'+t+'" timed out.');n.code="ETIMEDOUT",r&&(n.info=r),s=!0,o(n)},t),n.apply(null,i)})}var Rr=Math.ceil,Lr=Math.max;function Or(e,t,r,n){var i=v(r);Ce(function(e,t,r,n){for(var i=-1,o=Lr(Rr((t-e)/(r||1)),0),a=Array(o);o--;)a[n?o:++i]=e,e+=r;return a}(0,e,1),t,i,n)}var Dr=ke(Or,1/0),Fr=ke(Or,1);function qr(e,t,r,n){arguments.length<=3&&(n=r,r=t,t=$(e)?[]:{}),n=H(n||q);var i=v(r);Ie(e,function(e,r,n){i(t,e,r,n)},function(e){n(e,t)})}function Hr(e,t){var r,n=null;t=t||q,Kt(e,function(e,t){v(e)(function(e,o){r=arguments.length>2?i(arguments,1):o,n=e,t(!e)})},function(){t(n,r)})}function zr(e){return function(){return(e.unmemoized||e).apply(null,arguments)}}function Kr(e,t,r){r=Ae(r||q);var n=v(t);if(!e())return r(null);var o=function(t){if(t)return r(t);if(e())return n(o);var a=i(arguments,1);r.apply(null,[null].concat(a))};n(o)}function Vr(e,t,r){Kr(function(){return!e.apply(this,arguments)},t,r)}var Gr=function(e,t){if(t=H(t||q),!$(e))return t(new Error("First argument to waterfall must be an array of functions"));if(!e.length)return t();var r=0;function n(t){var n=v(e[r++]);t.push(Ae(o)),n.apply(null,t)}function o(o){if(o||r===e.length)return t.apply(null,arguments);n(i(arguments,1))}n([])},Wr={apply:o,applyEach:Be,applyEachSeries:Re,asyncify:d,auto:ze,autoInject:bt,cargo:gt,compose:Et,concat:St,concatLimit:kt,concatSeries:Mt,constant:It,detect:Bt,detectLimit:Pt,detectSeries:Ct,dir:Rt,doDuring:Lt,doUntil:Dt,doWhilst:Ot,during:Ft,each:Ht,eachLimit:zt,eachOf:Ie,eachOfLimit:xe,eachOfSeries:wt,eachSeries:Kt,ensureAsync:Vt,every:Wt,everyLimit:Yt,everySeries:Xt,filter:er,filterLimit:tr,filterSeries:rr,forever:nr,groupBy:or,groupByLimit:ir,groupBySeries:ar,log:sr,map:je,mapLimit:Ce,mapSeries:Ne,mapValues:cr,mapValuesLimit:ur,mapValuesSeries:fr,memoize:lr,nextTick:dr,parallel:br,parallelLimit:yr,priorityQueue:vr,queue:mr,race:gr,reduce:_t,reduceRight:wr,reflect:_r,reflectAll:Ar,reject:xr,rejectLimit:kr,rejectSeries:Sr,retry:Ir,retryable:Tr,seq:At,series:Ur,setImmediate:l,some:jr,someLimit:Br,someSeries:Pr,sortBy:Cr,timeout:Nr,times:Dr,timesLimit:Or,timesSeries:Fr,transform:qr,tryEach:Hr,unmemoize:zr,until:Vr,waterfall:Gr,whilst:Kr,all:Wt,allLimit:Yt,allSeries:Xt,any:jr,anyLimit:Br,anySeries:Pr,find:Bt,findLimit:Pt,findSeries:Ct,forEach:Ht,forEachSeries:Kt,forEachLimit:zt,forEachOf:Ie,forEachOfSeries:wt,forEachOfLimit:xe,inject:_t,foldl:_t,foldr:wr,select:er,selectLimit:tr,selectSeries:rr,wrapSync:d};r.default=Wr,r.apply=o,r.applyEach=Be,r.applyEachSeries=Re,r.asyncify=d,r.auto=ze,r.autoInject=bt,r.cargo=gt,r.compose=Et,r.concat=St,r.concatLimit=kt,r.concatSeries=Mt,r.constant=It,r.detect=Bt,r.detectLimit=Pt,r.detectSeries=Ct,r.dir=Rt,r.doDuring=Lt,r.doUntil=Dt,r.doWhilst=Ot,r.during=Ft,r.each=Ht,r.eachLimit=zt,r.eachOf=Ie,r.eachOfLimit=xe,r.eachOfSeries=wt,r.eachSeries=Kt,r.ensureAsync=Vt,r.every=Wt,r.everyLimit=Yt,r.everySeries=Xt,r.filter=er,r.filterLimit=tr,r.filterSeries=rr,r.forever=nr,r.groupBy=or,r.groupByLimit=ir,r.groupBySeries=ar,r.log=sr,r.map=je,r.mapLimit=Ce,r.mapSeries=Ne,r.mapValues=cr,r.mapValuesLimit=ur,r.mapValuesSeries=fr,r.memoize=lr,r.nextTick=dr,r.parallel=br,r.parallelLimit=yr,r.priorityQueue=vr,r.queue=mr,r.race=gr,r.reduce=_t,r.reduceRight=wr,r.reflect=_r,r.reflectAll=Ar,r.reject=xr,r.rejectLimit=kr,r.rejectSeries=Sr,r.retry=Ir,r.retryable=Tr,r.seq=At,r.series=Ur,r.setImmediate=l,r.some=jr,r.someLimit=Br,r.someSeries=Pr,r.sortBy=Cr,r.timeout=Nr,r.times=Dr,r.timesLimit=Or,r.timesSeries=Fr,r.transform=qr,r.tryEach=Hr,r.unmemoize=zr,r.until=Vr,r.waterfall=Gr,r.whilst=Kr,r.all=Wt,r.allLimit=Yt,r.allSeries=Xt,r.any=jr,r.anyLimit=Br,r.anySeries=Pr,r.find=Bt,r.findLimit=Pt,r.findSeries=Ct,r.forEach=Ht,r.forEachSeries=Kt,r.forEachLimit=zt,r.forEachOf=Ie,r.forEachOfSeries=wt,r.forEachOfLimit=xe,r.inject=_t,r.foldl=_t,r.foldr=wr,r.select=er,r.selectLimit=tr,r.selectSeries=rr,r.wrapSync=d,Object.defineProperty(r,"__esModule",{value:!0})})}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257}],22:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r,a){(0,n.default)(t)(e,(0,i.default)((0,o.default)(r)),a)};var n=a(e("./internal/eachOfLimit")),i=a(e("./internal/withoutIndex")),o=a(e("./internal/wrapAsync"));function a(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./internal/eachOfLimit":29,"./internal/withoutIndex":39,"./internal/wrapAsync":40}],23:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r){((0,n.default)(e)?l:d)(e,(0,f.default)(t),r)};var n=h(e("lodash/isArrayLike")),i=h(e("./internal/breakLoop")),o=h(e("./eachOfLimit")),a=h(e("./internal/doLimit")),s=h(e("lodash/noop")),u=h(e("./internal/once")),c=h(e("./internal/onlyOnce")),f=h(e("./internal/wrapAsync"));function h(e){return e&&e.__esModule?e:{default:e}}function l(e,t,r){r=(0,u.default)(r||s.default);var n=0,o=0,a=e.length;function f(e,t){e?r(e):++o!==a&&t!==i.default||r(null)}for(0===a&&r(null);n2&&(n=(0,o.default)(arguments,1)),s[t]=n,r(e)})},function(e){r(e,s)})};var n=s(e("lodash/noop")),i=s(e("lodash/isArrayLike")),o=s(e("./slice")),a=s(e("./wrapAsync"));function s(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./slice":38,"./wrapAsync":40,"lodash/isArrayLike":221,"lodash/noop":229}],37:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.hasNextTick=r.hasSetImmediate=void 0,r.fallback=c,r.wrap=f;var n,i=e("./slice"),o=(n=i)&&n.__esModule?n:{default:n};var a,s=r.hasSetImmediate="function"==typeof setImmediate&&setImmediate,u=r.hasNextTick="object"==typeof t&&"function"==typeof t.nextTick;function c(e){setTimeout(e,0)}function f(e){return function(t){var r=(0,o.default)(arguments,1);e(function(){t.apply(null,r)})}}a=s?setImmediate:u?t.nextTick:c,r.default=f(a)}).call(this,e("_process"))},{"./slice":38,_process:257}],38:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i0,"Expected a maximum number of retry greater than 0 but got %s.",e),this.maxNumberOfRetry_=e},o.prototype.backoff=function(e){i.checkState(-1===this.timeoutID_,"Backoff in progress."),this.backoffNumber_===this.maxNumberOfRetry_?(this.emit("fail",e),this.reset()):(this.backoffDelay_=this.backoffStrategy_.next(),this.timeoutID_=setTimeout(this.handlers.backoff,this.backoffDelay_),this.emit("backoff",this.backoffNumber_,this.backoffDelay_,e))},o.prototype.onBackoff_=function(){this.timeoutID_=-1,this.emit("ready",this.backoffNumber_,this.backoffDelay_),this.backoffNumber_++},o.prototype.reset=function(){this.backoffNumber_=0,this.backoffStrategy_.reset(),clearTimeout(this.timeoutID_),this.timeoutID_=-1},t.exports=o},{events:157,precond:253,util:333}],47:[function(e,t,r){var n=e("events"),i=e("precond"),o=e("util"),a=e("./backoff"),s=e("./strategy/fibonacci");function u(e,t,r){n.EventEmitter.call(this),i.checkIsFunction(e,"Expected fn to be a function."),i.checkIsArray(t,"Expected args to be an array."),i.checkIsFunction(r,"Expected callback to be a function."),this.function_=e,this.arguments_=t,this.callback_=r,this.lastResult_=[],this.numRetries_=0,this.backoff_=null,this.strategy_=null,this.failAfter_=-1,this.retryPredicate_=u.DEFAULT_RETRY_PREDICATE_,this.state_=u.State_.PENDING}o.inherits(u,n.EventEmitter),u.State_={PENDING:0,RUNNING:1,COMPLETED:2,ABORTED:3},u.DEFAULT_RETRY_PREDICATE_=function(e){return!0},u.prototype.isPending=function(){return this.state_==u.State_.PENDING},u.prototype.isRunning=function(){return this.state_==u.State_.RUNNING},u.prototype.isCompleted=function(){return this.state_==u.State_.COMPLETED},u.prototype.isAborted=function(){return this.state_==u.State_.ABORTED},u.prototype.setStrategy=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.strategy_=e,this},u.prototype.retryIf=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.retryPredicate_=e,this},u.prototype.getLastResult=function(){return this.lastResult_.concat()},u.prototype.getNumRetries=function(){return this.numRetries_},u.prototype.failAfter=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.failAfter_=e,this},u.prototype.abort=function(){this.isCompleted()||this.isAborted()||(this.isRunning()&&this.backoff_.reset(),this.state_=u.State_.ABORTED,this.lastResult_=[new Error("Backoff aborted.")],this.emit("abort"),this.doCallback_())},u.prototype.start=function(e){i.checkState(!this.isAborted(),"FunctionCall is aborted."),i.checkState(this.isPending(),"FunctionCall already started.");var t=this.strategy_||new s;this.backoff_=e?e(t):new a(t),this.backoff_.on("ready",this.doCall_.bind(this,!0)),this.backoff_.on("fail",this.doCallback_.bind(this)),this.backoff_.on("backoff",this.handleBackoff_.bind(this)),this.failAfter_>0&&this.backoff_.failAfter(this.failAfter_),this.state_=u.State_.RUNNING,this.doCall_(!1)},u.prototype.doCall_=function(e){e&&this.numRetries_++;var t=["call"].concat(this.arguments_);n.EventEmitter.prototype.emit.apply(this,t);var r=this.handleFunctionCallback_.bind(this);this.function_.apply(null,this.arguments_.concat(r))},u.prototype.doCallback_=function(){this.callback_.apply(null,this.lastResult_)},u.prototype.handleFunctionCallback_=function(){if(!this.isAborted()){var e=Array.prototype.slice.call(arguments);this.lastResult_=e,n.EventEmitter.prototype.emit.apply(this,["callback"].concat(e));var t=e[0];t&&this.retryPredicate_(t)?this.backoff_.backoff(t):(this.state_=u.State_.COMPLETED,this.doCallback_())}},u.prototype.handleBackoff_=function(e,t,r){this.emit("backoff",e,t,r)},t.exports=u},{"./backoff":46,"./strategy/fibonacci":49,events:157,precond:253,util:333}],48:[function(e,t,r){var n=e("util"),i=e("precond"),o=e("./strategy");function a(e){o.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay(),this.factor_=a.DEFAULT_FACTOR,e&&void 0!==e.factor&&(i.checkArgument(e.factor>1,"Exponential factor should be greater than 1 but got %s.",e.factor),this.factor_=e.factor)}n.inherits(a,o),a.DEFAULT_FACTOR=2,a.prototype.next_=function(){return this.backoffDelay_=Math.min(this.nextBackoffDelay_,this.getMaxDelay()),this.nextBackoffDelay_=this.backoffDelay_*this.factor_,this.backoffDelay_},a.prototype.reset_=function(){this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()},t.exports=a},{"./strategy":50,precond:253,util:333}],49:[function(e,t,r){var n=e("util"),i=e("./strategy");function o(e){i.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}n.inherits(o,i),o.prototype.next_=function(){var e=Math.min(this.nextBackoffDelay_,this.getMaxDelay());return this.nextBackoffDelay_+=this.backoffDelay_,this.backoffDelay_=e,e},o.prototype.reset_=function(){this.nextBackoffDelay_=this.getInitialDelay(),this.backoffDelay_=0},t.exports=o},{"./strategy":50,util:333}],50:[function(e,t,r){e("events"),e("util");function n(e){return null!=e}function i(e){if(n((e=e||{}).initialDelay)&&e.initialDelay<1)throw new Error("The initial timeout must be greater than 0.");if(n(e.maxDelay)&&e.maxDelay<1)throw new Error("The maximal timeout must be greater than 0.");if(this.initialDelay_=e.initialDelay||100,this.maxDelay_=e.maxDelay||1e4,this.maxDelay_<=this.initialDelay_)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");if(n(e.randomisationFactor)&&(e.randomisationFactor<0||e.randomisationFactor>1))throw new Error("The randomisation factor must be between 0 and 1.");this.randomisationFactor_=e.randomisationFactor||0}i.prototype.getMaxDelay=function(){return this.maxDelay_},i.prototype.getInitialDelay=function(){return this.initialDelay_},i.prototype.next=function(){var e=this.next_(),t=1+Math.random()*this.randomisationFactor_;return Math.round(e*t)},i.prototype.next_=function(){throw new Error("BackoffStrategy.next_() unimplemented.")},i.prototype.reset=function(){this.reset_()},i.prototype.reset_=function(){throw new Error("BackoffStrategy.reset_() unimplemented.")},t.exports=i},{events:157,util:333}],51:[function(e,t,r){"use strict";r.byteLength=function(e){return 3*e.length/4-c(e)},r.toByteArray=function(e){var t,r,n,a,s,u=e.length;a=c(e),s=new o(3*u/4-a),r=a>0?u-4:u;var f=0;for(t=0;t>16&255,s[f++]=n>>8&255,s[f++]=255&n;2===a?(n=i[e.charCodeAt(t)]<<2|i[e.charCodeAt(t+1)]>>4,s[f++]=255&n):1===a&&(n=i[e.charCodeAt(t)]<<10|i[e.charCodeAt(t+1)]<<4|i[e.charCodeAt(t+2)]>>2,s[f++]=n>>8&255,s[f++]=255&n);return s},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o="",a=[],s=0,u=r-i;su?u:s+16383));1===i?(t=e[r-1],o+=n[t>>2],o+=n[t<<4&63],o+="=="):2===i&&(t=(e[r-2]<<8)+e[r-1],o+=n[t>>10],o+=n[t>>4&63],o+=n[t<<2&63],o+="=");return a.push(o),a.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function f(e,t,r){for(var i,o,a=[],s=t;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],52:[function(e,t,r){var n=e("safe-buffer").Buffer;t.exports={check:function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))},decode:function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");var r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},encode:function(e,t){var r=e.length,i=t.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(i>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+r]=2,o[5+r]=t.length,t.copy(o,6+r),o}}},{"safe-buffer":290}],53:[function(e,t,r){!function(t,r){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var a;"object"==typeof t?t.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{a=e("buffer").Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:55}],54:[function(e,t,r){var n;function i(e){this.rand=e}if(t.exports=function(e){return n||(n=new i(null)),n.generate(e)},t.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^t[m++],a=c[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^t[m++],s=c[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^t[m++],u=c[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^t[m++],d=o,p=a,b=s,y=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^t[m++],a=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^t[m++],s=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[m++],u=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^t[m++],[o>>>=0,a>>>=0,s>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],u=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,u=0;u<256;++u){var c=s^s<<1^s<<2^s<<3^s<<4;c=c>>>8^255&c^99,r[a]=c,n[c]=a;var f=e[a],h=e[f],l=e[h],d=257*e[c]^16843008*c;i[0][a]=d<<24|d>>>8,i[1][a]=d<<16|d>>>16,i[2][a]=d<<8|d>>>24,i[3][a]=d,d=16843009*l^65537*h^257*f^16843008*a,o[0][c]=d<<24|d>>>8,o[1][c]=d<<16|d>>>16,o[2][c]=d<<8|d>>>24,o[3][c]=d,0===a?a=s=1:(a=f^e[e[e[l^f]]],s^=e[e[s]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(e){this._key=i(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a],a^=s[o/t|0]<<24):t>6&&o%t==4&&(a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a]),i[o]=i[o-t]^a}for(var c=[],f=0;f>>24]]^u.INV_SUB_MIX[1][u.SBOX[l>>>16&255]]^u.INV_SUB_MIX[2][u.SBOX[l>>>8&255]]^u.INV_SUB_MIX[3][u.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},c.prototype.encryptBlockRaw=function(e){return a(e=i(e),this._keySchedule,u.SUB_MIX,u.SBOX,this._nRounds)},c.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=n.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},c.prototype.decryptBlock=function(e){var t=(e=i(e))[1];e[1]=e[3],e[3]=t;var r=a(e,this._invKeySchedule,u.INV_SUB_MIX,u.INV_SBOX,this._nRounds),o=n.allocUnsafe(16);return o.writeUInt32BE(r[0],0),o.writeUInt32BE(r[3],4),o.writeUInt32BE(r[2],8),o.writeUInt32BE(r[1],12),o},c.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},t.exports.AES=c},{"safe-buffer":290}],57:[function(e,t,r){var n=e("./aes"),i=e("safe-buffer").Buffer,o=e("cipher-base"),a=e("inherits"),s=e("./ghash"),u=e("buffer-xor"),c=e("./incr32");function f(e,t,r,a){o.call(this);var u=i.alloc(4,0);this._cipher=new n.AES(t);var f=this._cipher.encryptBlock(u);this._ghash=new s(f),r=function(e,t,r){if(12===t.length)return e._finID=i.concat([t,i.from([0,0,0,1])]),i.concat([t,i.from([0,0,0,2])]);var n=new s(r),o=t.length,a=o%16;n.update(t),a&&(a=16-a,n.update(i.alloc(a,0))),n.update(i.alloc(8,0));var u=8*o,f=i.alloc(8);f.writeUIntBE(u,0,8),n.update(f),e._finID=n.state;var h=i.from(e._finID);return c(h),h}(this,r,f),this._prev=i.from(r),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=a,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}a(f,o),f.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=i.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},f.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=u(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var n=Math.min(e.length,t.length),i=0;i16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},h.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(e,t){var r=o[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(t,!1,r.key,r.iv);return l(e,n.key,n.iv)},r.createDecipheriv=l},{"./aes":56,"./authCipher":57,"./modes":69,"./streamCipher":72,"cipher-base":86,evp_bytestokey:158,inherits:180,"safe-buffer":290}],60:[function(e,t,r){var n=e("./modes"),i=e("./authCipher"),o=e("safe-buffer").Buffer,a=e("./streamCipher"),s=e("cipher-base"),u=e("./aes"),c=e("evp_bytestokey");function f(e,t,r){s.call(this),this._cache=new l,this._cipher=new u.AES(t),this._prev=o.from(r),this._mode=e,this._autopadding=!0}e("inherits")(f,s),f.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get();)r=this._mode.encrypt(this,t),n.push(r);return o.concat(n)};var h=o.alloc(16,16);function l(){this.cache=o.allocUnsafe(0)}function d(e,t,r){var s=n[e.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=o.from(t)),t.length!==s.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=o.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new a(s.module,t,r):"auth"===s.type?new i(s.module,t,r):new f(s.module,t,r)}f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(h))throw this._cipher.scrub(),new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},l.prototype.add=function(e){this.cache=o.concat([this.cache,e])},l.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},l.prototype.flush=function(){for(var e=16-this.cache.length,t=o.allocUnsafe(e),r=-1;++r>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function a(e){this.h=e,this.state=n.alloc(16,0),this.cache=n.allocUnsafe(0)}a.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=o(i)},a.prototype.update=function(e){var t;for(this.cache=n.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},a.prototype.final=function(e,t){return this.cache.length&&this.ghash(n.concat([this.cache,i],16)),this.ghash(o([0,e,0,t])),this.state},t.exports=a},{"safe-buffer":290}],62:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],63:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":83}],64:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("buffer-xor");function o(e,t,r){var o=t.length,a=i(t,e._cache);return e._cache=e._cache.slice(o),e._prev=n.concat([e._prev,r?t:a]),a}r.encrypt=function(e,t,r){for(var i,a=n.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=n.allocUnsafe(0)),!(e._cache.length<=t.length)){a=n.concat([a,o(e,t,r)]);break}i=e._cache.length,a=n.concat([a,o(e,t.slice(0,i),r)]),t=t.slice(i)}return a}},{"buffer-xor":83,"safe-buffer":290}],65:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t,r){for(var n,i,a=-1,s=0;++a<8;)n=t&1<<7-a?128:0,s+=(128&(i=e._cipher.encryptBlock(e._prev)[0]^n))>>a%8,e._prev=o(e._prev,r?n:i);return s}function o(e,t){var r=e.length,i=-1,o=n.allocUnsafe(e.length);for(e=n.concat([e,n.from([t])]);++i>7;return o}r.encrypt=function(e,t,r){for(var o=t.length,a=n.allocUnsafe(o),s=-1;++s=0||!r.umod(e.prime1)||!r.umod(e.prime2);)r=new n(i(t));return r}t.exports=o,o.getr=a}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84,randombytes:270}],77:[function(e,t,r){t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":78}],78:[function(e,t,r){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],79:[function(e,t,r){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],80:[function(e,t,r){(function(r){var n=e("create-hash"),i=e("stream"),o=e("inherits"),a=e("./sign"),s=e("./verify"),u=e("./algorithms.json");function c(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function f(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function h(e){return new c(e)}function l(e){return new f(e)}Object.keys(u).forEach(function(e){u[e].id=new r(u[e].id,"hex"),u[e.toLowerCase()]=u[e]}),o(c,i.Writable),c.prototype._write=function(e,t,r){this._hash.update(e),r()},c.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},c.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),n=a(r,e,this._hashType,this._signType,this._tag);return t?n.toString(t):n},o(f,i.Writable),f.prototype._write=function(e,t,r){this._hash.update(e),r()},f.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},f.prototype.verify=function(e,t,n){"string"==typeof t&&(t=new r(t,n)),this.end();var i=this._hash.digest();return s(t,i,e,this._signType,this._tag)},t.exports={Sign:h,Verify:l,createSign:h,createVerify:l}}).call(this,e("buffer").Buffer)},{"./algorithms.json":78,"./sign":81,"./verify":82,buffer:84,"create-hash":91,inherits:180,stream:311}],81:[function(e,t,r){(function(r){var n=e("create-hmac"),i=e("browserify-rsa"),o=e("elliptic").ec,a=e("bn.js"),s=e("parse-asn1"),u=e("./curves.json");function c(e,t,i,o){if((e=new r(e.toArray())).length0&&r.ishrn(n),r}function h(e,t,i){var o,a;do{for(o=new r(0);8*o.length=t)throw new Error("invalid sig")}t.exports=function(e,t,u,c,f){var h=o(u);if("ec"===h.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var n=a[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),s=r.data.subjectPrivateKey.data;return o.verify(t,e,s)}(e,t,h)}if("dsa"===h.type){if("dsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var i=r.data.p,a=r.data.q,u=r.data.g,c=r.data.pub_key,f=o.signature.decode(e,"der"),h=f.s,l=f.r;s(h,a),s(l,a);var d=n.mont(i),p=h.invm(a);return 0===u.toRed(d).redPow(new n(t).mul(p).mod(a)).fromRed().mul(c.toRed(d).redPow(l.mul(p).mod(a)).fromRed()).mod(i).mod(a).cmp(l)}(e,t,h)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");t=r.concat([f,t]);for(var l=h.modulus.byteLength(),d=[1],p=0;t.length+d.length+2o)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=s.prototype,t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(e)}return u(e,t,r)}function u(e,t,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return F(e)?function(e,t,r){if(t<0||e.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function d(e,t){if(s.isBuffer(e))return e.length;if(q(e)||F(e))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return O(e).length;default:if(n)return L(e).length;t=(""+t).toLowerCase(),n=!0}}function p(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var o,a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var f=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function x(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return x(this,t,r);case"ascii":return S(this,t,r);case"latin1":case"binary":return M(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},s.prototype.compare=function(e,t,r,n,i){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),u=Math.min(o,a),c=this.slice(n,i),f=e.slice(t,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return m(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return g(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function S(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,r,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function B(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function C(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,8),i.write(e,t,r,n,52,8),r+8}s.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},s.prototype.readUInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeFloatLE=function(e,t,r){return P(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return P(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return C(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return C(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(e){return n.toByteArray(function(e){if((e=e.trim().replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function F(e){return e instanceof ArrayBuffer||null!=e&&null!=e.constructor&&"ArrayBuffer"===e.constructor.name&&"number"==typeof e.byteLength}function q(e){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(e)}function H(e){return e!=e}},{"base64-js":51,ieee754:178}],85:[function(e,t,r){t.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],86:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("stream").Transform,o=e("string_decoder").StringDecoder;function a(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(a,i),a.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},a.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},a.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},a.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},t.exports=a},{inherits:180,"safe-buffer":290,stream:311,string_decoder:317}],87:[function(e,t,r){(function(e){var r=function(){"use strict";function t(e,t){return null!=t&&e instanceof t}var r,n,i;try{r=Map}catch(e){r=function(){}}try{n=Set}catch(e){n=function(){}}try{i=Promise}catch(e){i=function(){}}function o(a,u,c,f,h){"object"==typeof u&&(c=u.depth,f=u.prototype,h=u.includeNonEnumerable,u=u.circular);var l=[],d=[],p=void 0!==e;return void 0===u&&(u=!0),void 0===c&&(c=1/0),function a(c,b){if(null===c)return null;if(0===b)return c;var y,m;if("object"!=typeof c)return c;if(t(c,r))y=new r;else if(t(c,n))y=new n;else if(t(c,i))y=new i(function(e,t){c.then(function(t){e(a(t,b-1))},function(e){t(a(e,b-1))})});else if(o.__isArray(c))y=[];else if(o.__isRegExp(c))y=new RegExp(c.source,s(c)),c.lastIndex&&(y.lastIndex=c.lastIndex);else if(o.__isDate(c))y=new Date(c.getTime());else{if(p&&e.isBuffer(c))return y=e.allocUnsafe?e.allocUnsafe(c.length):new e(c.length),c.copy(y),y;t(c,Error)?y=Object.create(c):void 0===f?(m=Object.getPrototypeOf(c),y=Object.create(m)):(y=Object.create(f),m=f)}if(u){var v=l.indexOf(c);if(-1!=v)return d[v];l.push(c),d.push(y)}for(var g in t(c,r)&&c.forEach(function(e,t){var r=a(t,b-1),n=a(e,b-1);y.set(r,n)}),t(c,n)&&c.forEach(function(e){var t=a(e,b-1);y.add(t)}),c){var w;m&&(w=Object.getOwnPropertyDescriptor(m,g)),w&&null==w.set||(y[g]=a(c[g],b-1))}if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(c);for(g=0;g<_.length;g++){var A=_[g];(!(x=Object.getOwnPropertyDescriptor(c,A))||x.enumerable||h)&&(y[A]=a(c[A],b-1),x.enumerable||Object.defineProperty(y,A,{enumerable:!1}))}}if(h){var E=Object.getOwnPropertyNames(c);for(g=0;g>>2),a=0,s=0;a>5]|=128<>>9<<4)]=t;for(var r=1732584193,n=-271733879,i=-1732584194,o=271733878,h=0;h>>32-s,r);var a,s}function a(e,t,r,n,i,a,s){return o(t&r|~t&n,e,t,i,a,s)}function s(e,t,r,n,i,a,s){return o(t&n|r&~n,e,t,i,a,s)}function u(e,t,r,n,i,a,s){return o(t^r^n,e,t,i,a,s)}function c(e,t,r,n,i,a,s){return o(r^(t|~n),e,t,i,a,s)}function f(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}t.exports=function(e){return n(e,i)}},{"./make-hash":92}],94:[function(e,t,r){"use strict";var n=e("inherits"),i=e("./legacy"),o=e("cipher-base"),a=e("safe-buffer").Buffer,s=e("create-hash/md5"),u=e("ripemd160"),c=e("sha.js"),f=a.alloc(128);function h(e,t){o.call(this,"digest"),"string"==typeof t&&(t=a.from(t));var r="sha512"===e||"sha384"===e?128:64;(this._alg=e,this._key=t,t.length>r)?t=("rmd160"===e?new u:c(e)).update(t).digest():t.lengths?t=e(t):t.length-1};f.prototype.append=function(e,t){e=s(e),t=u(t);var r=this.map[e];this.map[e]=r?r+","+t:t},f.prototype.delete=function(e){delete this.map[s(e)]},f.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},f.prototype.set=function(e,t){this.map[s(e)]=u(t)},f.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},f.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),c(e)},f.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),c(e)},f.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),c(e)},t.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);var o=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},b.call(y.prototype),b.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:0,statusText:""});return e.type="error",e};var a=[301,302,303,307,308];v.redirect=function(e,t){if(-1===a.indexOf(t))throw new RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},e.Headers=f,e.Request=y,e.Response=v,e.fetch=function(e,r){return new Promise(function(n,i){var o=new y(e,r),a=new XMLHttpRequest;a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new v(i,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&t.blob&&(a.responseType="blob"),o.headers.forEach(function(e,t){a.setRequestHeader(t,e)}),a.send(void 0===o._bodyInit?null:o._bodyInit)})},e.fetch.polyfill=!0}function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function u(e){return"string"!=typeof e&&(e=String(e)),e}function c(e){var r={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t.iterable&&(r[Symbol.iterator]=function(){return r}),r}function f(e){this.map={},e instanceof f?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function h(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function l(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function d(e){var t=new FileReader,r=l(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(t.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(t.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(t.arrayBuffer&&t.blob&&n(e))this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!t.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(e)&&!i(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=p(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},t.blob&&(this.blob=function(){var e=h(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var e,t,r,n=h(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=l(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function v(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}}(void 0!==e?e:this)}).call(n,void 0);var i=n.fetch;i.Response=n.Response,i.Request=n.Request,i.Headers=n.Headers;"object"==typeof t&&t.exports&&(t.exports=i,t.exports.default=i)},{}],97:[function(e,t,r){"use strict";r.randomBytes=r.rng=r.pseudoRandomBytes=r.prng=e("randombytes"),r.createHash=r.Hash=e("create-hash"),r.createHmac=r.Hmac=e("create-hmac");var n=e("browserify-sign/algos"),i=Object.keys(n),o=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(i);r.getHashes=function(){return o};var a=e("pbkdf2");r.pbkdf2=a.pbkdf2,r.pbkdf2Sync=a.pbkdf2Sync;var s=e("browserify-cipher");r.Cipher=s.Cipher,r.createCipher=s.createCipher,r.Cipheriv=s.Cipheriv,r.createCipheriv=s.createCipheriv,r.Decipher=s.Decipher,r.createDecipher=s.createDecipher,r.Decipheriv=s.Decipheriv,r.createDecipheriv=s.createDecipheriv,r.getCiphers=s.getCiphers,r.listCiphers=s.listCiphers;var u=e("diffie-hellman");r.DiffieHellmanGroup=u.DiffieHellmanGroup,r.createDiffieHellmanGroup=u.createDiffieHellmanGroup,r.getDiffieHellman=u.getDiffieHellman,r.createDiffieHellman=u.createDiffieHellman,r.DiffieHellman=u.DiffieHellman;var c=e("browserify-sign");r.createSign=c.createSign,r.Sign=c.Sign,r.createVerify=c.createVerify,r.Verify=c.Verify,r.createECDH=e("create-ecdh");var f=e("public-encrypt");r.publicEncrypt=f.publicEncrypt,r.privateEncrypt=f.privateEncrypt,r.publicDecrypt=f.publicDecrypt,r.privateDecrypt=f.privateDecrypt;var h=e("randomfill");r.randomFill=h.randomFill,r.randomFillSync=h.randomFillSync,r.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))},r.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},{"browserify-cipher":73,"browserify-sign":80,"browserify-sign/algos":77,"create-ecdh":90,"create-hash":91,"create-hmac":94,"diffie-hellman":105,pbkdf2:247,"public-encrypt":259,randombytes:270,randomfill:271}],98:[function(e,t,r){"use strict";var n=new RegExp("%[a-f0-9]{2}","gi"),i=new RegExp("(%[a-f0-9]{2})+","gi");function o(e,t){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],o(r),o(n))}function a(e){try{return decodeURIComponent(e)}catch(i){for(var t=e.match(n),r=1;r0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];r=a.r28shl(r,s),i=a.r28shl(i,s),a.pc2(r,i,e.keys,o)}},u.prototype._update=function(e,t,r,n){var i=this._desState,o=a.readUInt32BE(e,t),s=a.readUInt32BE(e,t+4);a.ip(o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,s,i.tmp,0):this._decrypt(i,o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],a.writeUInt32BE(r,o,n),a.writeUInt32BE(r,s,n+4)},u.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,o=l}a.rip(s,o,n,i)},u.prototype._decrypt=function(e,t,r,n,i){for(var o=r,s=t,u=e.keys.length-2;u>=0;u-=2){var c=e.keys[u],f=e.keys[u+1];a.expand(o,e.tmp,0),c^=e.tmp[0],f^=e.tmp[1];var h=a.substitute(c,f),l=o;o=(s^a.permute(h))>>>0,s=l}a.rip(o,s,n,i)}},{"../des":99,inherits:180,"minimalistic-assert":234}],103:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits"),o=e("../des"),a=o.Cipher,s=o.DES;function u(e){a.call(this,e);var t=new function(e,t){n.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),i=t.slice(8,16),o=t.slice(16,24);this.ciphers="encrypt"===e?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edgeState=t}i(u,a),t.exports=u,u.create=function(e){return new u(e)},u.prototype._update=function(e,t,r,n){var i=this._edgeState;i.ciphers[0]._update(e,t,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},u.prototype._pad=s.prototype._pad,u.prototype._unpad=s.prototype._unpad},{"../des":99,inherits:180,"minimalistic-assert":234}],104:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,n){for(var i=0,o=0,a=6;a>=0;a-=2){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>>s+a&1}for(a=6;a>=0;a-=2){for(s=1;s<=25;s+=8)o<<=1,o|=t>>>s+a&1;for(s=1;s<=25;s+=8)o<<=1,o|=e>>>s+a&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(e,t,r,n){for(var i=0,o=0,a=0;a<4;a++)for(var s=24;s>=0;s-=8)i<<=1,i|=t>>>s+a&1,i<<=1,i|=e>>>s+a&1;for(a=4;a<8;a++)for(s=24;s>=0;s-=8)o<<=1,o|=t>>>s+a&1,o<<=1,o|=e>>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(e,t,r,n){for(var i=0,o=0,a=7;a>=5;a--){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+a&1}for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(a=1;a<=3;a++){for(s=0;s<=24;s+=8)o<<=1,o|=t>>s+a&1;for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1}for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,i){for(var o=0,a=0,s=n.length>>>1,u=0;u>>n[u]&1;for(u=s;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=a>>>0},r.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var n=e.toString(2);n.lengthe;)r.ishrn(1);if(r.isEven()&&r.iadd(s),r.testn(1)||r.iadd(u),t.cmp(u)){if(!t.cmp(c))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&m(p)&&m(r)&&a.test(p)&&a.test(r))return r}}},{"bn.js":53,"miller-rabin":233,randombytes:270}],108:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],109:[function(e,t,r){"use strict";var n=r;n.version=e("../package.json").version,n.utils=e("./elliptic/utils"),n.rand=e("brorand"),n.curve=e("./elliptic/curve"),n.curves=e("./elliptic/curves"),n.ec=e("./elliptic/ec"),n.eddsa=e("./elliptic/eddsa")},{"../package.json":124,"./elliptic/curve":112,"./elliptic/curves":115,"./elliptic/ec":116,"./elliptic/eddsa":119,"./elliptic/utils":123,brorand:54}],110:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.getNAF,a=i.getJSF,s=i.assert;function u(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){s(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=u;t--)c=(c<<1)+n[t];a.push(c)}for(var f=this.jpoint(null,null,null),h=this.jpoint(null,null,null),l=i;l>0;l--){for(u=0;u=0;c--){for(t=0;c>=0&&0===a[c];c--)t++;if(c>=0&&t++,u=u.dblp(t),c<0)break;var f=a[c];s(0!==f),u="affine"===e.type?f>0?u.mixedAdd(i[f-1>>1]):u.mixedAdd(i[-f-1>>1].neg()):f>0?u.add(i[f-1>>1]):u.add(i[-f-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){for(var s=this._wnafT1,u=this._wnafT2,c=this._wnafT3,f=0,h=0;h=1;h-=2){var d=h-1,p=h;if(1===s[d]&&1===s[p]){var b=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(b[1]=t[d].add(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].add(t[p].neg())):(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],m=a(r[d],r[p]);f=Math.max(m[0].length,f),c[d]=new Array(f),c[p]=new Array(f);for(var v=0;v=0;h--){for(var E=0;h>=0;){var x=!0;for(v=0;v=0&&E++,_=_.dblp(E),h<0)break;for(v=0;v0?k=u[v][S-1>>1]:S<0&&(k=u[v][-S-1>>1].neg()),_="affine"===k.type?_.mixedAdd(k):_.add(k))}}for(h=0;h=Math.ceil((e.bitLength()+1)/t.step)},c.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},f.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},f.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(r),s=n.redSub(t),u=i.redMul(a),c=o.redMul(s),f=i.redMul(s),h=a.redMul(o);return this.curve.point(u,c,h,f)},f.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var a=(c=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(a.redSub(this.curve.two)),t=a.redMul(c.redSub(o)),r=a.redSqr().redSub(a).redSub(a);else{var s=this.z.redSqr(),u=a.redSub(s).redISub(s);e=n.redSub(i).redISub(o).redMul(u),t=a.redMul(c.redSub(o)),r=a.redMul(u)}}else{var c=i.redAdd(o);s=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=c.redSub(s).redSub(s);e=this.curve._mulC(n.redISub(c)).redMul(u),t=this.curve._mulC(c).redMul(i.redISub(o)),r=c.redMul(u)}return this.curve.point(e,t,r)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},f.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=i.redSub(n),s=i.redAdd(n),u=r.redAdd(t),c=o.redMul(a),f=s.redMul(u),h=o.redMul(u),l=a.redMul(s);return this.curve.point(c,f,l,h)},f.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),c=i.redAdd(s),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),h=n.redMul(u).redMul(f);return this.curve.twisted?(t=n.redMul(c).redMul(a.redSub(this.curve._mulA(o))),r=u.redMul(c)):(t=n.redMul(c).redMul(a.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(h,t,r)},f.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},f.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},f.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},f.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},f.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()},f.prototype.getY=function(){return this.normalize(),this.y.fromRed()},f.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},f.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}return!1},f.prototype.toP=f.prototype.normalize,f.prototype.mixedAdd=f.prototype.add},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],112:[function(e,t,r){"use strict";var n=r;n.base=e("./base"),n.short=e("./short"),n.mont=e("./mont"),n.edwards=e("./edwards")},{"./base":110,"./edwards":111,"./mont":113,"./short":114}],113:[function(e,t,r){"use strict";var n=e("../curve"),i=e("bn.js"),o=e("inherits"),a=n.base,s=e("../../elliptic").utils;function u(e){a.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,r){a.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(u,a),t.exports=u,u.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},o(c,a.BasePoint),u.prototype.decodePoint=function(e,t){return this.point(s.toArray(e,t),1)},u.prototype.point=function(e,t){return new c(this,e,t)},u.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=i.redMul(n),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},c.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],114:[function(e,t,r){"use strict";var n=e("../curve"),i=e("../../elliptic"),o=e("bn.js"),a=e("inherits"),s=n.base,u=i.utils.assert;function c(e){s.call(this,"short",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function f(e,t,r,n){s.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new o(t,16),this.y=new o(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function h(e,t,r,n){s.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new o(0)):(this.x=new o(t,16),this.y=new o(r,16),this.z=new o(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}a(c,s),t.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new o(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new o(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?r=i[0]:(r=i[1],u(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new o(e.a,16),b:new o(e.b,16)}}):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:o.mont(e),r=new o(2).toRed(t).redInvm(),n=r.redNeg(),i=new o(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,r,n,i,a,s,u,c,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=e,d=this.n.clone(),p=new o(1),b=new o(0),y=new o(0),m=new o(1),v=0;0!==l.cmpn(0);){var g=d.div(l);c=d.sub(g.mul(l)),f=y.sub(g.mul(p));var w=m.sub(g.mul(b));if(!n&&c.cmp(h)<0)t=u.neg(),r=p,n=c.neg(),i=f;else if(n&&2==++v)break;u=c,d=l,l=c,y=p,p=f,m=b,b=w}a=c.neg(),s=f;var _=n.sqr().add(i.sqr());return a.sqr().add(s.sqr()).cmp(_)>=0&&(a=t,s=r),n.negative&&(n=n.neg(),i=i.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:n,b:i},{a:a,b:s}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(c).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},f.prototype.isInfinity=function(){return this.inf},f.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},f.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},f.prototype.getX=function(){return this.x.fromRed()},f.prototype.getY=function(){return this.y.fromRed()},f.prototype.mul=function(e){return e=new o(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},f.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},f.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},f.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},f.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},a(h,s.BasePoint),c.prototype.jpoint=function(e,t,r){return new h(this,e,t,r)},h.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},h.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},h.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),f=c.redMul(s),h=n.redMul(c),l=u.redSqr().redIAdd(f).redISub(h).redISub(h),d=u.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(l,d,p)},h.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),f=r.redMul(u),h=s.redSqr().redIAdd(c).redISub(f).redISub(f),l=s.redMul(f.redISub(h)).redISub(i.redMul(c)),d=this.z.redMul(a);return this.curve.jpoint(h,l,d)},h.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}return!1},h.prototype.inspect=function(){return this.isInfinity()?"":""},h.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],115:[function(e,t,r){"use strict";var n,i=r,o=e("hash.js"),a=e("../elliptic"),s=a.utils.assert;function u(e){"short"===e.type?this.curve=new a.curve.short(e):"edwards"===e.type?this.curve=new a.curve.edwards(e):this.curve=new a.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=e("./precomputed/secp256k1")}catch(e){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"../elliptic":109,"./precomputed/secp256k1":122,"hash.js":162}],116:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("hmac-drbg"),o=e("../../elliptic"),a=o.utils.assert,s=e("./key"),u=e("./signature");function c(e){if(!(this instanceof c))return new c(e);"string"==typeof e&&(a(o.curves.hasOwnProperty(e),"Unknown curve "+e),e=o.curves[e]),e instanceof o.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=c,c.prototype.keyPair=function(e){return new s(this,e)},c.prototype.keyFromPrivate=function(e,t){return s.fromPrivate(this,e,t)},c.prototype.keyFromPublic=function(e,t){return s.fromPublic(this,e,t)},c.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||o.rand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),a=this.n.sub(new n(2));;){var s=new n(t.generate(r));if(!(s.cmp(a)>0))return s.iaddn(1),this.keyFromPrivate(s)}},c.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},c.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),c=e.toArray("be",a),f=new i({hash:this.hash,entropy:s,nonce:c,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(f.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var m=d.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),v^=1),new u({r:y,s:m,recoveryParam:v})}}}}}},c.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new u(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,c=a.invm(this.n),f=c.mul(e).umod(this.n),h=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(f,r.getPublic(),h)).isInfinity()&&s.eqXToP(o):!(s=this.g.mulAdd(f,r.getPublic(),h)).isInfinity()&&0===s.getX().umod(this.n).cmp(o)},c.prototype.recoverPubKey=function(e,t,r,i){a((3&r)===r,"The recovery param is more than two bits"),t=new u(t,i);var o=this.n,s=new n(e),c=t.r,f=t.s,h=1&r,l=r>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find second key candidate");c=l?this.curve.pointFromX(c.add(this.curve.n),h):this.curve.pointFromX(c,h);var d=t.r.invm(o),p=o.sub(s).mul(d).umod(o),b=f.mul(d).umod(o);return this.g.mulAdd(p,c,b)},c.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new u(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":109,"./key":117,"./signature":118,"bn.js":53,"hmac-drbg":174}],117:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils.assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../../elliptic":109,"bn.js":53}],118:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new function(){this.place=0};if(48!==e[r.place++])return!1;if(s(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=s(e,r),a=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var u=s(e,r);if(e.length!==u+r.place)return!1;var c=e.slice(r.place,u+r.place);return 0===a[0]&&128&a[1]&&(a=a.slice(1)),0===c[0]&&128&c[1]&&(c=c.slice(1)),this.r=new n(a),this.s=new n(c),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=u(t),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),a=[48];return c(a,o.length),a=a.concat(o),i.encode(a,e)}},{"../../elliptic":109,"bn.js":53}],119:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("../../elliptic"),o=i.utils,a=o.assert,s=o.parseBytes,u=e("./key"),c=e("./signature");function f(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}t.exports=f,f.prototype.sign=function(e,t){e=s(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),u=n.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(e,t,r){e=s(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var s=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,c=t.andln(3)+i&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!=(s=e.andln(7)+n&7)&&5!==s||2!==c?u:-u,r[0].push(o),a=0==(1&c)?0:3!=(s=t.andln(7)+i&7)&&5!==s||2!==u?c:-c,r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},{"bn.js":53,"minimalistic-assert":234,"minimalistic-crypto-utils":235}],124:[function(e,t,r){t.exports={_from:"elliptic@^6.0.0",_id:"elliptic@6.4.0",_inBundle:!1,_integrity:"sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=",_location:"/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.0.0",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.0.0",saveSpec:null,fetchSpec:"^6.0.0"},_requiredBy:["/browserify-sign","/create-ecdh"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",_shasum:"cac9af8762c85836187003c8dfe193e5e2eae5df",_spec:"elliptic@^6.0.0",_where:"/Users/alexvlasov/Blockchain/web3swift_jsproxy/node_modules/browserify-sign",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.4.0"}},{}],125:[function(e,t,r){"use strict";const n=e("ethjs-util");function i(e){let t=n.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}t.exports={incrementHexNumber:function(e){return i(n.intToHex(parseInt(e,16)+1))},formatHex:i}},{"ethjs-util":155}],126:[function(e,t,r){const n=e("eth-query"),i=e("events"),o=e("pify"),a=e("./hexUtils"),s=a.incrementHexNumber,u=1e3,c=60*u;t.exports=class extends i{constructor(e={}){if(super(),!e.provider)throw new Error("RpcBlockTracker - no provider specified.");this._provider=e.provider,this._query=new n(e.provider),this._pollingInterval=e.pollingInterval||4*u,this._syncingTimeout=e.syncingTimeout||1*c,this._trackingBlock=null,this._trackingBlockTimestamp=null,this._currentBlock=null,this._isRunning=!1,this._performSync=this._performSync.bind(this),this._handleNewBlockNotification=this._handleNewBlockNotification.bind(this)}getTrackingBlock(){return this._trackingBlock}getCurrentBlock(){return this._currentBlock}async awaitCurrentBlock(){return this._currentBlock?this._currentBlock:(await new Promise(e=>this.once("latest",e)),this._currentBlock)}async start(e={}){this._isRunning||(this._isRunning=!0,e.fromBlock?await this._setTrackingBlock(await this._fetchBlockByNumber(e.fromBlock)):await this._setTrackingBlock(await this._fetchLatestBlock()),this._provider.on?await this._initSubscription():this._performSync().catch(e=>{e&&console.error(e)}))}async stop(){this._isRunning=!1,this._provider.on&&await this._removeSubscription()}async _setTrackingBlock(e){if(this._trackingBlock&&this._trackingBlock.hash===e.hash)return;const t=this._trackingBlockTimestamp,r=Date.now();t&&r-t>this._syncingTimeout?(this._trackingBlockTimestamp=null,await this._warpToLatest()):(this._trackingBlock=e,this._trackingBlockTimestamp=r,this.emit("block",e))}async _setCurrentBlock(e){if(this._currentBlock&&this._currentBlock.hash===e.hash)return;const t=this._currentBlock;this._currentBlock=e,this.emit("latest",e),this.emit("sync",{newBlock:e,oldBlock:t})}async _warpToLatest(){await this._setTrackingBlock(await this._fetchLatestBlock())}async _pollForNextBlock(){setTimeout(()=>this._performSync(),this._pollingInterval)}async _performSync(){if(!this._isRunning)return;const e=this.getTrackingBlock();if(!e)throw new Error("RpcBlockTracker - tracking block is missing");const t=s(e.number);try{const r=await this._fetchBlockByNumber(t);r?(await this._setTrackingBlock(r),this._performSync()):(await this._setCurrentBlock(e),this._pollForNextBlock())}catch(t){t.message.includes("index out of range")||t.message.includes("Couldn't find block by reference")?(await this._setCurrentBlock(e),this._pollForNextBlock()):(console.error(t),this._pollForNextBlock())}}async _handleNewBlockNotification(e,t){t.id==this._subscriptionId&&(e&&(this.emit("error",e),await this._removeSubscription()),await this._setTrackingBlock(await this._fetchBlockByNumber(t.result.number)))}async _initSubscription(){this._provider.on("data",this._handleNewBlockNotification);let e=await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_subscribe",params:["newHeads"]});this._subscriptionId=e.result}async _removeSubscription(){if(!this._subscriptionId)throw new Error("Not subscribed.");this._provider.removeListener("data",this._handleNewBlockNotification),await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_unsubscribe",params:[this._subscriptionId]}),delete this._subscriptionId}_fetchLatestBlock(){return o(this._query.getBlockByNumber).call(this._query,"latest",!0)}_fetchBlockByNumber(e){const t=a.formatHex(e);return o(this._query.getBlockByNumber).call(this._query,t,!0)}}},{"./hexUtils":125,"eth-query":135,events:157,pify:252}],127:[function(e,t,r){(function(t){var n=e("js-sha3").keccak_256,i=e("idna-uts46-hx");function o(e){return e?i.toUnicode(e,{useStd3ASCII:!0,transitional:!1}):e}r.hash=function(e){for(var r="",i=0;i<32;i++)r+="00";if(name=o(e),name){var a=name.split(".");for(i=a.length-1;i>=0;i--){var s=n(a[i]);r=n(new t(r+s,"hex"))}}return"0x"+r},r.normalize=o}).call(this,e("buffer").Buffer)},{buffer:84,"idna-uts46-hx":177,"js-sha3":128}],128:[function(e,t,r){(function(e,r){!function(){"use strict";var n="object"==typeof window?window:{};!n.JS_SHA3_NO_NODE_JS&&"object"==typeof e&&e.versions&&e.versions.node&&(n=r);for(var i=!n.JS_SHA3_NO_COMMON_JS&&"object"==typeof t&&t.exports,o="0123456789abcdef".split(""),a=[0,8,16,24],s=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],u=[224,256,384,512],c=["hex","buffer","arrayBuffer","array"],f=function(e,t,r){return function(n){return new _(e,t,e).update(n)[r]()}},h=function(e,t,r){return function(n,i){return new _(e,t,i).update(n)[r]()}},l=function(e,t){var r=f(e,t,"hex");r.create=function(){return new _(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}_.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,o=this.blocks,s=this.byteCount,u=this.blockCount,c=0,f=this.s;c>2]|=e[c]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(o[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=s){for(this.start=r-s,this.block=o[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+o[15&e]+o[e>>12&15]+o[e>>8&15]+o[e>>20&15]+o[e>>16&15]+o[e>>28&15]+o[e>>24&15];s%t==0&&(A(r),a=0)}return i&&(e=r[a],i>0&&(u+=o[e>>4&15]+o[15&e]),i>1&&(u+=o[e>>12&15]+o[e>>8&15]),i>2&&(u+=o[e>>20&15]+o[e>>16&15])),u},_.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&A(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var A=function(e){var t,r,n,i,o,a,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],a=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(a<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|a>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=a^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=s[n],e[1]^=s[n+1]};if(i)t.exports=p;else for(y=0;y{setTimeout(t,e)})}function c(e){const t=e.toString();return s.some(e=>t.includes(e))}async function f(e,t,r){const{fetchUrl:n,fetchParams:a}=h({network:e,req:t}),s=await o(n,a),u=await s.text();if(!s.ok)switch(s.status){case 405:throw new i.MethodNotFound;case 418:throw l("Request is being rate limited.");case 503:case 504:throw function(){let e="Gateway timeout. The request took too long to process. ";return e+="This can happen when querying logs over too wide a block range.",l("Gateway timeout. The request took too long to process. This can happen when querying logs over too wide a block range.")}();default:throw l(u)}if("eth_getBlockByNumber"===t.method&&"Not Found"===u)return void(r.result=null);const c=JSON.parse(u);r.result=c.result,r.error=c.error}function h({network:e,req:t}){const r=function(e){return{id:e.id,jsonrpc:e.jsonrpc,method:e.method,params:e.params}}(t),{method:n,params:i}=r,o={};let s=`https://api.infura.io/v1/jsonrpc/${e}`;if(a.includes(n))o.method="POST",o.headers={Accept:"application/json","Content-Type":"application/json"},o.body=JSON.stringify(r);else{o.method="GET",s+=`/${n}?params=${encodeURIComponent(JSON.stringify(i))}`}return{fetchUrl:s,fetchParams:o}}function l(e){const t=new Error(e);return new i.InternalError(t)}t.exports=function(e={}){const t=e.network||"mainnet",r=e.maxAttempts||5;if(!r)throw new Error(`Invalid value for 'maxAttempts': "${r}" (${typeof r})`);return n(async(e,n,i)=>{for(let i=1;i<=r;i++)try{await f(t,e,n);break}catch(e){if(!c(e))throw e;const t=r-i;if(!t){const t=`InfuraProvider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,r=new Error(t);throw r}await u(1e3)}})},t.exports.fetchConfigFromReq=h},{"cross-fetch":96,"json-rpc-engine/src/createAsyncMiddleware":187,"json-rpc-error":189}],131:[function(e,t,r){t.exports=function(e){return{sendAsync:e.handle.bind(e)}}},{}],132:[function(e,t,r){var n=function(e,t){for(var r=[],n=0;n>6|192);else{if(i>55295&&i<56320){if(++n==e.length)return null;var o=e.charCodeAt(n);if(o<56320||o>57343)return null;r+=t((i=65536+((1023&i)<<10)+(1023&o))>>18|240),r+=t(i>>12&63|128)}else r+=t(i>>12|224);r+=t(i>>6&63|128)}r+=t(63&i|128)}}return r},toString:function(e){for(var t="",r=0,o=i(e);r127){if(a>191&&a<224){if(r>=o)return null;a=(31&a)<<6|63&n(e,r)}else if(a>223&&a<240){if(r+1>=o)return null;a=(15&a)<<12|(63&n(e,r))<<6|63&n(e,++r)}else{if(!(a>239&&a<248))return null;if(r+2>=o)return null;a=(7&a)<<18|(63&n(e,r))<<12|(63&n(e,++r))<<6|63&n(e,++r)}++r}if(a<=65535)t+=String.fromCharCode(a);else{if(!(a<=1114111))return null;a-=65536,t+=String.fromCharCode(a>>10|55296),t+=String.fromCharCode(1023&a|56320)}}return t},fromNumber:function(e){var t=e.toString(16);return t.length%2==0?"0x"+t:"0x0"+t},toNumber:function(e){return parseInt(e.slice(2),16)},fromNat:function(e){return"0x0"===e?"0x":e.length%2==0?e:"0x0"+e.slice(2)},toNat:function(e){return"0"===e[2]?"0x"+e.slice(3):e},fromArray:a,toArray:o,fromUint8Array:function(e){return a([].slice.call(e,0))},toUint8Array:function(e){return new Uint8Array(o(e))}}},{"./array.js":132}],134:[function(e,t,r){var n="0123456789abcdef".split(""),i=[1,256,65536,16777216],o=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],s=function(e){var t,r,n,i,o,s,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=a[n],e[1]^=a[n+1]},u=function(e){return function(t){var r;if("0x"===t.slice(0,2)){r=[];for(var a=2,u=t.length;a>2]|=t[d]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|63&r)<=57344?(u[y>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<=c){for(e.start=y-c,e.block=u[f],y=0;y>2]|=i[3&y],e.lastByteIndex===c)for(u[0]=u[f],y=1;y>4&15]+n[15&p]+n[p>>12&15]+n[p>>8&15]+n[p>>20&15]+n[p>>16&15]+n[p>>28&15]+n[p>>24&15];m%f==0&&(s(l),y=0)}return"0x"+b}(function(e){return{blocks:[],reset:!0,block:0,start:0,blockCount:1600-(e<<1)>>5,outputBlocks:e>>5,s:(t=[0,0,0,0,0,0,0,0,0,0],[].concat(t,t,t,t,t))};var t}(e),r)}};t.exports={keccak256:u(256),keccak512:u(512),keccak256s:u(256),keccak512s:u(512)}},{}],135:[function(e,t,r){const n=e("xtend"),i=e("json-rpc-random-id")();function o(e){this.currentProvider=e}function a(e){return function(){var t=[].slice.call(arguments),r=t.pop();this.sendAsync({method:e,params:t},r)}}function s(e,t){return function(){var r=[].slice.call(arguments),n=r.pop();r.lengtho)throw new Error("Elements exceed array size: "+o);for(d in h=[],e=e.slice(0,e.lastIndexOf("[")),"string"==typeof t&&(t=JSON.parse(t)),t)h.push(l(e,t[d]));if("dynamic"===o){var p=l("uint256",t.length);h.unshift(p)}return r.concat(h)}if("bytes"===e)return t=new r(t),h=r.concat([l("uint256",t.length),t]),t.length%32!=0&&(h=r.concat([h,n.zeros(32-t.length%32)])),h;if(e.startsWith("bytes")){if((o=s(e))<1||o>32)throw new Error("Invalid bytes width: "+o);return n.setLengthRight(t,32)}if(e.startsWith("uint")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid uint width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied uint exceeds width: "+o+" vs "+a.bitLength());if(a<0)throw new Error("Supplied uint is negative");return a.toArrayLike(r,"be",32)}if(e.startsWith("int")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid int width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied int exceeds width: "+o+" vs "+a.bitLength());return a.toTwos(256).toArrayLike(r,"be",32)}if(e.startsWith("ufixed")){if(o=u(e),(a=f(t))<0)throw new Error("Supplied ufixed is negative");return l("uint256",a.mul(new i(2).pow(new i(o[1]))))}if(e.startsWith("fixed"))return o=u(e),l("int256",f(t).mul(new i(2).pow(new i(o[1]))));throw new Error("Unsupported or invalid type: "+e)}function d(e,t,n){var o,a,s,u;if("string"==typeof e&&(e=p(e)),"address"===e.name)return d(e.rawType,t,n).toArrayLike(r,"be",20).toString("hex");if("bool"===e.name)return d(e.rawType,t,n).toString()===new i(1).toString();if("string"===e.name){var c=d(e.rawType,t,n);return new r(c,"utf8").toString()}if(e.isArray){for(s=[],o=e.size,"dynamic"===e.size&&(o=d("uint256",t,n=d("uint256",t,n).toNumber()).toNumber(),n+=32),u=0;ue.size)throw new Error("Decoded int exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("int")){if((a=new i(t.slice(n,n+32),16,"be").fromTwos(256)).bitLength()>e.size)throw new Error("Decoded uint exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("ufixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("uint256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}if(e.name.startsWith("fixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("int256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}throw new Error("Unsupported or invalid type: "+e.name)}function p(e){var t,r,n;if(y(e)){t=c(e);var i=e.slice(0,e.lastIndexOf("["));return i=p(i),r={isArray:!0,name:e,size:t,memoryUsage:"dynamic"===t?32:i.memoryUsage*t,subArray:i}}switch(e){case"address":n="uint160";break;case"bool":n="uint8";break;case"string":n="bytes"}if(r={rawType:n,name:e,memoryUsage:32},e.startsWith("bytes")&&"bytes"!==e||e.startsWith("uint")||e.startsWith("int")?r.size=s(e):(e.startsWith("ufixed")||e.startsWith("fixed"))&&(r.size=u(e)),e.startsWith("bytes")&&"bytes"!==e&&(r.size<1||r.size>32))throw new Error("Invalid bytes width: "+r.size);if((e.startsWith("uint")||e.startsWith("int"))&&(r.size%8||r.size<8||r.size>256))throw new Error("Invalid int/uint width: "+r.size);return r}function b(e){return"string"===e||"bytes"===e||"dynamic"===c(e)}function y(e){return e.lastIndexOf("]")===e.length-1}function m(e,t){return e.startsWith("address")||e.startsWith("bytes")?"0x"+t.toString("hex"):t.toString()}o.eventID=function(e,t){var i=e+"("+t.map(a).join(",")+")";return n.sha3(new r(i))},o.methodID=function(e,t){return o.eventID(e,t).slice(0,4)},o.rawEncode=function(e,t){var n=[],i=[],o=0;e.forEach(function(e){if(y(e)){var t=c(e);o+="dynamic"!==t?32*t:32}else o+=32});for(var s=0;s32)throw new Error("Invalid bytes width: "+i);u.push(n.setLengthRight(l,i))}else if(h.startsWith("uint")){if((i=s(h))%8||i<8||i>256)throw new Error("Invalid uint width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied uint exceeds width: "+i+" vs "+o.bitLength());u.push(o.toArrayLike(r,"be",i/8))}else{if(!h.startsWith("int"))throw new Error("Unsupported or invalid type: "+h);if((i=s(h))%8||i<8||i>256)throw new Error("Invalid int width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied int exceeds width: "+i+" vs "+o.bitLength());u.push(o.toTwos(i).toArrayLike(r,"be",i/8))}}return r.concat(u)},o.soliditySHA3=function(e,t){return n.sha3(o.solidityPack(e,t))},o.soliditySHA256=function(e,t){return n.sha256(o.solidityPack(e,t))},o.solidityRIPEMD160=function(e,t){return n.ripemd160(o.solidityPack(e,t),!0)},o.fromSerpent=function(e){for(var t,r=[],n=0;n="0"&&t<="9");)o+=e[a]-"0",a++;n=a-1,r.push(o)}else if("i"===i)r.push("int256");else{if("a"!==i)throw new Error("Unsupported or invalid type: "+i);r.push("int256[]")}}return r},o.toSerpent=function(e){for(var t=[],r=0;r0){var r=this.raw.slice();this.v=this._chainId,this.r=0,this.s=0,t=this.raw,this.raw=r}else t=this.raw.slice(0,6);return n.rlphash(t)},e.prototype.getChainId=function(){return this._chainId},e.prototype.getSenderAddress=function(){if(this._from)return this._from;var e=this.getSenderPublicKey();return this._from=n.publicToAddress(e),this._from},e.prototype.getSenderPublicKey=function(){if(!(this._senderPubKey&&this._senderPubKey.length||this.verifySignature()))throw new Error("Invalid Signature");return this._senderPubKey},e.prototype.verifySignature=function(){var e=this.hash(!1);if(this._homestead&&1===new o(this.s).cmp(a))return!1;try{var t=n.bufferToInt(this.v);this._chainId>0&&(t-=2*this._chainId+8),this._senderPubKey=n.ecrecover(e,t,this.r,this.s)}catch(e){return!1}return!!this._senderPubKey},e.prototype.sign=function(e){var t=this.hash(!1),r=n.ecsign(t,e);this._chainId>0&&(r.v+=2*this._chainId+8),Object.assign(this,r)},e.prototype.getDataFee=function(){for(var e=this.raw[5],t=new o(0),r=0;r0&&t.push(["gas limit is too low. Need at least "+this.getBaseFee()]),void 0===e||!1===e?0===t.length:t.join(" ")},e}();t.exports=s}).call(this,e("buffer").Buffer)},{buffer:84,"ethereum-common/params.json":137,"ethereumjs-util":141}],141:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("keccak"),o=e("secp256k1"),a=e("assert"),s=e("rlp"),u=e("bn.js"),c=e("create-hash"),f=e("safe-buffer").Buffer;Object.assign(r,e("ethjs-util")),r.MAX_INTEGER=new u("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16),r.TWO_POW256=new u("10000000000000000000000000000000000000000000000000000000000000000",16),r.KECCAK256_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",r.SHA3_NULL_S=r.KECCAK256_NULL_S,r.KECCAK256_NULL=f.from(r.KECCAK256_NULL_S,"hex"),r.SHA3_NULL=r.KECCAK256_NULL,r.KECCAK256_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",r.SHA3_RLP_ARRAY_S=r.KECCAK256_RLP_ARRAY_S,r.KECCAK256_RLP_ARRAY=f.from(r.KECCAK256_RLP_ARRAY_S,"hex"),r.SHA3_RLP_ARRAY=r.KECCAK256_RLP_ARRAY,r.KECCAK256_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",r.SHA3_RLP_S=r.KECCAK256_RLP_S,r.KECCAK256_RLP=f.from(r.KECCAK256_RLP_S,"hex"),r.SHA3_RLP=r.KECCAK256_RLP,r.BN=u,r.rlp=s,r.secp256k1=o,r.zeros=function(e){return f.allocUnsafe(e).fill(0)},r.zeroAddress=function(){var e=r.zeros(20);return r.bufferToHex(e)},r.setLengthLeft=r.setLength=function(e,t,n){var i=r.zeros(t);return e=r.toBuffer(e),n?e.length0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e},r.toBuffer=function(e){if(!f.isBuffer(e))if(Array.isArray(e))e=f.from(e);else if("string"==typeof e)e=r.isHexString(e)?f.from(r.padToEven(r.stripHexPrefix(e)),"hex"):f.from(e);else if("number"==typeof e)e=r.intToBuffer(e);else if(null==e)e=f.allocUnsafe(0);else if(u.isBN(e))e=e.toArrayLike(f);else{if(!e.toArray)throw new Error("invalid type");e=f.from(e.toArray())}return e},r.bufferToInt=function(e){return new u(r.toBuffer(e)).toNumber()},r.bufferToHex=function(e){return"0x"+(e=r.toBuffer(e)).toString("hex")},r.fromSigned=function(e){return new u(e).fromTwos(256)},r.toUnsigned=function(e){return f.from(e.toTwos(256).toArray())},r.keccak=function(e,t){return e=r.toBuffer(e),t||(t=256),i("keccak"+t).update(e).digest()},r.keccak256=function(e){return r.keccak(e)},r.sha3=r.keccak,r.sha256=function(e){return e=r.toBuffer(e),c("sha256").update(e).digest()},r.ripemd160=function(e,t){e=r.toBuffer(e);var n=c("rmd160").update(e).digest();return!0===t?r.setLength(n,32):n},r.rlphash=function(e){return r.keccak(s.encode(e))},r.isValidPrivate=function(e){return o.privateKeyVerify(e)},r.isValidPublic=function(e,t){return 64===e.length?o.publicKeyVerify(f.concat([f.from([4]),e])):!!t&&o.publicKeyVerify(e)},r.pubToAddress=r.publicToAddress=function(e,t){return e=r.toBuffer(e),t&&64!==e.length&&(e=o.publicKeyConvert(e,!1).slice(1)),a(64===e.length),r.keccak(e).slice(-20)};var h=r.privateToPublic=function(e){return e=r.toBuffer(e),o.publicKeyCreate(e,!1).slice(1)};r.importPublic=function(e){return 64!==(e=r.toBuffer(e)).length&&(e=o.publicKeyConvert(e,!1).slice(1)),e},r.ecsign=function(e,t){var r=o.sign(e,t),n={};return n.r=r.signature.slice(0,32),n.s=r.signature.slice(32,64),n.v=r.recovery+27,n},r.hashPersonalMessage=function(e){var t=r.toBuffer("Ethereum Signed Message:\n"+e.length.toString());return r.keccak(f.concat([t,e]))},r.ecrecover=function(e,t,n,i){var a=f.concat([r.setLength(n,32),r.setLength(i,32)],64),s=t-27;if(0!==s&&1!==s)throw new Error("Invalid signature v value");var u=o.recover(e,a,s);return o.publicKeyConvert(u,!1).slice(1)},r.toRpcSig=function(e,t,n){if(27!==e&&28!==e)throw new Error("Invalid recovery id");return r.bufferToHex(f.concat([r.setLengthLeft(t,32),r.setLengthLeft(n,32),r.toBuffer(e-27)]))},r.fromRpcSig=function(e){if(65!==(e=r.toBuffer(e)).length)throw new Error("Invalid signature length");var t=e[64];return t<27&&(t+=27),{v:t,r:e.slice(0,32),s:e.slice(32,64)}},r.privateToAddress=function(e){return r.publicToAddress(h(e))},r.isValidAddress=function(e){return/^0x[0-9a-fA-F]{40}$/.test(e)},r.isZeroAddress=function(e){return r.zeroAddress()===r.addHexPrefix(e)},r.toChecksumAddress=function(e){e=r.stripHexPrefix(e).toLowerCase();for(var t=r.keccak(e).toString("hex"),n="0x",i=0;i=8?n+=e[i].toUpperCase():n+=e[i];return n},r.isValidChecksumAddress=function(e){return r.isValidAddress(e)&&r.toChecksumAddress(e)===e},r.generateAddress=function(e,t){return e=r.toBuffer(e),t=(t=new u(t)).isZero()?null:f.from(t.toArray()),r.rlphash([e,t]).slice(-20)},r.isPrecompiled=function(e){var t=r.unpad(e);return 1===t.length&&t[0]>=1&&t[0]<=8},r.addHexPrefix=function(e){return"string"!=typeof e?e:r.isHexPrefixed(e)?e:"0x"+e},r.isValidSignature=function(e,t,r,n){var i=new u("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16),o=new u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16);return 32===t.length&&32===r.length&&((27===e||28===e)&&(t=new u(t),r=new u(r),!(t.isZero()||t.gt(o)||r.isZero()||r.gt(o))&&(!1!==n||1!==new u(r).cmp(i))))},r.baToJSON=function(e){if(f.isBuffer(e))return"0x"+e.toString("hex");if(e instanceof Array){for(var t=[],n=0;n=i.length,"The field "+t.name+" must not have more "+t.length+" bytes")):t.allowZero&&0===i.length||!t.length||a(t.length===i.length,"The field "+t.name+" must have byte length of "+t.length),e.raw[n]=i}e._fields.push(t.name),Object.defineProperty(e,t.name,{enumerable:!0,configurable:!0,get:i,set:o}),t.default&&(e[t.name]=t.default),t.alias&&Object.defineProperty(e,t.alias,{enumerable:!1,configurable:!0,set:o,get:i})}),i)if("string"==typeof i&&(i=f.from(r.stripHexPrefix(i),"hex")),f.isBuffer(i)&&(i=s.decode(i)),Array.isArray(i)){if(i.length>e._fields.length)throw new Error("wrong number of fields in data");i.forEach(function(t,n){e[e._fields[n]]=r.toBuffer(t)})}else{if("object"!==(void 0===i?"undefined":n(i)))throw new Error("invalid data");var o=Object.keys(i);t.forEach(function(t){-1!==o.indexOf(t.name)&&(e[t.name]=i[t.name]),-1!==o.indexOf(t.alias)&&(e[t.alias]=i[t.alias])})}}},{assert:19,"bn.js":53,"create-hash":91,"ethjs-util":155,keccak:195,rlp:289,"safe-buffer":290,secp256k1:295}],142:[function(e,t,r){arguments[4][128][0].apply(r,arguments)},{_process:257,dup:128}],143:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var a=e("./address"),s=e("./bignumber"),u=e("./bytes"),c=e("./utf8"),f=e("./properties"),h=o(e("./errors")),l=new RegExp(/^bytes([0-9]*)$/),d=new RegExp(/^(u?int)([0-9]*)$/),p=new RegExp(/^(.*)\[([0-9]*)\]$/);r.defaultCoerceFunc=function(e,t){var r=e.match(d);return r&&parseInt(r[2])<=48?t.toNumber():t};var b=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"),y=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function m(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}function v(e,t){function r(t){throw new Error('unexpected character "'+e[t]+'" at position '+t+' in "'+e+'"')}for(var n={type:"",name:"",state:{allowType:!0}},i=n,o=0;o1){var i=r[1].match(b);if(""!=i[1].trim()||""!=i[3].trim())throw new Error("unexpected tokens");L(i[2]).forEach(function(e){t.outputs.push(v(e))})}return t}(e.trim()));throw new Error("unknown signature")};var w=function(){return function(e,t,r,n,i){this.coerceFunc=e,this.name=t,this.type=r,this.localName=n,this.dynamic=i}}(),_=function(e){function t(t){var r=e.call(this,t.coerceFunc,t.name,t.type,void 0,t.dynamic)||this;return f.defineReadOnly(r,"coder",t),r}return i(t,e),t.prototype.encode=function(e){return this.coder.encode(e)},t.prototype.decode=function(e,t){return this.coder.decode(e,t)},t}(w),A=function(e){function t(t,r){return e.call(this,t,"null","",r,!1)||this}return i(t,e),t.prototype.encode=function(e){return u.arrayify([])},t.prototype.decode=function(e,t){if(t>e.length)throw new Error("invalid null");return{consumed:0,value:this.coerceFunc("null",void 0)}},t}(w),E=function(e){function t(t,r,n,i){var o=this,a=(n?"int":"uint")+8*r;return(o=e.call(this,t,a,a,i,!1)||this).size=r,o.signed=n,o}return i(t,e),t.prototype.encode=function(e){try{var t=s.bigNumberify(e);return t=t.toTwos(8*this.size).maskn(8*this.size),this.signed&&(t=t.fromTwos(8*this.size).toTwos(256)),u.padZeros(u.arrayify(t),32)}catch(t){h.throwError("invalid number value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:e})}return null},t.prototype.decode=function(e,t){e.length32)throw new Error;t.set(r)}catch(t){h.throwError("invalid "+this.name+" value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:t.value||e})}return t},t.prototype.decode=function(e,t){return e.length=0?n:"")+"]",s=-1===n||r.dynamic;return(o=e.call(this,t,"array",a,i,s)||this).coder=r,o.length=n,o}return i(t,e),t.prototype.encode=function(e){Array.isArray(e)||h.throwError("expected array value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:"array",value:e});var t=this.length,r=new Uint8Array(0);-1===t&&(t=e.length,r=x.encode(t)),h.checkArgumentCount(t,e.length,"in coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i256||i%8!=0)&&h.throwError("invalid "+r[1]+" bit length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new E(e,i/8,"int"===r[1],t.name);if(r=t.type.match(l))return(0===(i=parseInt(r[1]))||i>32)&&h.throwError("invalid bytes length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new S(e,i,t.name);if(r=t.type.match(p)){var i=parseInt(r[2]||"-1");return(t=f.jsonCopy(t)).type=r[1],new N(e,D(e,t),i,t.name)}return"tuple"===t.type.substring(0,5)?function(e,t,r){t||(t=[]);var n=[];return t.forEach(function(t){n.push(D(e,t))}),new R(e,n,r)}(e,t.components,t.name):""===t.type?new A(e,t.name):(h.throwError("invalid type",h.INVALID_ARGUMENT,{arg:"type",value:t.type}),null)}var F=function(){function e(t){h.checkNew(this,e),t||(t=r.defaultCoerceFunc),f.defineReadOnly(this,"coerceFunc",t)}return e.prototype.encode=function(e,t){e.length!==t.length&&h.throwError("types/values length mismatch",h.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):e,r.push(D(this.coerceFunc,t))},this),u.hexlify(new R(this.coerceFunc,r,"_").encode(t))},e.prototype.decode=function(e,t){var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):f.jsonCopy(e),r.push(D(this.coerceFunc,t))},this),new R(this.coerceFunc,r,"_").decode(u.arrayify(t),0).value},e}();r.AbiCoder=F,r.defaultAbiCoder=new F},{"./address":144,"./bignumber":145,"./bytes":146,"./errors":147,"./properties":149,"./utf8":152}],144:[function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var i=n(e("bn.js")),o=e("./bytes"),a=e("./keccak256"),s=e("./rlp"),u=e("./errors");function c(e){"string"==typeof e&&e.match(/^0x[0-9A-Fa-f]{40}$/)||u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=o.arrayify(a.keccak256(r));for(var i=0;i<40;i+=2)r[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(15&r[i>>1])>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}for(var f={},h=0;h<10;h++)f[String(h)]=String(h);for(h=0;h<26;h++)f[String.fromCharCode(65+h)]=String(10+h);var l,d=Math.floor((l=9007199254740991,Math.log10?Math.log10(l):Math.log(l)/Math.LN10));function p(e){e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00";var t="";for(e.split("").forEach(function(e){t+=f[e]});t.length>=d;){var r=t.substring(0,d);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function b(e){var t=null;if("string"!=typeof e&&u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e}),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=c(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&u.throwError("bad address checksum",u.INVALID_ARGUMENT,{arg:"address",value:e});else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==p(e)&&u.throwError("bad icap checksum",u.INVALID_ARGUMENT,{arg:"address",value:e}),t=new i.default.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=c("0x"+t)}else u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});return t}r.getAddress=b,r.getIcapAddress=function(e){for(var t=new i.default.BN(b(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+p("XE00"+t)+t},r.getContractAddress=function(e){if(!e.from)throw new Error("missing from address");var t=e.nonce;return b("0x"+a.keccak256(s.encode([b(e.from),o.stripZeros(o.hexlify(t))])).substring(26))}},{"./bytes":146,"./errors":147,"./keccak256":148,"./rlp":150,"bn.js":53}],145:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=o(e("bn.js")),u=e("./bytes"),c=e("./properties"),f=e("./types"),h=a(e("./errors")),l=new s.default.BN(-1);function d(e){var t=e.toString(16);return"-"===t[0]?t.length%2==0?"-0x0"+t.substring(1):"-0x"+t.substring(1):t.length%2==1?"0x0"+t:"0x"+t}function p(e){return m(e)._bn}function b(e){return new y(d(e))}var y=function(e){function t(r){var n=e.call(this)||this;if(h.checkNew(n,t),"string"==typeof r)u.isHexString(r)?("0x"==r&&(r="0x0"),c.defineReadOnly(n,"_hex",r)):"-"===r[0]&&u.isHexString(r.substring(1))?c.defineReadOnly(n,"_hex",r):r.match(/^-?[0-9]*$/)?(""==r&&(r="0"),c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))):h.throwError("invalid BigNumber string value",h.INVALID_ARGUMENT,{arg:"value",value:r});else if("number"==typeof r){parseInt(String(r))!==r&&h.throwError("underflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"underflow",value:r,outputValue:parseInt(String(r))});try{c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}}else r instanceof t?c.defineReadOnly(n,"_hex",r._hex):r.toHexString?c.defineReadOnly(n,"_hex",d(p(r.toHexString()))):u.isArrayish(r)?c.defineReadOnly(n,"_hex",d(new s.default.BN(u.hexlify(r).substring(2),16))):h.throwError("invalid BigNumber value",h.INVALID_ARGUMENT,{arg:"value",value:r});return n}return i(t,e),Object.defineProperty(t.prototype,"_bn",{get:function(){return"-"===this._hex[0]?new s.default.BN(this._hex.substring(3),16).mul(l):new s.default.BN(this._hex.substring(2),16)},enumerable:!0,configurable:!0}),t.prototype.fromTwos=function(e){return b(this._bn.fromTwos(e))},t.prototype.toTwos=function(e){return b(this._bn.toTwos(e))},t.prototype.add=function(e){return b(this._bn.add(p(e)))},t.prototype.sub=function(e){return b(this._bn.sub(p(e)))},t.prototype.div=function(e){return m(e).isZero()&&h.throwError("division by zero",h.NUMERIC_FAULT,{operation:"divide",fault:"division by zero"}),b(this._bn.div(p(e)))},t.prototype.mul=function(e){return b(this._bn.mul(p(e)))},t.prototype.mod=function(e){return b(this._bn.mod(p(e)))},t.prototype.pow=function(e){return b(this._bn.pow(p(e)))},t.prototype.maskn=function(e){return b(this._bn.maskn(e))},t.prototype.eq=function(e){return this._bn.eq(p(e))},t.prototype.lt=function(e){return this._bn.lt(p(e))},t.prototype.lte=function(e){return this._bn.lte(p(e))},t.prototype.gt=function(e){return this._bn.gt(p(e))},t.prototype.gte=function(e){return this._bn.gte(p(e))},t.prototype.isZero=function(){return this._bn.isZero()},t.prototype.toNumber=function(){try{return this._bn.toNumber()}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}return null},t.prototype.toString=function(){return this._bn.toString(10)},t.prototype.toHexString=function(){return this._hex},t}(f.BigNumber);function m(e){return e instanceof y?e:new y(e)}r.bigNumberify=m,r.ConstantNegativeOne=m(-1),r.ConstantZero=m(0),r.ConstantOne=m(1),r.ConstantTwo=m(2),r.ConstantWeiPerEther=m("1000000000000000000")},{"./bytes":146,"./errors":147,"./properties":149,"./types":151,"bn.js":53}],146:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./errors");function i(e){return!!e._bn}function o(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return new Uint8Array(Array.prototype.slice.apply(e,t))},e)}function a(e){if(!e||parseInt(String(e.length))!=e.length||"string"==typeof e)return!1;for(var t=0;t=256||parseInt(String(r))!=r)return!1}return!0}function s(e){if(null==e&&n.throwError("cannot convert null value to array",n.INVALID_ARGUMENT,{arg:"value",value:e}),i(e)&&(e=e.toHexString()),"string"==typeof e){var t=e.match(/^(0x)?[0-9a-fA-F]*$/);t||n.throwError("invalid hexadecimal string",n.INVALID_ARGUMENT,{arg:"value",value:e}),"0x"!==t[1]&&n.throwError("hex string must have 0x prefix",n.INVALID_ARGUMENT,{arg:"value",value:e}),(e=e.substring(2)).length%2&&(e="0"+e);for(var r=[],s=0;s>4]+f[15&u])}return"0x"+o.join("")}return n.throwError("invalid hexlify value",null,{arg:"value",value:e}),"never"}function l(e,t){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length<2*t+2;)e="0x0"+e.substring(2);return e}function d(e){var t,r=0,i="0x",o="0x";if((t=e)&&null!=t.r&&null!=t.s){null==e.v&&null==e.recoveryParam&&n.throwError("at least on of recoveryParam or v must be specified",n.INVALID_ARGUMENT,{argument:"signature",value:e}),i=l(e.r,32),o=l(e.s,32),"string"==typeof(r=e.v)&&(r=parseInt(r,16));var a=e.recoveryParam;null==a&&null!=e.v&&(a=1-r%2),r=27+a}else{var u=s(e);if(65!==u.length)throw new Error("invalid signature");i=h(u.slice(0,32)),o=h(u.slice(32,64)),27!==(r=u[64])&&28!==r&&(r=27+r%2)}return{r:i,s:o,recoveryParam:r-27,v:r}}r.hexlify=h,r.hexDataLength=function(e){return c(e)&&e.length%2==0?(e.length-2)/2:null},r.hexDataSlice=function(e,t,r){return c(e)||n.throwError("invalid hex data",n.INVALID_ARGUMENT,{arg:"value",value:e}),e.length%2!=0&&n.throwError("hex data length must be even",n.INVALID_ARGUMENT,{arg:"value",value:e}),t=2+2*t,null!=r?"0x"+e.substring(t,t+2*r):"0x"+e.substring(t)},r.hexStripZeros=function(e){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length>3&&"0x0"===e.substring(0,3);)e="0x"+e.substring(3);return e},r.hexZeroPad=l,r.splitSignature=d,r.joinSignature=function(e){return h(u([(e=d(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}},{"./errors":147}],147:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.MISSING_NEW="MISSING_NEW",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.NUMERIC_FAULT="NUMERIC_FAULT",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION";var n=!1,i=!1;function o(e,t,n){if(i)throw new Error("unknown error");t||(t=r.UNKNOWN_ERROR),n||(n={});var o=[];Object.keys(n).forEach(function(e){try{o.push(e+"="+JSON.stringify(n[e]))}catch(t){o.push(e+"="+JSON.stringify(n[e].toString()))}});var a=e;o.length&&(e+=" ("+o.join(", ")+")");var s=new Error(e);throw s.reason=a,s.code=t,Object.keys(n).forEach(function(e){s[e]=n[e]}),s}r.throwError=o,r.checkNew=function(e,t){e instanceof t||o("missing new",r.MISSING_NEW,{name:t.name})},r.checkArgumentCount=function(e,t,n){n||(n=""),et&&o("too many arguments"+n,r.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})},r.setCensorship=function(e,t){n&&o("error censorship permanent",r.UNSUPPORTED_OPERATION,{operation:"setCersorship"}),i=!!e,n=!!t}},{}],148:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("js-sha3"),i=e("./bytes");r.keccak256=function(e){return"0x"+n.keccak_256(i.arrayify(e))}},{"./bytes":146,"js-sha3":142}],149:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defineReadOnly=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})},r.defineFrozen=function(e,t,r){var n=JSON.stringify(r);Object.defineProperty(e,t,{enumerable:!0,get:function(){return JSON.parse(n)}})},r.resolveProperties=function(e){var t={},r=[];return Object.keys(e).forEach(function(n){var i=e[n];i instanceof Promise?r.push(i.then(function(e){return t[n]=e,null})):t[n]=i}),Promise.all(r).then(function(){return t})},r.shallowCopy=function(e){var t={};for(var r in e)t[r]=e[r];return t},r.jsonCopy=function(e){return JSON.parse(JSON.stringify(e))}},{}],150:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./bytes");function i(e){for(var t=[];e;)t.unshift(255&e),e>>=8;return t}function o(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function s(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(r=e[t]-247)>e.length)throw new Error("too short");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("to short");return a(e,t,t+1+r,r+i)}if(e[t]>=192){if(t+1+(i=e[t]-192)>e.length)throw new Error("invalid rlp data");return a(e,t,t+1,i)}if(e[t]>=184){var r;if(t+1+(r=e[t]-183)>e.length)throw new Error("invalid rlp data");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("invalid rlp data");return{consumed:1+r+i,result:n.hexlify(e.slice(t+1+r,t+1+r+i))}}if(e[t]>=128){var i;if(t+1+(i=e[t]-128)>e.length)throw new Error("invalid rlp data");return{consumed:1+i,result:n.hexlify(e.slice(t+1,t+1+i))}}return{consumed:1,result:n.hexlify(e[t])}}r.encode=function(e){return n.hexlify(function e(t){if(Array.isArray(t)){var r=[];return t.forEach(function(t){r=r.concat(e(t))}),r.length<=55?(r.unshift(192+r.length),r):((o=i(r.length)).unshift(247+o.length),o.concat(r))}var o,a=Array.prototype.slice.call(n.arrayify(t));return 1===a.length&&a[0]<=127?a:a.length<=55?(a.unshift(128+a.length),a):((o=i(a.length)).unshift(183+o.length),o.concat(a))}(e))},r.decode=function(e){var t=n.arrayify(e),r=s(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}},{"./bytes":146}],151:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=function(){return function(){}}();r.BigNumber=n;var i=function(){return function(){}}();r.Indexed=i;var o=function(){return function(){}}();r.MinimalProvider=o;var a=function(){return function(){}}();r.Signer=a;var s=function(){return function(){}}();r.HDNode=s},{}],152:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,i=e("./bytes");!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(n=r.UnicodeNormalizationForm||(r.UnicodeNormalizationForm={})),r.toUtf8Bytes=function(e,t){void 0===t&&(t=n.current),t!=n.current&&(e=e.normalize(t));for(var r=[],o=0,a=0;a>6|192,r[o++]=63&s|128):55296==(64512&s)&&a+1>18|240,r[o++]=s>>12&63|128,r[o++]=s>>6&63|128,r[o++]=63&s|128):(r[o++]=s>>12|224,r[o++]=s>>6&63|128,r[o++]=63&s|128)}return i.arrayify(r)},r.toUtf8String=function(e){e=i.arrayify(e);for(var t="",r=0;r>7!=0){if(n>>6!=2){var o=null;if(n>>5==6)o=1;else if(n>>4==14)o=2;else if(n>>3==30)o=3;else if(n>>2==62)o=4;else{if(n>>1!=126)continue;o=5}if(r+o>e.length){for(;r>6==2;r++);if(r!=e.length)continue;return t}var a,s=n&(1<<8-o-1)-1;for(a=0;a>6!=2)break;s=s<<6|63&u}a==o?s<=65535?t+=String.fromCharCode(s):(s-=65536,t+=String.fromCharCode(55296+(s>>10&1023),56320+(1023&s))):r--}}else t+=String.fromCharCode(n)}return t}},{"./bytes":146}],153:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("number-to-bn"),o=new n(0),a=new n(-1),s={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",Gwei:"1000000000",shannon:"1000000000",nanoether:"1000000000",nano:"1000000000",szabo:"1000000000000",microether:"1000000000000",micro:"1000000000000",finney:"1000000000000000",milliether:"1000000000000000",milli:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"};function u(e){var t=e?e.toLowerCase():"ether",r=s[t];if("string"!=typeof r)throw new Error("[ethjs-unit] the unit provided "+e+" doesn't exists, please use the one of the following units "+JSON.stringify(s,null,2));return new n(r,10)}function c(e){if("string"==typeof e){if(!e.match(/^-?[0-9.]+$/))throw new Error("while converting number to string, invalid number value '"+e+"', should be a number matching (^-?[0-9.]+).");return e}if("number"==typeof e)return String(e);if("object"==typeof e&&e.toString&&(e.toTwos||e.dividedToIntegerBy))return e.toPrecision?String(e.toPrecision()):e.toString(10);throw new Error("while converting number to string, invalid number value '"+e+"' type "+typeof e+".")}t.exports={unitMap:s,numberToString:c,getValueOfUnit:u,fromWei:function(e,t,r){var n=i(e),c=n.lt(o),f=u(t),h=s[t].length-1||1,l=r||{};c&&(n=n.mul(a));for(var d=n.mod(f).toString(10);d.length2)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal points");var l=h[0],d=h[1];if(l||(l="0"),d||(d="0"),d.length>o)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal places");for(;d.length=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{}],155:[function(e,t,r){(function(r){"use strict";var n=e("is-hex-prefixed"),i=e("strip-hex-prefix");function o(e){var t=e;if("string"!=typeof t)throw new Error("[ethjs-util] while padding to even, value must be string, is currently "+typeof t+", while padToEven.");return t.length%2&&(t="0"+t),t}function a(e){return"0x"+e.toString(16)}t.exports={arrayContainsArray:function(e,t,r){if(!0!==Array.isArray(e))throw new Error("[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '"+typeof e+"'");if(!0!==Array.isArray(t))throw new Error("[ethjs-util] method arrayContainsArray requires input 'subset' to be an array got type '"+typeof t+"'");return t[Boolean(r)?"some":"every"](function(t){return e.indexOf(t)>=0})},intToBuffer:function(e){var t=a(e);return new r(o(t.slice(2)),"hex")},getBinarySize:function(e){if("string"!=typeof e)throw new Error("[ethjs-util] while getting binary size, method getBinarySize requires input 'str' to be type String, got '"+typeof e+"'.");return r.byteLength(e,"utf8")},isHexPrefixed:n,stripHexPrefix:i,padToEven:o,intToHex:a,fromAscii:function(e){for(var t="",r=0;r0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var r,n,a,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(r=this._events[e]).length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=a;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){n=s;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],158:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("md5.js");t.exports=function(e,t,r,o){if(n.isBuffer(e)||(e=n.from(e,"binary")),t&&(n.isBuffer(t)||(t=n.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var a=r/8,s=n.alloc(a),u=n.alloc(o||0),c=n.alloc(0);a>0||o>0;){var f=new i;f.update(c),f.update(e),t&&f.update(t),c=f.digest();var h=0;if(a>0){var l=s.length-a;h=Math.min(a,c.length),c.copy(s,l,0,h),a-=h}if(h0){var d=u.length-o,p=Math.min(o,c.length-h);c.copy(u,d,h,h+p),o-=p}}return c.fill(0),{key:s,iv:u}}},{"md5.js":231,"safe-buffer":290}],159:[function(e,t,r){"use strict";var n=e("is-callable"),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.exports=function(e,t,r){if(!n(t))throw new TypeError("iterator must be a function");var a;arguments.length>=3&&(a=r),"[object Array]"===i.call(e)?function(e,t,r){for(var n=0,i=e.length;n=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},i.prototype._update=function(e){throw new Error("_update is not implemented")},i.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();return void 0!==e&&(t=t.toString(e)),t},i.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=i}).call(this,e("buffer").Buffer)},{buffer:84,inherits:180,stream:311}],162:[function(e,t,r){var n=r;n.utils=e("./hash/utils"),n.common=e("./hash/common"),n.sha=e("./hash/sha"),n.ripemd=e("./hash/ripemd"),n.hmac=e("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":163,"./hash/hmac":164,"./hash/ripemd":165,"./hash/sha":166,"./hash/utils":173}],163:[function(e,t,r){"use strict";var n=e("./utils"),i=e("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},{"../utils":173}],173:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits");function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function s(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=i,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,a=255&i;o?r.push(o,a):r.push(a)}else for(n=0;n>>0}return a},r.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},r.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},r.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},r.sum64_lo=function(e,t,r,n){return t+n>>>0},r.sum64_4_hi=function(e,t,r,n,i,o,a,s){var u=0,c=t;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},r.sum64_5_hi=function(e,t,r,n,i,o,a,s,u,c){var f=0,h=t;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,n,i,o,a,s,u,c){return t+n+o+s+c>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:180,"minimalistic-assert":234}],174:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("minimalistic-crypto-utils"),o=e("minimalistic-assert");function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}t.exports=a,a.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},a.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length\\$%@ءؤة\"'^|~⦅⦆・ゥャ¢£¬¦¥₩│←↑→↓■○𐐨𐐩𐐪𐐫𐐬𐐭𐐮𐐯𐐰𐐱𐐲𐐳𐐴𐐵𐐶𐐷𐐸𐐹𐐺𐐻𐐼𐐽𐐾𐐿𐑀𐑁𐑂𐑃𐑄𐑅𐑆𐑇𐑈𐑉𐑊𐑋𐑌𐑍𐑎𐑏𐓘𐓙𐓚𐓛𐓜𐓝𐓞𐓟𐓠𐓡𐓢𐓣𐓤𐓥𐓦𐓧𐓨𐓩𐓪𐓫𐓬𐓭𐓮𐓯𐓰𐓱𐓲𐓳𐓴𐓵𐓶𐓷𐓸𐓹𐓺𐓻𐳀𐳁𐳂𐳃𐳄𐳅𐳆𐳇𐳈𐳉𐳊𐳋𐳌𐳍𐳎𐳏𐳐𐳑𐳒𐳓𐳔𐳕𐳖𐳗𐳘𐳙𐳚𐳛𐳜𐳝𐳞𐳟𐳠𐳡𐳢𐳣𐳤𐳥𐳦𐳧𐳨𐳩𐳪𐳫𐳬𐳭𐳮𐳯𐳰𐳱𐳲𑣀𑣁𑣂𑣃𑣄𑣅𑣆𑣇𑣈𑣉𑣊𑣋𑣌𑣍𑣎𑣏𑣐𑣑𑣒𑣓𑣔𑣕𑣖𑣗𑣘𑣙𑣚𑣛𑣜𑣝𑣞𑣟ıȷ∇∂𞤢𞤣𞤤𞤥𞤦𞤧𞤨𞤩𞤪𞤫𞤬𞤭𞤮𞤯𞤰𞤱𞤲𞤳𞤴𞤵𞤶𞤷𞤸𞤹𞤺𞤻𞤼𞤽𞤾𞤿𞥀𞥁𞥂𞥃ٮڡٯ字双多解交映無前後再新初終販声吹演投捕遊指禁空合満申割営配得可丽丸乁𠄢你侻倂偺備像㒞𠘺兔兤具𠔜㒹內𠕋冗冤仌冬𩇟刃㓟刻剆剷㔕包匆卉博即卽卿𠨬灰及叟𠭣叫叱吆咞吸呈周咢哶唐啓啣善喫喳嗂圖圗噑噴壮城埴堍型堲報墬𡓤売壷夆夢奢𡚨𡛪姬娛娧姘婦㛮嬈嬾𡧈寃寘寳𡬘寿将㞁屠峀岍𡷤嵃𡷦嵮嵫嵼巡巢㠯巽帨帽幩㡢𢆃㡼庰庳庶𪎒𢌱舁弢㣇𣊸𦇚形彫㣣徚忍志忹悁㤺㤜𢛔惇慈慌慺憲憤憯懞戛扝抱拔捐𢬌挽拼捨掃揤𢯱搢揅掩㨮摩摾撝摷㩬敬𣀊旣書晉㬙㬈㫤冒冕最暜肭䏙朡杞杓𣏃㭉柺枅桒𣑭梎栟椔楂榣槪檨𣚣櫛㰘次𣢧歔㱎歲殟殻𣪍𡴋𣫺汎𣲼沿泍汧洖派浩浸涅𣴞洴港湮㴳滇𣻑淹潮𣽞𣾎濆瀹瀛㶖灊災灷炭𠔥煅𤉣熜爨牐𤘈犀犕𤜵𤠔獺王㺬玥㺸瑇瑜璅瓊㼛甤𤰶甾𤲒𢆟瘐𤾡𤾸𥁄㿼䀈𥃳𥃲𥄙𥄳眞真瞋䁆䂖𥐝硎䃣𥘦𥚚𥛅秫䄯穊穏𥥼𥪧䈂𥮫篆築䈧𥲀糒䊠糨糣紀𥾆絣䌁緇縂繅䌴𦈨𦉇䍙𦋙罺𦌾羕翺𦓚𦔣聠𦖨聰𣍟䏕育脃䐋脾媵𦞧𦞵𣎓𣎜舄辞䑫芑芋芝劳花芳芽苦𦬼茝荣莭茣莽菧荓菊菌菜𦰶𦵫𦳕䔫蓱蓳蔖𧏊蕤𦼬䕝䕡𦾱𧃒䕫虐虧虩蚩蚈蜎蛢蜨蝫螆蟡蠁䗹衠𧙧裗裞䘵裺㒻𧢮𧥦䚾䛇誠𧲨貫賁贛起𧼯𠠄跋趼跰𠣞軔𨗒𨗭邔郱鄑𨜮鄛鈸鋗鋘鉼鏹鐕𨯺開䦕閷𨵷䧦雃嶲霣𩅅𩈚䩮䩶韠𩐊䪲𩒖頩𩖶飢䬳餩馧駂駾䯎𩬰鱀鳽䳎䳭鵧𪃎䳸𪄅𪈎𪊑䵖黾鼅鼏鼖𪘀",mapChar:function(r){return r>=196608?r>=917760&&r<=917999?18874368:0:e[t[r>>4]][15&r]}}},"function"==typeof define&&define.amd?define([],function(){return i()}):"object"==typeof r?t.exports=i():n.uts46_map=i()},{}],177:[function(e,t,r){var n,i;n=this,i=function(e,t){function r(r,n,i){for(var o=[],a=e.ucs2.decode(r),s=0;s>23,l=f>>21&3,d=f>>5&65535,p=31&f,b=t.mapStr.substr(d,p);if(0===l||n&&1&h)throw new Error("Illegal char "+c);1===l?o.push(b):2===l?o.push(i?b:c):3===l&&o.push(c)}return o.join("").normalize("NFC")}function n(t,n,o){void 0===o&&(o=!1);var a=r(t,o,n).split(".");return(a=a.map(function(t){return t.startsWith("xn--")?i(t=e.decode(t.substring(4)),o,!1):i(t,o,n),t})).join(".")}function i(e,n,i){if("-"===e[2]&&"-"===e[3])throw new Error("Failed to validate "+e);if(e.startsWith("-")||e.endsWith("-"))throw new Error("Failed to validate "+e);if(e.includes("."))throw new Error("Failed to validate "+e);if(r(e,n,i)!==e)throw new Error("Failed to validate "+e);var o=e.codePointAt(0);if(t.mapChar(o)&2<<23)throw new Error("Label contains illegal character: "+o)}return{toUnicode:function(e,t){return void 0===t&&(t={}),n(e,!1,"useStd3ASCII"in t&&t.useStd3ASCII)},toAscii:function(t,r){void 0===r&&(r={});var i,o=!("transitional"in r)||r.transitional,a="useStd3ASCII"in r&&r.useStd3ASCII,s="verifyDnsLength"in r&&r.verifyDnsLength,u=n(t,o,a).split(".").map(e.toASCII),c=u.join(".");if(s){if(c.length<1||c.length>253)throw new Error("DNS name has wrong length: "+c);for(i=0;i63)throw new Error("DNS label has wrong length: "+f)}}return c}}},"function"==typeof define&&define.amd?define(["punycode","./idna-map"],function(e,t){return i(e,t)}):"object"==typeof r?t.exports=i(e("punycode"),e("./idna-map")):n.uts46=i(n.punycode,n.idna_map)},{"./idna-map":176,punycode:265}],178:[function(e,t,r){r.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,f=-7,h=r?i-1:0,l=r?-1:1,d=e[t+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=s;f>0;o=256*o+e[t+h],h+=l,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+e[t+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=c}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var a,s,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(a++,u/=2),a+h>=f?(s=0,a=f):a+h>=1?(s=(t*u-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;e[r+d]=255&a,d+=p,a/=256,c-=8);e[r+d-p]|=128*b}},{}],179:[function(e,t,r){var n=[].indexOf;t.exports=function(e,t){if(n)return e.indexOf(t);for(var r=0;r-32e3)throw new Error("Invalid error code");if(!(this instanceof f))return new f(e);i.call(this,"Server error",e)};n(f,i),i.ParseError=o,i.InvalidRequest=a,i.MethodNotFound=s,i.InvalidParams=u,i.InternalError=c,i.ServerError=f,t.exports=i},{inherits:180}],191:[function(e,t,r){t.exports=function(e){var t=(e=e||{}).max||Number.MAX_SAFE_INTEGER,r=void 0!==e.start?e.start:Math.floor(Math.random()*t);return function(){return r%=t,r++}}},{}],192:[function(e,t,r){r.parse=e("./lib/parse"),r.stringify=e("./lib/stringify")},{"./lib/parse":193,"./lib/stringify":194}],193:[function(e,t,r){var n,i,o,a,s={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},u=function(e){throw{name:"SyntaxError",message:e,at:n,text:o}},c=function(e){return e&&e!==i&&u("Expected '"+e+"' instead of '"+i+"'"),i=o.charAt(n),n+=1,i},f=function(){var e,t="";for("-"===i&&(t="-",c("-"));i>="0"&&i<="9";)t+=i,c();if("."===i)for(t+=".";c()&&i>="0"&&i<="9";)t+=i;if("e"===i||"E"===i)for(t+=i,c(),"-"!==i&&"+"!==i||(t+=i,c());i>="0"&&i<="9";)t+=i,c();if(e=+t,isFinite(e))return e;u("Bad number")},h=function(){var e,t,r,n="";if('"'===i)for(;c();){if('"'===i)return c(),n;if("\\"===i)if(c(),"u"===i){for(r=0,t=0;t<4&&(e=parseInt(c(),16),isFinite(e));t+=1)r=16*r+e;n+=String.fromCharCode(r)}else{if("string"!=typeof s[i])break;n+=s[i]}else n+=i}u("Bad string")},l=function(){for(;i&&i<=" ";)c()};a=function(){switch(l(),i){case"{":return function(){var e,t={};if("{"===i){if(c("{"),l(),"}"===i)return c("}"),t;for(;i;){if(e=h(),l(),c(":"),Object.hasOwnProperty.call(t,e)&&u('Duplicate key "'+e+'"'),t[e]=a(),l(),"}"===i)return c("}"),t;c(","),l()}}u("Bad object")}();case"[":return function(){var e=[];if("["===i){if(c("["),l(),"]"===i)return c("]"),e;for(;i;){if(e.push(a()),l(),"]"===i)return c("]"),e;c(","),l()}}u("Bad array")}();case'"':return h();case"-":return f();default:return i>="0"&&i<="9"?f():function(){switch(i){case"t":return c("t"),c("r"),c("u"),c("e"),!0;case"f":return c("f"),c("a"),c("l"),c("s"),c("e"),!1;case"n":return c("n"),c("u"),c("l"),c("l"),null}u("Unexpected '"+i+"'")}()}},t.exports=function(e,t){var r;return o=e,n=0,i=" ",r=a(),l(),i&&u("Syntax error"),"function"==typeof t?function e(r,n){var i,o,a=r[n];if(a&&"object"==typeof a)for(i in a)Object.prototype.hasOwnProperty.call(a,i)&&(void 0!==(o=e(a,i))?a[i]=o:delete a[i]);return t.call(r,n,a)}({"":r},""):r}},{}],194:[function(e,t,r){var n,i,o,a=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,s={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function u(e){return a.lastIndex=0,a.test(e)?'"'+e.replace(a,function(e){var t=s[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}t.exports=function(e,t,r){var a;if(n="",i="","number"==typeof r)for(a=0;a>>31),p=l^(a<<1|o>>>31),b=e[0]^d,y=e[1]^p,m=e[10]^d,v=e[11]^p,g=e[20]^d,w=e[21]^p,_=e[30]^d,A=e[31]^p,E=e[40]^d,x=e[41]^p;d=r^(s<<1|u>>>31),p=i^(u<<1|s>>>31);var k=e[2]^d,S=e[3]^p,M=e[12]^d,I=e[13]^p,T=e[22]^d,U=e[23]^p,j=e[32]^d,B=e[33]^p,P=e[42]^d,C=e[43]^p;d=o^(c<<1|f>>>31),p=a^(f<<1|c>>>31);var N=e[4]^d,R=e[5]^p,L=e[14]^d,O=e[15]^p,D=e[24]^d,F=e[25]^p,q=e[34]^d,H=e[35]^p,z=e[44]^d,K=e[45]^p;d=s^(h<<1|l>>>31),p=u^(l<<1|h>>>31);var V=e[6]^d,G=e[7]^p,W=e[16]^d,Y=e[17]^p,X=e[26]^d,Z=e[27]^p,J=e[36]^d,$=e[37]^p,Q=e[46]^d,ee=e[47]^p;d=c^(r<<1|i>>>31),p=f^(i<<1|r>>>31);var te=e[8]^d,re=e[9]^p,ne=e[18]^d,ie=e[19]^p,oe=e[28]^d,ae=e[29]^p,se=e[38]^d,ue=e[39]^p,ce=e[48]^d,fe=e[49]^p,he=b,le=y,de=v<<4|m>>>28,pe=m<<4|v>>>28,be=g<<3|w>>>29,ye=w<<3|g>>>29,me=A<<9|_>>>23,ve=_<<9|A>>>23,ge=E<<18|x>>>14,we=x<<18|E>>>14,_e=k<<1|S>>>31,Ae=S<<1|k>>>31,Ee=I<<12|M>>>20,xe=M<<12|I>>>20,ke=T<<10|U>>>22,Se=U<<10|T>>>22,Me=B<<13|j>>>19,Ie=j<<13|B>>>19,Te=P<<2|C>>>30,Ue=C<<2|P>>>30,je=R<<30|N>>>2,Be=N<<30|R>>>2,Pe=L<<6|O>>>26,Ce=O<<6|L>>>26,Ne=F<<11|D>>>21,Re=D<<11|F>>>21,Le=q<<15|H>>>17,Oe=H<<15|q>>>17,De=K<<29|z>>>3,Fe=z<<29|K>>>3,qe=V<<28|G>>>4,He=G<<28|V>>>4,ze=Y<<23|W>>>9,Ke=W<<23|Y>>>9,Ve=X<<25|Z>>>7,Ge=Z<<25|X>>>7,We=J<<21|$>>>11,Ye=$<<21|J>>>11,Xe=ee<<24|Q>>>8,Ze=Q<<24|ee>>>8,Je=te<<27|re>>>5,$e=re<<27|te>>>5,Qe=ne<<20|ie>>>12,et=ie<<20|ne>>>12,tt=ae<<7|oe>>>25,rt=oe<<7|ae>>>25,nt=se<<8|ue>>>24,it=ue<<8|se>>>24,ot=ce<<14|fe>>>18,at=fe<<14|ce>>>18;e[0]=he^~Ee&Ne,e[1]=le^~xe&Re,e[10]=qe^~Qe&be,e[11]=He^~et&ye,e[20]=_e^~Pe&Ve,e[21]=Ae^~Ce&Ge,e[30]=Je^~de&ke,e[31]=$e^~pe&Se,e[40]=je^~ze&tt,e[41]=Be^~Ke&rt,e[2]=Ee^~Ne&We,e[3]=xe^~Re&Ye,e[12]=Qe^~be&Me,e[13]=et^~ye&Ie,e[22]=Pe^~Ve&nt,e[23]=Ce^~Ge&it,e[32]=de^~ke&Le,e[33]=pe^~Se&Oe,e[42]=ze^~tt&me,e[43]=Ke^~rt&ve,e[4]=Ne^~We&ot,e[5]=Re^~Ye&at,e[14]=be^~Me&De,e[15]=ye^~Ie&Fe,e[24]=Ve^~nt&ge,e[25]=Ge^~it&we,e[34]=ke^~Le&Xe,e[35]=Se^~Oe&Ze,e[44]=tt^~me&Te,e[45]=rt^~ve&Ue,e[6]=We^~ot&he,e[7]=Ye^~at&le,e[16]=Me^~De&qe,e[17]=Ie^~Fe&He,e[26]=nt^~ge&_e,e[27]=it^~we&Ae,e[36]=Le^~Xe&Je,e[37]=Oe^~Ze&$e,e[46]=me^~Te&je,e[47]=ve^~Ue&Be,e[8]=ot^~he&Ee,e[9]=at^~le&xe,e[18]=De^~qe&Qe,e[19]=Fe^~He&et,e[28]=ge^~_e&Pe,e[29]=we^~Ae&Ce,e[38]=Xe^~Je&de,e[39]=Ze^~$e&pe,e[48]=Te^~je&ze,e[49]=Ue^~Be&Ke,e[0]^=n[2*t],e[1]^=n[2*t+1]}}},{}],200:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("./keccak-state-unroll");function o(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}o.prototype.initialize=function(e,t){for(var r=0;r<50;++r)this.state[r]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},o.prototype.absorb=function(e){for(var t=0;t>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(i.p1600(this.state),this.count=0);return t},o.prototype.copy=function(e){for(var t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},t.exports=o},{"./keccak-state-unroll":199,"safe-buffer":290}],201:[function(e,t,r){var n=e("./_root").Symbol;t.exports=n},{"./_root":217}],202:[function(e,t,r){var n=e("./_baseTimes"),i=e("./isArguments"),o=e("./isArray"),a=e("./isBuffer"),s=e("./_isIndex"),u=e("./isTypedArray"),c=Object.prototype.hasOwnProperty;t.exports=function(e,t){var r=o(e),f=!r&&i(e),h=!r&&!f&&a(e),l=!r&&!f&&!h&&u(e),d=r||f||h||l,p=d?n(e.length,String):[],b=p.length;for(var y in e)!t&&!c.call(e,y)||d&&("length"==y||h&&("offset"==y||"parent"==y)||l&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||s(y,b))||p.push(y);return p}},{"./_baseTimes":207,"./_isIndex":211,"./isArguments":219,"./isArray":220,"./isBuffer":222,"./isTypedArray":227}],203:[function(e,t,r){var n=e("./_Symbol"),i=e("./_getRawTag"),o=e("./_objectToString"),a="[object Null]",s="[object Undefined]",u=n?n.toStringTag:void 0;t.exports=function(e){return null==e?void 0===e?s:a:u&&u in Object(e)?i(e):o(e)}},{"./_Symbol":201,"./_getRawTag":210,"./_objectToString":215}],204:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isObjectLike"),o="[object Arguments]";t.exports=function(e){return i(e)&&n(e)==o}},{"./_baseGetTag":203,"./isObjectLike":226}],205:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isLength"),o=e("./isObjectLike"),a={};a["[object Float32Array]"]=a["[object Float64Array]"]=a["[object Int8Array]"]=a["[object Int16Array]"]=a["[object Int32Array]"]=a["[object Uint8Array]"]=a["[object Uint8ClampedArray]"]=a["[object Uint16Array]"]=a["[object Uint32Array]"]=!0,a["[object Arguments]"]=a["[object Array]"]=a["[object ArrayBuffer]"]=a["[object Boolean]"]=a["[object DataView]"]=a["[object Date]"]=a["[object Error]"]=a["[object Function]"]=a["[object Map]"]=a["[object Number]"]=a["[object Object]"]=a["[object RegExp]"]=a["[object Set]"]=a["[object String]"]=a["[object WeakMap]"]=!1,t.exports=function(e){return o(e)&&i(e.length)&&!!a[n(e)]}},{"./_baseGetTag":203,"./isLength":224,"./isObjectLike":226}],206:[function(e,t,r){var n=e("./_isPrototype"),i=e("./_nativeKeys"),o=Object.prototype.hasOwnProperty;t.exports=function(e){if(!n(e))return i(e);var t=[];for(var r in Object(e))o.call(e,r)&&"constructor"!=r&&t.push(r);return t}},{"./_isPrototype":212,"./_nativeKeys":213}],207:[function(e,t,r){t.exports=function(e,t){for(var r=-1,n=Array(e);++r-1&&e%1==0&&e-1&&e%1==0&&e<=n}},{}],225:[function(e,t,r){t.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},{}],226:[function(e,t,r){t.exports=function(e){return null!=e&&"object"==typeof e}},{}],227:[function(e,t,r){var n=e("./_baseIsTypedArray"),i=e("./_baseUnary"),o=e("./_nodeUtil"),a=o&&o.isTypedArray,s=a?i(a):n;t.exports=s},{"./_baseIsTypedArray":205,"./_baseUnary":208,"./_nodeUtil":214}],228:[function(e,t,r){var n=e("./_arrayLikeKeys"),i=e("./_baseKeys"),o=e("./isArrayLike");t.exports=function(e){return o(e)?n(e):i(e)}},{"./_arrayLikeKeys":202,"./_baseKeys":206,"./isArrayLike":221}],229:[function(e,t,r){t.exports=function(){}},{}],230:[function(e,t,r){t.exports=function(){return!1}},{}],231:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base"),o=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function s(e,t){return e<>>32-t}function u(e,t,r,n,i,o,a){return s(e+(t&r|~t&n)+i+o|0,a)+t|0}function c(e,t,r,n,i,o,a){return s(e+(t&n|r&~n)+i+o|0,a)+t|0}function f(e,t,r,n,i,o,a){return s(e+(t^r^n)+i+o|0,a)+t|0}function h(e,t,r,n,i,o,a){return s(e+(r^(t|~n))+i+o|0,a)+t|0}n(a,i),a.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,a=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,a=u(a,r=u(r,n,i,a,e[0],3614090360,7),n,i,e[1],3905402710,12),r,n,e[2],606105819,17),a,r,e[3],3250441966,22),i=u(i,a=u(a,r=u(r,n,i,a,e[4],4118548399,7),n,i,e[5],1200080426,12),r,n,e[6],2821735955,17),a,r,e[7],4249261313,22),i=u(i,a=u(a,r=u(r,n,i,a,e[8],1770035416,7),n,i,e[9],2336552879,12),r,n,e[10],4294925233,17),a,r,e[11],2304563134,22),i=u(i,a=u(a,r=u(r,n,i,a,e[12],1804603682,7),n,i,e[13],4254626195,12),r,n,e[14],2792965006,17),a,r,e[15],1236535329,22),i=c(i,a=c(a,r=c(r,n,i,a,e[1],4129170786,5),n,i,e[6],3225465664,9),r,n,e[11],643717713,14),a,r,e[0],3921069994,20),i=c(i,a=c(a,r=c(r,n,i,a,e[5],3593408605,5),n,i,e[10],38016083,9),r,n,e[15],3634488961,14),a,r,e[4],3889429448,20),i=c(i,a=c(a,r=c(r,n,i,a,e[9],568446438,5),n,i,e[14],3275163606,9),r,n,e[3],4107603335,14),a,r,e[8],1163531501,20),i=c(i,a=c(a,r=c(r,n,i,a,e[13],2850285829,5),n,i,e[2],4243563512,9),r,n,e[7],1735328473,14),a,r,e[12],2368359562,20),i=f(i,a=f(a,r=f(r,n,i,a,e[5],4294588738,4),n,i,e[8],2272392833,11),r,n,e[11],1839030562,16),a,r,e[14],4259657740,23),i=f(i,a=f(a,r=f(r,n,i,a,e[1],2763975236,4),n,i,e[4],1272893353,11),r,n,e[7],4139469664,16),a,r,e[10],3200236656,23),i=f(i,a=f(a,r=f(r,n,i,a,e[13],681279174,4),n,i,e[0],3936430074,11),r,n,e[3],3572445317,16),a,r,e[6],76029189,23),i=f(i,a=f(a,r=f(r,n,i,a,e[9],3654602809,4),n,i,e[12],3873151461,11),r,n,e[15],530742520,16),a,r,e[2],3299628645,23),i=h(i,a=h(a,r=h(r,n,i,a,e[0],4096336452,6),n,i,e[7],1126891415,10),r,n,e[14],2878612391,15),a,r,e[5],4237533241,21),i=h(i,a=h(a,r=h(r,n,i,a,e[12],1700485571,6),n,i,e[3],2399980690,10),r,n,e[10],4293915773,15),a,r,e[1],2240044497,21),i=h(i,a=h(a,r=h(r,n,i,a,e[8],1873313359,6),n,i,e[15],4264355552,10),r,n,e[6],2734768916,15),a,r,e[13],1309151649,21),i=h(i,a=h(a,r=h(r,n,i,a,e[4],4149444226,6),n,i,e[11],3174756917,10),r,n,e[2],718787259,15),a,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+a|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=a}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":232,inherits:180}],232:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("stream").Transform;function o(e){i.call(this),this._block=n.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}e("inherits")(o,i),o.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},o.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},o.prototype.update=function(e,t){if(function(e,t){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");n.isBuffer(e)||(e=n.from(e,t));for(var r=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},{inherits:180,"safe-buffer":290,stream:311}],233:[function(e,t,r){var n=e("bn.js"),i=e("brorand");function o(e){this.rand=e||new i.Rand}t.exports=o,o.create=function(e){return new o(e)},o.prototype._randbelow=function(e){var t=e.bitLength(),r=Math.ceil(t/8);do{var i=new n(this.rand.generate(r))}while(i.cmp(e)>=0);return i},o.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},o.prototype.test=function(e,t,r){var i=e.bitLength(),o=n.mont(e),a=new n(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var s=e.subn(1),u=0;!s.testn(u);u++);for(var c=e.shrn(u),f=s.toRed(o);t>0;t--){var h=this._randrange(new n(2),s);r&&r(h);var l=h.toRed(o).redPow(c);if(0!==l.cmp(a)&&0!==l.cmp(f)){for(var d=1;d0;t--){var f=this._randrange(new n(2),a),h=e.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(u);if(0!==l.cmp(o)&&0!==l.cmp(c)){for(var d=1;d>8,a=255&i;o?r.push(o,a):r.push(a)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},{}],236:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],237:[function(e,t,r){var n=e("bn.js"),i=e("strip-hex-prefix");t.exports=function(e){if("string"==typeof e||"number"==typeof e){var t=new n(1),r=String(e).toLowerCase().trim(),o="0x"===r.substr(0,2)||"-0x"===r.substr(0,3),a=i(r);if("-"===a.substr(0,1)&&(a=i(a.slice(1)),t=new n(-1,10)),!(a=""===a?"0":a).match(/^-?[0-9]+$/)&&a.match(/^[0-9A-Fa-f]+$/)||a.match(/^[a-fA-F]+$/)||!0===o&&a.match(/^[0-9A-Fa-f]+$/))return new n(a,16).mul(t);if((a.match(/^-?[0-9]+$/)||""===a)&&!1===o)return new n(a,10).mul(t)}else if("object"==typeof e&&e.toString&&!e.pop&&!e.push&&e.toString(10).match(/^-?[0-9]+$/)&&(e.mul||e.dividedToIntegerBy))return new n(e.toString(10),10);throw new Error("[number-to-bn] while converting number "+JSON.stringify(e)+" to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.")}},{"bn.js":236,"strip-hex-prefix":318}],238:[function(e,t,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,a,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),u=1;u0;)if(q+=r,r=e.charAt(o++),4===H?(N+=String.fromCharCode(parseInt(q,16)),H=0,c=o-1):H++,!r)break e;if('"'===r&&!L){D=F.pop()||p,N+=e.substring(c,o-1);break}if(!("\\"!==r||L||(L=!0,N+=e.substring(c,o-1),r=e.charAt(o++))))break;if(L){if(L=!1,"n"===r?N+="\n":"r"===r?N+="\r":"t"===r?N+="\t":"f"===r?N+="\f":"b"===r?N+="\b":"u"===r?(H=1,q=""):N+=r,r=e.charAt(o++),c=o-1,r)continue;break}h.lastIndex=o;var l=h.exec(e);if(!l){o=e.length+1,N+=e.substring(c,o-1);break}if(o=l.index+1,!(r=e.charAt(l.index))){N+=e.substring(c,o-1);break}}continue;case A:if(!r)continue;if("r"!==r)return W("Invalid true started with t"+r);D=E;continue;case E:if(!r)continue;if("u"!==r)return W("Invalid true started with tr"+r);D=x;continue;case x:if(!r)continue;if("e"!==r)return W("Invalid true started with tru"+r);a(!0),u(),D=F.pop()||p;continue;case k:if(!r)continue;if("a"!==r)return W("Invalid false started with f"+r);D=S;continue;case S:if(!r)continue;if("l"!==r)return W("Invalid false started with fa"+r);D=M;continue;case M:if(!r)continue;if("s"!==r)return W("Invalid false started with fal"+r);D=I;continue;case I:if(!r)continue;if("e"!==r)return W("Invalid false started with fals"+r);a(!1),u(),D=F.pop()||p;continue;case T:if(!r)continue;if("u"!==r)return W("Invalid null started with n"+r);D=U;continue;case U:if(!r)continue;if("l"!==r)return W("Invalid null started with nu"+r);D=j;continue;case j:if(!r)continue;if("l"!==r)return W("Invalid null started with nul"+r);a(null),u(),D=F.pop()||p;continue;case B:if("."!==r)return W("Leading zero not followed by .");R+=r,D=P;continue;case P:if(-1!=="0123456789".indexOf(r))R+=r;else if("."===r){if(-1!==R.indexOf("."))return W("Invalid number has two dots");R+=r}else if("e"===r||"E"===r){if(-1!==R.indexOf("e")||-1!==R.indexOf("E"))return W("Invalid number has two exponential");R+=r}else if("+"===r||"-"===r){if("e"!==n&&"E"!==n)return W("Invalid symbol in number");R+=r}else R&&(a(parseFloat(R)),u(),R=""),o--,D=F.pop()||p;continue;default:return W("Unknown state: "+D)}K>=C&&(X=0,N!==s&&N.length>f&&(W("Max buffer length exceeded: textNode"),X=Math.max(X,N.length)),R.length>f&&(W("Max buffer length exceeded: numberNode"),X=Math.max(X,R.length)),C=f-X+K);var X}),e(ce).on(function(){if(D==d)return a({}),u(),void(O=!0);D===p&&0===z||W("Unexpected end");N!==s&&(a(N),u(),N=s);O=!0})}var C,N,R,L,O,D,F,q,H,z,K,V=(C=d(function(e){return e.unshift(/^/),(t=RegExp(e.map(f("source")).join(""))).exec.bind(t);var t}),L=C(N=/(\$?)/,/([\w-_]+|\*)/,R=/(?:{([\w ]*?)})?/),O=C(N,/\["([^"]+)"\]/,R),D=C(N,/\[(\d+|\*)\]/,R),F=C(N,/()/,/{([\w ]*?)}/),q=C(/\.\./),H=C(/\./),z=C(N,/!/),K=C(/$/),function(e){return e(h(L,O,D,F),q,H,z,K)});function G(e,t){return{key:e,node:t}}var W=f("key"),Y=f("node"),X={};function Z(e){var t=e(ee).emit,r=e(te).emit,n=e(ae).emit,o=e(oe).emit;function a(e,t,r){Y(x(e))[t]=r}function s(e,r,n){e&&a(e,r,n);var i=A(G(r,n),e);return t(i),i}var u={};return u[le]=function(e,t){if(!e)return n(t),s(e,X,t);var r=function(e,t){var r=Y(x(e));return m(i,r)?s(e,v(r),t):e}(e,t),o=k(r),u=W(x(r));return a(o,u,t),A(G(u,t),o)},u[de]=function(e){return r(e),k(e)||o(Y(x(e)))},u[he]=s,u}var J=V(function(e,t,r,n,i){var a=1,s=2,f=3,l=c(W,x),d=c(Y,x);function b(e,t){return!!t[a]?p(e,x):e}function m(e){if(e==y)return y;return p(function(e){return l(e)!=X},c(e,k))}function g(){return function(e){return l(e)==X}}function w(e,t,r,n,i){var o=e(r);if(o){var a=function(e,t,r){return U(function(e,t){return t(e,r)},t,e)}(t,n,o);return i(r.substr(v(o[0])),a)}}function A(e,t){return u(w,e,t)}var E=h(A(e,M(b,function(e,t){var r=t[f];return r?p(c(u(_,S(r.split(/\W+/))),d),e):e},function(e,t){var r=t[s];return p(r&&"*"!=r?function(e){return l(e)==r}:y,e)},m)),A(t,M(function(e){if(e==y)return y;var t=g(),r=e,n=m(function(e){return i(e)}),i=h(t,r,n);return i})),A(r,M()),A(n,M(b,g)),A(i,M(function(e){return function(t){var r=e(t);return!0===r?x(t):r}})),function(e){throw o('"'+e+'" could not be tokenised')});function I(e,t){return t}function T(e,t){return E(e,t,e?T:I)}return function(e){try{return T(e,y)}catch(t){throw o('Could not compile "'+e+'" because '+t.message)}}});function $(e,t,r){var n,i;function o(e){return function(t){return t.id==e}}return{on:function(r,o){var a={listener:r,id:o||r};return t&&t.emit(e,r,a.id),n=A(a,n),i=A(r,i),this},emit:function(){!function e(t,r){t&&(x(t).apply(null,r),e(k(t),r))}(i,arguments)},un:function(t){var a;n=j(n,o(t),function(e){a=e}),a&&(i=j(i,function(e){return e==a.listener}),r&&r.emit(e,a.listener,a.id))},listeners:function(){return i},hasListener:function(e){return w(function e(t,r){return r&&(t(x(r))?x(r):e(t,k(r)))}(e?o(e):y,n))}}}var Q=1,ee=Q++,te=Q++,re=Q++,ne=Q++,ie="fail",oe=Q++,ae=Q++,se="start",ue="data",ce="end",fe=Q++,he=Q++,le=Q++,de=Q++;function pe(e,t,r){try{var n=a.parse(t)}catch(e){}return{statusCode:e,body:t,jsonBody:n,thrown:r}}function be(e,t){var r={node:e(te),path:e(ee)};function n(t,r,n){var i=e(t).emit;r.on(function(e){var t=n(e);!1!==t&&function(e,t,r){var n=B(r);e(t,I(k(T(W,n))),I(T(Y,n)))}(i,Y(t),e)},t),e("removeListener").on(function(n){n==t&&(e(n).listeners()||r.un(t))})}e("newListener").on(function(e){var i=/(node|path):(.*)/.exec(e);if(i){var o=r[i[1]];o.hasListener(e)||n(e,o,t(i[2]))}})}function ye(e,t){var r,n=/^(node|path):./,i=e(oe),o=e(ne).emit,a=e(re).emit,s=d(function(t,i){if(r[t])l(i,r[t]);else{var o=e(t),a=i[0];n.test(t)?c(o,a):o.on(a)}return r});function c(e,t,n){n=n||t;var i=f(t);return e.on(function(){var t=!1;r.forget=function(){t=!0},l(arguments,i),delete r.forget,t&&e.un(n)},n),r}function f(e){return function(){try{return e.apply(r,arguments)}catch(e){setTimeout(function(){throw e})}}}function h(t,r,n){var i;i="node"==t?function(e){return function(){var t=e.apply(this,arguments);w(t)&&(t==ge.drop?o():a(t))}}(n):n,c(function(t,r){return e(t+":"+r)}(t,r),i,n)}function p(e,t,n){return g(t)?h(e,t,n):function(e,t){for(var r in t)h(e,r,t[r])}(e,t),r}return e(ae).on(function(e){var t;r.root=(t=e,function(){return t})}),e(se).on(function(e,t){r.header=function(e){return e?t[e]:t}}),r={on:s,addListener:s,removeListener:function(t,n,o){if("done"==t)i.un(n);else if("node"==t||"path"==t)e.un(t+":"+n,o);else{var a=n;e(t).un(a)}return r},emit:e.emit,node:u(p,"node"),path:u(p,"path"),done:u(c,i),start:u(function(t,n){return e(t).on(f(n),n),r},se),fail:e(ie).on,abort:e(fe).emit,header:b,root:b,source:t}}function me(t,r,n,i,o){var a=function(){var e={},t=n("newListener"),r=n("removeListener");function n(n){return e[n]=$(n,t,r)}function i(t){return e[t]||n(t)}return["emit","on","un"].forEach(function(e){i[e]=d(function(t,r){l(r,i(t)[e])})}),i}();return r&&function(t,r,n,i,o,a,c){"use strict";var f=t(ue).emit,h=t(ie).emit,l=0,d=!0;function p(){var e=r.responseText,t=e.substr(l);t&&f(t),l=v(e)}t(fe).on(function(){r.onreadystatechange=null,r.abort()}),"onprogress"in r&&(r.onprogress=p),r.onreadystatechange=function(){function e(){try{d&&t(se).emit(r.status,(e=r.getAllResponseHeaders(),n={},e&&e.split("\r\n").forEach(function(e){var t=e.indexOf(": ");n[e.substring(0,t)]=e.substring(t+2)}),n)),d=!1}catch(e){}var e,n}switch(r.readyState){case 2:case 3:return e();case 4:e(),2==String(r.status)[0]?(p(),t(ce).emit()):h(pe(r.status,r.responseText))}};try{for(var b in r.open(n,i,!0),a)r.setRequestHeader(b,a[b]);(function(e,t){function r(t){return t.port||{"http:":80,"https:":443}[t.protocol||e.protocol]}return!!(t.protocol&&t.protocol!=e.protocol||t.host&&t.host!=e.host||t.host&&r(t)!=r(e))})(e.location,function(e){var t=/(\w+:)?(?:\/\/)([\w.-]+)?(?::(\d+))?\/?/.exec(e)||[];return{protocol:t[1]||"",host:t[2]||"",port:t[3]||""}}(i))||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.withCredentials=c,r.send(o)}catch(t){e.setTimeout(u(h,pe(s,s,t)),0)}}(a,new XMLHttpRequest,t,r,n,i,o),P(a),function(e,t){"use strict";var r,n={};function i(e){return function(t){r=e(r,t)}}for(var o in t)e(o).on(i(t[o]),n);e(re).on(function(e){var t=x(r),n=W(t),i=k(r);i&&(Y(x(i))[n]=e)}),e(ne).on(function(){var e=x(r),t=W(e),n=k(r);n&&delete Y(x(n))[t]}),e(fe).on(function(){for(var r in t)e(r).un(n)})}(a,Z(a)),be(a,J),ye(a,r)}function ve(e,t,r,n,i,o,s){return i=i?a.parse(a.stringify(i)):{},n?g(n)||(n=a.stringify(n),i["Content-Type"]=i["Content-Type"]||"application/json"):n=null,e(r||"GET",function(e,t){return!1===t&&(-1==e.indexOf("?")?e+="?":e+="&",e+="_="+(new Date).getTime()),e}(t,s),n,i,o||!1)}function ge(e){var t=M("resume","pause","pipe"),r=u(_,t);return e?r(e)||g(e)?ve(me,e):ve(me,e.url,e.method,e.body,e.headers,e.withCredentials,e.cached):me()}ge.drop=function(){return ge.drop},"function"==typeof define&&define.amd?define("oboe",[],function(){return ge}):"object"==typeof r?t.exports=ge:e.oboe=ge}(function(){try{return window}catch(e){return self}}(),Object,Array,Error,JSON)},{}],240:[function(e,t,r){r.endianness=function(){return"LE"},r.hostname=function(){return"undefined"!=typeof location?location.hostname:""},r.loadavg=function(){return[]},r.uptime=function(){return 0},r.freemem=function(){return Number.MAX_VALUE},r.totalmem=function(){return Number.MAX_VALUE},r.cpus=function(){return[]},r.type=function(){return"Browser"},r.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},r.networkInterfaces=r.getNetworkInterfaces=function(){return{}},r.arch=function(){return"javascript"},r.platform=function(){return"browser"},r.tmpdir=r.tmpDir=function(){return"/tmp"},r.EOL="\n",r.homedir=function(){return"/"}},{}],241:[function(e,t,r){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],242:[function(e,t,r){"use strict";var n=e("asn1.js");r.certificate=e("./certificate");var i=n.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});r.RSAPrivateKey=i;var o=n.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});r.RSAPublicKey=o;var a=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())});r.PublicKey=a;var s=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),u=n.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(s),this.key("subjectPrivateKey").octstr())});r.PrivateKey=u;var c=n.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});r.EncryptedPrivateKey=c;var f=n.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});r.DSAPrivateKey=f,r.DSAparam=n.define("DSAparam",function(){this.int()});var h=n.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(l),this.key("publicKey").optional().explicit(1).bitstr())});r.ECPrivateKey=h;var l=n.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});r.signature=n.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},{"./certificate":243,"asn1.js":5}],243:[function(e,t,r){"use strict";var n=e("asn1.js"),i=n.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),o=n.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),a=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional())}),s=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())}),u=n.define("RelativeDistinguishedName",function(){this.setof(o)}),c=n.define("RDNSequence",function(){this.seqof(u)}),f=n.define("Name",function(){this.choice({rdnSequence:this.use(c)})}),h=n.define("Validity",function(){this.seq().obj(this.key("notBefore").use(i),this.key("notAfter").use(i))}),l=n.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),d=n.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int(),this.key("serialNumber").int(),this.key("signature").use(a),this.key("issuer").use(f),this.key("validity").use(h),this.key("subject").use(f),this.key("subjectPublicKeyInfo").use(s),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(l).optional())}),p=n.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(a),this.key("signatureValue").bitstr())});t.exports=p},{"asn1.js":5}],244:[function(e,t,r){(function(r){var n=/Proc-Type: 4,ENCRYPTED\n\r?DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\n\r?\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?/m,i=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n/m,o=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?-----END \1-----$/m,a=e("evp_bytestokey"),s=e("browserify-aes");t.exports=function(e,t){var u,c=e.toString(),f=c.match(n);if(f){var h="aes"+f[1],l=new r(f[2],"hex"),d=new r(f[3].replace(/\r?\n/g,""),"base64"),p=a(t,l.slice(0,8),parseInt(f[1],10)).key,b=[],y=s.createDecipheriv(h,p,l);b.push(y.update(d)),b.push(y.final()),u=r.concat(b)}else{var m=c.match(o);u=new r(m[2].replace(/\r?\n/g,""),"base64")}return{tag:c.match(i)[1],data:u}}}).call(this,e("buffer").Buffer)},{"browserify-aes":58,buffer:84,evp_bytestokey:158}],245:[function(e,t,r){(function(r){var n=e("./asn1"),i=e("./aesid.json"),o=e("./fixProc"),a=e("browserify-aes"),s=e("pbkdf2");function u(e){var t;"object"!=typeof e||r.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=new r(e));var u,c,f=o(e,t),h=f.tag,l=f.data;switch(h){case"CERTIFICATE":c=n.certificate.decode(l,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(c||(c=n.PublicKey.decode(l,"der")),u=c.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPublicKey.decode(c.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return c.subjectPrivateKey=c.subjectPublicKey,{type:"ec",data:c};case"1.2.840.10040.4.1":return c.algorithm.params.pub_key=n.DSAparam.decode(c.subjectPublicKey.data,"der"),{type:"dsa",data:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"ENCRYPTED PRIVATE KEY":l=function(e,t){var n=e.algorithm.decrypt.kde.kdeparams.salt,o=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),u=i[e.algorithm.decrypt.cipher.algo.join(".")],c=e.algorithm.decrypt.cipher.iv,f=e.subjectPrivateKey,h=parseInt(u.split("-")[1],10)/8,l=s.pbkdf2Sync(t,n,o,h),d=a.createDecipheriv(u,l,c),p=[];return p.push(d.update(f)),p.push(d.final()),r.concat(p)}(l=n.EncryptedPrivateKey.decode(l,"der"),t);case"PRIVATE KEY":switch(u=(c=n.PrivateKey.decode(l,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPrivateKey.decode(c.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:c.algorithm.curve,privateKey:n.ECPrivateKey.decode(c.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return c.algorithm.params.priv_key=n.DSAparam.decode(c.subjectPrivateKey,"der"),{type:"dsa",params:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"RSA PUBLIC KEY":return n.RSAPublicKey.decode(l,"der");case"RSA PRIVATE KEY":return n.RSAPrivateKey.decode(l,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:n.DSAPrivateKey.decode(l,"der")};case"EC PRIVATE KEY":return{curve:(l=n.ECPrivateKey.decode(l,"der")).parameters.value,privateKey:l.privateKey};default:throw new Error("unknown key type "+h)}}t.exports=u,u.signature=n.signature}).call(this,e("buffer").Buffer)},{"./aesid.json":241,"./asn1":242,"./fixProc":244,"browserify-aes":58,buffer:84,pbkdf2:247}],246:[function(e,t,r){var n=e("trim"),i=e("for-each");t.exports=function(e){if(!e)return{};var t={};return i(n(e).split("\n"),function(e){var r,i=e.indexOf(":"),o=n(e.slice(0,i)).toLowerCase(),a=n(e.slice(i+1));void 0===t[o]?t[o]=a:(r=t[o],"[object Array]"===Object.prototype.toString.call(r)?t[o].push(a):t[o]=[t[o],a])}),t}},{"for-each":159,trim:324}],247:[function(e,t,r){r.pbkdf2=e("./lib/async"),r.pbkdf2Sync=e("./lib/sync")},{"./lib/async":248,"./lib/sync":251}],248:[function(e,t,r){(function(r,n){var i,o=e("./precondition"),a=e("./default-encoding"),s=e("./sync"),u=e("safe-buffer").Buffer,c=n.crypto&&n.crypto.subtle,f={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},h=[];function l(e,t,r,n,i){return c.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then(function(e){return c.deriveBits({name:"PBKDF2",salt:t,iterations:r,hash:{name:i}},e,n<<3)}).then(function(e){return u.from(e)})}t.exports=function(e,t,d,p,b,y){if(u.isBuffer(e)||(e=u.from(e,a)),u.isBuffer(t)||(t=u.from(t,a)),o(d,p),"function"==typeof b&&(y=b,b=void 0),"function"!=typeof y)throw new Error("No callback provided to pbkdf2");var m=f[(b=b||"sha1").toLowerCase()];if(!m||"function"!=typeof n.Promise)return r.nextTick(function(){var r;try{r=s(e,t,d,p,b)}catch(e){return y(e)}y(null,r)});!function(e,t){e.then(function(e){r.nextTick(function(){t(null,e)})},function(e){r.nextTick(function(){t(e)})})}(function(e){if(n.process&&!n.process.browser)return Promise.resolve(!1);if(!c||!c.importKey||!c.deriveBits)return Promise.resolve(!1);if(void 0!==h[e])return h[e];var t=l(i=i||u.alloc(8),i,10,128,e).then(function(){return!0}).catch(function(){return!1});return h[e]=t,t}(m).then(function(r){return r?l(e,t,d,p,m):s(e,t,d,p,b)}),y)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-encoding":249,"./precondition":250,"./sync":251,_process:257,"safe-buffer":290}],249:[function(e,t,r){(function(e){var r;e.browser?r="utf-8":r=parseInt(e.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary";t.exports=r}).call(this,e("_process"))},{_process:257}],250:[function(e,t,r){var n=Math.pow(2,30)-1;t.exports=function(e,t){if("number"!=typeof e)throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if("number"!=typeof t)throw new TypeError("Key length not a number");if(t<0||t>n||t!=t)throw new TypeError("Bad key length")}},{}],251:[function(e,t,r){var n=e("create-hash/md5"),i=e("ripemd160"),o=e("sha.js"),a=e("./precondition"),s=e("./default-encoding"),u=e("safe-buffer").Buffer,c=u.alloc(128),f={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function h(e,t,r){var a=function(e){return"rmd160"===e||"ripemd160"===e?i:"md5"===e?n:function(t){return o(e).update(t).digest()}}(e),s="sha512"===e||"sha384"===e?128:64;t.length>s?t=a(t):t.length1)for(var r=1;rp||new a(t).cmp(d.modulus)>=0)throw new Error("decryption error");l=f?c(new a(t),d):s(t,d);var b=new r(p-l.length);if(b.fill(0),l=r.concat([b,l],p),4===h)return function(e,t){e.modulus;var n=e.modulus.byteLength(),a=(t.length,u("sha1").update(new r("")).digest()),s=a.length;if(0!==t[0])throw new Error("decryption error");var c=t.slice(1,s+1),f=t.slice(s+1),h=o(c,i(f,s)),l=o(f,i(h,n-s-1));if(function(e,t){e=new r(e),t=new r(t);var n=0,i=e.length;e.length!==t.length&&(n++,i=Math.min(e.length,t.length));var o=-1;for(;++o=t.length){o++;break}var a=t.slice(2,i-1);t.slice(i-1,i);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;a.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,l,f);if(3===h)return l;throw new Error("unknown padding")}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245}],262:[function(e,t,r){(function(r){var n=e("parse-asn1"),i=e("randombytes"),o=e("create-hash"),a=e("./mgf"),s=e("./xor"),u=e("bn.js"),c=e("./withPublic"),f=e("browserify-rsa");t.exports=function(e,t,h){var l;l=e.padding?e.padding:h?1:4;var d,p=n(e);if(4===l)d=function(e,t){var n=e.modulus.byteLength(),c=t.length,f=o("sha1").update(new r("")).digest(),h=f.length,l=2*h;if(c>n-l-2)throw new Error("message too long");var d=new r(n-c-l-2);d.fill(0);var p=n-h-1,b=i(h),y=s(r.concat([f,d,new r([1]),t],p),a(b,p)),m=s(b,a(y,h));return new u(r.concat([new r([0]),m,y],n))}(p,t);else if(1===l)d=function(e,t,n){var o,a=t.length,s=e.modulus.byteLength();if(a>s-11)throw new Error("message too long");n?(o=new r(s-a-3)).fill(255):o=function(e,t){var n,o=new r(e),a=0,s=i(2*e),u=0;for(;a=0)throw new Error("data too long for modulus")}return h?f(d,p):c(d,p)}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245,randombytes:270}],263:[function(e,t,r){(function(r){var n=e("bn.js");t.exports=function(e,t){return new r(e.toRed(n.mont(t.modulus)).redPow(new n(t.publicExponent)).fromRed().toArray())}}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84}],264:[function(e,t,r){t.exports=function(e,t){for(var r=e.length,n=-1;++n= 0x80 (not a basic code point)","invalid-input":"Invalid input"},A=f-h,E=Math.floor,x=String.fromCharCode;function k(e){throw new RangeError(_[e])}function S(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function M(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+S((e=e.replace(w,".")).split("."),t).join(".")}function I(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=x((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=x(e)}).join("")}function U(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function j(e,t,r){var n=0;for(e=r?E(e/p):e>>1,e+=E(e/t);e>A*l>>1;n+=f)e=E(e/A);return E(n+(A+1)*e/(e+d))}function B(e){var t,r,n,i,o,a,s,u,d,p,v,g=[],w=e.length,_=0,A=y,x=b;for((r=e.lastIndexOf(m))<0&&(r=0),n=0;n=128&&k("not-basic"),g.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=w&&k("invalid-input"),((u=(v=e.charCodeAt(i++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:f)>=f||u>E((c-_)/a))&&k("overflow"),_+=u*a,!(u<(d=s<=x?h:s>=x+l?l:s-x));s+=f)a>E(c/(p=f-d))&&k("overflow"),a*=p;x=j(_-o,t=g.length+1,0==o),E(_/t)>c-A&&k("overflow"),A+=E(_/t),_%=t,g.splice(_++,0,A)}return T(g)}function P(e){var t,r,n,i,o,a,s,u,d,p,v,g,w,_,A,S=[];for(g=(e=I(e)).length,t=y,r=0,o=b,a=0;a=t&&vE((c-r)/(w=n+1))&&k("overflow"),r+=(s-t)*w,t=s,a=0;ac&&k("overflow"),v==t){for(u=r,d=f;!(u<(p=d<=o?h:d>=o+l?l:d-o));d+=f)A=u-p,_=f-p,S.push(x(U(p+A%_,0))),u=E(A/_);S.push(x(U(u,0))),o=j(r,w,n==i),r=0,++n}++r,++t}return S.join("")}if(s={version:"1.4.1",ucs2:{decode:I,encode:T},decode:B,encode:P,toASCII:function(e){return M(e,function(e){return g.test(e)?"xn--"+P(e):e})},toUnicode:function(e){return M(e,function(e){return v.test(e)?B(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return s});else if(i&&o)if(t.exports==i)o.exports=s;else for(u in s)s.hasOwnProperty(u)&&(i[u]=s[u]);else n.punycode=s}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],266:[function(e,t,r){"use strict";var n=e("strict-uri-encode"),i=e("object-assign"),o=e("decode-uri-component");function a(e,t){return t.encode?t.strict?n(e):encodeURIComponent(e):e}function s(e){var t=e.indexOf("?");return-1===t?"":e.slice(t+1)}function u(e,t){var r=function(e){var t;switch(e.arrayFormat){case"index":return function(e,r,n){t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return function(e,r,n){t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};default:return function(e,t,r){void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t=i({arrayFormat:"none"},t)),n=Object.create(null);return"string"!=typeof e?n:(e=e.trim().replace(/^[?#&]/,""))?(e.split("&").forEach(function(e){var t=e.replace(/\+/g," ").split("="),i=t.shift(),a=t.length>0?t.join("="):void 0;a=void 0===a?null:o(a),r(o(i),a,n)}),Object.keys(n).sort().reduce(function(e,t){var r=n[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=function e(t){return Array.isArray(t)?t.sort():"object"==typeof t?e(Object.keys(t)).sort(function(e,t){return Number(e)-Number(t)}).map(function(e){return t[e]}):t}(r):e[t]=r,e},Object.create(null))):n}r.extract=s,r.parse=u,r.stringify=function(e,t){!1===(t=i({encode:!0,strict:!0,arrayFormat:"none"},t)).sort&&(t.sort=function(){});var r=function(e){switch(e.arrayFormat){case"index":return function(t,r,n){return null===r?[a(t,e),"[",n,"]"].join(""):[a(t,e),"[",a(n,e),"]=",a(r,e)].join("")};case"bracket":return function(t,r){return null===r?a(t,e):[a(t,e),"[]=",a(r,e)].join("")};default:return function(t,r){return null===r?a(t,e):[a(t,e),"=",a(r,e)].join("")}}}(t);return e?Object.keys(e).sort(t.sort).map(function(n){var i=e[n];if(void 0===i)return"";if(null===i)return a(n,t);if(Array.isArray(i)){var o=[];return i.slice().forEach(function(e){void 0!==e&&o.push(r(n,e,o.length))}),o.join("&")}return a(n,t)+"="+a(i,t)}).filter(function(e){return e.length>0}).join("&"):""},r.parseUrl=function(e,t){return{url:e.split("?")[0]||"",query:u(s(e),t)}}},{"decode-uri-component":98,"object-assign":238,"strict-uri-encode":316}],267:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&",r=r||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(a,d)?i(a[d])?a[d].push(p):a[d]=[a[d],p]:a[d]=p}return a};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],268:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,s){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),function(a){var s=encodeURIComponent(n(a))+r;return i(e[a])?o(e[a],function(e){return s+encodeURIComponent(n(e))}).join(t):s+encodeURIComponent(n(e[a]))}).join(t):s?encodeURIComponent(n(s))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n65536)throw new Error("requested too many random bytes");var a=new n.Uint8Array(e);e>0&&o.getRandomValues(a);var s=i.from(a.buffer);if("function"==typeof t)return r.nextTick(function(){t(null,s)});return s}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,"safe-buffer":290}],271:[function(e,t,r){(function(t,n){"use strict";function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=e("safe-buffer"),a=e("randombytes"),s=o.Buffer,u=o.kMaxLength,c=n.crypto||n.msCrypto,f=Math.pow(2,32)-1;function h(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>f||e<0)throw new TypeError("offset must be a uint32");if(e>u||e>t)throw new RangeError("offset out of range")}function l(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>f||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>u)throw new RangeError("buffer too small")}function d(e,r,n,i){if(t.browser){var o=e.buffer,s=new Uint8Array(o,r,n);return c.getRandomValues(s),i?void t.nextTick(function(){i(null,e)}):e}if(!i)return a(n).copy(e,r),e;a(n,function(t,n){if(t)return i(t);n.copy(e,r),i(null,e)})}c&&c.getRandomValues||!t.browser?(r.randomFill=function(e,t,r,i){if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)i=t,t=0,r=e.length;else if("function"==typeof r)i=r,r=e.length-t;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return h(t,e.length),l(r,t,e.length),d(e,t,r,i)},r.randomFillSync=function(e,t,r){void 0===t&&(t=0);if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');h(t,e.length),void 0===r&&(r=e.length-t);return l(r,t,e.length),d(e,t,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,randombytes:270,"safe-buffer":290}],272:[function(e,t,r){t.exports=window.crypto},{}],273:[function(e,t,r){t.exports=e("crypto")},{crypto:272}],274:[function(e,t,r){t.exports=function(t,r){var n=e("./crypto.js"),i="function"==typeof r;if(t>65536){if(!i)throw new Error("Requested too many random bytes.");r(new Error("Requested too many random bytes."))}if(void 0!==n&&n.randomBytes){if(!i)return"0x"+n.randomBytes(t).toString("hex");n.randomBytes(t,function(e,t){e?r(u):r(null,"0x"+t.toString("hex"))})}else{var o;if(void 0!==n?o=n:"undefined"!=typeof msCrypto&&(o=msCrypto),o&&o.getRandomValues){var a=o.getRandomValues(new Uint8Array(t)),s="0x"+Array.from(a).map(function(e){return e.toString(16)}).join("");if(!i)return s;r(null,s)}else{var u=new Error('No "crypto" object available. This Browser doesn\'t support generating secure random bytes.');if(!i)throw u;r(u)}}}},{"./crypto.js":273}],275:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":276}],276:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick,i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=h;var o=e("core-util-is");o.inherits=e("inherits");var a=e("./_stream_readable"),s=e("./_stream_writable");o.inherits(h,a);for(var u=i(s.prototype),c=0;c0?("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),n?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):_(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?_(e,a,t,!1):S(e,a)):_(e,a,t,!1))):n||(a.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=A?e=A:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(d("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i(k,e):k(e))}function k(e){d("emit readable"),e.emit("readable"),U(e)}function S(e,t){t.readingMore||(t.readingMore=!0,i(M,e,t))}function M(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=c.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,a),0===(e-=a)){a===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function B(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i(P,t,e))}function P(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function C(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return d("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?B(this):x(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&B(this),null;var n,i=t.needReadable;return d("need readable",i),(0===t.length||t.length-e0?j(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&B(this)),null!==n&&this.emit("data",n),n},g.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},g.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,d("pipe count=%d opts=%j",o.pipesCount,t);var u=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?f:g;function c(t,r){d("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,d("cleanup"),e.removeListener("close",m),e.removeListener("finish",v),e.removeListener("drain",h),e.removeListener("error",y),e.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",g),n.removeListener("data",b),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||h())}function f(){d("onend"),e.end()}o.endEmitted?i(u):n.once("end",u),e.on("unpipe",c);var h=function(e){return function(){var t=e._readableState;d("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,U(e))}}(n);e.on("drain",h);var l=!1;var p=!1;function b(t){d("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==C(o.pipes,e))&&!l&&(d("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(t){d("onerror",t),g(),e.removeListener("error",y),0===s(e,"error")&&e.emit("error",t)}function m(){e.removeListener("finish",v),g()}function v(){d("onfinish"),e.removeListener("close",m),g()}function g(){d("unpipe"),n.unpipe(e)}return n.on("data",b),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?a(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",y),e.once("close",m),e.once("finish",v),e.emit("pipe",n),o.flowing||(d("pipe resume"),n.resume()),e},g.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:i;m.WritableState=y;var u=e("core-util-is");u.inherits=e("inherits");var c={deprecate:e("util-deprecate")},f=e("./internal/streams/stream"),h=e("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=e("./internal/streams/destroy");function b(){}function y(t,r){a=a||e("./_stream_duplex"),t=t||{};var n=r instanceof a;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var u=t.highWaterMark,c=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=u||0===u?u:n&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===t.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,o=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,o){--t.pendingcb,r?(i(o,n),i(E,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(o(n),e._writableState.errorEmitted=!0,e.emit("error",n),E(e,t))}(e,r,n,t,o);else{var a=_(r);a||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),n?s(g,e,r,a,o):g(e,r,a,o)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function m(t){if(a=a||e("./_stream_duplex"),!(d.call(m,this)||this instanceof a))return new m(t);this._writableState=new y(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),f.call(this)}function v(e,t,r,n,i,o,a){t.writelen=n,t.writecb=a,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function g(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),E(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),a=t.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,v(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,h=r.callback;if(v(e,t,!1,t.objectMode?1:c.length,c,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function A(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),E(e,t)})}function E(e,t){var r=_(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,i(A,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}u.inherits(m,f),y.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(y.prototype,"buffer",{get:c.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===m&&(e&&e._writableState instanceof y)}})):d=function(e){return e instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(e,t,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=e,h.isBuffer(n)||n instanceof l);return s&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof r&&(r=b),o.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),i(t,r)}(this,r):(s||function(e,t,r,n){var o=!0,a=!1;return null===r?a=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),i(n,a),o=!1),o}(this,o,e,r))&&(o.pendingcb++,a=function(e,t,r,n,i,o){if(!r){var a=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,r));return t}(t,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=t.objectMode?1:n.length;t.length+=s;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},m.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,E(e,t),r&&(t.finished?i(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),m.prototype.destroy=p.destroy,m.prototype._undestroy=p.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":276,"./internal/streams/destroy":282,"./internal/streams/stream":283,_process:257,"core-util-is":89,inherits:180,"process-nextick-args":256,"safe-buffer":290,"util-deprecate":330}],281:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,i,o=n.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,r=o,i=s,t.copy(r,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":290,util:55}],282:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick;function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var r=this,o=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return o||a?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||n(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n(i,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":256}],283:[function(e,t,r){t.exports=e("events").EventEmitter},{events:157}],284:[function(e,t,r){t.exports=e("./readable").PassThrough},{"./readable":285}],285:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":276,"./lib/_stream_passthrough.js":277,"./lib/_stream_readable.js":278,"./lib/_stream_transform.js":279,"./lib/_stream_writable.js":280}],286:[function(e,t,r){t.exports=e("./readable").Transform},{"./readable":285}],287:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":280}],288:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base");function o(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function a(e,t){return e<>>32-t}function s(e,t,r,n,i,o,s,u){return a(e+(t^r^n)+o+s|0,u)+i|0}function u(e,t,r,n,i,o,s,u){return a(e+(t&r|~t&n)+o+s|0,u)+i|0}function c(e,t,r,n,i,o,s,u){return a(e+((t|~r)^n)+o+s|0,u)+i|0}function f(e,t,r,n,i,o,s,u){return a(e+(t&n|r&~n)+o+s|0,u)+i|0}function h(e,t,r,n,i,o,s,u){return a(e+(t^(r|~n))+o+s|0,u)+i|0}n(o,i),o.prototype._update=function(){for(var e=new Array(16),t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,o=this._d,l=this._e;l=s(l,r=s(r,n,i,o,l,e[0],0,11),n,i=a(i,10),o,e[1],0,14),n=s(n=a(n,10),i=s(i,o=s(o,l,r,n,i,e[2],0,15),l,r=a(r,10),n,e[3],0,12),o,l=a(l,10),r,e[4],0,5),o=s(o=a(o,10),l=s(l,r=s(r,n,i,o,l,e[5],0,8),n,i=a(i,10),o,e[6],0,7),r,n=a(n,10),i,e[7],0,9),r=s(r=a(r,10),n=s(n,i=s(i,o,l,r,n,e[8],0,11),o,l=a(l,10),r,e[9],0,13),i,o=a(o,10),l,e[10],0,14),i=s(i=a(i,10),o=s(o,l=s(l,r,n,i,o,e[11],0,15),r,n=a(n,10),i,e[12],0,6),l,r=a(r,10),n,e[13],0,7),l=u(l=a(l,10),r=s(r,n=s(n,i,o,l,r,e[14],0,9),i,o=a(o,10),l,e[15],0,8),n,i=a(i,10),o,e[7],1518500249,7),n=u(n=a(n,10),i=u(i,o=u(o,l,r,n,i,e[4],1518500249,6),l,r=a(r,10),n,e[13],1518500249,8),o,l=a(l,10),r,e[1],1518500249,13),o=u(o=a(o,10),l=u(l,r=u(r,n,i,o,l,e[10],1518500249,11),n,i=a(i,10),o,e[6],1518500249,9),r,n=a(n,10),i,e[15],1518500249,7),r=u(r=a(r,10),n=u(n,i=u(i,o,l,r,n,e[3],1518500249,15),o,l=a(l,10),r,e[12],1518500249,7),i,o=a(o,10),l,e[0],1518500249,12),i=u(i=a(i,10),o=u(o,l=u(l,r,n,i,o,e[9],1518500249,15),r,n=a(n,10),i,e[5],1518500249,9),l,r=a(r,10),n,e[2],1518500249,11),l=u(l=a(l,10),r=u(r,n=u(n,i,o,l,r,e[14],1518500249,7),i,o=a(o,10),l,e[11],1518500249,13),n,i=a(i,10),o,e[8],1518500249,12),n=c(n=a(n,10),i=c(i,o=c(o,l,r,n,i,e[3],1859775393,11),l,r=a(r,10),n,e[10],1859775393,13),o,l=a(l,10),r,e[14],1859775393,6),o=c(o=a(o,10),l=c(l,r=c(r,n,i,o,l,e[4],1859775393,7),n,i=a(i,10),o,e[9],1859775393,14),r,n=a(n,10),i,e[15],1859775393,9),r=c(r=a(r,10),n=c(n,i=c(i,o,l,r,n,e[8],1859775393,13),o,l=a(l,10),r,e[1],1859775393,15),i,o=a(o,10),l,e[2],1859775393,14),i=c(i=a(i,10),o=c(o,l=c(l,r,n,i,o,e[7],1859775393,8),r,n=a(n,10),i,e[0],1859775393,13),l,r=a(r,10),n,e[6],1859775393,6),l=c(l=a(l,10),r=c(r,n=c(n,i,o,l,r,e[13],1859775393,5),i,o=a(o,10),l,e[11],1859775393,12),n,i=a(i,10),o,e[5],1859775393,7),n=f(n=a(n,10),i=f(i,o=c(o,l,r,n,i,e[12],1859775393,5),l,r=a(r,10),n,e[1],2400959708,11),o,l=a(l,10),r,e[9],2400959708,12),o=f(o=a(o,10),l=f(l,r=f(r,n,i,o,l,e[11],2400959708,14),n,i=a(i,10),o,e[10],2400959708,15),r,n=a(n,10),i,e[0],2400959708,14),r=f(r=a(r,10),n=f(n,i=f(i,o,l,r,n,e[8],2400959708,15),o,l=a(l,10),r,e[12],2400959708,9),i,o=a(o,10),l,e[4],2400959708,8),i=f(i=a(i,10),o=f(o,l=f(l,r,n,i,o,e[13],2400959708,9),r,n=a(n,10),i,e[3],2400959708,14),l,r=a(r,10),n,e[7],2400959708,5),l=f(l=a(l,10),r=f(r,n=f(n,i,o,l,r,e[15],2400959708,6),i,o=a(o,10),l,e[14],2400959708,8),n,i=a(i,10),o,e[5],2400959708,6),n=h(n=a(n,10),i=f(i,o=f(o,l,r,n,i,e[6],2400959708,5),l,r=a(r,10),n,e[2],2400959708,12),o,l=a(l,10),r,e[4],2840853838,9),o=h(o=a(o,10),l=h(l,r=h(r,n,i,o,l,e[0],2840853838,15),n,i=a(i,10),o,e[5],2840853838,5),r,n=a(n,10),i,e[9],2840853838,11),r=h(r=a(r,10),n=h(n,i=h(i,o,l,r,n,e[7],2840853838,6),o,l=a(l,10),r,e[12],2840853838,8),i,o=a(o,10),l,e[2],2840853838,13),i=h(i=a(i,10),o=h(o,l=h(l,r,n,i,o,e[10],2840853838,12),r,n=a(n,10),i,e[14],2840853838,5),l,r=a(r,10),n,e[1],2840853838,12),l=h(l=a(l,10),r=h(r,n=h(n,i,o,l,r,e[3],2840853838,13),i,o=a(o,10),l,e[8],2840853838,14),n,i=a(i,10),o,e[11],2840853838,11),n=h(n=a(n,10),i=h(i,o=h(o,l,r,n,i,e[6],2840853838,8),l,r=a(r,10),n,e[15],2840853838,5),o,l=a(l,10),r,e[13],2840853838,6),o=a(o,10);var d=this._a,p=this._b,b=this._c,y=this._d,m=this._e;m=h(m,d=h(d,p,b,y,m,e[5],1352829926,8),p,b=a(b,10),y,e[14],1352829926,9),p=h(p=a(p,10),b=h(b,y=h(y,m,d,p,b,e[7],1352829926,9),m,d=a(d,10),p,e[0],1352829926,11),y,m=a(m,10),d,e[9],1352829926,13),y=h(y=a(y,10),m=h(m,d=h(d,p,b,y,m,e[2],1352829926,15),p,b=a(b,10),y,e[11],1352829926,15),d,p=a(p,10),b,e[4],1352829926,5),d=h(d=a(d,10),p=h(p,b=h(b,y,m,d,p,e[13],1352829926,7),y,m=a(m,10),d,e[6],1352829926,7),b,y=a(y,10),m,e[15],1352829926,8),b=h(b=a(b,10),y=h(y,m=h(m,d,p,b,y,e[8],1352829926,11),d,p=a(p,10),b,e[1],1352829926,14),m,d=a(d,10),p,e[10],1352829926,14),m=f(m=a(m,10),d=h(d,p=h(p,b,y,m,d,e[3],1352829926,12),b,y=a(y,10),m,e[12],1352829926,6),p,b=a(b,10),y,e[6],1548603684,9),p=f(p=a(p,10),b=f(b,y=f(y,m,d,p,b,e[11],1548603684,13),m,d=a(d,10),p,e[3],1548603684,15),y,m=a(m,10),d,e[7],1548603684,7),y=f(y=a(y,10),m=f(m,d=f(d,p,b,y,m,e[0],1548603684,12),p,b=a(b,10),y,e[13],1548603684,8),d,p=a(p,10),b,e[5],1548603684,9),d=f(d=a(d,10),p=f(p,b=f(b,y,m,d,p,e[10],1548603684,11),y,m=a(m,10),d,e[14],1548603684,7),b,y=a(y,10),m,e[15],1548603684,7),b=f(b=a(b,10),y=f(y,m=f(m,d,p,b,y,e[8],1548603684,12),d,p=a(p,10),b,e[12],1548603684,7),m,d=a(d,10),p,e[4],1548603684,6),m=f(m=a(m,10),d=f(d,p=f(p,b,y,m,d,e[9],1548603684,15),b,y=a(y,10),m,e[1],1548603684,13),p,b=a(b,10),y,e[2],1548603684,11),p=c(p=a(p,10),b=c(b,y=c(y,m,d,p,b,e[15],1836072691,9),m,d=a(d,10),p,e[5],1836072691,7),y,m=a(m,10),d,e[1],1836072691,15),y=c(y=a(y,10),m=c(m,d=c(d,p,b,y,m,e[3],1836072691,11),p,b=a(b,10),y,e[7],1836072691,8),d,p=a(p,10),b,e[14],1836072691,6),d=c(d=a(d,10),p=c(p,b=c(b,y,m,d,p,e[6],1836072691,6),y,m=a(m,10),d,e[9],1836072691,14),b,y=a(y,10),m,e[11],1836072691,12),b=c(b=a(b,10),y=c(y,m=c(m,d,p,b,y,e[8],1836072691,13),d,p=a(p,10),b,e[12],1836072691,5),m,d=a(d,10),p,e[2],1836072691,14),m=c(m=a(m,10),d=c(d,p=c(p,b,y,m,d,e[10],1836072691,13),b,y=a(y,10),m,e[0],1836072691,13),p,b=a(b,10),y,e[4],1836072691,7),p=u(p=a(p,10),b=u(b,y=c(y,m,d,p,b,e[13],1836072691,5),m,d=a(d,10),p,e[8],2053994217,15),y,m=a(m,10),d,e[6],2053994217,5),y=u(y=a(y,10),m=u(m,d=u(d,p,b,y,m,e[4],2053994217,8),p,b=a(b,10),y,e[1],2053994217,11),d,p=a(p,10),b,e[3],2053994217,14),d=u(d=a(d,10),p=u(p,b=u(b,y,m,d,p,e[11],2053994217,14),y,m=a(m,10),d,e[15],2053994217,6),b,y=a(y,10),m,e[0],2053994217,14),b=u(b=a(b,10),y=u(y,m=u(m,d,p,b,y,e[5],2053994217,6),d,p=a(p,10),b,e[12],2053994217,9),m,d=a(d,10),p,e[2],2053994217,12),m=u(m=a(m,10),d=u(d,p=u(p,b,y,m,d,e[13],2053994217,9),b,y=a(y,10),m,e[9],2053994217,12),p,b=a(b,10),y,e[7],2053994217,5),p=s(p=a(p,10),b=u(b,y=u(y,m,d,p,b,e[10],2053994217,15),m,d=a(d,10),p,e[14],2053994217,8),y,m=a(m,10),d,e[12],0,8),y=s(y=a(y,10),m=s(m,d=s(d,p,b,y,m,e[15],0,5),p,b=a(b,10),y,e[10],0,12),d,p=a(p,10),b,e[4],0,9),d=s(d=a(d,10),p=s(p,b=s(b,y,m,d,p,e[1],0,12),y,m=a(m,10),d,e[5],0,5),b,y=a(y,10),m,e[8],0,14),b=s(b=a(b,10),y=s(y,m=s(m,d,p,b,y,e[7],0,6),d,p=a(p,10),b,e[6],0,8),m,d=a(d,10),p,e[2],0,13),m=s(m=a(m,10),d=s(d,p=s(p,b,y,m,d,e[13],0,6),b,y=a(y,10),m,e[14],0,5),p,b=a(b,10),y,e[0],0,15),p=s(p=a(p,10),b=s(b,y=s(y,m,d,p,b,e[3],0,13),m,d=a(d,10),p,e[9],0,11),y,m=a(m,10),d,e[11],0,11),y=a(y,10);var v=this._b+i+y|0;this._b=this._c+o+m|0,this._c=this._d+l+d|0,this._d=this._e+r+p|0,this._e=this._a+n+b|0,this._a=v},o.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=o}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":161,inherits:180}],289:[function(e,t,r){const n=e("assert"),i=e("safe-buffer").Buffer;function o(e,t){if("00"===e.slice(0,2))throw new Error("invalid RLP: extra zeros");return parseInt(e,t)}function a(e,t){if(e<56)return i.from([e+t]);var r=u(e),n=u(t+55+r.length/2);return i.from(n+r,"hex")}function s(e){return"0x"===e.slice(0,2)}function u(e){var t=e.toString(16);return t.length%2&&(t="0"+t),t}function c(e){if(!i.isBuffer(e))if("string"==typeof e)e=s(e)?i.from(((r="string"!=typeof(n=e)?n:s(n)?n.slice(2):n).length%2&&(r="0"+r),r),"hex"):i.from(e);else if("number"==typeof e)e?(t=u(e),e=i.from(t,"hex")):e=i.from([]);else if(null==e)e=i.from([]);else{if(!e.toArray)throw new Error("invalid type");e=i.from(e.toArray())}var t,r,n;return e}r.encode=function(e){if(e instanceof Array){for(var t=[],n=0;nt.length)throw new Error("invalid rlp: total length is larger than the data");if(0===(s=t.slice(n,h)).length)throw new Error("invalid rlp, List has a invalid length");for(;s.length;)u=e(s),c.push(u.data),s=u.remainder;return{data:c,remainder:t.slice(h)}}(e=c(e));return t?r:(n.equal(r.remainder.length,0,"invalid remainder"),r.data)},r.getLength=function(e){if(!e||0===e.length)return i.from([]);var t=(e=c(e))[0];if(t<=127)return e.length;if(t<=183)return t-127;if(t<=191)return t-182;if(t<=247)return t-191;var r=t-246;return r+o(e.slice(1,r).toString("hex"),16)}},{assert:19,"safe-buffer":290}],290:[function(e,t,r){var n=e("buffer"),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function a(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,r),r.Buffer=a),o(i,a),a.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:84}],291:[function(e,t,r){const n=e("util"),i=e("events/");var o="object"==typeof Reflect?Reflect:null,a=o&&"function"==typeof o.apply?o.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};function s(){i.call(this)}function u(e,t,r){try{a(e,t,r)}catch(e){setTimeout(()=>{throw e})}}t.exports=s,n.inherits(s,i),s.prototype.emit=function(e){for(var t=[],r=1;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var s=i[e];if(void 0===s)return!1;if("function"==typeof s)u(s,this,t);else{var c=s.length,f=function(e,t){for(var r=new Array(t),n=0;n0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=function(){for(var e=[],t=0;t0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var c=u.length,f=p(u,c);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return l(this,e,!0)},s.prototype.rawListeners=function(e){return l(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},{}],293:[function(e,t,r){t.exports=e("scryptsy")},{scryptsy:294}],294:[function(e,t,r){(function(r){var n=e("pbkdf2").pbkdf2Sync,i=2147483647;function o(e,t,n,i,o){if(r.isBuffer(e)&&r.isBuffer(n))e.copy(n,i,t,t+o);else for(;o--;)n[i++]=e[t++]}t.exports=function(e,t,a,s,u,c,f){if(0===a||0!=(a&a-1))throw Error("N must be > 0 and a power of 2");if(a>i/128/s)throw Error("Parameter N is too large");if(s>i/128/u)throw Error("Parameter r is too large");var h,l=new r(256*s),d=new r(128*s*a),p=new Int32Array(16),b=new Int32Array(16),y=new r(64),m=n(e,t,1,128*u*s,"sha256");if(f){var v=u*a*2,g=0;h=function(){++g%1e3==0&&f({current:g,total:v,percent:g/v*100})}}for(var w=0;w>>32-t}function x(e){var t;for(t=0;t<16;t++)p[t]=(255&e[4*t+0])<<0,p[t]|=(255&e[4*t+1])<<8,p[t]|=(255&e[4*t+2])<<16,p[t]|=(255&e[4*t+3])<<24;for(o(p,0,b,0,16),t=8;t>0;t-=2)b[4]^=E(b[0]+b[12],7),b[8]^=E(b[4]+b[0],9),b[12]^=E(b[8]+b[4],13),b[0]^=E(b[12]+b[8],18),b[9]^=E(b[5]+b[1],7),b[13]^=E(b[9]+b[5],9),b[1]^=E(b[13]+b[9],13),b[5]^=E(b[1]+b[13],18),b[14]^=E(b[10]+b[6],7),b[2]^=E(b[14]+b[10],9),b[6]^=E(b[2]+b[14],13),b[10]^=E(b[6]+b[2],18),b[3]^=E(b[15]+b[11],7),b[7]^=E(b[3]+b[15],9),b[11]^=E(b[7]+b[3],13),b[15]^=E(b[11]+b[7],18),b[1]^=E(b[0]+b[3],7),b[2]^=E(b[1]+b[0],9),b[3]^=E(b[2]+b[1],13),b[0]^=E(b[3]+b[2],18),b[6]^=E(b[5]+b[4],7),b[7]^=E(b[6]+b[5],9),b[4]^=E(b[7]+b[6],13),b[5]^=E(b[4]+b[7],18),b[11]^=E(b[10]+b[9],7),b[8]^=E(b[11]+b[10],9),b[9]^=E(b[8]+b[11],13),b[10]^=E(b[9]+b[8],18),b[12]^=E(b[15]+b[14],7),b[13]^=E(b[12]+b[15],9),b[14]^=E(b[13]+b[12],13),b[15]^=E(b[14]+b[13],18);for(t=0;t<16;++t)p[t]=b[t]+p[t];for(t=0;t<16;t++){var r=4*t;e[r+0]=p[t]>>0&255,e[r+1]=p[t]>>8&255,e[r+2]=p[t]>>16&255,e[r+3]=p[t]>>24&255}}function k(e,t,r,n,i){for(var o=0;o=r)throw RangeError(n)}}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":181}],297:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("bip66"),o=n.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),a=n.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(e,t,r){var i=n.from(r?o:a);return e.copy(i,r?8:9),t.copy(i,r?181:214),i},r.privateKeyImport=function(e){var t=e.length,r=0;if(!(t2||t1?e[r+n-2]<<8:0);if(!(t<(r+=n)+i||t32||t1&&0===t[o]&&!(128&t[o+1]);--r,++o);for(var a=n.concat([n.from([0]),e.s]),s=33,u=0;s>1&&0===a[u]&&!(128&a[u+1]);--s,++u);return i.encode(t.slice(o),a.slice(u))},r.signatureImport=function(e){var t=n.alloc(32,0),r=n.alloc(32,0);try{var o=i.decode(e);if(33===o.r.length&&0===o.r[0]&&(o.r=o.r.slice(1)),o.r.length>32)throw new Error("R length is too long");if(33===o.s.length&&0===o.s[0]&&(o.s=o.s.slice(1)),o.s.length>32)throw new Error("S length is too long")}catch(e){return}return o.r.copy(t,32-o.r.length),o.s.copy(r,32-o.s.length),{r:t,s:r}},r.signatureImportLax=function(e){var t=n.alloc(32,0),r=n.alloc(32,0),i=e.length,o=0;if(48===e[o++]){var a=e[o++];if(!(128&a&&(o+=a-128)>i)&&2===e[o++]){var s=e[o++];if(128&s){if(o+(a=s-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(s=0;a>0;o+=1,a-=1)s=(s<<8)+e[o]}if(!(s>i-o)){var u=o;if(o+=s,2===e[o++]){var c=e[o++];if(128&c){if(o+(a=c-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(c=0;a>0;o+=1,a-=1)c=(c<<8)+e[o]}if(!(c>i-o)){var f=o;for(o+=c;s>0&&0===e[u];s-=1,u+=1);if(!(s>32)){var h=e.slice(u,u+s);for(h.copy(t,32-h.length);c>0&&0===e[f];c-=1,f+=1);if(!(c>32)){var l=e.slice(f,f+c);return l.copy(r,32-l.length),{r:t,s:r}}}}}}}}}},{bip66:52,"safe-buffer":290}],298:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("create-hash"),o=e("bn.js"),a=e("elliptic").ec,s=e("../messages.json"),u=new a("secp256k1"),c=u.curve;function f(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new o(t);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),u.keyPair({pub:{x:r,y:n}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new o(t),i=new o(r);if(n.cmp(c.p)>=0||i.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),i=i.toRed(c.red),(6===e||7===e)&&i.isOdd()!==(7===e))return null;var a=n.redSqr().redIMul(n);return i.redSqr().redISub(a.redIAdd(c.b)).isZero()?u.keyPair({pub:{x:n,y:i}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}r.privateKeyVerify=function(e){var t=new o(e);return t.cmp(c.n)<0&&!t.isZero()},r.privateKeyExport=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.privateKeyNegate=function(e){var t=new o(e);return t.isZero()?n.alloc(32):c.n.sub(t).umod(c.n).toArrayLike(n,"be",32)},r.privateKeyModInverse=function(e){var t=new o(e);if(t.cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(c.n).toArrayLike(n,"be",32)},r.privateKeyTweakAdd=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new o(e)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(n,"be",32)},r.privateKeyTweakMul=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new o(e)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(n,"be",32)},r.publicKeyCreate=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.publicKeyConvert=function(e,t){var r=f(e);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return n.from(r.getPublic(t,!0))},r.publicKeyVerify=function(e){return null!==f(e)},r.publicKeyTweakAdd=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return n.from(c.g.mul(t).add(i.pub).encode(!0,r))},r.publicKeyTweakMul=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return n.from(i.pub.mul(t).encode(!0,r))},r.publicKeyCombine=function(e,t){for(var r=new Array(e.length),i=0;i=0||r.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var i=n.from(e);return 1===r.cmp(u.nh)&&c.n.sub(r).toArrayLike(n,"be",32).copy(i,32),i},r.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new o(t).cmp(c.n)>=0||new o(r).cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},r.signatureImport=function(e){var t=new o(e.r);t.cmp(c.n)>=0&&(t=new o(0));var r=new o(e.s);return r.cmp(c.n)>=0&&(r=new o(0)),n.concat([t.toArrayLike(n,"be",32),r.toArrayLike(n,"be",32)])},r.sign=function(e,t,r,i){if("function"==typeof r){var a=r;r=function(r){var u=a(e,t,null,i,r);if(!n.isBuffer(u)||32!==u.length)throw new Error(s.ECDSA_SIGN_FAIL);return new o(u)}}var f=new o(t);if(f.cmp(c.n)>=0||f.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var h=u.sign(e,t,{canonical:!0,k:r,pers:i});return{signature:n.concat([h.r.toArrayLike(n,"be",32),h.s.toArrayLike(n,"be",32)]),recovery:h.recoveryParam}},r.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},i=new o(n.r),a=new o(n.s);if(i.cmp(c.n)>=0||a.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===a.cmp(u.nh)||i.isZero()||a.isZero())return!1;var h=f(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return u.verify(e,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(e,t,r,i){var a={r:t.slice(0,32),s:t.slice(32,64)},f=new o(a.r),h=new o(a.s);if(f.cmp(c.n)>=0||h.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(f.isZero()||h.isZero())throw new Error;var l=u.recoverPubKey(e,a,r);return n.from(l.encode(!0,i))}catch(e){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(e,t){var n=r.ecdhUnsafe(e,t,!0);return i("sha256").update(n).digest()},r.ecdhUnsafe=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var a=new o(t);if(a.cmp(c.n)>=0||a.isZero())throw new Error(s.ECDH_FAIL);return n.from(i.pub.mul(a).encode(!0,r))}},{"../messages.json":300,"bn.js":53,"create-hash":91,elliptic:109,"safe-buffer":290}],299:[function(e,t,r){"use strict";var n=e("./assert"),i=e("./der"),o=e("./messages.json");function a(e,t){return void 0===e?t:(n.isBoolean(e,o.COMPRESSED_TYPE_INVALID),e)}t.exports=function(e){return{privateKeyVerify:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0);var s=e.privateKeyExport(t,r);return i.privateKeyExport(t,s,r)},privateKeyImport:function(t){if(n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),(t=i.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakAdd(t,r,i)},publicKeyTweakMul:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakMul(t,r,i)},publicKeyCombine:function(t,r){n.isArray(t,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(t,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=2&&("function"==typeof arguments[1]?r.task=arguments[1]:r.n=arguments[1]);var n=r.task;if(r.task=function(){n(t.leave)},t.current+r.n-e>t.capacity)return 1===e&&(t.current--,t.firstHere=!1),t.queue.push(r);t.current+=r.n-e,r.task(t.leave),1===e&&(t.firstHere=!1)},leave:function(e){if(e=e||1,t.current-=e,t.queue.length){var r=t.queue[0];r.n+t.current>t.capacity||(t.queue.shift(),t.current+=r.n,i(r.task))}else if(t.current<0)throw new Error("leave called too many times.")},available:function(e){return e=e||1,t.current+e<=t.capacity}};return t}void 0!==e&&e&&"function"==typeof e.nextTick&&(i=e.nextTick),"object"==typeof r?t.exports=o:"function"==typeof define&&define.amd?define(function(){return o}):n.semaphore=o}(this)}).call(this,e("_process"))},{_process:257}],302:[function(e,t,r){"use strict";t.exports="function"==typeof setImmediate?setImmediate:function(){var e=[].slice.apply(arguments);e.splice(1,0,0),setTimeout.apply(null,e)}},{}],303:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t){this._block=n.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}i.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=n.from(e,t));for(var r=this._block,i=this._blockSize,o=e.length,a=this._len,s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},{"safe-buffer":290}],304:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":305,"./sha1":306,"./sha224":307,"./sha256":308,"./sha384":309,"./sha512":310}],305:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((t=n)<<5|t>>>27)+f(d,i,o,s)+u+r[l]+a[d];u=s,s=o,o=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],306:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function h(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=(t=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=c(n)+h(p,i,o,s)+u+r[d]+a[p]|0;u=s,s=o,o=f(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],307:[function(e,t,r){var n=e("inherits"),i=e("./sha256"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}n(u,i),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=u},{"./hash":303,"./sha256":308,inherits:180,"safe-buffer":290}],308:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function l(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(u,i),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,m=0;m<16;++m)r[m]=e.readInt32BE(4*m);for(;m<64;++m)r[m]=0|(((t=r[m-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[m-7]+d(r[m-15])+r[m-16];for(var v=0;v<64;++v){var g=y+l(u)+c(u,p,b)+a[v]+r[v]|0,w=h(n)+f(n,i,o)|0;y=b,b=p,p=u,u=s+g|0,s=o,o=i,i=n,n=g+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},u.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],309:[function(e,t,r){var n=e("inherits"),i=e("./sha512"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}n(u,i),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=u},{"./hash":303,"./sha512":310,inherits:180,"safe-buffer":290}],310:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function l(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function y(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function m(e,t){return e>>>0>>0?1:0}n(u,i),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,s=0|this._eh,u=0|this._fh,v=0|this._gh,g=0|this._hh,w=0|this._al,_=0|this._bl,A=0|this._cl,E=0|this._dl,x=0|this._el,k=0|this._fl,S=0|this._gl,M=0|this._hl,I=0;I<32;I+=2)t[I]=e.readInt32BE(4*I),t[I+1]=e.readInt32BE(4*I+4);for(;I<160;I+=2){var T=t[I-30],U=t[I-30+1],j=d(T,U),B=p(U,T),P=b(T=t[I-4],U=t[I-4+1]),C=y(U,T),N=t[I-14],R=t[I-14+1],L=t[I-32],O=t[I-32+1],D=B+R|0,F=j+N+m(D,B)|0;F=(F=F+P+m(D=D+C|0,C)|0)+L+m(D=D+O|0,O)|0,t[I]=F,t[I+1]=D}for(var q=0;q<160;q+=2){F=t[q],D=t[q+1];var H=f(r,n,i),z=f(w,_,A),K=h(r,w),V=h(w,r),G=l(s,x),W=l(x,s),Y=a[q],X=a[q+1],Z=c(s,u,v),J=c(x,k,S),$=M+W|0,Q=g+G+m($,M)|0;Q=(Q=(Q=Q+Z+m($=$+J|0,J)|0)+Y+m($=$+X|0,X)|0)+F+m($=$+D|0,D)|0;var ee=V+z|0,te=K+H+m(ee,V)|0;g=v,M=S,v=u,S=k,u=s,k=x,s=o+Q+m(x=E+$|0,E)|0,o=i,E=A,i=n,A=_,n=r,_=w,r=Q+te+m(w=$+ee|0,$)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+A|0,this._dl=this._dl+E|0,this._el=this._el+x|0,this._fl=this._fl+k|0,this._gl=this._gl+S|0,this._hl=this._hl+M|0,this._ah=this._ah+r+m(this._al,w)|0,this._bh=this._bh+n+m(this._bl,_)|0,this._ch=this._ch+i+m(this._cl,A)|0,this._dh=this._dh+o+m(this._dl,E)|0,this._eh=this._eh+s+m(this._el,x)|0,this._fh=this._fh+u+m(this._fl,k)|0,this._gh=this._gh+v+m(this._gl,S)|0,this._hh=this._hh+g+m(this._hl,M)|0},u.prototype._hash=function(){var e=o.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],311:[function(e,t,r){t.exports=i;var n=e("events").EventEmitter;function i(){n.call(this)}e("inherits")(i,n),i.Readable=e("readable-stream/readable.js"),i.Writable=e("readable-stream/writable.js"),i.Duplex=e("readable-stream/duplex.js"),i.Transform=e("readable-stream/transform.js"),i.PassThrough=e("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,e.end())}function u(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(f(),0===n.listenerCount(this,"error"))throw e}function f(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),e.removeListener("close",f)}return r.on("error",c),e.on("error",c),r.on("end",f),r.on("close",f),e.on("close",f),e.emit("pipe",r),e}},{events:157,inherits:180,"readable-stream/duplex.js":275,"readable-stream/passthrough.js":284,"readable-stream/readable.js":285,"readable-stream/transform.js":286,"readable-stream/writable.js":287}],312:[function(e,t,r){(function(t){var n=e("./lib/request"),i=e("./lib/response"),o=e("xtend"),a=e("builtin-status-codes"),s=e("url"),u=r;u.request=function(e,r){e="string"==typeof e?s.parse(e):o(e);var i=-1===t.location.protocol.search(/^https?:$/)?"http:":"",a=e.protocol||i,u=e.hostname||e.host,c=e.port,f=e.path||"/";u&&-1!==u.indexOf(":")&&(u="["+u+"]"),e.url=(u?a+"//"+u:"")+(c?":"+c:"")+f,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var h=new n(e);return r&&h.on("response",r),h},u.get=function(e,t){var r=u.request(e,t);return r.end(),r},u.ClientRequest=n,u.IncomingMessage=i,u.Agent=function(){},u.Agent.defaultMaxSockets=4,u.STATUS_CODES=a,u.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/request":314,"./lib/response":315,"builtin-status-codes":85,url:327,xtend:423}],313:[function(e,t,r){(function(e){r.fetch=s(e.fetch)&&s(e.ReadableStream),r.writableStream=s(e.WritableStream),r.abortController=s(e.AbortController),r.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),r.blobConstructor=!0}catch(e){}var t;function n(){if(void 0!==t)return t;if(e.XMLHttpRequest){t=new e.XMLHttpRequest;try{t.open("GET",e.XDomainRequest?"/":"https://example.com")}catch(e){t=null}}else t=null;return t}function i(e){var t=n();if(!t)return!1;try{return t.responseType=e,t.responseType===e}catch(e){}return!1}var o=void 0!==e.ArrayBuffer,a=o&&s(e.ArrayBuffer.prototype.slice);function s(e){return"function"==typeof e}r.arraybuffer=r.fetch||o&&i("arraybuffer"),r.msstream=!r.fetch&&a&&i("ms-stream"),r.mozchunkedarraybuffer=!r.fetch&&o&&i("moz-chunked-arraybuffer"),r.overrideMimeType=r.fetch||!!n()&&s(n().overrideMimeType),r.vbArray=s(e.VBArray),t=null}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],314:[function(e,t,r){(function(r,n,i){var o=e("./capability"),a=e("inherits"),s=e("./response"),u=e("readable-stream"),c=e("to-arraybuffer"),f=s.IncomingMessage,h=s.readyStates;var l=t.exports=function(e){var t,r=this;u.Writable.call(r),r._opts=e,r._body=[],r._headers={},e.auth&&r.setHeader("Authorization","Basic "+new i(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){r.setHeader(t,e.headers[t])});var n=!0;if("disable-fetch"===e.mode||"requestTimeout"in e&&!o.abortController)n=!1,t=!0;else if("prefer-streaming"===e.mode)t=!1;else if("allow-wrong-content-type"===e.mode)t=!o.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");t=!0}r._mode=function(e,t){return o.fetch&&t?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&e?"arraybuffer":o.vbArray&&e?"text:vbarray":"text"}(t,n),r.on("finish",function(){r._onFinish()})};a(l,u.Writable),l.prototype.setHeader=function(e,t){var r=e.toLowerCase();-1===d.indexOf(r)&&(this._headers[r]={name:e,value:t})},l.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},l.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},l.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,a=e._headers,s=null;"GET"!==t.method&&"HEAD"!==t.method&&(s=o.arraybuffer?c(i.concat(e._body)):o.blobConstructor?new n.Blob(e._body.map(function(e){return c(e)}),{type:(a["content-type"]||{}).value||""}):i.concat(e._body).toString());var u=[];if(Object.keys(a).forEach(function(e){var t=a[e].name,r=a[e].value;Array.isArray(r)?r.forEach(function(e){u.push([t,e])}):u.push([t,r])}),"fetch"===e._mode){var f=null;if(o.abortController){var l=new AbortController;f=l.signal,e._fetchAbortController=l,"requestTimeout"in t&&0!==t.requestTimeout&&n.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},t.requestTimeout)}n.fetch(e._opts.url,{method:e._opts.method,headers:u,body:s||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin",signal:f}).then(function(t){e._fetchResponse=t,e._connect()},function(t){e.emit("error",t)})}else{var d=e._xhr=new n.XMLHttpRequest;try{d.open(e._opts.method,e._opts.url,!0)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}"responseType"in d&&(d.responseType=e._mode.split(":")[0]),"withCredentials"in d&&(d.withCredentials=!!t.withCredentials),"text"===e._mode&&"overrideMimeType"in d&&d.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in t&&(d.timeout=t.requestTimeout,d.ontimeout=function(){e.emit("requestTimeout")}),u.forEach(function(e){d.setRequestHeader(e[0],e[1])}),e._response=null,d.onreadystatechange=function(){switch(d.readyState){case h.LOADING:case h.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(d.onprogress=function(){e._onXHRProgress()}),d.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{d.send(s)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}}}},l.prototype._onXHRProgress=function(){(function(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}})(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},l.prototype._connect=function(){var e=this;e._destroyed||(e._response=new f(e._xhr,e._fetchResponse,e._mode),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},l.prototype._write=function(e,t,r){this._body.push(e),r()},l.prototype.abort=l.prototype.destroy=function(){this._destroyed=!0,this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},l.prototype.end=function(e,t,r){"function"==typeof e&&(r=e,e=void 0),u.Writable.prototype.end.call(this,e,t,r)},l.prototype.flushHeaders=function(){},l.prototype.setTimeout=function(){},l.prototype.setNoDelay=function(){},l.prototype.setSocketKeepAlive=function(){};var d=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referrer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,"./response":315,_process:257,buffer:84,inherits:180,"readable-stream":285,"to-arraybuffer":323}],315:[function(e,t,r){(function(t,n,i){var o=e("./capability"),a=e("inherits"),s=e("readable-stream"),u=r.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},c=r.IncomingMessage=function(e,r,n){var a=this;if(s.Readable.call(a),a._mode=n,a.headers={},a.rawHeaders=[],a.trailers={},a.rawTrailers=[],a.on("end",function(){t.nextTick(function(){a.emit("close")})}),"fetch"===n){if(a._fetchResponse=r,a.url=r.url,a.statusCode=r.status,a.statusMessage=r.statusText,r.headers.forEach(function(e,t){a.headers[t.toLowerCase()]=e,a.rawHeaders.push(t,e)}),o.writableStream){var u=new WritableStream({write:function(e){return new Promise(function(t,r){a._destroyed||(a.push(new i(e))?t():a._resumeFetch=t)})},close:function(){a._destroyed||a.push(null)},abort:function(e){a._destroyed||a.emit("error",e)}});try{return void r.body.pipeTo(u)}catch(e){}}var c=r.body.getReader();!function e(){c.read().then(function(t){a._destroyed||(t.done?a.push(null):(a.push(new i(t.value)),e()))}).catch(function(e){a._destroyed||a.emit("error",e)})}()}else{if(a._xhr=e,a._pos=0,a.url=e.responseURL,a.statusCode=e.status,a.statusMessage=e.statusText,e.getAllResponseHeaders().split(/\r?\n/).forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var r=t[1].toLowerCase();"set-cookie"===r?(void 0===a.headers[r]&&(a.headers[r]=[]),a.headers[r].push(t[2])):void 0!==a.headers[r]?a.headers[r]+=", "+t[2]:a.headers[r]=t[2],a.rawHeaders.push(t[1],t[2])}}),a._charset="x-user-defined",!o.overrideMimeType){var f=a.rawHeaders["mime-type"];if(f){var h=f.match(/;\s*charset=([^;])(;|$)/);h&&(a._charset=h[1].toLowerCase())}a._charset||(a._charset="utf-8")}}};a(c,s.Readable),c.prototype._read=function(){var e=this._resumeFetch;e&&(this._resumeFetch=null,e())},c.prototype._onXHRProgress=function(){var e=this,t=e._xhr,r=null;switch(e._mode){case"text:vbarray":if(t.readyState!==u.DONE)break;try{r=new n.VBArray(t.responseBody).toArray()}catch(e){}if(null!==r){e.push(new i(r));break}case"text":try{r=t.responseText}catch(t){e._mode="text:vbarray";break}if(r.length>e._pos){var o=r.substr(e._pos);if("x-user-defined"===e._charset){for(var a=new i(o.length),s=0;se._pos&&(e.push(new i(new Uint8Array(c.result.slice(e._pos)))),e._pos=c.result.byteLength)},c.onload=function(){e.push(null)},c.readAsArrayBuffer(r)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,_process:257,buffer:84,inherits:180,"readable-stream":285}],316:[function(e,t,r){"use strict";t.exports=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}},{}],317:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=f,this.end=h,t=3;break;default:return this.write=l,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:-1}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�".repeat(r);if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�".repeat(r+1);if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�".repeat(r+2)}}(this,e,t);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function l(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}r.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":290}],318:[function(e,t,r){var n=e("is-hex-prefixed");t.exports=function(e){return"string"!=typeof e?e:n(e)?e.slice(2):e}},{"is-hex-prefixed":185}],319:[function(e,t,r){var n=function(){throw"This swarm.js function isn't available on the browser."},i={readFile:n},o={download:n,safeDownloadArchived:n,directoryTree:n},a={platform:n,arch:n},s={join:n,slice:n},u={spawn:n},c={lookup:n},f=e("xhr-request-promise"),h=e("eth-lib/lib/bytes"),l=e("./swarm-hash.js"),d=e("./pick.js"),p=e("./swarm");t.exports=p({fsp:i,files:o,os:a,path:s,child_process:u,defaultArchives:{},mimetype:c,request:f,downloadUrl:null,bytes:h,hash:l,pick:d})},{"./pick.js":320,"./swarm":322,"./swarm-hash.js":321,"eth-lib/lib/bytes":133,"xhr-request-promise":411}],320:[function(e,t,r){var n=function(e){return function(){return new Promise(function(t,r){var n=function(r){var n={},i=r.target.files.length,o=0;[].map.call(r.target.files,function(r){var a=new FileReader;a.onload=function(a){var s=new Uint8Array(a.target.result);if("directory"===e){var u=r.webkitRelativePath;n[u.slice(u.indexOf("/")+1)]={type:"text/plain",data:s},++o===i&&t(n)}else if("file"===e){var c=r.webkitRelativePath;t({type:mimetype.lookup(c),data:s})}else t(s)},a.readAsArrayBuffer(r)})},i=void 0;"directory"===e?((i=document.createElement("input")).addEventListener("change",n),i.type="file",i.webkitdirectory=!0,i.mozdirectory=!0,i.msdirectory=!0,i.odirectory=!0,i.directory=!0):((i=document.createElement("input")).addEventListener("change",n),i.type="file");var o=document.createEvent("MouseEvents");o.initEvent("click",!0,!1),i.dispatchEvent(o)})}};t.exports={data:n("data"),file:n("file"),directory:n("directory")}},{}],321:[function(e,t,r){var n=e("eth-lib/lib/hash").keccak256,i=e("eth-lib/lib/bytes"),o=function(e,t){var r=i.reverse(i.pad(6,i.fromNumber(e))),o=i.flatten([r,"0x0000",t]);return n(o).slice(2)};t.exports=function e(t){"string"==typeof t&&"0x"!==t.slice(0,2)?t=i.fromString(t):"string"!=typeof t&&void 0!==t.length&&(t=i.fromUint8Array(t));var r=i.length(t);if(r<=4096)return o(r,t);for(var n=4096;128*n0){var a=i.join(r,o);n.push(g(e)(t[o])(a))}return Promise.all(n).then(function(){return r})})}}},_=function(e){return function(t){return u(e+"/bzzr:/",{body:"string"==typeof t?L(t):t,method:"POST"})}},A=function(e){return function(t){return function(r){return function(n){return function i(o){var a="/"===r[0]?r:"/"+r,s=e+"/bzz:/"+t+a,c={method:"PUT",headers:{"Content-Type":n.type},body:n.data};return u(s,c).then(function(e){if(-1!==e.indexOf("error"))throw e;return e}).catch(function(e){return o>0&&i(o-1)})}(3)}}}},E=function(e){return function(t){return k(e)({"":t})}},x=function(e){return function(r){return t.readFile(r).then(function(t){return E(e)({type:a.lookup(r),data:t})})}},k=function(e){return function(t){return _(e)("{}").then(function(r){return Object.keys(t).reduce(function(r,n){return r.then(function(r){return function(n){return A(e)(n)(r)(t[r])}}(n))},Promise.resolve(r))})}},S=function(e){return function(r){return t.readFile(r).then(_(e))}},M=function(e){return function(n){return function(i){return r.directoryTree(i).then(function(e){return Promise.all(e.map(function(e){return t.readFile(e)})).then(function(t){var r=e.map(function(e){return e.slice(i.length)}),n=e.map(function(e){return a.lookup(e)||"text/plain"});return d(r)(t.map(function(e,t){return{type:n[t],data:e}}))})}).then(function(e){return(t=n?{"":e[n]}:{},function(e){var r={};for(var n in t)r[n]=t[n];for(var i in e)r[i]=e[i];return r})(e);var t}).then(k(e))}}},I=function(e){return function(t){if("data"===t.pick)return l.data().then(_(e));if("file"===t.pick)return l.file().then(E(e));if("directory"===t.pick)return l.directory().then(k(e));if(t.path)switch(t.kind){case"data":return S(e)(t.path);case"file":return x(e)(t.path);case"directory":return M(e)(t.defaultFile)(t.path)}else{if(t.length||"string"==typeof t)return _(e)(t);if(t instanceof Object)return k(e)(t)}return Promise.reject(new Error("Bad arguments"))}},T=function(e){return function(t){return function(r){return C(e)(t).then(function(n){return n?r?w(e)(t)(r):v(e)(t):r?g(e)(t)(r):b(e)(t)})}}},U=function(e,t){var i=n.platform().replace("win32","windows")+"-"+("x64"===n.arch()?"amd64":"386"),o=(t||s)[i],a=c+o.archive+".tar.gz",u=o.archiveMD5,f=o.binaryMD5;return r.safeDownloadArchived(a)(u)(f)(e)},j=function(e){return new Promise(function(t,r){var n=o.spawn,i=function(e){return function(t){return-1!==(""+t).indexOf(e)}},a=e.account,s=e.password,u=e.dataDir,c=e.ensApi,f=e.privateKey,h=0,l=n(e.binPath,["--bzzaccount",a||f,"--datadir",u,"--ens-api",c]),d=function(e){0===h&&i("Passphrase")(e)?setTimeout(function(){h=1,l.stdin.write(s+"\n")},500):i("Swarm http proxy started")(e)&&(h=2,clearTimeout(p),t(l))};l.stdout.on("data",d),l.stderr.on("data",d);var p=setTimeout(function(){return r(new Error("Couldn't start swarm process."))},2e4)})},B=function(e){return new Promise(function(t,r){e.stderr.removeAllListeners("data"),e.stdout.removeAllListeners("data"),e.stdin.removeAllListeners("error"),e.removeAllListeners("error"),e.removeAllListeners("exit"),e.kill("SIGINT");var n=setTimeout(function(){return e.kill("SIGKILL")},8e3);e.once("close",function(){clearTimeout(n),t()})})},P=function(e){return _(e)("test").then(function(e){return"c9a99c7d326dcc6316f32fe2625b311f6dc49a175e6877681ded93137d3569e7"===e}).catch(function(){return!1})},C=function(e){return function(t){return b(e)(t).then(function(e){try{return!!JSON.parse(R(e)).entries}catch(e){return!1}})}},N=function(e){return function(t,r,n,i,o){var a;return void 0!==t&&(a=e(t)),void 0!==r&&(a=e(r)),void 0!==n&&(a=e(n)),void 0!==i&&(a=e(i)),void 0!==o&&(a=e(o)),a}},R=function(e){return f.toString(f.fromUint8Array(e))},L=function(e){return f.toUint8Array(f.fromString(e))},O=function(e){return{download:function(t,r){return T(e)(t)(r)},downloadData:N(b(e)),downloadDataToDisk:N(g(e)),downloadDirectory:N(v(e)),downloadDirectoryToDisk:N(w(e)),downloadEntries:N(y(e)),downloadRoutes:N(m(e)),isAvailable:function(){return P(e)},upload:function(t){return I(e)(t)},uploadData:N(_(e)),uploadFile:N(E(e)),uploadFileFromDisk:N(E(e)),uploadDataFromDisk:N(S(e)),uploadDirectory:N(k(e)),uploadDirectoryFromDisk:N(M(e)),uploadToManifest:N(A(e)),pick:l,hash:h,fromString:L,toString:R}};return{at:O,local:function(e){return function(t){return P("http://localhost:8500").then(function(r){return r?t(O("http://localhost:8500")).then(function(){}):U(e.binPath,e.archives).onData(function(t){return(e.onProgress||function(){})(t.length)}).then(function(){return j(e)}).then(function(e){return t(O("http://localhost:8500")).then(function(){return e})}).then(B)})}},download:T,downloadBinary:U,downloadData:b,downloadDataToDisk:g,downloadDirectory:v,downloadDirectoryToDisk:w,downloadEntries:y,downloadRoutes:m,isAvailable:P,startProcess:j,stopProcess:B,upload:I,uploadData:_,uploadDataFromDisk:S,uploadFile:E,uploadFileFromDisk:x,uploadDirectory:k,uploadDirectoryFromDisk:M,uploadToManifest:A,pick:l,hash:h,fromString:L,toString:R}}},{}],323:[function(e,t,r){var n=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(n.isBuffer(e)){for(var t=new Uint8Array(e.length),r=e.length,i=0;i=0&&t<=A};function k(e){return function(t,r,n,i){r=m(r,i,4);var o=!x(t)&&y.keys(t),a=(o||t).length,s=e>0?0:a-1;return arguments.length<3&&(n=t[o?o[s]:s],s+=e),function(t,r,n,i,o,a){for(;o>=0&&o=0},y.invoke=function(e,t){var r=u.call(arguments,2),n=y.isFunction(t);return y.map(e,function(e){var i=n?t:e[t];return null==i?i:i.apply(e,r)})},y.pluck=function(e,t){return y.map(e,y.property(t))},y.where=function(e,t){return y.filter(e,y.matcher(t))},y.findWhere=function(e,t){return y.find(e,y.matcher(t))},y.max=function(e,t,r){var n,i,o=-1/0,a=-1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;so&&(o=n);else t=v(t,r),y.each(e,function(e,r,n){((i=t(e,r,n))>a||i===-1/0&&o===-1/0)&&(o=e,a=i)});return o},y.min=function(e,t,r){var n,i,o=1/0,a=1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;sn||void 0===r)return 1;if(r0?0:i-1;o>=0&&o0?a=o>=0?o:Math.max(o+s,a):s=o>=0?Math.min(o+1,s):o+s+1;else if(r&&o&&s)return n[o=r(n,i)]===i?o:-1;if(i!=i)return(o=t(u.call(n,a,s),y.isNaN))>=0?o+a:-1;for(o=e>0?a:s-1;o>=0&&ot?(a&&(clearTimeout(a),a=null),s=c,o=e.apply(n,i),a||(n=i=null)):a||!1===r.trailing||(a=setTimeout(u,f)),o}},y.debounce=function(e,t,r){var n,i,o,a,s,u=function(){var c=y.now()-a;c=0?n=setTimeout(u,t-c):(n=null,r||(s=e.apply(o,i),n||(o=i=null)))};return function(){o=this,i=arguments,a=y.now();var c=r&&!n;return n||(n=setTimeout(u,t)),c&&(s=e.apply(o,i),o=i=null),s}},y.wrap=function(e,t){return y.partial(t,e)},y.negate=function(e){return function(){return!e.apply(this,arguments)}},y.compose=function(){var e=arguments,t=e.length-1;return function(){for(var r=t,n=e[t].apply(this,arguments);r--;)n=e[r].call(this,n);return n}},y.after=function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},y.before=function(e,t){var r;return function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=null),r}},y.once=y.partial(y.before,2);var j=!{toString:null}.propertyIsEnumerable("toString"),B=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];function P(e,t){var r=B.length,n=e.constructor,i=y.isFunction(n)&&n.prototype||o,a="constructor";for(y.has(e,a)&&!y.contains(t,a)&&t.push(a);r--;)(a=B[r])in e&&e[a]!==i[a]&&!y.contains(t,a)&&t.push(a)}y.keys=function(e){if(!y.isObject(e))return[];if(l)return l(e);var t=[];for(var r in e)y.has(e,r)&&t.push(r);return j&&P(e,t),t},y.allKeys=function(e){if(!y.isObject(e))return[];var t=[];for(var r in e)t.push(r);return j&&P(e,t),t},y.values=function(e){for(var t=y.keys(e),r=t.length,n=Array(r),i=0;i":">",'"':""","'":"'","`":"`"},R=y.invert(N),L=function(e){var t=function(t){return e[t]},r="(?:"+y.keys(e).join("|")+")",n=RegExp(r),i=RegExp(r,"g");return function(e){return e=null==e?"":""+e,n.test(e)?e.replace(i,t):e}};y.escape=L(N),y.unescape=L(R),y.result=function(e,t,r){var n=null==e?void 0:e[t];return void 0===n&&(n=r),y.isFunction(n)?n.call(e):n};var O=0;y.uniqueId=function(e){var t=++O+"";return e?e+t:t},y.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var D=/(.)^/,F={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},q=/\\|'|\r|\n|\u2028|\u2029/g,H=function(e){return"\\"+F[e]};y.template=function(e,t,r){!t&&r&&(t=r),t=y.defaults({},t,y.templateSettings);var n=RegExp([(t.escape||D).source,(t.interpolate||D).source,(t.evaluate||D).source].join("|")+"|$","g"),i=0,o="__p+='";e.replace(n,function(t,r,n,a,s){return o+=e.slice(i,s).replace(q,H),i=s+t.length,r?o+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":n?o+="'+\n((__t=("+n+"))==null?'':__t)+\n'":a&&(o+="';\n"+a+"\n__p+='"),t}),o+="';\n",t.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{var a=new Function(t.variable||"obj","_",o)}catch(e){throw e.source=o,e}var s=function(e){return a.call(this,e,y)},u=t.variable||"obj";return s.source="function("+u+"){\n"+o+"}",s},y.chain=function(e){var t=y(e);return t._chain=!0,t};var z=function(e,t){return e._chain?y(t).chain():t};y.mixin=function(e){y.each(y.functions(e),function(t){var r=y[t]=e[t];y.prototype[t]=function(){var e=[this._wrapped];return s.apply(e,arguments),z(this,r.apply(y,e))}})},y.mixin(y),y.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=i[e];y.prototype[e]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==e&&"splice"!==e||0!==r.length||delete r[0],z(this,r)}}),y.each(["concat","join","slice"],function(e){var t=i[e];y.prototype[e]=function(){return z(this,t.apply(this._wrapped,arguments))}}),y.prototype.value=function(){return this._wrapped},y.prototype.valueOf=y.prototype.toJSON=y.prototype.value,y.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return y})}).call(this)},{}],326:[function(e,t,r){t.exports=function(e,t){if(t){t=(t=t.trim().replace(/^(\?|#|&)/,""))?"?"+t:t;var r=e.split(/[\?\#]/),n=r[0];t&&/\:\/\/[^\/]*$/.test(n)&&(n+="/");var i=e.match(/(\#.*)$/);e=n+t,i&&(e+=i[0])}return e}},{}],327:[function(e,t,r){"use strict";var n=e("punycode"),i=e("./util");function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}r.parse=g,r.resolve=function(e,t){return g(e,!1,!0).resolve(t)},r.resolveObject=function(e,t){return e?g(e,!1,!0).resolveObject(t):t},r.format=function(e){i.isString(e)&&(e=g(e));return e instanceof o?e.format():o.prototype.format.call(e)},r.Url=o;var a=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=e("querystring");function g(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o127?P+="x":P+=B[C];if(!P.match(d)){var R=U.slice(0,M),L=U.slice(M+1),O=B.match(p);O&&(R.push(O[1]),L.unshift(O[2])),L.length&&(g="/"+L.join(".")+g),this.hostname=R.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),T||(this.hostname=n.toASCII(this.hostname));var D=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+D,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==g[0]&&(g="/"+g))}if(!b[A])for(M=0,j=f.length;M0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift());return r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!E.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var k=E.slice(-1)[0],S=(r.host||e.host||E.length>1)&&("."===k||".."===k)||""===k,M=0,I=E.length;I>=0;I--)"."===(k=E[I])?E.splice(I,1):".."===k?(E.splice(I,1),M++):M&&(E.splice(I,1),M--);if(!_&&!A)for(;M--;M)E.unshift("..");!_||""===E[0]||E[0]&&"/"===E[0].charAt(0)||E.unshift(""),S&&"/"!==E.join("/").substr(-1)&&E.push("");var T,U=""===E[0]||E[0]&&"/"===E[0].charAt(0);x&&(r.hostname=r.host=U?"":E.length?E.shift():"",(T=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift()));return(_=_||r.host&&E.length)&&!U&&E.unshift(""),E.length?r.pathname=E.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":328,punycode:265,querystring:269}],328:[function(e,t,r){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],329:[function(e,t,r){(function(e){!function(n){var i="object"==typeof r&&r,o="object"==typeof t&&t&&t.exports==i&&t,a="object"==typeof e&&e;a.global!==a&&a.window!==a||(n=a);var s,u,c,f=String.fromCharCode;function h(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i=55296&&e<=57343)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value")}function d(e,t){return f(e>>t&63|128)}function p(e){if(0==(4294967168&e))return f(e);var t="";return 0==(4294965248&e)?t=f(e>>6&31|192):0==(4294901760&e)?(l(e),t=f(e>>12&15|224),t+=d(e,6)):0==(4292870144&e)&&(t=f(e>>18&7|240),t+=d(e,12),t+=d(e,6)),t+=f(63&e|128)}function b(){if(c>=u)throw Error("Invalid byte index");var e=255&s[c];if(c++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function y(){var e,t;if(c>u)throw Error("Invalid byte index");if(c==u)return!1;if(e=255&s[c],c++,0==(128&e))return e;if(192==(224&e)){if((t=(31&e)<<6|b())>=128)return t;throw Error("Invalid continuation byte")}if(224==(240&e)){if((t=(15&e)<<12|b()<<6|b())>=2048)return l(t),t;throw Error("Invalid continuation byte")}if(240==(248&e)&&(t=(15&e)<<18|b()<<12|b()<<6|b())>=65536&&t<=1114111)return t;throw Error("Invalid UTF-8 detected")}var m={version:"2.0.0",encode:function(e){for(var t=h(e),r=t.length,n=-1,i="";++n65535&&(i+=f((t-=65536)>>>10&1023|55296),t=56320|1023&t),i+=f(t);return i}(r)}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return m});else if(i&&!i.nodeType)if(o)o.exports=m;else{var v={}.hasOwnProperty;for(var g in m)v.call(m,g)&&(i[g]=m[g])}else n.utf8=m}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],330:[function(e,t,r){(function(e){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],331:[function(e,t,r){arguments[4][180][0].apply(r,arguments)},{dup:180}],332:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],333:[function(e,t,r){(function(t,n){var i=/%[sdj%]/g;r.format=function(e){if(!m(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(t)?n.showHidden=t:t&&r._extend(n,t),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,e,n.depth)}function u(e,t){var r=s.styles[t];return r?"["+s.colors[r][0]+"m"+e+"["+s.colors[r][1]+"m":e}function c(e,t){return e}function f(e,t,n){if(e.customInspect&&t&&E(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return m(i)||(i=f(e,i,n)),i}var o=function(e,t){if(v(t))return e.stylize("undefined","undefined");if(m(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(y(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(b(t))return e.stylize("null","null")}(e,t);if(o)return o;var a=Object.keys(t),s=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),A(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return h(t);if(0===a.length){if(E(t)){var u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","special")}if(g(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(_(t))return e.stylize(Date.prototype.toString.call(t),"date");if(A(t))return h(t)}var c,w="",x=!1,k=["{","}"];(d(t)&&(x=!0,k=["[","]"]),E(t))&&(w=" [Function"+(t.name?": "+t.name:"")+"]");return g(t)&&(w=" "+RegExp.prototype.toString.call(t)),_(t)&&(w=" "+Date.prototype.toUTCString.call(t)),A(t)&&(w=" "+h(t)),0!==a.length||x&&0!=t.length?n<0?g(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=x?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(c,w,k)):k[0]+w+k[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),M(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=b(r)?f(e,u.value,null):f(e,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n")):s=e.stylize("[Circular]","special")),v(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function b(e){return null===e}function y(e){return"number"==typeof e}function m(e){return"string"==typeof e}function v(e){return void 0===e}function g(e){return w(e)&&"[object RegExp]"===x(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===x(e)}function A(e){return w(e)&&("[object Error]"===x(e)||e instanceof Error)}function E(e){return"function"==typeof e}function x(e){return Object.prototype.toString.call(e)}function k(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(v(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=t.pid;a[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else a[e]=function(){};return a[e]},r.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(e){return null==e},r.isNumber=y,r.isString=m,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=v,r.isRegExp=g,r.isObject=w,r.isDate=_,r.isError=A,r.isFunction=E,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[k(e.getHours()),k(e.getMinutes()),k(e.getSeconds())].join(":"),[e.getDate(),S[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":332,_process:257,inherits:331}],334:[function(require,module,exports){var indexOf=require("indexof"),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},c.prototype.getCall=function(e){return n.isFunction(this.call)?this.call(e):this.call},c.prototype.extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},c.prototype.validateArgs=function(e){if(e.length!==this.params)throw i.InvalidNumberOfParams(e.length,this.params,this.name)},c.prototype.formatInput=function(e){var t=this;return this.inputFormatter?this.inputFormatter.map(function(r,n){return r?r.call(t,e[n]):e[n]}):e},c.prototype.formatOutput=function(e){var t=this;return n.isArray(e)?e.map(function(e){return t.outputFormatter&&e?t.outputFormatter(e):e}):this.outputFormatter&&e?this.outputFormatter(e):e},c.prototype.toPayload=function(e){var t=this.getCall(e),r=this.extractCallback(e),n=this.formatInput(e);this.validateArgs(n);var i={method:t,params:n,callback:r};return this.transformPayload&&(i=this.transformPayload(i)),i},c.prototype._confirmTransaction=function(e,t,r){var i=this,f=!1,h=!0,l=0,d=0,p=null,b="",y=n.isObject(r.params[0])&&r.params[0].gas?r.params[0].gas:null,m=n.isObject(r.params[0])&&r.params[0].data&&r.params[0].from&&!r.params[0].to,v=[new c({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:o.outputTransactionReceiptFormatter}),new c({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[o.inputAddressFormatter,o.inputDefaultBlockNumberFormatter]}),new u({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:o.outputBlockFormatter}}})],g={};n.each(v,function(e){e.attachToObject(g),e.requestManager=i.requestManager});var w=function(r,n,o,u,c){if(!o)return c||(c={unsubscribe:function(){clearInterval(p)}}),(r?s.resolve(r):g.getTransactionReceipt(t)).catch(function(t){c.unsubscribe(),f=!0,a._fireError({message:"Failed to check for transaction receipt:",data:t},e.eventEmitter,e.reject)}).then(function(t){if(!t||!t.blockHash)throw new Error("Receipt missing or blockHash null");return i.extraFormatters&&i.extraFormatters.receiptFormatter&&(t=i.extraFormatters.receiptFormatter(t)),e.eventEmitter.listeners("confirmation").length>0&&(void 0!==r&&0===d||e.eventEmitter.emit("confirmation",d,t),h=!1,25===++d&&(c.unsubscribe(),e.eventEmitter.removeAllListeners())),t}).then(function(t){if(m&&!f){if(!t.contractAddress)return h&&(c.unsubscribe(),f=!0),void a._fireError(new Error("The transaction receipt didn't contain a contract address."),e.eventEmitter,e.reject);g.getCode(t.contractAddress,function(r,n){n&&(n.length>2?(e.eventEmitter.emit("receipt",t),i.extraFormatters&&i.extraFormatters.contractDeployFormatter?e.resolve(i.extraFormatters.contractDeployFormatter(t)):e.resolve(t),h&&e.eventEmitter.removeAllListeners()):a._fireError(new Error("The contract code couldn't be stored, please check your gas limit."),e.eventEmitter,e.reject),h&&c.unsubscribe(),f=!0)})}return t}).then(function(t){m||f||(t.outOfGas||y&&y===t.gasUsed||!0!==t.status&&"0x1"!==t.status&&void 0!==t.status?(b=JSON.stringify(t,null,2),!1===t.status||"0x0"===t.status?a._fireError(new Error("Transaction has been reverted by the EVM:\n"+b),e.eventEmitter,e.reject):a._fireError(new Error("Transaction ran out of gas. Please provide more gas:\n"+b),e.eventEmitter,e.reject)):(e.eventEmitter.emit("receipt",t),e.resolve(t),h&&e.eventEmitter.removeAllListeners()),h&&c.unsubscribe(),f=!0)}).catch(function(){l++,n?l-1>=750&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject)):l-1>=50&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject))});c.unsubscribe(),f=!0,a._fireError({message:"Failed to subscribe to new newBlockHeaders to confirm the transaction receipts.",data:o},e.eventEmitter,e.reject)},_=function(e){n.isFunction(this.requestManager.provider.on)?g.subscribe("newBlockHeaders",w.bind(null,e,!1)):p=setInterval(w.bind(null,e,!0),1e3)}.bind(this);g.getTransactionReceipt(t).then(function(t){t&&t.blockHash?(e.eventEmitter.listeners("confirmation").length>0&&_(t),w(t,!1)):f||_()}).catch(function(){f||_()})};var f=function(e,t){return n.isNumber(e)?t.wallet[e]:n.isObject(e)&&e.address&&e.privateKey?e:t.wallet[e.toLowerCase()]};c.prototype.buildCall=function(){var e=this,t="eth_sendTransaction"===e.call||"eth_sendRawTransaction"===e.call,r=function(){var r=s(!t),i=e.toPayload(Array.prototype.slice.call(arguments)),o=function(n,o){try{o=e.formatOutput(o)}catch(e){n=e}if(o instanceof Error&&(n=o),n)return n.error&&(n=n.error),a._fireError(n,r.eventEmitter,r.reject,i.callback);i.callback&&i.callback(null,o),t?(r.eventEmitter.emit("transactionHash",o),e._confirmTransaction(r,o,i)):n||r.resolve(o)},u=function(t){var r=n.extend({},i,{method:"eth_sendRawTransaction",params:[t.rawTransaction]});e.requestManager.send(r,o)},h=function(e,t){var i;if(t&&t.accounts&&t.accounts.wallet&&t.accounts.wallet.length)if("eth_sendTransaction"===e.method){var a=e.params[0];if((i=f(n.isObject(a)?a.from:null,t.accounts))&&i.privateKey)return t.accounts.signTransaction(n.omit(a,"from"),i.privateKey).then(u)}else if("eth_sign"===e.method){var s=e.params[1];if((i=f(e.params[0],t.accounts))&&i.privateKey){var c=t.accounts.sign(s,i.privateKey);return e.callback&&e.callback(null,c.signature),void r.resolve(c.signature)}}return t.requestManager.send(e,o)};t&&n.isObject(i.params[0])&&void 0===i.params[0].gasPrice?new c({name:"getGasPrice",call:"eth_gasPrice",params:0}).createFunction(e.requestManager)(function(t,r){r&&(i.params[0].gasPrice=r),h(i,e)}):h(i,e);return r.eventEmitter};return r.method=e,r.request=this.request.bind(this),r},c.prototype.request=function(){var e=this.toPayload(Array.prototype.slice.call(arguments));return e.format=this.formatOutput.bind(this),e},t.exports=c},{underscore:325,"web3-core-helpers":338,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-utils":403}],340:[function(e,t,r){"use strict";var n=e("eventemitter3"),i=e("any-promise"),o=function(e){var t,r,o=new i(function(){t=arguments[0],r=arguments[1]});if(e)return{resolve:t,reject:r,eventEmitter:o};var a=new n;return o._events=a._events,o.emit=a.emit,o.on=a.on,o.once=a.once,o.off=a.off,o.listeners=a.listeners,o.addListener=a.addListener,o.removeListener=a.removeListener,o.removeAllListeners=a.removeAllListeners,{resolve:t,reject:r,eventEmitter:o}};o.resolve=function(e){var t=o(!0);return t.resolve(e),t.eventEmitter},t.exports=o},{"any-promise":2,eventemitter3:156}],341:[function(e,t,r){"use strict";var n=e("./jsonrpc"),i=e("web3-core-helpers").errors,o=function(e){this.requestManager=e,this.requests=[]};o.prototype.add=function(e){this.requests.push(e)},o.prototype.execute=function(){var e=this.requests;this.requestManager.sendBatch(e,function(t,r){r=r||[],e.map(function(e,t){return r[t]||{}}).forEach(function(t,r){if(e[r].callback){if(t&&t.error)return e[r].callback(i.ErrorResponse(t));if(!n.isValidResponse(t))return e[r].callback(i.InvalidResponse(t));try{e[r].callback(null,e[r].format?e[r].format(t.result):t.result)}catch(t){e[r].callback(t)}}})})},t.exports=o},{"./jsonrpc":344,"web3-core-helpers":338}],342:[function(e,t,r){"use strict";var n=null,i=window;void 0!==i.ethereumProvider?n=i.ethereumProvider:void 0!==i.web3&&i.web3.currentProvider&&(i.web3.currentProvider.sendAsync&&(i.web3.currentProvider.send=i.web3.currentProvider.sendAsync,delete i.web3.currentProvider.sendAsync),!i.web3.currentProvider.on&&i.web3.currentProvider.connection&&"ipcProviderWrapper"===i.web3.currentProvider.connection.constructor.name&&(i.web3.currentProvider.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.connection.on("data",function(e){var r="";e=e.toString();try{r=JSON.parse(e)}catch(r){return t(new Error("Couldn't parse response data"+e))}r.id||-1===r.method.indexOf("_subscription")||t(null,r)});break;default:this.connection.on(e,t)}}),n=i.web3.currentProvider),t.exports=n},{}],343:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("./jsonrpc.js"),a=e("./batch.js"),s=e("./givenProvider.js"),u=function e(t){this.provider=null,this.providers=e.providers,this.setProvider(t),this.subscriptions={}};u.givenProvider=s,u.providers={WebsocketProvider:e("web3-providers-ws"),HttpProvider:e("web3-providers-http"),IpcProvider:e("web3-providers-ipc")},u.prototype.setProvider=function(e,t){var r=this;if(e&&"string"==typeof e&&this.providers)if(/^http(s)?:\/\//i.test(e))e=new this.providers.HttpProvider(e);else if(/^ws(s)?:\/\//i.test(e))e=new this.providers.WebsocketProvider(e);else if(e&&"object"==typeof t&&"function"==typeof t.connect)e=new this.providers.IpcProvider(e,t);else if(e)throw new Error("Can't autodetect provider for \""+e+'"');this.provider&&this.provider.connected&&this.clearSubscriptions(),this.provider=e||null,this.provider&&this.provider.on&&this.provider.on("data",function(e,t){(e=e||t).method&&r.subscriptions[e.params.subscription]&&r.subscriptions[e.params.subscription].callback&&r.subscriptions[e.params.subscription].callback(null,e.params.result)})},u.prototype.send=function(e,t){if(t=t||function(){},!this.provider)return t(i.InvalidProvider());var r=o.toPayload(e.method,e.params);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,n){return n&&n.id&&r.id!==n.id?t(new Error('Wrong response id "'+n.id+'" (expected: "'+r.id+'") in '+JSON.stringify(r))):e?t(e):n&&n.error?t(i.ErrorResponse(n)):o.isValidResponse(n)?void t(null,n.result):t(i.InvalidResponse(n))})},u.prototype.sendBatch=function(e,t){if(!this.provider)return t(i.InvalidProvider());var r=o.toBatchPayload(e);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,r){return e?t(e):n.isArray(r)?void t(null,r):t(i.InvalidResponse(r))})},u.prototype.addSubscription=function(e,t,r,n){if(!this.provider.on)throw new Error("The provider doesn't support subscriptions: "+this.provider.constructor.name);this.subscriptions[e]={callback:n,type:r,name:t}},u.prototype.removeSubscription=function(e,t){this.subscriptions[e]&&(this.send({method:this.subscriptions[e].type+"_unsubscribe",params:[e]},t),delete this.subscriptions[e])},u.prototype.clearSubscriptions=function(e){var t=this;Object.keys(this.subscriptions).forEach(function(r){e&&"syncing"===t.subscriptions[r].name||t.removeSubscription(r)}),this.provider.reset&&this.provider.reset()},t.exports={Manager:u,BatchManager:a}},{"./batch.js":341,"./givenProvider.js":342,"./jsonrpc.js":344,underscore:325,"web3-core-helpers":338,"web3-providers-http":398,"web3-providers-ipc":399,"web3-providers-ws":400}],344:[function(e,t,r){"use strict";var n={messageId:0,toPayload:function(e,t){if(!e)throw new Error('JSONRPC method should be specified for params: "'+JSON.stringify(t)+'"!');return n.messageId++,{jsonrpc:"2.0",id:n.messageId,method:e,params:t||[]}},isValidResponse:function(e){return Array.isArray(e)?e.every(t):t(e);function t(e){return!(!e||e.error||"2.0"!==e.jsonrpc||"number"!=typeof e.id&&"string"!=typeof e.id||void 0===e.result)}},toBatchPayload:function(e){return e.map(function(e){return n.toPayload(e.method,e.params)})}};t.exports=n},{}],345:[function(e,t,r){"use strict";var n=e("./subscription.js"),i=function(e){this.name=e.name,this.type=e.type,this.subscriptions=e.subscriptions||{},this.requestManager=null};i.prototype.setRequestManager=function(e){this.requestManager=e},i.prototype.attachToObject=function(e){var t=this.buildCall(),r=this.name.split(".");r.length>1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},i.prototype.buildCall=function(){var e=this;return function(){e.subscriptions[arguments[0]]||console.warn("Subscription "+JSON.stringify(arguments[0])+" doesn't exist. Subscribing anyway.");var t=new n({subscription:e.subscriptions[arguments[0]],requestManager:e.requestManager,type:e.type});return t.subscribe.apply(t,arguments)}},t.exports={subscriptions:i,subscription:n}},{"./subscription.js":346}],346:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("eventemitter3");function a(e){o.call(this),this.id=null,this.callback=n.identity,this.arguments=null,this._reconnectIntervalId=null,this.options={subscription:e.subscription,type:e.type,requestManager:e.requestManager}}a.prototype=Object.create(o.prototype),a.prototype.constructor=a,a.prototype._extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},a.prototype._validateArgs=function(e){var t=this.options.subscription;if(t||(t={}),t.params||(t.params=0),e.length!==t.params)throw i.InvalidNumberOfParams(e.length,t.params+1,e[0])},a.prototype._formatInput=function(e){var t=this.options.subscription;return t&&t.inputFormatter?t.inputFormatter.map(function(t,r){return t?t(e[r]):e[r]}):e},a.prototype._formatOutput=function(e){var t=this.options.subscription;return t&&t.outputFormatter&&e?t.outputFormatter(e):e},a.prototype._toPayload=function(e){var t=[];if(this.callback=this._extractCallback(e)||n.identity,this.subscriptionMethod||(this.subscriptionMethod=e.shift(),this.options.subscription.subscriptionName&&(this.subscriptionMethod=this.options.subscription.subscriptionName)),this.arguments||(this.arguments=this._formatInput(e),this._validateArgs(this.arguments),e=[]),t.push(this.subscriptionMethod),t=t.concat(this.arguments),e.length)throw new Error("Only a callback is allowed as parameter on an already instantiated subscription.");return{method:this.options.type+"_subscribe",params:t}},a.prototype.unsubscribe=function(e){this.options.requestManager.removeSubscription(this.id,e),this.id=null,this.removeAllListeners(),clearInterval(this._reconnectIntervalId)},a.prototype.subscribe=function(){var e=this,t=Array.prototype.slice.call(arguments),r=this._toPayload(t);if(!r)return this;if(!this.options.requestManager.provider){var i=new Error("No provider set.");return this.callback(i,null,this),this.emit("error",i),this}if(!this.options.requestManager.provider.on){var o=new Error("The current provider doesn't support subscriptions: "+this.options.requestManager.provider.constructor.name);return this.callback(o,null,this),this.emit("error",o),this}return this.id&&this.unsubscribe(),this.options.params=r.params[1],"logs"===r.params[0]&&n.isObject(r.params[1])&&r.params[1].hasOwnProperty("fromBlock")&&isFinite(r.params[1].fromBlock)&&this.options.requestManager.send({method:"eth_getLogs",params:[r.params[1]]},function(t,r){t?(e.callback(t,null,e),e.emit("error",t)):r.forEach(function(t){var r=e._formatOutput(t);e.callback(null,r,e),e.emit("data",r)})}),"object"==typeof r.params[1]&&delete r.params[1].fromBlock,this.options.requestManager.send(r,function(t,i){!t&&i?(e.id=i,e.options.requestManager.addSubscription(e.id,r.params[0],e.options.type,function(t,r){t?(e.options.requestManager.removeSubscription(e.id),e.options.requestManager.provider.once&&(e._reconnectIntervalId=setInterval(function(){e.options.requestManager.provider.reconnect&&e.options.requestManager.provider.reconnect()},500),e.options.requestManager.provider.once("connect",function(){clearInterval(e._reconnectIntervalId),e.subscribe(e.callback)})),e.emit("error",t),e.callback(t,null,e)):(n.isArray(r)||(r=[r]),r.forEach(function(t){var r=e._formatOutput(t);if(n.isFunction(e.options.subscription.subscriptionHandler))return e.options.subscription.subscriptionHandler.call(e,r);e.emit("data",r),e.callback(null,r,e)}))})):(e.callback(t,null,e),e.emit("error",t))}),this},t.exports=a},{eventemitter3:156,underscore:325,"web3-core-helpers":338}],347:[function(e,t,r){"use strict";var n=e("web3-core-helpers").formatters,i=e("web3-core-method"),o=e("web3-utils");t.exports=function(e){var t=function(t){var r;return t.property?(e[t.property]||(e[t.property]={}),r=e[t.property]):r=e,t.methods&&t.methods.forEach(function(t){t instanceof i||(t=new i(t)),t.attachToObject(r),t.setRequestManager(e._requestManager)}),e};return t.formatters=n,t.utils=o,t.Method=i,t}},{"web3-core-helpers":338,"web3-core-method":339,"web3-utils":403}],348:[function(e,t,r){"use strict";var n=e("web3-core-requestmanager"),i=e("./extend.js");t.exports={packageInit:function(e,t){if(t=Array.prototype.slice.call(t),!e)throw new Error('You need to instantiate using the "new" keyword.');Object.defineProperty(e,"currentProvider",{get:function(){return e._provider},set:function(t){return e.setProvider(t)},enumerable:!0,configurable:!0}),t[0]&&t[0]._requestManager?e._requestManager=new n.Manager(t[0].currentProvider):(e._requestManager=new n.Manager,e._requestManager.setProvider(t[0],t[1])),e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers,e._provider=e._requestManager.provider,e.setProvider||(e.setProvider=function(t,r){return e._requestManager.setProvider(t,r),e._provider=e._requestManager.provider,!0}),e.BatchRequest=n.BatchManager.bind(null,e._requestManager),e.extend=i(e)},addProviders:function(e){e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers}}},{"./extend.js":347,"web3-core-requestmanager":343}],349:[function(e,t,r){var n=e("underscore"),i=e("web3-utils"),o=new(0,e("ethers/utils/abi-coder").AbiCoder)(function(e,t){return!e.match(/^u?int/)||n.isArray(t)||n.isObject(t)&&"BN"===t.constructor.name?t:t.toString()});function a(){}var s=function(){};s.prototype.encodeFunctionSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e).slice(0,10)},s.prototype.encodeEventSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e)},s.prototype.encodeParameter=function(e,t){return this.encodeParameters([e],[t])},s.prototype.encodeParameters=function(e,t){return o.encode(this.mapTypes(e),t)},s.prototype.mapTypes=function(e){var t=this,r=[];return e.forEach(function(e){if(t.isSimplifiedStructFormat(e)){var n=Object.keys(e)[0];r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}else r.push(e)}),r},s.prototype.isSimplifiedStructFormat=function(e){return"object"==typeof e&&void 0===e.components&&void 0===e.name},s.prototype.mapStructNameAndType=function(e){var t="tuple";return e.indexOf("[]")>-1&&(t="tuple[]",e=e.slice(0,-2)),{type:t,name:e}},s.prototype.mapStructToCoderFormat=function(e){var t=this,r=[];return Object.keys(e).forEach(function(n){"object"!=typeof e[n]?r.push({name:n,type:e[n]}):r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}),r},s.prototype.encodeFunctionCall=function(e,t){return this.encodeFunctionSignature(e)+this.encodeParameters(e.inputs,t).replace("0x","")},s.prototype.decodeParameter=function(e,t){return this.decodeParameters([e],t)[0]},s.prototype.decodeParameters=function(e,t){if(!t||"0x"===t||"0X"===t)throw new Error("Returned values aren't valid, did it run Out of Gas?");var r=o.decode(this.mapTypes(e),"0x"+t.replace(/0x/i,"")),i=new a;return i.__length__=0,e.forEach(function(e,t){var o=r[i.__length__];o="0x"===o?null:o,i[t]=o,n.isObject(e)&&e.name&&(i[e.name]=o),i.__length__++}),i},s.prototype.decodeLog=function(e,t,r){var i=this;r=n.isArray(r)?r:[r],t=t||"";var o=[],s=[],u=0;e.forEach(function(e,t){e.indexed?(s[t]=["bool","int","uint","address","fixed","ufixed"].find(function(t){return-1!==e.type.indexOf(t)})?i.decodeParameter(e.type,r[u]):r[u],u++):o[t]=e});var c=t,f=c?this.decodeParameters(o,c):[],h=new a;return h.__length__=0,e.forEach(function(e,t){h[t]="string"===e.type?"":null,void 0!==f[t]&&(h[t]=f[t]),void 0!==s[t]&&(h[t]=s[t]),e.name&&(h[e.name]=h[t]),h.__length__++}),h};var u=new s;t.exports=u},{"ethers/utils/abi-coder":143,underscore:325,"web3-utils":403}],350:[function(e,t,r){(function(r){var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=e("./bytes"),o=e("./nat"),a=e("elliptic"),s=(e("./rlp"),new a.ec("secp256k1")),u=e("./hash"),c=u.keccak256,f=u.keccak256s,h=function(e){for(var t=f(e.slice(2)),r="0x",n=0;n<40;n++)r+=parseInt(t[n+2],16)>7?e[n+2].toUpperCase():e[n+2];return r},l=function(e){var t=new r(e.slice(2),"hex"),n="0x"+s.keyFromPrivate(t).getPublic(!1,"hex").slice(2),i=c(n);return{address:h("0x"+i.slice(-40)),privateKey:e}},d=function(e){var t=n(e,3),r=t[0],o=i.pad(32,t[1]),a=i.pad(32,t[2]);return i.flatten([o,a,r])},p=function(e){return[i.slice(64,i.length(e),e),i.slice(0,32,e),i.slice(32,64,e)]},b=function(e){return function(t,n){var a=s.keyFromPrivate(new r(n.slice(2),"hex")).sign(new r(t.slice(2),"hex"),{canonical:!0});return d([o.fromString(i.fromNumber(e+a.recoveryParam)),i.pad(32,i.fromNat("0x"+a.r.toString(16))),i.pad(32,i.fromNat("0x"+a.s.toString(16)))])}},y=b(27);t.exports={create:function(e){var t=c(i.concat(i.random(32),e||i.random(32))),r=i.concat(i.concat(i.random(32),t),i.random(32)),n=c(r);return l(n)},toChecksum:h,fromPrivate:l,sign:y,makeSigner:b,recover:function(e,t){var n=p(t),o={v:i.toNumber(n[0]),r:n[1].slice(2),s:n[2].slice(2)},a="0x"+s.recoverPubKey(new r(e.slice(2),"hex"),o,o.v<2?o.v:1-o.v%2).encode("hex",!1).slice(2),u=c(a);return h("0x"+u.slice(-40))},encodeSignature:d,decodeSignature:p}}).call(this,e("buffer").Buffer)},{"./bytes":352,"./hash":353,"./nat":354,"./rlp":355,buffer:84,elliptic:109}],351:[function(e,t,r){arguments[4][132][0].apply(r,arguments)},{dup:132}],352:[function(e,t,r){arguments[4][133][0].apply(r,arguments)},{"./array.js":351,dup:133}],353:[function(e,t,r){arguments[4][134][0].apply(r,arguments)},{dup:134}],354:[function(e,t,r){var n=e("bn.js"),i=e("./bytes"),o=function(e){return new n(e.slice(2),16)},a=function(e){var t="0x"+("0x"===e.slice(0,2)?new n(e.slice(2),16):new n(e,10)).toString("hex");return"0x0"===t?"0x":t},s=function(e){return"string"==typeof e?/^0x/.test(e)?e:"0x"+e:"0x"+new n(e).toString("hex")},u=function(e){return o(e).toNumber()},c=function(e){return function(t,r){return"0x"+o(t)[e](o(r)).toString("hex")}},f=c("add"),h=c("mul"),l=c("div"),d=c("sub");t.exports={toString:function(e){return o(e).toString(10)},fromString:a,toNumber:u,fromNumber:s,toEther:function(e){return u(l(e,a("10000000000")))/1e8},fromEther:function(e){return h(s(Math.floor(1e8*e)),a("10000000000"))},toUint256:function(e){return i.pad(32,e)},add:f,mul:h,div:l,sub:d}},{"./bytes":352,"bn.js":53}],355:[function(e,t,r){t.exports={encode:function(e){var t=function(e){return(t=e.toString(16)).length%2==0?t:"0"+t;var t},r=function(e,r){return e<56?t(r+e):t(r+t(e).length/2+55)+t(e)};return"0x"+function e(t){if("string"==typeof t){var n=t.slice(2);return(2!=n.length||n>="80"?r(n.length/2,128):"")+n}var i=t.map(e).join("");return r(i.length/2,192)+i}(e)},decode:function(e){var t=2,r=function(){if(t>=e.length)throw"";var r=e.slice(t,t+2);return r<"80"?(t+=2,"0x"+r):r<"c0"?i():o()},n=function(){var r=parseInt(e.slice(t,t+=2),16)%64;return r<56?r:parseInt(e.slice(t,t+=2*(r-55)),16)},i=function(){var r=n();return"0x"+e.slice(t,t+=2*r)},o=function(){for(var e=2*n()+t,i=[];t>>((3&t)<<3)&255;return i}}t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],357:[function(e,t,r){for(var n=e("./rng"),i=[],o={},a=0;a<256;a++)i[a]=(a+256).toString(16).substr(1),o[i[a]]=a;function s(e,t){var r=t||0,n=i;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var u=n(),c=[1|u[0],u[1],u[2],u[3],u[4],u[5]],f=16383&(u[6]<<8|u[7]),h=0,l=0;function d(e,t,r){var i=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||n)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var a=0;a<16;a++)t[i+a]=o[a];return t||s(o)}var p=d;p.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:f,a=void 0!==e.msecs?e.msecs:(new Date).getTime(),u=void 0!==e.nsecs?e.nsecs:l+1,d=a-h+(u-l)/1e4;if(d<0&&void 0===e.clockseq&&(o=o+1&16383),(d<0||a>h)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");h=a,l=u,f=o;var p=(1e4*(268435455&(a+=122192928e5))+u)%4294967296;i[n++]=p>>>24&255,i[n++]=p>>>16&255,i[n++]=p>>>8&255,i[n++]=255&p;var b=a/4294967296*1e4&268435455;i[n++]=b>>>8&255,i[n++]=255&b,i[n++]=b>>>24&15|16,i[n++]=b>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var y=e.node||c,m=0;m<6;m++)i[n+m]=y[m];return t||s(i)},p.v4=d,p.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=o[e])});i<16;)t[n+i++]=0;return t},p.unparse=s,t.exports=p},{"./rng":356}],358:[function(e,t,r){(function(r,n){"use strict";var i=e("underscore"),o=e("web3-core"),a=e("web3-core-method"),s=e("any-promise"),u=e("eth-lib/lib/account"),c=e("eth-lib/lib/hash"),f=e("eth-lib/lib/rlp"),h=e("eth-lib/lib/nat"),l=e("eth-lib/lib/bytes"),d=e(void 0===r?"crypto-browserify":"crypto"),p=e("scrypt.js"),b=e("uuid"),y=e("web3-utils"),m=e("web3-core-helpers"),v=function(e){return i.isUndefined(e)||i.isNull(e)},g=function(e){for(;e&&e.startsWith("0x0");)e="0x"+e.slice(3);return e},w=function(e){return e.length%2==1&&(e=e.replace("0x","0x0")),e},_=function(){var e=this;o.packageInit(this,arguments),delete this.BatchRequest,delete this.extend;var t=[new a({name:"getId",call:"net_version",params:0,outputFormatter:y.hexToNumber}),new a({name:"getGasPrice",call:"eth_gasPrice",params:0}),new a({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[function(e){if(y.isAddress(e))return e;throw new Error("Address "+e+' is not a valid address to get the "transactionCount".')},function(){return"latest"}]})];this._ethereumCall={},i.each(t,function(t){t.attachToObject(e._ethereumCall),t.setRequestManager(e._requestManager)}),this.wallet=new A(this)};function A(e){this._accounts=e,this.length=0,this.defaultKeyName="web3js_wallet"}_.prototype._addAccountFunctions=function(e){var t=this;return e.signTransaction=function(r,n){return t.signTransaction(r,e.privateKey,n)},e.sign=function(r){return t.sign(r,e.privateKey)},e.encrypt=function(r,n){return t.encrypt(e.privateKey,r,n)},e},_.prototype.create=function(e){return this._addAccountFunctions(u.create(e||y.randomHex(32)))},_.prototype.privateKeyToAccount=function(e){return this._addAccountFunctions(u.fromPrivate(e))},_.prototype.signTransaction=function(e,t,r){var n,o=!1;if(r=r||function(){},!e)return o=new Error("No transaction object given!"),r(o),s.reject(o);function a(e){if(e.gas||e.gasLimit||(o=new Error('"gas" is missing')),(e.nonce<0||e.gas<0||e.gasPrice<0||e.chainId<0)&&(o=new Error("Gas, gasPrice, nonce or chainId is lower than 0")),o)return r(o),s.reject(o);try{var i=e=m.formatters.inputCallFormatter(e);i.to=e.to||"0x",i.data=e.data||"0x",i.value=e.value||"0x",i.chainId=y.numberToHex(e.chainId);var a=f.encode([l.fromNat(i.nonce),l.fromNat(i.gasPrice),l.fromNat(i.gas),i.to.toLowerCase(),l.fromNat(i.value),i.data,l.fromNat(i.chainId||"0x1"),"0x","0x"]),d=c.keccak256(a),p=u.makeSigner(2*h.toNumber(i.chainId||"0x1")+35)(c.keccak256(a),t),b=f.decode(a).slice(0,6).concat(u.decodeSignature(p));b[6]=w(g(b[6])),b[7]=w(g(b[7])),b[8]=w(g(b[8]));var v=f.encode(b),_=f.decode(v);n={messageHash:d,v:g(_[6]),r:g(_[7]),s:g(_[8]),rawTransaction:v}}catch(e){return r(e),s.reject(e)}return r(null,n),n}return void 0!==e.nonce&&void 0!==e.chainId&&void 0!==e.gasPrice?s.resolve(a(e)):s.all([v(e.chainId)?this._ethereumCall.getId():e.chainId,v(e.gasPrice)?this._ethereumCall.getGasPrice():e.gasPrice,v(e.nonce)?this._ethereumCall.getTransactionCount(this.privateKeyToAccount(t).address):e.nonce]).then(function(t){if(v(t[0])||v(t[1])||v(t[2]))throw new Error('One of the values "chainId", "gasPrice", or "nonce" couldn\'t be fetched: '+JSON.stringify(t));return a(i.extend(e,{chainId:t[0],gasPrice:t[1],nonce:t[2]}))})},_.prototype.recoverTransaction=function(e){var t=f.decode(e),r=u.encodeSignature(t.slice(6,9)),n=l.toNumber(t[6]),i=n<35?[]:[l.fromNumber(n-35>>1),"0x","0x"],o=t.slice(0,6).concat(i),a=f.encode(o);return u.recover(c.keccak256(a),r)},_.prototype.hashMessage=function(e){var t=y.isHexStrict(e)?y.hexToBytes(e):e,r=n.from(t),i="Ethereum Signed Message:\n"+t.length,o=n.from(i),a=n.concat([o,r]);return c.keccak256s(a)},_.prototype.sign=function(e,t){var r=this.hashMessage(e),n=u.sign(r,t),i=u.decodeSignature(n);return{message:e,messageHash:r,v:i[0],r:i[1],s:i[2],signature:n}},_.prototype.recover=function(e,t,r){var n=[].slice.apply(arguments);return i.isObject(e)?this.recover(e.messageHash,u.encodeSignature([e.v,e.r,e.s]),!0):(r||(e=this.hashMessage(e)),n.length>=4?(r=n.slice(-1)[0],r=!!i.isBoolean(r)&&!!r,this.recover(e,u.encodeSignature(n.slice(1,4)),r)):u.recover(e,t))},_.prototype.decrypt=function(e,t,r){if(!i.isString(t))throw new Error("No password given.");var o,a,s=i.isObject(e)?e:JSON.parse(r?e.toLowerCase():e);if(3!==s.version)throw new Error("Not a valid V3 wallet");if("scrypt"===s.crypto.kdf)a=s.crypto.kdfparams,o=p(new n(t),new n(a.salt,"hex"),a.n,a.r,a.p,a.dklen);else{if("pbkdf2"!==s.crypto.kdf)throw new Error("Unsupported key derivation scheme");if("hmac-sha256"!==(a=s.crypto.kdfparams).prf)throw new Error("Unsupported parameters to PBKDF2");o=d.pbkdf2Sync(new n(t),new n(a.salt,"hex"),a.c,a.dklen,"sha256")}var u=new n(s.crypto.ciphertext,"hex");if(y.sha3(n.concat([o.slice(16,32),u])).replace("0x","")!==s.crypto.mac)throw new Error("Key derivation failed - possibly wrong password");var c=d.createDecipheriv(s.crypto.cipher,o.slice(0,16),new n(s.crypto.cipherparams.iv,"hex")),f="0x"+n.concat([c.update(u),c.final()]).toString("hex");return this.privateKeyToAccount(f)},_.prototype.encrypt=function(e,t,r){var i,o=this.privateKeyToAccount(e),a=(r=r||{}).salt||d.randomBytes(32),s=r.iv||d.randomBytes(16),u=r.kdf||"scrypt",c={dklen:r.dklen||32,salt:a.toString("hex")};if("pbkdf2"===u)c.c=r.c||262144,c.prf="hmac-sha256",i=d.pbkdf2Sync(new n(t),a,c.c,c.dklen,"sha256");else{if("scrypt"!==u)throw new Error("Unsupported kdf");c.n=r.n||8192,c.r=r.r||8,c.p=r.p||1,i=p(new n(t),a,c.n,c.r,c.p,c.dklen)}var f=d.createCipheriv(r.cipher||"aes-128-ctr",i.slice(0,16),s);if(!f)throw new Error("Unsupported cipher");var h=n.concat([f.update(new n(o.privateKey.replace("0x",""),"hex")),f.final()]),l=y.sha3(n.concat([i.slice(16,32),new n(h,"hex")])).replace("0x","");return{version:3,id:b.v4({random:r.uuid||d.randomBytes(16)}),address:o.address.toLowerCase().replace("0x",""),crypto:{ciphertext:h.toString("hex"),cipherparams:{iv:s.toString("hex")},cipher:r.cipher||"aes-128-ctr",kdf:u,kdfparams:c,mac:l.toString("hex")}}},A.prototype._findSafeIndex=function(e){return e=e||0,i.has(this,e)?this._findSafeIndex(e+1):e},A.prototype._currentIndexes=function(){return Object.keys(this).map(function(e){return parseInt(e)}).filter(function(e){return e<9e20})},A.prototype.create=function(e,t){for(var r=0;r=2?t.slice(2):t;var r=h.decodeParameters(e,t);return 1===r.__length__?r[0]:(delete r.__length__,r)},l.prototype.deploy=function(e,t){if((e=e||{}).arguments=e.arguments||[],!(e=this._getOrSetDefaultOptions(e)).data)return a._fireError(new Error('No "data" specified in neither the given options, nor the default options.'),null,null,t);var r=n.find(this.options.jsonInterface,function(e){return"constructor"===e.type})||{};return r.signature="constructor",this._createTxObject.apply({method:r,parent:this,deployData:e.data,_ethAccounts:this.constructor._ethAccounts},e.arguments)},l.prototype._generateEventOptions=function(){var e=Array.prototype.slice.call(arguments),t=this._getCallback(e),r=n.isObject(e[e.length-1])?e.pop():{},i=n.isString(e[0])?e[0]:"allevents";if(!(i="allevents"===i.toLowerCase()?{name:"ALLEVENTS",jsonInterface:this.options.jsonInterface}:this.options.jsonInterface.find(function(e){return"event"===e.type&&(e.name===i||e.signature==="0x"+i.replace("0x",""))})))throw new Error('Event "'+i.name+"\" doesn't exist in this contract.");if(!a.isAddress(this.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return{params:this._encodeEventABI(i,r),event:i,callback:t}},l.prototype.clone=function(){return new this.constructor(this.options.jsonInterface,this.options.address,this.options)},l.prototype.once=function(e,t,r){var i=Array.prototype.slice.call(arguments);if(!(r=this._getCallback(i)))throw new Error("Once requires a callback as the second parameter.");t&&delete t.fromBlock,this._on(e,t,function(e,t,i){i.unsubscribe(),n.isFunction(r)&&r(e,t,i)})},l.prototype._on=function(){var e=this._generateEventOptions.apply(this,arguments);this._checkListener("newListener",e.event.name,e.callback),this._checkListener("removeListener",e.event.name,e.callback);var t=new s({subscription:{params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event),subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},type:"eth",requestManager:this._requestManager});return t.subscribe("logs",e.params,e.callback||function(){}),t},l.prototype.getPastEvents=function(){var e=this._generateEventOptions.apply(this,arguments),t=new o({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event)});t.setRequestManager(this._requestManager);var r=t.buildCall();return t=null,r(e.params,e.callback)},l.prototype._createTxObject=function(){var e=Array.prototype.slice.call(arguments),t={};if("function"===this.method.type&&(t.call=this.parent._executeMethod.bind(t,"call"),t.call.request=this.parent._executeMethod.bind(t,"call",!0)),t.send=this.parent._executeMethod.bind(t,"send"),t.send.request=this.parent._executeMethod.bind(t,"send",!0),t.encodeABI=this.parent._encodeMethodABI.bind(t),t.estimateGas=this.parent._executeMethod.bind(t,"estimate"),e&&this.method.inputs&&e.length!==this.method.inputs.length){if(this.nextMethod)return this.nextMethod.apply(null,e);throw c.InvalidNumberOfParams(e.length,this.method.inputs.length,this.method.name)}return t.arguments=e||[],t._method=this.method,t._parent=this.parent,t._ethAccounts=this.parent.constructor._ethAccounts||this._ethAccounts,this.deployData&&(t._deployData=this.deployData),t},l.prototype._processExecuteArguments=function(e,t){var r={};if(r.type=e.shift(),r.callback=this._parent._getCallback(e),"call"===r.type&&!0!==e[e.length-1]&&(n.isString(e[e.length-1])||isFinite(e[e.length-1]))&&(r.defaultBlock=e.pop()),r.options=n.isObject(e[e.length-1])?e.pop():{},r.generateRequest=!0===e[e.length-1]&&e.pop(),r.options=this._parent._getOrSetDefaultOptions(r.options),r.options.data=this.encodeABI(),!this._deployData&&!a.isAddress(this._parent.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return this._deployData||(r.options.to=this._parent.options.address),r.options.data?r:a._fireError(new Error("Couldn't find a matching contract method, or the number of parameters is wrong."),t.eventEmitter,t.reject,r.callback)},l.prototype._executeMethod=function(){var e=this,t=this._parent._processExecuteArguments.call(this,Array.prototype.slice.call(arguments),r),r=f("send"!==t.type),i=e.constructor._ethAccounts||e._ethAccounts;if(t.generateRequest){var s={params:[u.inputCallFormatter.call(this._parent,t.options)],callback:t.callback};return"call"===t.type?(s.params.push(u.inputDefaultBlockNumberFormatter.call(this._parent,t.defaultBlock)),s.method="eth_call",s.format=this._parent._decodeMethodReturn.bind(null,this._method.outputs)):s.method="eth_sendTransaction",s}switch(t.type){case"estimate":return new o({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[u.inputCallFormatter],outputFormatter:a.hexToNumber,requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.callback);case"call":return new o({name:"call",call:"eth_call",params:2,inputFormatter:[u.inputCallFormatter,u.inputDefaultBlockNumberFormatter],outputFormatter:function(t){return e._parent._decodeMethodReturn(e._method.outputs,t)},requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.defaultBlock,t.callback);case"send":if(!a.isAddress(t.options.from))return a._fireError(new Error('No "from" address specified in neither the given options, nor the default options.'),r.eventEmitter,r.reject,t.callback);if(n.isBoolean(this._method.payable)&&!this._method.payable&&t.options.value&&t.options.value>0)return a._fireError(new Error("Can not send value to non-payable contract method or constructor"),r.eventEmitter,r.reject,t.callback);var c={receiptFormatter:function(t){if(n.isArray(t.logs)){var r=n.map(t.logs,function(t){return e._parent._decodeEventABI.call({name:"ALLEVENTS",jsonInterface:e._parent.options.jsonInterface},t)});t.events={};var i=0;r.forEach(function(e){e.event?t.events[e.event]?Array.isArray(t.events[e.event])?t.events[e.event].push(e):t.events[e.event]=[t.events[e.event],e]:t.events[e.event]=e:(t.events[i]=e,i++)}),delete t.logs}return t},contractDeployFormatter:function(t){var r=e._parent.clone();return r.options.address=t.contractAddress,r}};return new o({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[u.inputTransactionFormatter],requestManager:e._parent._requestManager,accounts:e.constructor._ethAccounts||e._ethAccounts,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock,extraFormatters:c}).createFunction()(t.options,t.callback)}},t.exports=l},{underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-utils":403}],360:[function(e,t,r){"use strict";var n=e("./config"),i=e("./contracts/Registry"),o=e("./lib/ResolverMethodHandler");function a(e){this.eth=e}Object.defineProperty(a.prototype,"registry",{get:function(){return new i(this)},enumerable:!0}),Object.defineProperty(a.prototype,"resolverMethodHandler",{get:function(){return new o(this.registry)},enumerable:!0}),a.prototype.resolver=function(e){return this.registry.resolver(e)},a.prototype.getAddress=function(e,t){return this.resolverMethodHandler.method(e,"addr",[]).call(t)},a.prototype.setAddress=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setAddr",[t]).send(r,n)},a.prototype.getPubkey=function(e,t){return this.resolverMethodHandler.method(e,"pubkey",[],t).call(t)},a.prototype.setPubkey=function(e,t,r,n,i){return this.resolverMethodHandler.method(e,"setPubkey",[t,r]).send(n,i)},a.prototype.getContent=function(e,t){return this.resolverMethodHandler.method(e,"content",[]).call(t)},a.prototype.setContent=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setContent",[t]).send(r,n)},a.prototype.getMultihash=function(e,t){return this.resolverMethodHandler.method(e,"multihash",[]).call(t)},a.prototype.setMultihash=function(e,t,r,n){return this.resolverMethodHandler.method(e,"multihash",[t]).send(r,n)},a.prototype.checkNetwork=function(){var e=this;return e.eth.getBlock("latest").then(function(t){var r=new Date/1e3-t.timestamp;if(r>3600)throw new Error("Network not synced; last block was "+r+" seconds ago");return e.eth.net.getNetworkType()}).then(function(e){var t=n.addresses[e];if(void 0===t)throw new Error("ENS is not supported on network "+e);return t})},t.exports=a},{"./config":361,"./contracts/Registry":362,"./lib/ResolverMethodHandler":364}],361:[function(e,t,r){"use strict";t.exports={addresses:{main:"0x314159265dD8dbb310642f98f50C066173C1259b",ropsten:"0x112234455c3a32fd11230c42e7bccd4a84e02010",rinkeby:"0xe7410170f87102df0055eb195163a03b7f2bff4a"}}},{}],362:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-eth-contract"),o=e("eth-ens-namehash"),a=e("web3-core-promievent"),s=e("../ressources/ABI/Registry"),u=e("../ressources/ABI/Resolver");function c(e){var t=this;this.ens=e,this.contract=e.checkNetwork().then(function(e){var r=new i(s,e);return r.setProvider(t.ens.eth.currentProvider),r})}c.prototype.owner=function(e,t){var r=new a(!0);return this.contract.then(function(i){i.methods.owner(o.hash(e)).call().then(function(e){r.resolve(e),n.isFunction(t)&&t(e)}).catch(function(e){r.reject(e),n.isFunction(t)&&t(e)})}),r.eventEmitter},c.prototype.resolver=function(e){var t=this;return this.contract.then(function(t){return t.methods.resolver(o.hash(e)).call()}).then(function(e){var r=new i(u,e);return r.setProvider(t.ens.eth.currentProvider),r})},t.exports=c},{"../ressources/ABI/Registry":365,"../ressources/ABI/Resolver":366,"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340,"web3-eth-contract":359}],363:[function(e,t,r){"use strict";var n=e("./ENS");t.exports=n},{"./ENS":360}],364:[function(e,t,r){"use strict";var n=e("web3-core-promievent"),i=e("eth-ens-namehash"),o=e("underscore");function a(e){this.registry=e}a.prototype.method=function(e,t,r,n){return{call:this.call.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this}),send:this.send.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this})}},a.prototype.call=function(e){var t=this,r=new n,i=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){t.parent.handleCall(r,n.methods[t.methodName],i,e)}).catch(function(e){r.reject(e)}),r.eventEmitter},a.prototype.send=function(e,t){var r=this,i=new n,o=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){r.parent.handleSend(i,n.methods[r.methodName],o,e,t)}).catch(function(e){i.reject(e)}),i.eventEmitter},a.prototype.handleCall=function(e,t,r,n){return t.apply(this,r).call().then(function(t){e.resolve(t),o.isFunction(n)&&n(t)}).catch(function(t){e.reject(t),o.isFunction(n)&&n(t)}),e},a.prototype.handleSend=function(e,t,r,n,i){return t.apply(this,r).send(n).on("transactionHash",function(t){e.eventEmitter.emit("transactionHash",t)}).on("confirmation",function(t,r){e.eventEmitter.emit("confirmation",t,r)}).on("receipt",function(t){e.eventEmitter.emit("receipt",t),e.resolve(t),o.isFunction(i)&&i(t)}).on("error",function(t){e.eventEmitter.emit("error",t),e.reject(t),o.isFunction(i)&&i(t)}),e},a.prototype.prepareArguments=function(e,t){var r=i.hash(e);return t.length>0?(t.unshift(r),t):[r]},t.exports=a},{"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340}],365:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"resolver",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"owner",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"label",type:"bytes32"},{name:"owner",type:"address"}],name:"setSubnodeOwner",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"ttl",type:"uint64"}],name:"setTTL",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"ttl",outputs:[{name:"",type:"uint64"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"resolver",type:"address"}],name:"setResolver",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"owner",type:"address"}],name:"setOwner",outputs:[],payable:!1,type:"function"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"label",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"NewOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"resolver",type:"address"}],name:"NewResolver",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"ttl",type:"uint64"}],name:"NewTTL",type:"event"}]},{}],366:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"interfaceID",type:"bytes4"}],name:"supportsInterface",outputs:[{name:"",type:"bool"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"},{name:"contentTypes",type:"uint256"}],name:"ABI",outputs:[{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes"}],name:"setMultihash",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"multihash",outputs:[{name:"",type:"bytes"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"setPubkey",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"content",outputs:[{name:"ret",type:"bytes32"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"addr",outputs:[{name:"ret",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],name:"setABI",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"name",outputs:[{name:"ret",type:"string"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"name",type:"string"}],name:"setName",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes32"}],name:"setContent",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"pubkey",outputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"addr",type:"address"}],name:"setAddr",outputs:[],payable:!1,type:"function"},{inputs:[{name:"ensAddr",type:"address"}],payable:!1,type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"a",type:"address"}],name:"AddrChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"hash",type:"bytes32"}],name:"ContentChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"name",type:"string"}],name:"NameChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"contentType",type:"uint256"}],name:"ABIChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"x",type:"bytes32"},{indexed:!1,name:"y",type:"bytes32"}],name:"PubkeyChanged",type:"event"}]},{}],367:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],368:[function(e,t,r){"use strict";var n=e("web3-utils"),i=e("bn.js"),o=function(e){var t="A".charCodeAt(0),r="Z".charCodeAt(0);return(e=(e=e.toUpperCase()).substr(4)+e.substr(0,4)).split("").map(function(e){var n=e.charCodeAt(0);return n>=t&&n<=r?n-t+10:e}).join("")},a=function(e){for(var t,r=e;r.length>2;)t=r.slice(0,9),r=parseInt(t,10)%97+r.slice(t.length);return parseInt(r,10)%97},s=function(e){this._iban=e};s.toAddress=function(e){if(!(e=new s(e)).isDirect())throw new Error("IBAN is indirect and can't be converted");return e.toAddress()},s.toIban=function(e){return s.fromAddress(e).toString()},s.fromAddress=function(e){if(!n.isAddress(e))throw new Error("Provided address is not a valid address: "+e);e=e.replace("0x","").replace("0X","");var t=function(e,t){for(var r=e;r.length<2*t;)r="0"+r;return r}(new i(e,16).toString(36),15);return s.fromBban(t.toUpperCase())},s.fromBban=function(e){var t=("0"+(98-a(o("XE00"+e)))).slice(-2);return new s("XE"+t+e)},s.createIndirect=function(e){return s.fromBban("ETH"+e.institution+e.identifier)},s.isValid=function(e){return new s(e).isValid()},s.prototype.isValid=function(){return/^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban)&&1===a(o(this._iban))},s.prototype.isDirect=function(){return 34===this._iban.length||35===this._iban.length},s.prototype.isIndirect=function(){return 20===this._iban.length},s.prototype.checksum=function(){return this._iban.substr(2,2)},s.prototype.institution=function(){return this.isIndirect()?this._iban.substr(7,4):""},s.prototype.client=function(){return this.isIndirect()?this._iban.substr(11):""},s.prototype.toAddress=function(){if(this.isDirect()){var e=this._iban.substr(4),t=new i(e,36);return n.toChecksumAddress(t.toString(16,20))}return""},s.prototype.toString=function(){return this._iban},t.exports=s},{"bn.js":367,"web3-utils":403}],369:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=e("web3-net"),s=e("web3-core-helpers").formatters,u=function(){var e=this;n.packageInit(this,arguments),this.net=new a(this.currentProvider);var t=null,r="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return t},set:function(e){return e&&(t=o.toChecksumAddress(s.inputAddressFormatter(e))),u.forEach(function(e){e.defaultAccount=t}),e},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return r},set:function(e){return r=e,u.forEach(function(e){e.defaultBlock=r}),e},enumerable:!0});var u=[new i({name:"getAccounts",call:"personal_listAccounts",params:0,outputFormatter:o.toChecksumAddress}),new i({name:"newAccount",call:"personal_newAccount",params:1,inputFormatter:[null],outputFormatter:o.toChecksumAddress}),new i({name:"unlockAccount",call:"personal_unlockAccount",params:3,inputFormatter:[s.inputAddressFormatter,null,null]}),new i({name:"lockAccount",call:"personal_lockAccount",params:1,inputFormatter:[s.inputAddressFormatter]}),new i({name:"importRawKey",call:"personal_importRawKey",params:2}),new i({name:"sendTransaction",call:"personal_sendTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"signTransaction",call:"personal_signTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"sign",call:"personal_sign",params:3,inputFormatter:[s.inputSignFormatter,s.inputAddressFormatter,null]}),new i({name:"ecRecover",call:"personal_ecRecover",params:2,inputFormatter:[s.inputSignFormatter,null]})];u.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};n.addProviders(u),t.exports=u},{"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-net":372,"web3-utils":403}],370:[function(e,t,r){"use strict";var n=e("underscore");t.exports=function(e){var t,r=this;return this.net.getId().then(function(e){return t=e,r.getBlock(0)}).then(function(r){var i="private";return"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"===r.hash&&1===t&&(i="main"),"0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303"===r.hash&&2===t&&(i="morden"),"0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"===r.hash&&3===t&&(i="ropsten"),"0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177"===r.hash&&4===t&&(i="rinkeby"),"0xa3c565fc15c7478862d50ccd6561e3c06b24cc509bf388941c25ea985ce32cb9"===r.hash&&42===t&&(i="kovan"),n.isFunction(e)&&e(null,i),i}).catch(function(t){if(!n.isFunction(e))throw t;e(t)})}},{underscore:325}],371:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core"),o=e("web3-core-helpers"),a=e("web3-core-subscriptions").subscriptions,s=e("web3-core-method"),u=e("web3-utils"),c=e("web3-net"),f=e("web3-eth-ens"),h=e("web3-eth-personal"),l=e("web3-eth-contract"),d=e("web3-eth-iban"),p=e("web3-eth-accounts"),b=e("web3-eth-abi"),y=e("./getNetworkType.js"),m=o.formatters,v=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},g=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},w=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},_=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},A=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"},E=function(){var e=this;i.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments),e.personal.setProvider.apply(e,arguments),e.accounts.setProvider.apply(e,arguments),e.Contract.setProvider(e.currentProvider,e.accounts)};var r=null,o="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return r},set:function(t){return t&&(r=u.toChecksumAddress(m.inputAddressFormatter(t))),e.Contract.defaultAccount=r,e.personal.defaultAccount=r,k.forEach(function(e){e.defaultAccount=r}),t},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return o},set:function(t){return o=t,e.Contract.defaultBlock=o,e.personal.defaultBlock=o,k.forEach(function(e){e.defaultBlock=o}),t},enumerable:!0}),this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new c(this.currentProvider),this.net.getNetworkType=y.bind(this),this.accounts=new p(this.currentProvider),this.personal=new h(this.currentProvider),this.personal.defaultAccount=this.defaultAccount;var E=this,x=function(){l.apply(this,arguments);var e=this,t=E.setProvider;E.setProvider=function(){t.apply(E,arguments),i.packageInit(e,[E.currentProvider])}};x.setProvider=function(){l.setProvider.apply(this,arguments)},(x.prototype=Object.create(l.prototype)).constructor=x,this.Contract=x,this.Contract.defaultAccount=this.defaultAccount,this.Contract.defaultBlock=this.defaultBlock,this.Contract.setProvider(this.currentProvider,this.accounts),this.Iban=d,this.abi=b,this.ens=new f(this);var k=[new s({name:"getNodeInfo",call:"web3_clientVersion"}),new s({name:"getProtocolVersion",call:"eth_protocolVersion",params:0}),new s({name:"getCoinbase",call:"eth_coinbase",params:0}),new s({name:"isMining",call:"eth_mining",params:0}),new s({name:"getHashrate",call:"eth_hashrate",params:0,outputFormatter:u.hexToNumber}),new s({name:"isSyncing",call:"eth_syncing",params:0,outputFormatter:m.outputSyncingFormatter}),new s({name:"getGasPrice",call:"eth_gasPrice",params:0,outputFormatter:m.outputBigNumberFormatter}),new s({name:"getAccounts",call:"eth_accounts",params:0,outputFormatter:u.toChecksumAddress}),new s({name:"getBlockNumber",call:"eth_blockNumber",params:0,outputFormatter:u.hexToNumber}),new s({name:"getBalance",call:"eth_getBalance",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:m.outputBigNumberFormatter}),new s({name:"getStorageAt",call:"eth_getStorageAt",params:3,inputFormatter:[m.inputAddressFormatter,u.numberToHex,m.inputDefaultBlockNumberFormatter]}),new s({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"getBlock",call:v,params:2,inputFormatter:[m.inputBlockNumberFormatter,function(e){return!!e}],outputFormatter:m.outputBlockFormatter}),new s({name:"getUncle",call:w,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputBlockFormatter}),new s({name:"getBlockTransactionCount",call:_,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getBlockUncleCount",call:A,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getTransaction",call:"eth_getTransactionByHash",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionFromBlock",call:g,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionReceiptFormatter}),new s({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"sendSignedTransaction",call:"eth_sendRawTransaction",params:1,inputFormatter:[null]}),new s({name:"signTransaction",call:"eth_signTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sign",call:"eth_sign",params:2,inputFormatter:[m.inputSignFormatter,m.inputAddressFormatter],transformPayload:function(e){return e.params.reverse(),e}}),new s({name:"call",call:"eth_call",params:2,inputFormatter:[m.inputCallFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[m.inputCallFormatter],outputFormatter:u.hexToNumber}),new s({name:"submitWork",call:"eth_submitWork",params:3}),new s({name:"getWork",call:"eth_getWork",params:0}),new s({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter}),new a({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:m.outputBlockFormatter},pendingTransactions:{subscriptionName:"newPendingTransactions",params:0},logs:{params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter,subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},syncing:{params:0,outputFormatter:m.outputSyncingFormatter,subscriptionHandler:function(e){var t=this;!0!==this._isSyncing?(this._isSyncing=!0,this.emit("changed",t._isSyncing),n.isFunction(this.callback)&&this.callback(null,t._isSyncing,this),setTimeout(function(){t.emit("data",e),n.isFunction(t.callback)&&t.callback(null,e,t)},0)):(this.emit("data",e),n.isFunction(t.callback)&&this.callback(null,e,this),clearTimeout(this._isSyncingTimeout),this._isSyncingTimeout=setTimeout(function(){e.currentBlock>e.highestBlock-200&&(t._isSyncing=!1,t.emit("changed",t._isSyncing),n.isFunction(t.callback)&&t.callback(null,t._isSyncing,t))},500))}}}})];k.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager,e.accounts),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};i.addProviders(E),t.exports=E},{"./getNetworkType.js":370,underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-eth-accounts":358,"web3-eth-contract":359,"web3-eth-ens":363,"web3-eth-iban":368,"web3-eth-personal":369,"web3-net":372,"web3-utils":403}],372:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=function(){var e=this;n.packageInit(this,arguments),[new i({name:"getId",call:"net_version",params:0,outputFormatter:o.hexToNumber}),new i({name:"isListening",call:"net_listening",params:0}),new i({name:"getPeerCount",call:"net_peerCount",params:0,outputFormatter:o.hexToNumber})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(a),t.exports=a},{"web3-core":348,"web3-core-method":339,"web3-utils":403}],373:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits,o=e("ethereumjs-util"),a=e("eth-block-tracker"),s=e("async/map"),u=e("async/eachSeries"),c=e("./util/stoplight.js");e("./util/rpc-cache-utils.js"),e("./util/create-payload.js");function f(e){const t=this;n.call(t),t.setMaxListeners(30),e=e||{};const r={sendAsync:t._handleAsync.bind(t)},i=e.blockTrackerProvider||r;t._blockTracker=e.blockTracker||new a({provider:i,pollingInterval:e.pollingInterval||4e3}),t._blockTracker.on("block",e=>{const r=function(e){return{number:o.toBuffer(e.number),hash:o.toBuffer(e.hash),parentHash:o.toBuffer(e.parentHash),nonce:o.toBuffer(e.nonce),mixHash:o.toBuffer(e.mixHash),sha3Uncles:o.toBuffer(e.sha3Uncles),logsBloom:o.toBuffer(e.logsBloom),transactionsRoot:o.toBuffer(e.transactionsRoot),stateRoot:o.toBuffer(e.stateRoot),receiptsRoot:o.toBuffer(e.receiptRoot||e.receiptsRoot),miner:o.toBuffer(e.miner),difficulty:o.toBuffer(e.difficulty),totalDifficulty:o.toBuffer(e.totalDifficulty),size:o.toBuffer(e.size),extraData:o.toBuffer(e.extraData),gasLimit:o.toBuffer(e.gasLimit),gasUsed:o.toBuffer(e.gasUsed),timestamp:o.toBuffer(e.timestamp),transactions:e.transactions}}(e);t._setCurrentBlock(r)}),t._blockTracker.on("block",t.emit.bind(t,"rawBlock")),t._blockTracker.on("sync",t.emit.bind(t,"sync")),t._blockTracker.on("latest",t.emit.bind(t,"latest")),t._ready=new c,t._blockTracker.once("block",()=>{t._ready.go()}),t.currentBlock=null,t._providers=[]}t.exports=f,i(f,n),f.prototype.start=function(e=function(){}){this._blockTracker.start().then(e).catch(e)},f.prototype.stop=function(){this._blockTracker.stop()},f.prototype.addProvider=function(e){this._providers.push(e),e.setEngine(this)},f.prototype.send=function(e){throw new Error("Web3ProviderEngine does not support synchronous requests.")},f.prototype.sendAsync=function(e,t){const r=this;r._ready.await(function(){Array.isArray(e)?s(e,r._handleAsync.bind(r),t):r._handleAsync(e,t)})},f.prototype._handleAsync=function(e,t){var r=this,n=-1,i=null,o=null,a=[];function s(r,n){o=r,i=n,u(a,function(e,t){e?e(o,i,t):t()},function(){var r={id:e.id,jsonrpc:e.jsonrpc,result:i};null!=o?(r.error={message:o.stack||o.message||o,code:-32e3},t(o,r)):t(null,r)})}!function t(i){n+=1;a.unshift(i);if(n>=r._providers.length)s(new Error('Request for method "'+e.method+'" not handled by any subprovider. Please check your subprovider configuration to ensure this method is handled.'));else try{var o=r._providers[n];o.handleRequest(e,t,s)}catch(e){s(e)}}()},f.prototype._setCurrentBlock=function(e){this.currentBlock=e,this.emit("block",e)}},{"./util/create-payload.js":391,"./util/rpc-cache-utils.js":394,"./util/stoplight.js":396,"async/eachSeries":25,"async/map":41,"eth-block-tracker":126,"ethereumjs-util":141,events:157,util:333}],374:[function(e,t,r){var n="undefined"!=typeof JSON?JSON:e("jsonify");t.exports=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var r=t.space||"";"number"==typeof r&&(r=Array(r+1).join(" "));var a,s="boolean"==typeof t.cycles&&t.cycles,u=t.replacer||function(e,t){return t},c=t.cmp&&(a=t.cmp,function(e){return function(t,r){var n={key:t,value:e[t]},i={key:r,value:e[r]};return a(n,i)}}),f=[];return function e(t,a,h,l){var d=r?"\n"+new Array(l+1).join(r):"",p=r?": ":":";if(h&&h.toJSON&&"function"==typeof h.toJSON&&(h=h.toJSON()),void 0!==(h=u.call(t,a,h))){if("object"!=typeof h||null===h)return n.stringify(h);if(i(h)){for(var b=[],y=0;y dist/ProviderEngine.js","bundle-zero":"browserify -s ZeroClientProvider -e zero.js -t [ babelify --presets [ es2015 ] ] > dist/ZeroClientProvider.js",prepublish:"npm run build && npm run bundle",test:"node test/index.js"},version:"14.1.0"}},{}],376:[function(e,t,r){const n=e("util").inherits,i=e("ethereumjs-util"),o=i.BN,a=e("clone"),s=e("../util/rpc-cache-utils.js"),u=e("../util/stoplight.js"),c=e("./subprovider.js");function f(e){e=e||{},this._ready=new u,this.strategies={perma:new l({eth_getTransactionByHash:p,eth_getTransactionReceipt:p}),block:new d(this),fork:new d(this)}}function h(){var e=this;e.cache={};var t=setInterval(function(){e.cache={}},6e5);t.unref&&t.unref()}function l(e){this.strategy=new h,this.conditionals=e}function d(){this.cache={}}function p(e){if(!e)return!1;if(!e.blockHash)return!1;var t;return(t=e.blockHash,new o(i.toBuffer(t))).gt(new o(0))}t.exports=f,n(f,c),f.prototype.setEngine=function(e){const t=this;function r(e){var r=t.currentBlock;t.currentBlock=e,r&&(t.strategies.block.cacheRollOff(r),t.strategies.fork.cacheRollOff(r))}t.engine=e,e.once("block",function(n){t.currentBlock=n,t._ready.go(),e.on("block",r)})},f.prototype.handleRequest=function(e,t,r){const n=this;return e.skipCache?t():"eth_getBlockByNumber"===e.method&&"latest"===e.params[0]?t():void n._ready.await(function(){n._handleRequest(e,t,r)})},f.prototype._handleRequest=function(e,t,r){const n=this;var o=s.cacheTypeForPayload(e),a=this.strategies[o];if(!a)return t();if(!a.canCache(e))return t();var u,c=s.blockTagForPayload(e);c||(c="latest"),u="earliest"===c?"0x00":"latest"===c?i.bufferToHex(n.currentBlock.number):c,a.hitCheck(e,u,r,function(){t(function(t,r,n){if(t)return n();a.cacheResult(e,r,u,n)})})},h.prototype.hitCheck=function(e,t,r,n){var i,o,u,c,f=s.cacheIdentifierForPayload(e),h=this.cache[f];return h&&(i=t,o=h.blockNumber,u=parseInt(i,16),c=parseInt(o,16),(u===c?0:u>c?1:-1)>=0)?r(null,a(h.result)):n()},h.prototype.cacheResult=function(e,t,r,n){var i=s.cacheIdentifierForPayload(e);if(t){var o=a(t);this.cache[i]={blockNumber:r,result:o}}n()},h.prototype.canCache=function(e){return s.canCache(e)},l.prototype.hitCheck=function(e,t,r,n){return this.strategy.hitCheck(e,t,r,n)},l.prototype.cacheResult=function(e,t,r,n){var i=this.conditionals[e.method];i?i(t)?this.strategy.cacheResult(e,t,r,n):n():this.strategy.cacheResult(e,t,r,n)},l.prototype.canCache=function(e){return this.strategy.canCache(e)},d.prototype.getBlockCacheForPayload=function(e,t){const r=Number.parseInt(t,16);let n=this.cache[r];if(!n){const e={};this.cache[r]=e,n=e}return n},d.prototype.hitCheck=function(e,t,r,n){var i=this.getBlockCacheForPayload(e,t);if(!i)return n();var o=i[s.cacheIdentifierForPayload(e)];return o?r(null,o):n()},d.prototype.cacheResult=function(e,t,r,n){t&&(this.getBlockCacheForPayload(e,r)[s.cacheIdentifierForPayload(e)]=t);n()},d.prototype.canCache=function(e){return!!s.canCache(e)&&"pending"!==s.blockTagForPayload(e)},d.prototype.cacheRollOff=function(e){const t=this,r=i.bufferToHex(e.number),n=Number.parseInt(r,16);Object.keys(t.cache).map(Number).filter(e=>e<=n).forEach(e=>delete t.cache[e])}},{"../util/rpc-cache-utils.js":394,"../util/stoplight.js":396,"./subprovider.js":387,clone:87,"ethereumjs-util":141,util:333}],377:[function(e,t,r){const n=e("util").inherits,i=e("xtend"),o=e("./fixture.js"),a=e("../package.json").version;function s(e){var t=i({web3_clientVersion:"ProviderEngine/v"+a+"/javascript",net_listening:!0,eth_hashrate:"0x00",eth_mining:!1},e=e||{});o.call(this,t)}t.exports=s,n(s,o)},{"../package.json":375,"./fixture.js":380,util:333,xtend:423}],378:[function(e,t,r){const n=e("cross-fetch"),i=e("util").inherits,o=e("async/retry"),a=e("async/waterfall"),s=e("async/asyncify"),u=e("json-rpc-error"),c=e("promise-to-callback"),f=e("../util/create-payload.js"),h=e("./subprovider.js"),l=["Gateway timeout","ETIMEDOUT","SyntaxError"];function d(e){this.rpcUrl=e.rpcUrl,this.originHttpHeaderKey=e.originHttpHeaderKey}function p(e){const t=e.toString();return l.some(e=>t.includes(e))}t.exports=d,i(d,h),d.prototype.handleRequest=function(e,t,r){const n=this,i=e.origin,a=f(e);delete a.origin;const s={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(a)};n.originHttpHeaderKey&&i&&(s.headers[n.originHttpHeaderKey]=i),o({times:5,interval:1e3,errorFilter:p},e=>n._submitRequest(s,e),(e,t)=>{if(e&&p(e)){const t=`FetchSubprovider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,n=new Error(t);return r(n)}return r(e,t)})},d.prototype._submitRequest=function(e,t){const r=this.rpcUrl;c(n(r,e))((e,r)=>{if(e)return t(e);a([function(e){switch(r.status){case 405:return e(new u.MethodNotFound);case 418:return e(function(){const e=new Error("Request is being rate limited.");return new u.InternalError(e)}());case 503:case 504:return e(function(){let e="Gateway timeout. The request took too long to process. ";const t=new Error(e+="This can happen when querying logs over too wide a block range.");return new u.InternalError(t)}());default:return e()}},e=>c(r.text())(e),s(e=>JSON.parse(e)),function(e,t){if(200!==r.status)return t(new u.InternalError(e));if(e.error)return t(new u.InternalError(e.error));t(null,e.result)}],t)})}},{"../util/create-payload.js":391,"./subprovider.js":387,"async/asyncify":20,"async/retry":43,"async/waterfall":44,"cross-fetch":96,"json-rpc-error":189,"promise-to-callback":258,util:333}],379:[function(e,t,r){const n=e("async"),i=e("util").inherits,o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/stoplight.js"),u=e("events").EventEmitter;function c(e){e=e||{};const t=this;t.filterIndex=0,t.filters={},t.filterDestroyHandlers={},t.asyncBlockHandlers={},t.asyncPendingBlockHandlers={},t._ready=new s,t._ready.setMaxListeners(e.maxFilters||25),t._ready.go(),t.pendingBlockTimeout=e.pendingBlockTimeout||4e3,t.checkForPendingBlocksActive=!1,setTimeout(function(){t.engine.on("block",function(e){t._ready.stop();var r=v(t.asyncBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,function(e){e&&console.error(e),t._ready.go()})})})}function f(e){u.apply(this),this.type="block",this.engine=e.engine,this.blockNumber=e.blockNumber,this.updates=[]}function h(e){u.apply(this),this.type="log",this.fromBlock=void 0!==e.fromBlock?e.fromBlock:"latest",this.toBlock=void 0!==e.toBlock?e.toBlock:"latest";var t=e.address&&(Array.isArray(e.address)?e.address:[e.address]);this.address=t&&t.map(d),this.topics=e.topics||[],this.updates=[],this.allResults=[]}function l(){u.apply(this),this.type="pendingTx",this.updates=[],this.allResults=[]}function d(e){return"0x"===e.slice(0,2)?e:"0x"+e}function p(e){return o.intToHex(e)}function b(e){return Number(e)}function y(e){return function(e){let t=o.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}(e.toString("hex"))}function m(e){return e&&-1===["earliest","latest","pending"].indexOf(e)}function v(e){return Object.keys(e).map(function(t){return e[t]})}t.exports=c,i(c,a),c.prototype.handleRequest=function(e,t,r){const n=this;switch(e.method){case"eth_newBlockFilter":return void n.newBlockFilter(r);case"eth_newPendingTransactionFilter":return n.newPendingTransactionFilter(r),void n.checkForPendingBlocks();case"eth_newFilter":return void n.newLogFilter(e.params[0],r);case"eth_getFilterChanges":return void n._ready.await(function(){n.getFilterChanges(e.params[0],r)});case"eth_getFilterLogs":return void n._ready.await(function(){n.getFilterLogs(e.params[0],r)});case"eth_uninstallFilter":return void n._ready.await(function(){n.uninstallFilter(e.params[0],r)});default:return void t()}},c.prototype.newBlockFilter=function(e){const t=this;t._getBlockNumber(function(r,n){if(r)return e(r);var i=new f({blockNumber:n}),o=i.update.bind(i);t.engine.on("block",o);t.filterIndex++,t.filters[t.filterIndex]=i,t.filterDestroyHandlers[t.filterIndex]=function(){t.engine.removeListener("block",o)};var a=p(t.filterIndex);e(null,a)})},c.prototype.newLogFilter=function(e,t){const r=this;r._getBlockNumber(function(n,i){if(n)return t(n);var o=new h(e),a=o.update.bind(o);r.filterIndex++,r.asyncBlockHandlers[r.filterIndex]=function(e,t){r._logsForBlock(e,function(e,r){if(e)return t(e);a(r),t()})},r.filters[r.filterIndex]=o;var s=p(r.filterIndex);t(null,s)})},c.prototype.newPendingTransactionFilter=function(e){const t=this;var r=new l,n=r.update.bind(r);t.filterIndex++,t.asyncPendingBlockHandlers[t.filterIndex]=function(e,r){t._txHashesForBlock(e,function(e,t){if(e)return r(e);n(t),r()})},t.filters[t.filterIndex]=r,e(null,p(t.filterIndex))},c.prototype.getFilterChanges=function(e,t){var r=Number.parseInt(e,16),n=this.filters[r];if(n||console.warn("FilterSubprovider - no filter with that id:",e),!n)return t(null,[]);var i=n.getChanges();n.clearChanges(),t(null,i)},c.prototype.getFilterLogs=function(e,t){const r=this;var n=Number.parseInt(e,16),i=r.filters[n];if(i||console.warn("FilterSubprovider - no filter with that id:",e),!i)return t(null,[]);if("log"===i.type)r.emitPayload({method:"eth_getLogs",params:[{fromBlock:i.fromBlock,toBlock:i.toBlock,address:i.address,topics:i.topics}]},function(e,r){if(e)return t(e);t(null,r.result)});else{t(null,[])}},c.prototype.uninstallFilter=function(e,t){var r=Number.parseInt(e,16);if(this.filters[r]){this.filters[r].removeAllListeners();var n=this.filterDestroyHandlers[r];delete this.filters[r],delete this.asyncBlockHandlers[r],delete this.asyncPendingBlockHandlers[r],delete this.filterDestroyHandlers[r],n&&n(),t(null,!0)}else t(null,!1)},c.prototype.checkForPendingBlocks=function(){const e=this;e.checkForPendingBlocksActive||!!Object.keys(e.asyncPendingBlockHandlers).length&&(e.checkForPendingBlocksActive=!0,e.emitPayload({method:"eth_getBlockByNumber",params:["pending",!0]},function(t,r){if(t)return e.checkForPendingBlocksActive=!1,void console.error(t);e.onNewPendingBlock(r.result,function(t){t&&console.error(t),e.checkForPendingBlocksActive=!1,setTimeout(e.checkForPendingBlocks.bind(e),e.pendingBlockTimeout)})}))},c.prototype.onNewPendingBlock=function(e,t){var r=v(this.asyncPendingBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,t)},c.prototype._getBlockNumber=function(e){e(null,y(this.engine.currentBlock.number))},c.prototype._logsForBlock=function(e,t){var r=y(e.number);this.emitPayload({method:"eth_getLogs",params:[{fromBlock:r,toBlock:r}]},function(e,r){return e?t(e):r.error?t(r.error):void t(null,r.result)})},c.prototype._txHashesForBlock=function(e,t){var r=e.transactions;if(0===r.length)return t(null,[]);"string"==typeof r[0]?t(null,r):t(null,r.map(e=>e.hash))},i(f,u),f.prototype.update=function(e){var t="0x"+e.hash.toString("hex");this.updates.push(t),this.emit("data",e)},f.prototype.getChanges=function(){return this.updates},f.prototype.clearChanges=function(){this.updates=[]},i(h,u),h.prototype.validateLog=function(e){return!(m(this.fromBlock)&&b(this.fromBlock)>=b(e.blockNumber))&&(!(m(this.toBlock)&&b(this.toBlock)<=b(e.blockNumber))&&(!(this.address&&!this.address.map(e=>e.toLowerCase()).includes(e.address.toLowerCase()))&&this.topics.reduce(function(t,r,n){if(!t)return!1;if(!r)return!0;var i=e.topics[n];return!!i&&(Array.isArray(r)?r:[r]).filter(function(e){return i.toLowerCase()===e.toLowerCase()}).length>0},!0)))},h.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateLog(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},h.prototype.getChanges=function(){return this.updates},h.prototype.getAllResults=function(){return this.allResults},h.prototype.clearChanges=function(){this.updates=[]},i(l,u),l.prototype.validateUnique=function(e){return-1===this.allResults.indexOf(e)},l.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateUnique(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},l.prototype.getChanges=function(){return this.updates},l.prototype.getAllResults=function(){return this.allResults},l.prototype.clearChanges=function(){this.updates=[]}},{"../util/stoplight.js":396,"./subprovider.js":387,async:21,"ethereumjs-util":141,events:157,util:333}],380:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){e=e||{},this.staticResponses=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){var n=this.staticResponses[e.method];"function"==typeof n?n(e,t,r):void 0!==n?setTimeout(()=>r(null,n)):t()}},{"./subprovider.js":387,util:333}],381:[function(e,t,r){const n=e("async/waterfall"),i=e("async/parallel"),o=e("util").inherits,a=e("ethereumjs-util"),s=e("eth-sig-util"),u=e("xtend"),c=e("semaphore"),f=e("./subprovider.js"),h=e("../util/estimate-gas.js"),l=/^[0-9A-Fa-f]+$/g;function d(e){this.nonceLock=c(1),e.getAccounts&&(this.getAccounts=e.getAccounts),e.processTransaction&&(this.processTransaction=e.processTransaction),e.processMessage&&(this.processMessage=e.processMessage),e.processPersonalMessage&&(this.processPersonalMessage=e.processPersonalMessage),e.processTypedMessage&&(this.processTypedMessage=e.processTypedMessage),this.approveTransaction=e.approveTransaction||this.autoApprove,this.approveMessage=e.approveMessage||this.autoApprove,this.approvePersonalMessage=e.approvePersonalMessage||this.autoApprove,this.approveTypedMessage=e.approveTypedMessage||this.autoApprove,e.signTransaction&&(this.signTransaction=e.signTransaction||y("signTransaction")),e.signMessage&&(this.signMessage=e.signMessage||y("signMessage")),e.signPersonalMessage&&(this.signPersonalMessage=e.signPersonalMessage||y("signPersonalMessage")),e.signTypedMessage&&(this.signTypedMessage=e.signTypedMessage||y("signTypedMessage")),e.recoverPersonalSignature&&(this.recoverPersonalSignature=e.recoverPersonalSignature),e.publishTransaction&&(this.publishTransaction=e.publishTransaction)}function p(e){return e.toLowerCase()}function b(e){return"string"==typeof e&&("0x"===e.slice(0,2)&&e.slice(2).match(l))}function y(e){return function(t,r){r(new Error('ProviderEngine - HookedWalletSubprovider - Must provide "'+e+'" fn in constructor options'))}}t.exports=d,o(d,f),d.prototype.handleRequest=function(e,t,r){const i=this;let o,s,c,f,h;switch(i._parityRequests={},i._parityRequestCount=0,e.method){case"eth_coinbase":return void i.getAccounts(function(e,t){if(e)return r(e);let n=t[0]||null;r(null,n)});case"eth_accounts":return void i.getAccounts(function(e,t){if(e)return r(e);r(null,t)});case"eth_sendTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processTransaction(o,e)],r);case"eth_signTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processSignTransaction(o,e)],r);case"eth_sign":return h=e.params[0],f=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateMessage(s,e),e=>i.processMessage(s,e)],r);case"personal_sign":const l=e.params[0];if(function(e){const t=a.addHexPrefix(e);return!a.isValidAddress(t)&&b(e)}(e.params[1])&&function(e){const t=a.addHexPrefix(e);return a.isValidAddress(t)}(l)){let t="The eth_personalSign method requires params ordered ";t+="[message, address]. This was previously handled incorrectly, ",t+="and has been corrected automatically. ",t+="Please switch this param order for smooth behavior in the future.",console.warn(t),h=e.params[0],f=e.params[1]}else f=e.params[0],h=e.params[1];return c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validatePersonalMessage(s,e),e=>i.processPersonalMessage(s,e)],r);case"personal_ecRecover":f=e.params[0];let d=e.params[1];return c=e.params[2]||{},s=u(c,{sig:d,data:f}),void i.recoverPersonalSignature(s,r);case"eth_signTypedData":return f=e.params[0],h=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateTypedMessage(s,e),e=>i.processTypedMessage(s,e)],r);case"parity_postTransaction":return o=e.params[0],void i.parityPostTransaction(o,r);case"parity_postSign":return h=e.params[0],f=e.params[1],void i.parityPostSign(h,f,r);case"parity_checkRequest":const p=e.params[0];return void i.parityCheckRequest(p,r);case"parity_defaultAccount":return void i.getAccounts(function(e,t){if(e)return r(e);const n=t[0]||null;r(null,n)});default:return void t()}},d.prototype.getAccounts=function(e){e(null,[])},d.prototype.processTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeAndSubmitTx(e,t)],t)},d.prototype.processSignTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeTx(e,t)],t)},d.prototype.processMessage=function(e,t){const r=this;n([t=>r.approveMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signMessage(e,t)],t)},d.prototype.processPersonalMessage=function(e,t){const r=this;n([t=>r.approvePersonalMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signPersonalMessage(e,t)],t)},d.prototype.processTypedMessage=function(e,t){const r=this;n([t=>r.approveTypedMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signTypedMessage(e,t)],t)},d.prototype.autoApprove=function(e,t){t(null,!0)},d.prototype.checkApproval=function(e,t,r){r(t?null:new Error("User denied "+e+" signature."))},d.prototype.parityPostTransaction=function(e,t){const r=this,n=`0x${r._parityRequestCount.toString(16)}`;r._parityRequestCount++,r.emitPayload({method:"eth_sendTransaction",params:[e]},function(e,t){if(e)return void(r._parityRequests[n]={error:e});const i=t.result;r._parityRequests[n]=i}),t(null,n)},d.prototype.parityPostSign=function(e,t,r){const n=this,i=`0x${n._parityRequestCount.toString(16)}`;n._parityRequestCount++,n.emitPayload({method:"eth_sign",params:[e,t]},function(e,t){if(e)return void(n._parityRequests[i]={error:e});const r=t.result;n._parityRequests[i]=r}),r(null,i)},d.prototype.parityCheckRequest=function(e,t){const r=this._parityRequests[e]||null;return r?r.error?t(r.error):void t(null,r):t(null,null)},d.prototype.recoverPersonalSignature=function(e,t){let r;try{r=s.recoverPersonalSignature(e)}catch(e){return t(e)}t(null,r)},d.prototype.validateTransaction=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign transaction."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign transaction for this address: "${e.from}"`))})},d.prototype.validateMessage=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign message."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validatePersonalMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign personal message.")):void 0===e.data?t(new Error("Undefined message - message required to sign personal message.")):b(e.data)?void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))}):t(new Error("HookedWalletSubprovider - validateMessage - message was not encoded as hex."))},d.prototype.validateTypedMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign typed data.")):void 0===e.data?t(new Error("Undefined data - message required to sign typed data.")):void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validateSender=function(e,t){if(!e)return t(null,!1);this.getAccounts(function(r,n){if(r)return t(r);const i=-1!==n.map(p).indexOf(e.toLowerCase());t(null,i)})},d.prototype.finalizeAndSubmitTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r),r.publishTransaction.bind(r)],function(e,n){if(r.nonceLock.leave(),e)return t(e);t(null,n)})})},d.prototype.finalizeTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r)],function(n,i){if(r.nonceLock.leave(),n)return t(n);t(null,{raw:i,tx:e})})})},d.prototype.publishTransaction=function(e,t){this.emitPayload({method:"eth_sendRawTransaction",params:[e]},function(e,r){if(e)return t(e);t(null,r.result)})},d.prototype.fillInTxExtras=function(e,t){const r=this,n=e.from,o={};void 0===e.gasPrice&&(o.gasPrice=r.emitPayload.bind(r,{method:"eth_gasPrice",params:[]})),void 0===e.nonce&&(o.nonce=r.emitPayload.bind(r,{method:"eth_getTransactionCount",params:[n,"pending"]})),void 0===e.gas&&(o.gas=h.bind(null,r.engine,function(e){return{from:e.from,to:e.to,value:e.value,data:e.data,gas:e.gas,gasPrice:e.gasPrice,nonce:e.nonce}}(e))),i(o,function(r,n){if(r)return t(r);const i={};n.gasPrice&&(i.gasPrice=n.gasPrice.result),n.nonce&&(i.nonce=n.nonce.result),n.gas&&(i.gas=n.gas),t(null,u(e,i))})}},{"../util/estimate-gas.js":392,"./subprovider.js":387,"async/parallel":42,"async/waterfall":44,"eth-sig-util":136,"ethereumjs-util":141,semaphore:301,util:333,xtend:423}],382:[function(e,t,r){const n=e("../util/rpc-cache-utils.js").cacheIdentifierForPayload,i=e("./subprovider.js");t.exports=class extends i{constructor(e){super(),this.inflightRequests={}}addEngine(e){this.engine=e}handleRequest(e,t,r){const i=n(e,{includeBlockRef:!0});if(!i)return t();let o=this.inflightRequests[i];o?o.push(r):(o=[],this.inflightRequests[i]=o,t((e,t,r)=>{delete this.inflightRequests[i],o.forEach(r=>r(e,t)),r(e,t)}))}}},{"../util/rpc-cache-utils.js":394,"./subprovider.js":387}],383:[function(e,t,r){const n=e("eth-json-rpc-infura/src/createProvider"),i=e("./provider.js");t.exports=class extends i{constructor(e={}){super(n(e))}}},{"./provider.js":385,"eth-json-rpc-infura/src/createProvider":129}],384:[function(e,t,r){(function(r){const n=e("util").inherits,i=e("ethereumjs-tx"),o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/rpc-cache-utils").blockTagForPayload;function u(e){this.nonceCache={}}t.exports=u,n(u,a),u.prototype.handleRequest=function(e,t,n){const a=this;switch(e.method){case"eth_getTransactionCount":var u=s(e),c=e.params[0].toLowerCase(),f=a.nonceCache[c];return void("pending"===u?f?n(null,f):t(function(e,t,r){if(e)return r();void 0===a.nonceCache[c]&&(a.nonceCache[c]=t),r()}):t());case"eth_sendRawTransaction":return void t(function(t,n,s){if(t)return s();var u=e.params[0],c=(o.stripHexPrefix(u),new r(o.stripHexPrefix(u),"hex"),new i(new r(o.stripHexPrefix(u),"hex"))),f="0x"+c.getSenderAddress().toString("hex").toLowerCase(),h=o.bufferToInt(c.nonce),l=(++h).toString(16);l.length%2&&(l="0"+l),l="0x"+l,a.nonceCache[f]=l,s()});default:return void t()}}}).call(this,e("buffer").Buffer)},{"../util/rpc-cache-utils":394,"./subprovider.js":387,buffer:84,"ethereumjs-tx":140,"ethereumjs-util":141,util:333}],385:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){if(!e)throw new Error("ProviderSubprovider - no provider specified");if(!e.sendAsync)throw new Error("ProviderSubprovider - specified provider does not have a sendAsync method");this.provider=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){this.provider.sendAsync(e,function(e,t){return e?r(e):t.error?r(new Error(t.error.message)):void r(null,t.result)})}},{"./subprovider.js":387,util:333}],386:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js"),o=(e("xtend"),e("ethereumjs-util"));function a(e){}t.exports=a,n(a,i),a.prototype.handleRequest=function(e,t,r){var n=e.params[0];if("object"==typeof n&&!Array.isArray(n)){var i=function(e){return s.reduce(function(t,r){return r in e&&(Array.isArray(e[r])?t[r]=e[r].map(function(e){return u(e)}):t[r]=u(e[r])),t},{})}(n);e.params[0]=i}t()};var s=["from","to","value","data","gas","gasPrice","nonce","fromBlock","toBlock","address","topics"];function u(e){switch(e){case"latest":case"pending":case"earliest":return e;default:return"string"==typeof e?o.addHexPrefix(e.toLowerCase()):e}}},{"./subprovider.js":387,"ethereumjs-util":141,util:333,xtend:423}],387:[function(e,t,r){const n=e("../util/create-payload.js");function i(){}t.exports=i,i.prototype.setEngine=function(e){const t=this;t.engine=e,e.on("block",function(e){t.currentBlock=e})},i.prototype.handleRequest=function(e,t,r){throw new Error("Subproviders should override `handleRequest`.")},i.prototype.emitPayload=function(e,t){this.engine.sendAsync(n(e),t)}},{"../util/create-payload.js":391}],388:[function(e,t,r){const n=e("events").EventEmitter,i=e("./filters.js"),o=e("../util/rpc-hex-encoding.js"),a=e("util").inherits,s=e("ethereumjs-util");function u(e){e=e||{},n.apply(this,Array.prototype.slice.call(arguments)),i.apply(this,[e]),this.subscriptions={}}a(u,i),Object.assign(u.prototype,n.prototype),u.prototype.constructor=u,u.prototype.eth_subscribe=function(e,t){const r=this;let n=()=>{},i=e.params[0];switch(i){case"logs":let o=e.params[1];n=r.newLogFilter.bind(r,o);break;case"newPendingTransactions":n=r.newPendingTransactionFilter.bind(r);break;case"newHeads":n=r.newBlockFilter.bind(r);break;case"syncing":default:return void t(new Error("unsupported subscription type"))}n(function(e,n){if(e)return t(e);const o=Number.parseInt(n,16);r.subscriptions[o]=i,r.filters[o].on("data",function(e){Array.isArray(e)||(e=[e]);var t=r._notificationHandler.bind(r,n,i);e.forEach(t),r.filters[o].clearChanges()}),"newPendingTransactions"===i&&r.checkForPendingBlocks(),t(null,n)})},u.prototype.eth_unsubscribe=function(e,t){const r=this;let n=e.params[0];const i=Number.parseInt(n,16);if(r.subscriptions[i]){r.subscriptions[i];r.uninstallFilter(n,function(e,n){delete r.subscriptions[i],t(e,n)})}else t(new Error(`Subscription ID ${n} not found.`))},u.prototype._notificationHandler=function(e,t,r){const n=this;"newHeads"===t&&(r=n._notificationResultFromBlock(r)),n.emit("data",null,{jsonrpc:"2.0",method:"eth_subscription",params:{subscription:e,result:r}})},u.prototype._notificationResultFromBlock=function(e){return{hash:s.bufferToHex(e.hash),parentHash:s.bufferToHex(e.parentHash),sha3Uncles:s.bufferToHex(e.sha3Uncles),miner:s.bufferToHex(e.miner),stateRoot:s.bufferToHex(e.stateRoot),transactionsRoot:s.bufferToHex(e.transactionsRoot),receiptsRoot:s.bufferToHex(e.receiptsRoot),logsBloom:s.bufferToHex(e.logsBloom),difficulty:o.intToQuantityHex(s.bufferToInt(e.difficulty)),number:o.intToQuantityHex(s.bufferToInt(e.number)),gasLimit:o.intToQuantityHex(s.bufferToInt(e.gasLimit)),gasUsed:o.intToQuantityHex(s.bufferToInt(e.gasUsed)),nonce:e.nonce?s.bufferToHex(e.nonce):null,mixHash:s.bufferToHex(e.mixHash),timestamp:o.intToQuantityHex(s.bufferToInt(e.timestamp)),extraData:s.bufferToHex(e.extraData)}},u.prototype.handleRequest=function(e,t,r){switch(e.method){case"eth_subscribe":this.eth_subscribe(e,r);break;case"eth_unsubscribe":this.eth_unsubscribe(e,r);break;default:i.prototype.handleRequest.apply(this,Array.prototype.slice.call(arguments))}},t.exports=u},{"../util/rpc-hex-encoding.js":395,"./filters.js":379,"ethereumjs-util":141,events:157,util:333}],389:[function(e,t,r){(function(r){const n=e("backoff"),i=e("events"),o=(e("util").inherits,r.WebSocket||e("ws")),a=e("./subprovider"),s=e("../util/create-payload");class u extends a{constructor({rpcUrl:e,debug:t,origin:r}){super(),i.call(this),Object.defineProperties(this,{_backoff:{value:n.exponential({randomisationFactor:.2,maxDelay:5e3})},_connectTime:{value:null,writable:!0},_log:{value:t?(...e)=>console.info.apply(console,["[WSProvider]",...e]):()=>{}},_origin:{value:r},_pendingRequests:{value:new Map},_socket:{value:null,writable:!0},_unhandledRequests:{value:[]},_url:{value:e}}),this._handleSocketClose=this._handleSocketClose.bind(this),this._handleSocketMessage=this._handleSocketMessage.bind(this),this._handleSocketOpen=this._handleSocketOpen.bind(this),this._backoff.on("ready",()=>{this._openSocket()}),this._openSocket()}handleRequest(e,t,r){if(!this._socket||this._socket.readyState!==o.OPEN)return this._unhandledRequests.push(Array.from(arguments)),void this._log("Socket not open. Request queued.");this._pendingRequests.set(e.id,[e,r]);const n=s(e);delete n.origin,this._socket.send(JSON.stringify(n)),this._log(`Sent: ${n.method} #${n.id}`)}_handleSocketClose({reason:e,code:t}){this._log(`Socket closed, code ${t} (${e||"no reason"})`),this._connectTime&&Date.now()-this._connectTime>5e3&&this._backoff.reset(),this._socket.removeEventListener("close",this._handleSocketClose),this._socket.removeEventListener("message",this._handleSocketMessage),this._socket.removeEventListener("open",this._handleSocketOpen),this._socket=null,this._backoff.backoff()}_handleSocketMessage(e){let t;try{t=JSON.parse(e.data)}catch(e){return void this._log("Received a message that is not valid JSON:",t)}if(void 0===t.id)return this.emit("data",null,t);if(!this._pendingRequests.has(t.id))return;const[r,n]=this._pendingRequests.get(t.id);if(this._pendingRequests.delete(t.id),this._log(`Received: ${r.method} #${t.id}`),t.error)return n(new Error(t.error.message));n(null,t.result)}_handleSocketOpen(){this._log("Socket open."),this._connectTime=Date.now(),this._pendingRequests.forEach(([e,t])=>{this._unhandledRequests.push([e,null,t])}),this._pendingRequests.clear(),this._unhandledRequests.splice(0,this._unhandledRequests.length).forEach(e=>{this.handleRequest.apply(this,e)})}_openSocket(){this._log("Opening socket..."),this._socket=new o(this._url,null,{origin:this._origin}),this._socket.addEventListener("close",this._handleSocketClose),this._socket.addEventListener("message",this._handleSocketMessage),this._socket.addEventListener("open",this._handleSocketOpen)}}Object.assign(u.prototype,i.prototype),t.exports=u}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util/create-payload":391,"./subprovider":387,backoff:45,events:157,util:333,ws:55}],390:[function(e,t,r){t.exports=function(e,t){if(!e)throw t||"Assertion failed"}},{}],391:[function(e,t,r){const n=e("./random-id.js"),i=e("xtend");t.exports=function(e){return i({id:n(),jsonrpc:"2.0",params:[]},e)}},{"./random-id.js":393,xtend:423}],392:[function(e,t,r){const n=e("./create-payload.js");t.exports=function(e,t,r){e.sendAsync(n({method:"eth_estimateGas",params:[t]}),function(e,t){if(e)return"no contract code at given address"===e.message?r(null,"0xcf08"):r(e);r(null,t.result)})}},{"./create-payload.js":391}],393:[function(e,t,r){const n=3;t.exports=function(){var e=(new Date).getTime()*Math.pow(10,n),t=Math.floor(Math.random()*Math.pow(10,n));return e+t}},{}],394:[function(e,t,r){const n=e("json-stable-stringify");function i(e){return"never"!==s(e)}function o(e){var t=a(e);return t>=e.params.length?e.params:"eth_getBlockByNumber"===e.method?e.params.slice(1):e.params.slice(0,t)}function a(e){switch(e.method){case"eth_getStorageAt":return 2;case"eth_getBalance":case"eth_getCode":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":return 1;case"eth_getBlockByNumber":return 0;default:return}}function s(e){switch(e.method){case"web3_clientVersion":case"web3_sha3":case"eth_protocolVersion":case"eth_getBlockTransactionCountByHash":case"eth_getUncleCountByBlockHash":case"eth_getCode":case"eth_getBlockByHash":case"eth_getTransactionByHash":case"eth_getTransactionByBlockHashAndIndex":case"eth_getTransactionReceipt":case"eth_getUncleByBlockHashAndIndex":case"eth_getCompilers":case"eth_compileLLL":case"eth_compileSolidity":case"eth_compileSerpent":case"shh_version":return"perma";case"eth_getBlockByNumber":case"eth_getBlockTransactionCountByNumber":case"eth_getUncleCountByBlockNumber":case"eth_getTransactionByBlockNumberAndIndex":case"eth_getUncleByBlockNumberAndIndex":return"fork";case"eth_gasPrice":case"eth_blockNumber":case"eth_getBalance":case"eth_getStorageAt":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":case"eth_getFilterLogs":case"eth_getLogs":case"net_peerCount":return"block";case"net_version":case"net_peerCount":case"net_listening":case"eth_syncing":case"eth_sign":case"eth_coinbase":case"eth_mining":case"eth_hashrate":case"eth_accounts":case"eth_sendTransaction":case"eth_sendRawTransaction":case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_getFilterChanges":case"eth_getWork":case"eth_submitWork":case"eth_submitHashrate":case"db_putString":case"db_getString":case"db_putHex":case"db_getHex":case"shh_post":case"shh_newIdentity":case"shh_hasIdentity":case"shh_newGroup":case"shh_addToGroup":case"shh_newFilter":case"shh_uninstallFilter":case"shh_getFilterChanges":case"shh_getMessages":return"never"}}t.exports={cacheIdentifierForPayload:function(e,t={}){if(!i(e))return null;const{includeBlockRef:r}=t,a=r?e.params:o(e);return e.method+":"+n(a)},canCache:i,blockTagForPayload:function(e){var t=a(e);if(t>=e.params.length)return null;return e.params[t]},paramsWithoutBlockTag:o,blockTagParamIndex:a,cacheTypeForPayload:s}},{"json-stable-stringify":374}],395:[function(e,t,r){(function(r){const n=e("ethereumjs-util"),i=e("./assert.js");t.exports={intToQuantityHex:function(e){i("number"==typeof e&&e===Math.floor(e),"intToQuantityHex arg must be an integer");var t=n.toBuffer(e).toString("hex");"0"===t[0]&&(t=t.substring(1));return n.addHexPrefix(t)},quantityHexToInt:function(e){i("string"==typeof e,"arg to quantityHexToInt must be a string");var t=n.stripHexPrefix(e);t.length%2!=0&&(t="0"+t);var o=new r(t,"hex");return n.bufferToInt(o)}}}).call(this,e("buffer").Buffer)},{"./assert.js":390,buffer:84,"ethereumjs-util":141}],396:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits;function o(){n.call(this),this.isLocked=!0}t.exports=o,i(o,n),o.prototype.go=function(){this.isLocked=!1,this.emit("unlock")},o.prototype.stop=function(){this.isLocked=!0,this.emit("lock")},o.prototype.await=function(e){const t=this;t.isLocked?t.once("unlock",e):setTimeout(e)}},{events:157,util:333}],397:[function(e,t,r){const n=e("./index.js"),i=e("./subproviders/default-fixture.js"),o=e("./subproviders/nonce-tracker.js"),a=e("./subproviders/cache.js"),s=e("./subproviders/filters.js"),u=e("./subproviders/subscriptions"),c=e("./subproviders/inflight-cache"),f=e("./subproviders/hooked-wallet.js"),h=e("./subproviders/sanitizer.js"),l=e("./subproviders/infura.js"),d=e("./subproviders/fetch.js"),p=e("./subproviders/websocket.js");t.exports=function(e={}){const t=function({rpcUrl:e}){if(!e)return;switch(e.split(":")[0].toLowerCase()){case"http":case"https":return"http";case"ws":case"wss":return"ws";default:throw new Error(`ProviderEngine - unrecognized protocol in "${e}"`)}}(e),r=new n(e.engineParams),b=new i(e.static);r.addProvider(b),r.addProvider(new o);const y=new h;r.addProvider(y);const m=new a;if(r.addProvider(m),"ws"===t){const e=new s;r.addProvider(e)}else{const e=new u;e.on("data",(e,t)=>{r.emit("data",e,t)}),r.addProvider(e)}const v=new c;r.addProvider(v);const g=new f({getAccounts:e.getAccounts,processTransaction:e.processTransaction,approveTransaction:e.approveTransaction,signTransaction:e.signTransaction,publishTransaction:e.publishTransaction,processMessage:e.processMessage,approveMessage:e.approveMessage,signMessage:e.signMessage,processPersonalMessage:e.processPersonalMessage,processTypedMessage:e.processTypedMessage,approvePersonalMessage:e.approvePersonalMessage,approveTypedMessage:e.approveTypedMessage,signPersonalMessage:e.signPersonalMessage,signTypedMessage:e.signTypedMessage,personalRecoverSigner:e.personalRecoverSigner});r.addProvider(g);const w=e.dataSubprovider||function(e,t){const{rpcUrl:r,debug:n}=t;if(!e)return new l;if("http"===e)return new d({rpcUrl:r,debug:n});if("ws"===e)return new p({rpcUrl:r,debug:n});throw new Error(`ProviderEngine - unrecognized connectionType "${e}"`)}(t,e);"ws"===t&&w.on("data",(e,t)=>{r.emit("data",e,t)});r.addProvider(w),e.stopped||r.start();return r}},{"./index.js":373,"./subproviders/cache.js":376,"./subproviders/default-fixture.js":377,"./subproviders/fetch.js":378,"./subproviders/filters.js":379,"./subproviders/hooked-wallet.js":381,"./subproviders/inflight-cache":382,"./subproviders/infura.js":383,"./subproviders/nonce-tracker.js":384,"./subproviders/sanitizer.js":386,"./subproviders/subscriptions":388,"./subproviders/websocket.js":389}],398:[function(e,t,r){var n=e("web3-core-helpers").errors,i=e("xhr2-cookies").XMLHttpRequest,o=e("http"),a=e("https"),s=function(e,t){t=t||{},this.host=e||"http://localhost:8545","https"===this.host.substring(0,5)?this.httpsAgent=new a.Agent({keepAlive:!0}):this.httpAgent=new o.Agent({keepAlive:!0}),this.timeout=t.timeout||0,this.headers=t.headers,this.connected=!1};s.prototype._prepareRequest=function(){var e=new i;return e.nodejsSet({httpsAgent:this.httpsAgent,httpAgent:this.httpAgent}),e.open("POST",this.host,!0),e.setRequestHeader("Content-Type","application/json"),e.timeout=this.timeout&&1!==this.timeout?this.timeout:0,e.withCredentials=!0,this.headers&&this.headers.forEach(function(t){e.setRequestHeader(t.name,t.value)}),e},s.prototype.send=function(e,t){var r=this,i=this._prepareRequest();i.onreadystatechange=function(){if(4===i.readyState&&1!==i.timeout){var e=i.responseText,o=null;try{e=JSON.parse(e)}catch(e){o=n.InvalidResponse(i.responseText)}r.connected=!0,t(o,e)}},i.ontimeout=function(){r.connected=!1,t(n.ConnectionTimeout(this.timeout))};try{i.send(JSON.stringify(e))}catch(e){this.connected=!1,t(n.InvalidConnection(this.host))}},s.prototype.disconnect=function(){},t.exports=s},{http:312,https:175,"web3-core-helpers":338,"xhr2-cookies":418}],399:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("oboe"),a=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],this.path=e,this.connected=!1,this.connection=t.connect({path:this.path}),this.addDefaultEvents();var i=function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,t||-1===e.method.indexOf("_subscription")?r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t]):r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)})};"Socket"===t.constructor.name?o(this.connection).done(i):this.connection.on("data",function(e){r._parseResponse(e.toString()).forEach(i)})};a.prototype.addDefaultEvents=function(){var e=this;this.connection.on("connect",function(){e.connected=!0}),this.connection.on("close",function(){e.connected=!1}),this.connection.on("error",function(){e._timeout()}),this.connection.on("end",function(){e._timeout()}),this.connection.on("timeout",function(){e._timeout()})},a.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},a.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n},a.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on IPC")),delete this.responseCallbacks[e])},a.prototype.reconnect=function(){this.connection.connect({path:this.path})},a.prototype.send=function(e,t){this.connection.writable||this.connection.connect({path:this.path}),this.connection.write(JSON.stringify(e)),this._addResponseCallback(e,t)},a.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;default:this.connection.on(e,t)}},a.prototype.once=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");this.connection.once(e,t)},a.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)});break;default:this.connection.removeListener(e,t)}},a.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;default:this.connection.removeAllListeners(e)}},a.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.connection.removeAllListeners("error"),this.connection.removeAllListeners("end"),this.connection.removeAllListeners("timeout"),this.addDefaultEvents()},t.exports=a},{oboe:239,underscore:325,"web3-core-helpers":338}],400:[function(e,t,r){(function(r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=null,a=null,s=null;if("undefined"!=typeof window&&void 0!==window.WebSocket)o=function(e,t){return new window.WebSocket(e,t)},a=btoa,s=function(e){return new URL(e)};else{o=e("websocket").w3cwebsocket,a=function(e){return r(e).toString("base64")};var u=e("url");if(u.URL){var c=u.URL;s=function(e){return new c(e)}}else s=e("url").parse}var f=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],t=t||{},this._customTimeout=t.timeout;var i=s(e),u=t.headers||{},c=t.protocol||void 0;i.username&&i.password&&(u.authorization="Basic "+a(i.username+":"+i.password));var f=t.clientConfig||void 0;i.auth&&(u.authorization="Basic "+a(i.auth)),this.connection=new o(e,c,void 0,u,void 0,f),this.addDefaultEvents(),this.connection.onmessage=function(e){var t="string"==typeof e.data?e.data:"";r._parseResponse(t).forEach(function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,!t&&e&&e.method&&-1!==e.method.indexOf("_subscription")?r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)}):r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t])})},Object.defineProperty(this,"connected",{get:function(){return this.connection&&this.connection.readyState===this.connection.OPEN},enumerable:!0})};f.prototype.addDefaultEvents=function(){var e=this;this.connection.onerror=function(){e._timeout()},this.connection.onclose=function(){e._timeout(),e.reset()}},f.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},f.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n;var o=this;this._customTimeout&&setTimeout(function(){o.responseCallbacks[r]&&(o.responseCallbacks[r](i.ConnectionTimeout(o._customTimeout)),delete o.responseCallbacks[r])},this._customTimeout)},f.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on WS")),delete this.responseCallbacks[e])},f.prototype.send=function(e,t){var r=this;if(this.connection.readyState!==this.connection.CONNECTING){if(this.connection.readyState!==this.connection.OPEN)return console.error("connection not open on send()"),"function"==typeof this.connection.onerror?this.connection.onerror(new Error("connection not open")):console.error("no error callback"),void t(new Error("connection not open"));this.connection.send(JSON.stringify(e)),this._addResponseCallback(e,t)}else setTimeout(function(){r.send(e,t)},10)},f.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;case"connect":this.connection.onopen=t;break;case"end":this.connection.onclose=t;break;case"error":this.connection.onerror=t}},f.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)})}},f.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;case"connect":this.connection.onopen=null;break;case"end":this.connection.onclose=null;break;case"error":this.connection.onerror=null}},f.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.addDefaultEvents()},f.prototype.disconnect=function(){this.connection&&this.connection.close()},t.exports=f}).call(this,e("buffer").Buffer)},{buffer:84,underscore:325,url:327,"web3-core-helpers":338,websocket:408}],401:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-subscriptions").subscriptions,o=e("web3-core-method"),a=e("web3-net"),s=function(){var e=this;n.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments)},this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new a(this.currentProvider),[new i({name:"subscribe",type:"shh",subscriptions:{messages:{params:1}}}),new o({name:"getVersion",call:"shh_version",params:0}),new o({name:"getInfo",call:"shh_info",params:0}),new o({name:"setMaxMessageSize",call:"shh_setMaxMessageSize",params:1}),new o({name:"setMinPoW",call:"shh_setMinPoW",params:1}),new o({name:"markTrustedPeer",call:"shh_markTrustedPeer",params:1}),new o({name:"newKeyPair",call:"shh_newKeyPair",params:0}),new o({name:"addPrivateKey",call:"shh_addPrivateKey",params:1}),new o({name:"deleteKeyPair",call:"shh_deleteKeyPair",params:1}),new o({name:"hasKeyPair",call:"shh_hasKeyPair",params:1}),new o({name:"getPublicKey",call:"shh_getPublicKey",params:1}),new o({name:"getPrivateKey",call:"shh_getPrivateKey",params:1}),new o({name:"newSymKey",call:"shh_newSymKey",params:0}),new o({name:"addSymKey",call:"shh_addSymKey",params:1}),new o({name:"generateSymKeyFromPassword",call:"shh_generateSymKeyFromPassword",params:1}),new o({name:"hasSymKey",call:"shh_hasSymKey",params:1}),new o({name:"getSymKey",call:"shh_getSymKey",params:1}),new o({name:"deleteSymKey",call:"shh_deleteSymKey",params:1}),new o({name:"newMessageFilter",call:"shh_newMessageFilter",params:1}),new o({name:"getFilterMessages",call:"shh_getFilterMessages",params:1}),new o({name:"deleteMessageFilter",call:"shh_deleteMessageFilter",params:1}),new o({name:"post",call:"shh_post",params:1,inputFormatter:[null]}),new o({name:"unsubscribe",call:"shh_unsubscribe",params:1})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(s),t.exports=s},{"web3-core":348,"web3-core-method":339,"web3-core-subscriptions":345,"web3-net":372}],402:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],403:[function(e,t,r){var n=e("underscore"),i=e("ethjs-unit"),o=e("./utils.js"),a=e("./soliditySha3.js"),s=e("randomhex"),u=function(e,t){var r=[];return t.forEach(function(t){if("object"==typeof t.components){if("tuple"!==t.type.substring(0,5))throw new Error("components found but type is not tuple; report on GitHub");var i="",o=t.type.indexOf("[");o>=0&&(i=t.type.substring(o));var a=u(e,t.components);n.isArray(a)&&e?r.push("tuple("+a.join(",")+")"+i):e?r.push("("+a+")"):r.push("("+a.join(",")+")"+i)}else r.push(t.type)}),r},c=function(e){if(!o.isHexStrict(e))throw new Error("The parameter must be a valid HEX string.");var t="",r=0,n=e.length;for("0x"===e.substring(0,2)&&(r=2);r7?r+=e[n].toUpperCase():r+=e[n];return r},toHex:o.toHex,toBN:o.toBN,bytesToHex:o.bytesToHex,hexToBytes:o.hexToBytes,hexToNumberString:o.hexToNumberString,hexToNumber:o.hexToNumber,toDecimal:o.hexToNumber,numberToHex:o.numberToHex,fromDecimal:o.numberToHex,hexToUtf8:o.hexToUtf8,hexToString:o.hexToUtf8,toUtf8:o.hexToUtf8,utf8ToHex:o.utf8ToHex,stringToHex:o.utf8ToHex,fromUtf8:o.utf8ToHex,hexToAscii:c,toAscii:c,asciiToHex:f,fromAscii:f,unitMap:i.unitMap,toWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.toWei(e,t):i.toWei(e,t).toString(10)},fromWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.fromWei(e,t):i.fromWei(e,t).toString(10)},padLeft:o.leftPad,leftPad:o.leftPad,padRight:o.rightPad,rightPad:o.rightPad,toTwosComplement:o.toTwosComplement}},{"./soliditySha3.js":404,"./utils.js":405,"ethjs-unit":153,randomhex:274,underscore:325}],404:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("./utils.js"),a=function(e){var t=typeof e;if("string"===t)return o.isHexStrict(e)?new i(e.replace(/0x/i,""),16):new i(e,10);if("number"===t)return new i(e);if(o.isBigNumber(e))return new i(e.toString(10));if(o.isBN(e))return e;throw new Error(e+" is not a number")},s=function(e,t,r){var n,s,u;if("bytes"===(e=(u=e).startsWith("int[")?"int256"+u.slice(3):"int"===u?"int256":u.startsWith("uint[")?"uint256"+u.slice(4):"uint"===u?"uint256":u.startsWith("fixed[")?"fixed128x128"+u.slice(5):"fixed"===u?"fixed128x128":u.startsWith("ufixed[")?"ufixed128x128"+u.slice(6):"ufixed"===u?"ufixed128x128":u)){if(t.replace(/^0x/i,"").length%2!=0)throw new Error("Invalid bytes characters "+t.length);return t}if("string"===e)return o.utf8ToHex(t);if("bool"===e)return t?"01":"00";if(e.startsWith("address")){if(n=r?64:40,!o.isAddress(t))throw new Error(t+" is not a valid address, or the checksum is invalid.");return o.leftPad(t.toLowerCase(),n)}if(n=function(e){var t=/^\D+(\d+).*$/.exec(e);return t?parseInt(t[1],10):null}(e),e.startsWith("bytes")){if(!n)throw new Error("bytes[] not yet supported in solidity");if(r&&(n=32),n<1||n>32||n256)throw new Error("Invalid uint"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied uint exceeds width: "+n+" vs "+s.bitLength());if(s.lt(new i(0)))throw new Error("Supplied uint "+s.toString()+" is negative");return n?o.leftPad(s.toString("hex"),n/8*2):s}if(e.startsWith("int")){if(n%8||n<8||n>256)throw new Error("Invalid int"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied int exceeds width: "+n+" vs "+s.bitLength());return s.lt(new i(0))?s.toTwos(n).toString("hex"):n?o.leftPad(s.toString("hex"),n/8*2):s}throw new Error("Unsupported or invalid type: "+e)},u=function(e){if(n.isArray(e))throw new Error("Autodetection of array types is not supported.");var t,r,a="";if(n.isObject(e)&&(e.hasOwnProperty("v")||e.hasOwnProperty("t")||e.hasOwnProperty("value")||e.hasOwnProperty("type"))?(t=e.hasOwnProperty("t")?e.t:e.type,a=e.hasOwnProperty("v")?e.v:e.value):(t=o.toHex(e,!0),a=o.toHex(e),t.startsWith("int")||t.startsWith("uint")||(t="bytes")),!t.startsWith("int")&&!t.startsWith("uint")||"string"!=typeof a||/^(-)?0x/i.test(a)||(a=new i(a)),n.isArray(a)){if((r=function(e){var t=/^\D+\d*\[(\d+)\]$/.exec(e);return t?parseInt(t[1],10):null}(t))&&a.length!==r)throw new Error(t+" is not matching the given array "+JSON.stringify(a));r=a.length}return n.isArray(a)?a.map(function(e){return s(t,e,r).toString("hex").replace("0x","")}).join(""):s(t,a,r).toString("hex").replace("0x","")};t.exports=function(){var e=Array.prototype.slice.call(arguments),t=n.map(e,u);return o.sha3("0x"+t.join(""))}},{"./utils.js":405,"bn.js":402,underscore:325}],405:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("number-to-bn"),a=e("utf8"),s=e("eth-lib/lib/hash"),u=function(e){return e instanceof i||e&&e.constructor&&"BN"===e.constructor.name},c=function(e){return e&&e.constructor&&"BigNumber"===e.constructor.name},f=function(e){try{return o.apply(null,arguments)}catch(t){throw new Error(t+' Given value: "'+e+'"')}},h=function(e){return!!/^(0x)?[0-9a-f]{40}$/i.test(e)&&(!(!/^(0x|0X)?[0-9a-f]{40}$/.test(e)&&!/^(0x|0X)?[0-9A-F]{40}$/.test(e))||l(e))},l=function(e){e=e.replace(/^0x/i,"");for(var t=m(e.toLowerCase()).replace(/^0x/i,""),r=0;r<40;r++)if(parseInt(t[r],16)>7&&e[r].toUpperCase()!==e[r]||parseInt(t[r],16)<=7&&e[r].toLowerCase()!==e[r])return!1;return!0},d=function(e){var t="";e=(e=(e=(e=(e=a.encode(e)).replace(/^(?:\u0000)*/,"")).split("").reverse().join("")).replace(/^(?:\u0000)*/,"")).split("").reverse().join("");for(var r=0;r>>4).toString(16)),t.push((15&e[r]).toString(16));return"0x"+t.join("")},isHex:function(e){return(n.isString(e)||n.isNumber(e))&&/^(-0x|0x)?[0-9a-f]*$/i.test(e)},isHexStrict:y,leftPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+new Array(i).join(r||"0")+e},rightPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+e+new Array(i).join(r||"0")},toTwosComplement:function(e){return"0x"+f(e).toTwos(256).toString(16,64)},sha3:m}},{"bn.js":402,"eth-lib/lib/hash":134,"number-to-bn":237,underscore:325,utf8:329}],406:[function(e,t,r){t.exports={_from:"web3@1.0.0-beta.36",_id:"web3@1.0.0-beta.36",_inBundle:!1,_integrity:"sha512-fZDunw1V0AQS27r5pUN3eOVP7u8YAvyo6vOapdgVRolAu5LgaweP7jncYyLINqIX9ZgWdS5A090bt+ymgaYHsw==",_location:"/web3",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"web3@1.0.0-beta.36",name:"web3",escapedName:"web3",rawSpec:"1.0.0-beta.36",saveSpec:null,fetchSpec:"1.0.0-beta.36"},_requiredBy:["#USER","/"],_resolved:"https://registry.npmjs.org/web3/-/web3-1.0.0-beta.36.tgz",_shasum:"2954da9e431124c88396025510d840ba731c8373",_spec:"web3@1.0.0-beta.36",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy",author:{name:"ethereum.org"},authors:[{name:"Fabian Vogelsteller",email:"fabian@ethereum.org",homepage:"http://frozeman.de"},{name:"Marek Kotewicz",email:"marek@parity.io",url:"https://github.com/debris"},{name:"Marian Oancea",url:"https://github.com/cubedro"},{name:"Gav Wood",email:"g@parity.io",homepage:"http://gavwood.com"},{name:"Jeffery Wilcke",email:"jeffrey.wilcke@ethereum.org",url:"https://github.com/obscuren"}],bugs:{url:"https://github.com/ethereum/web3.js/issues"},bundleDependencies:!1,dependencies:{"web3-bzz":"1.0.0-beta.36","web3-core":"1.0.0-beta.36","web3-eth":"1.0.0-beta.36","web3-eth-personal":"1.0.0-beta.36","web3-net":"1.0.0-beta.36","web3-shh":"1.0.0-beta.36","web3-utils":"1.0.0-beta.36"},deprecated:!1,description:"Ethereum JavaScript API",keywords:["Ethereum","JavaScript","API"],license:"LGPL-3.0",main:"src/index.js",name:"web3",namespace:"ethereum",repository:{type:"git",url:"https://github.com/ethereum/web3.js/tree/master/packages/web3"},version:"1.0.0-beta.36"}},{}],407:[function(e,t,r){"use strict";var n=e("../package.json").version,i=e("web3-core"),o=e("web3-eth"),a=e("web3-net"),s=e("web3-eth-personal"),u=e("web3-shh"),c=e("web3-bzz"),f=e("web3-utils"),h=function(){var e=this;i.packageInit(this,arguments),this.version=n,this.utils=f,this.eth=new o(this),this.shh=new u(this),this.bzz=new c(this);var t=this.setProvider;this.setProvider=function(r,n){return t.apply(e,arguments),this.eth.setProvider(r,n),this.shh.setProvider(r,n),this.bzz.setProvider(r),!0}};h.version=n,h.utils=f,h.modules={Eth:o,Net:a,Personal:s,Shh:u,Bzz:c},i.addProviders(h),t.exports=h},{"../package.json":406,"web3-bzz":335,"web3-core":348,"web3-eth":371,"web3-eth-personal":369,"web3-net":372,"web3-shh":401,"web3-utils":403}],408:[function(e,t,r){var n=function(){return this||{}}(),i=n.WebSocket||n.MozWebSocket,o=e("./version");function a(e,t){return t?new i(e,t):new i(e)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(e){Object.defineProperty(a,e,{get:function(){return i[e]}})}),t.exports={w3cwebsocket:i?a:null,version:o}},{"./version":409}],409:[function(e,t,r){t.exports=e("../package.json").version},{"../package.json":410}],410:[function(e,t,r){t.exports={_from:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_id:"websocket@1.0.26",_inBundle:!1,_integrity:"",_location:"/websocket",_phantomChildren:{},_requested:{type:"git",raw:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",name:"websocket",escapedName:"websocket",rawSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",saveSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",fetchSpec:"git://github.com/frozeman/WebSocket-Node.git",gitCommittish:"browserifyCompatible"},_requiredBy:["/web3-providers-ws"],_resolved:"git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",_spec:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy/node_modules/web3-providers-ws",author:{name:"Brian McKelvey",email:"brian@worlize.com",url:"https://www.worlize.com/"},browser:"lib/browser.js",bugs:{url:"https://github.com/theturtle32/WebSocket-Node/issues"},bundleDependencies:!1,config:{verbose:!1},contributors:[{name:"Iñaki Baz Castillo",email:"ibc@aliax.net",url:"http://dev.sipdoc.net"}],dependencies:{debug:"^2.2.0",nan:"^2.3.3","typedarray-to-buffer":"^3.1.2",yaeti:"^0.0.6"},deprecated:!1,description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",devDependencies:{"buffer-equal":"^1.0.0",faucet:"^0.0.1",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-jshint":"^2.0.4",jshint:"^2.0.0","jshint-stylish":"^2.2.1",tape:"^4.0.1"},directories:{lib:"./lib"},engines:{node:">=0.10.0"},homepage:"https://github.com/theturtle32/WebSocket-Node",keywords:["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],license:"Apache-2.0",main:"index",name:"websocket",repository:{type:"git",url:"git+https://github.com/theturtle32/WebSocket-Node.git"},scripts:{gulp:"gulp",install:"(node-gyp rebuild 2> builderror.log) || (exit 0)",test:"faucet test/unit"},version:"1.0.26"}},{}],411:[function(e,t,r){var n=e("xhr-request");t.exports=function(e,t){return new Promise(function(r,i){n(e,t,function(e,t){e?i(e):r(t)})})}},{"xhr-request":412}],412:[function(e,t,r){var n=e("query-string"),i=e("url-set-query"),o=e("object-assign"),a=e("./lib/ensure-header.js"),s=e("./lib/request.js"),u="application/json",c=function(){};t.exports=function(e,t,r){if(!e||"string"!=typeof e)throw new TypeError("must specify a URL");"function"==typeof t&&(r=t,t={});if(r&&"function"!=typeof r)throw new TypeError("expected cb to be undefined or a function");r=r||c;var f=(t=t||{}).json?"json":"text",h=(t=o({responseType:f},t)).headers||{},l=(t.method||"GET").toUpperCase(),d=t.query;d&&("string"!=typeof d&&(d=n.stringify(d)),e=i(e,d));"json"===t.responseType&&a(h,"Accept",u);t.json&&"GET"!==l&&"HEAD"!==l&&(a(h,"Content-Type",u),t.body=JSON.stringify(t.body));return t.method=l,t.url=e,t.headers=h,delete t.query,delete t.json,s(t,r)}},{"./lib/ensure-header.js":413,"./lib/request.js":415,"object-assign":238,"query-string":266,"url-set-query":326}],413:[function(e,t,r){t.exports=function(e,t,r){var n=t.toLowerCase();e[t]||e[n]||(e[t]=r)}},{}],414:[function(e,t,r){t.exports=function(e,t){return t?{statusCode:t.statusCode,headers:t.headers,method:e.method,url:e.url,rawRequest:t.rawRequest?t.rawRequest:t}:null}},{}],415:[function(e,t,r){var n=e("xhr"),i=e("./normalize-response"),o=function(){};t.exports=function(e,t){delete e.uri;var r=!1;"json"===e.responseType&&(e.responseType="text",r=!0);var a=n(e,function(n,a,s){if(r&&!n)try{var u=a.rawRequest.responseText;s=JSON.parse(u)}catch(e){n=e}a=i(e,a),t(n,n?null:s,a),t=o}),s=a.onabort;return a.onabort=function(){var e=s.apply(a,Array.prototype.slice.call(arguments));return t(new Error("XHR Aborted")),t=o,e},a}},{"./normalize-response":414,xhr:416}],416:[function(e,t,r){"use strict";var n=e("global/window"),i=e("is-function"),o=e("parse-headers"),a=e("xtend");function s(e,t,r){var n=e;return i(t)?(r=t,"string"==typeof e&&(n={uri:e})):n=a(t,{uri:e}),n.callback=r,n}function u(e,t,r){return c(t=s(e,t,r))}function c(e){if(void 0===e.callback)throw new Error("callback argument missing");var t=!1,r=function(r,n,i){t||(t=!0,e.callback(r,n,i))};function n(e){return clearTimeout(f),e instanceof Error||(e=new Error(""+(e||"Unknown XMLHttpRequest Error"))),e.statusCode=0,r(e,m)}function i(){if(!s){var t;clearTimeout(f),t=e.useXDR&&void 0===c.status?200:1223===c.status?204:c.status;var n=m,i=null;return 0!==t?(n={body:function(){var e=void 0;if(e=c.response?c.response:c.responseText||function(e){try{if("document"===e.responseType)return e.responseXML;var t=e.responseXML&&"parsererror"===e.responseXML.documentElement.nodeName;if(""===e.responseType&&!t)return e.responseXML}catch(e){}return null}(c),y)try{e=JSON.parse(e)}catch(e){}return e}(),statusCode:t,method:l,headers:{},url:h,rawRequest:c},c.getAllResponseHeaders&&(n.headers=o(c.getAllResponseHeaders()))):i=new Error("Internal XMLHttpRequest Error"),r(i,n,n.body)}}var a,s,c=e.xhr||null;c||(c=e.cors||e.useXDR?new u.XDomainRequest:new u.XMLHttpRequest);var f,h=c.url=e.uri||e.url,l=c.method=e.method||"GET",d=e.body||e.data,p=c.headers=e.headers||{},b=!!e.sync,y=!1,m={body:void 0,headers:{},statusCode:0,method:l,url:h,rawRequest:c};if("json"in e&&!1!==e.json&&(y=!0,p.accept||p.Accept||(p.Accept="application/json"),"GET"!==l&&"HEAD"!==l&&(p["content-type"]||p["Content-Type"]||(p["Content-Type"]="application/json"),d=JSON.stringify(!0===e.json?d:e.json))),c.onreadystatechange=function(){4===c.readyState&&setTimeout(i,0)},c.onload=i,c.onerror=n,c.onprogress=function(){},c.onabort=function(){s=!0},c.ontimeout=n,c.open(l,h,!b,e.username,e.password),b||(c.withCredentials=!!e.withCredentials),!b&&e.timeout>0&&(f=setTimeout(function(){if(!s){s=!0,c.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT",n(e)}},e.timeout)),c.setRequestHeader)for(a in p)p.hasOwnProperty(a)&&c.setRequestHeader(a,p[a]);else if(e.headers&&!function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}(e.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in e&&(c.responseType=e.responseType),"beforeSend"in e&&"function"==typeof e.beforeSend&&e.beforeSend(c),c.send(d||null),c}t.exports=u,t.exports.default=u,u.XMLHttpRequest=n.XMLHttpRequest||function(){},u.XDomainRequest="withCredentials"in new u.XMLHttpRequest?u.XMLHttpRequest:n.XDomainRequest,function(e,t){for(var r=0;r=0)return this._url=this._parseUrl(t.headers.location),this._method="GET",this._loweredHeaders["content-type"]&&(delete this._headers[this._loweredHeaders["content-type"]],delete this._loweredHeaders["content-type"]),null!=this._headers["Content-Type"]&&delete this._headers["Content-Type"],delete this._headers["Content-Length"],this.upload._reset(),this._finalizeHeaders(),void this._sendHxxpRequest();this._response=t,this._response.on("data",function(e){return n._onHttpResponseData(t,e)}),this._response.on("end",function(){return n._onHttpResponseEnd(t)}),this._response.on("close",function(){return n._onHttpResponseClose(t)}),this.responseUrl=this._url.href.split("#")[0],this.status=t.statusCode,this.statusText=s.STATUS_CODES[this.status],this._parseResponseHeaders(t);var i=this._responseHeaders["content-length"]||"";this._totalBytes=+i,this._lengthComputable=!!i,this._setReadyState(r.HEADERS_RECEIVED)}},r.prototype._onHttpResponseData=function(e,t){this._response===e&&(this._responseParts.push(new n(t)),this._loadedBytes+=t.length,this.readyState!==r.LOADING&&this._setReadyState(r.LOADING),this._dispatchProgress("progress"))},r.prototype._onHttpResponseEnd=function(e){this._response===e&&(this._parseResponse(),this._request=null,this._response=null,this._setReadyState(r.DONE),this._dispatchProgress("load"),this._dispatchProgress("loadend"))},r.prototype._onHttpResponseClose=function(e){if(this._response===e){var t=this._request;this._setError(),t.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend")}},r.prototype._onHttpTimeout=function(e){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("timeout"),this._dispatchProgress("loadend"))},r.prototype._onHttpRequestError=function(e,t){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend"))},r.prototype._dispatchProgress=function(e){var t=new r.ProgressEvent(e);t.lengthComputable=this._lengthComputable,t.loaded=this._loadedBytes,t.total=this._totalBytes,this.dispatchEvent(t)},r.prototype._setError=function(){this._request=null,this._response=null,this._responseHeaders=null,this._responseParts=null},r.prototype._parseUrl=function(e,t,r){var n=null==this.nodejsBaseUrl?e:f.resolve(this.nodejsBaseUrl,e),i=f.parse(n,!1,!0);i.hash=null;var o=(i.auth||"").split(":"),a=o[0],s=o[1];return(a||s||t||r)&&(i.auth=(t||a||"")+":"+(r||s||"")),i},r.prototype._parseResponseHeaders=function(e){for(var t in this._responseHeaders={},e.headers){var r=t.toLowerCase();this._privateHeaders[r]||(this._responseHeaders[r]=e.headers[t])}null!=this._mimeOverride&&(this._responseHeaders["content-type"]=this._mimeOverride)},r.prototype._parseResponse=function(){var e=n.concat(this._responseParts);switch(this._responseParts=null,this.responseType){case"json":this.responseText=null;try{this.response=JSON.parse(e.toString("utf-8"))}catch(e){this.response=null}return;case"buffer":return this.responseText=null,void(this.response=e);case"arraybuffer":this.responseText=null;for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),i=0;i0&&(window.web3.eth.defaultAccount=t[0])})}window.ethereum=s}}},console.log("JS bridging rpc url access"),"undefined"!=typeof window&&window.bridge?window.bridge.post("getRPCurl",{},function(e,r){r&&t(r.description,null),t(null,e.rpcURL)}):(console.log("No bridge to native code is found"),t(!0,null))}()},{"./wk.bridge":424,web3:407,"web3-provider-engine/zero.js":397}],2:[function(e,t,r){t.exports=e("./register")().Promise},{"./register":4}],3:[function(e,t,r){"use strict";var n=null;t.exports=function(e,t){return function(r,i){r=r||null;var o=!1!==(i=i||{}).global;if(null===n&&o&&(n=e["@@any-promise/REGISTRATION"]||null),null!==n&&null!==r&&n.implementation!==r)throw new Error('any-promise already defined as "'+n.implementation+'". You can only register an implementation before the first call to require("any-promise") and an implementation cannot be changed');return null===n&&(n=null!==r&&void 0!==i.Promise?{Promise:i.Promise,implementation:r}:t(r),o&&(e["@@any-promise/REGISTRATION"]=n)),n}}},{}],4:[function(e,t,r){"use strict";t.exports=e("./loader")(window,function(){if(void 0===window.Promise)throw new Error("any-promise browser requires a polyfill or explicit registration e.g: require('any-promise/register/bluebird')");return{Promise:window.Promise,implementation:"window.Promise"}})},{"./loader":3}],5:[function(e,t,r){var n=r;n.bignum=e("bn.js"),n.define=e("./asn1/api").define,n.base=e("./asn1/base"),n.constants=e("./asn1/constants"),n.decoders=e("./asn1/decoders"),n.encoders=e("./asn1/encoders")},{"./asn1/api":6,"./asn1/base":8,"./asn1/constants":12,"./asn1/decoders":14,"./asn1/encoders":17,"bn.js":53}],6:[function(e,t,r){var n=e("../asn1"),i=e("inherits");function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}r.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(t){var r;try{r=e("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){r=function(e){this._initNamed(e)}}return i(r,t),r.prototype._initNamed=function(e){t.call(this,e)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(n.decoders[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(n.encoders[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},{"../asn1":5,inherits:180,vm:334}],7:[function(e,t,r){var n=e("inherits"),i=e("../base").Reporter,o=e("buffer").Buffer;function a(e,t){i.call(this,t),o.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function s(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return e instanceof s||(e=new s(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=o.byteLength(e);else{if(!o.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}n(a,i),r.DecoderBuffer=a,a.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},a.prototype.restore=function(e){var t=new a(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,i.prototype.restore.call(this,e.reporter),t},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},a.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new a(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},a.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},r.EncoderBuffer=s,s.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length?e:(Array.isArray(this.value)?this.value.forEach(function(r){r.join(e,t),t+=r.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):o.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},{"../base":8,buffer:84,inherits:180}],8:[function(e,t,r){var n=r;n.Reporter=e("./reporter").Reporter,n.DecoderBuffer=e("./buffer").DecoderBuffer,n.EncoderBuffer=e("./buffer").EncoderBuffer,n.Node=e("./node")},{"./buffer":7,"./node":9,"./reporter":10}],9:[function(e,t,r){var n=e("../base").Reporter,i=e("../base").EncoderBuffer,o=e("../base").DecoderBuffer,a=e("minimalistic-assert"),s=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],u=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function c(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}t.exports=c;var f=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){var e=this._baseState,t={};f.forEach(function(r){t[r]=e[r]});var r=new this.constructor(t.parent);return r._baseState=t,r},c.prototype._wrap=function(){var e=this._baseState;u.forEach(function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}},this)},c.prototype._init=function(e){var t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter(function(e){return e._baseState.parent===this},this),a.equal(t.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(e){var t=this._baseState,r=e.filter(function(e){return e instanceof this.constructor},this);e=e.filter(function(e){return!(e instanceof this.constructor)},this),0!==r.length&&(a(null===t.children),t.children=r,r.forEach(function(e){e._baseState.parent=this},this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map(function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach(function(r){r==(0|r)&&(r|=0);var n=e[r];t[n]=r}),t}))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(e){c.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}}),s.forEach(function(e){c.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(r),this}}),c.prototype.use=function(e){a(e);var t=this._baseState;return a(null===t.use),t.use=e,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(e){var t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},c.prototype.explicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},c.prototype.implicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},c.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},c.prototype.key=function(e){var t=this._baseState;return a(null===t.key),t.key=e,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(e){var t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map(function(t){return e[t]})),this},c.prototype.contains=function(e){var t=this._baseState;return a(null===t.use),t.contains=e,this},c.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var n,i=r.default,a=!0,s=null;if(null!==r.key&&(s=e.enterKey(r.key)),r.optional){var u=null;if(null!==r.explicit?u=r.explicit:null!==r.implicit?u=r.implicit:null!==r.tag&&(u=r.tag),null!==u||r.any){if(a=this._peekTag(e,u,r.any),e.isError(a))return a}else{var c=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(c)}}if(r.obj&&a&&(n=e.enterObject()),a){if(null!==r.explicit){var f=this._decodeTag(e,r.explicit);if(e.isError(f))return f;e=f}var h=e.offset;if(null===r.use&&null===r.choice){if(r.any)c=e.save();var l=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(l))return l;r.any?i=e.raw(c):e=l}if(t&&t.track&&null!==r.tag&&t.track(e.path(),h,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),i=r.any?i:null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),e.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach(function(r){r._decode(e,t)}),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var d=new o(i);i=this._getUse(r.contains,e._reporterState.obj)._decode(d,t)}}return r.obj&&a&&(i=e.leaveObject(n)),null===r.key||null===i&&!0!==a?null!==s&&e.exitKey(s):e.leaveKey(s,r.key,i),i},c.prototype._decodeGeneric=function(e,t,r){var n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},c.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},c.prototype._decodeChoice=function(e,t){var r=this._baseState,n=null,i=!1;return Object.keys(r.choice).some(function(o){var a=e.save(),s=r.choice[o];try{var u=s._decode(e,t);if(e.isError(u))return!1;n={type:o,value:u},i=!0}catch(t){return e.restore(a),!1}return!0},this),i?n:e.error("Choice not matched")},c.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},c.prototype._encode=function(e,t,r){var n=this._baseState;if(null===n.default||n.default!==e){var i=this._encodeValue(e,t,r);if(void 0!==i&&!this._skipDefault(i,t,r))return i}},c.prototype._encodeValue=function(e,t,r){var i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);var o=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}var a=null,s=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)a=this._getUse(i.contains,r)._encode(e,t),s=!0;else if(i.children)a=i.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i},this).filter(function(e){return e}),a=this._createEncoderBuffer(a);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var u=this.clone();u._baseState.implicit=null,a=this._createEncoderBuffer(e.map(function(r){var n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)},u))}else null!==i.use?o=this._getUse(i.use,r)._encode(e,t):(a=this._encodePrimitive(i.tag,e),s=!0);if(!i.any&&null===i.choice){var c=null!==i.implicit?i.implicit:i.tag,f=null===i.implicit?"universal":"context";null===c?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(c,s,f,a))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},c.prototype._encodeChoice=function(e,t){var r=this._baseState,n=r.choice[e.type];return n||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},c.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},c.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},c.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},{"../base":8,"minimalistic-assert":234}],10:[function(e,t,r){var n=e("inherits");function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}r.Reporter=i,i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,r){var n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){var t,r=this._reporterState,n=e instanceof o;if(t=n?e:new o(r.path.map(function(e){return"["+JSON.stringify(e)+"]"}).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},i.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},n(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{inherits:180}],11:[function(e,t,r){var n=e("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=n._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=n._reverse(r.tag)},{"../constants":12}],12:[function(e,t,r){var n=r;n._reverse=function(e){var t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r|=0);var n=e[r];t[n]=r}),t},n.der=e("./der")},{"./der":11}],13:[function(e,t,r){var n=e("inherits"),i=e("../../asn1"),o=i.base,a=i.bignum,s=i.constants.der;function u(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){o.Node.call(this,"der",e)}function f(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var n=s.tagClass[r>>6],i=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:s.tag[r]}}function h(e,t,r){var n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;var i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(var o=0;o=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=s.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(n.length<128)return(o=new i(2))[0]=a,o[1]=n.length,this._createEncoderBuffer([o,n]);for(var u=1,c=n.length;c>=256;c>>=8)u++;(o=new i(2+u))[0]=a,o[1]=128|u;c=1+u;for(var f=n.length;f>0;c--,f>>=8)o[c]=255&f;return this._createEncoderBuffer([o,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new i(2*e.length),n=0;n=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var o=0;for(n=0;n=128;a>>=7)o++}var s=new i(o),u=s.length-1;for(n=e.length-1;n>=0;n--){a=e[n];for(s[u--]=127&a;(a>>=7)>0;)s[u--]=128|127&a}return this._createEncoderBuffer(s)},c.prototype._encodeTime=function(e,t){var r,n=new Date(e);return"gentime"===t?r=[f(n.getFullYear()),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[f(n.getFullYear()%100),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!i.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new i(r)}if(i.isBuffer(e)){var n=e.length;0===e.length&&n++;var o=new i(n);return e.copy(o),0===e.length&&(o[0]=0),this._createEncoderBuffer(o)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);n=1;for(var a=e;a>=256;a>>=8)n++;for(a=(o=new Array(n)).length-1;a>=0;a--)o[a]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new i(o))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){var n,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,r).join()),o.length!==i.defaultBuffer.length)return!1;for(n=0;n=0;c--)if(f[c]!==h[c])return!1;for(c=f.length-1;c>=0;c--)if(u=f[c],!v(e[u],t[u],r,n))return!1;return!0}(e,t,r,a))}return r?e===t:e==t}function g(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function w(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function _(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&y(i,r,"Missing expected exception"+n);var a="string"==typeof n,s=!e&&i&&!r;if((!e&&o.isError(i)&&a&&w(i,r)||s)&&y(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(i,r)||!e&&i)throw i}h.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=p(b((t=this).actual),128)+" "+t.operator+" "+p(b(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=d(r),a=i.indexOf("\n"+o);if(a>=0){var s=i.indexOf("\n",a+1);i=i.substring(s+1)}this.stack=i}}},o.inherits(h.AssertionError,Error),h.fail=y,h.ok=m,h.equal=function(e,t,r){e!=t&&y(e,t,r,"==",h.equal)},h.notEqual=function(e,t,r){e==t&&y(e,t,r,"!=",h.notEqual)},h.deepEqual=function(e,t,r){v(e,t,!1)||y(e,t,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(e,t,r){v(e,t,!0)||y(e,t,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(e,t,r){v(e,t,!1)&&y(e,t,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function e(t,r,n){v(t,r,!0)&&y(t,r,n,"notDeepStrictEqual",e)},h.strictEqual=function(e,t,r){e!==t&&y(e,t,r,"===",h.strictEqual)},h.notStrictEqual=function(e,t,r){e===t&&y(e,t,r,"!==",h.notStrictEqual)},h.throws=function(e,t,r){_(!0,e,t,r)},h.doesNotThrow=function(e,t,r){_(!1,e,t,r)},h.ifError=function(e){if(e)throw e};var A=Object.keys||function(e){var t=[];for(var r in e)a.call(e,r)&&t.push(r);return t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":333}],20:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){return(0,i.default)(function(t,r){var i;try{i=e.apply(this,t)}catch(e){return r(e)}(0,n.default)(i)&&"function"==typeof i.then?i.then(function(e){s(r,null,e)},function(e){s(r,e.message?e:new Error(e))}):r(null,i)})};var n=a(e("lodash/isObject")),i=a(e("./internal/initialParams")),o=a(e("./internal/setImmediate"));function a(e){return e&&e.__esModule?e:{default:e}}function s(e,t,r){try{e(t,r)}catch(e){(0,o.default)(u,e)}}function u(e){throw e}t.exports=r.default},{"./internal/initialParams":31,"./internal/setImmediate":37,"lodash/isObject":225}],21:[function(e,t,r){(function(e,n){!function(e,n){"object"==typeof r&&void 0!==t?n(r):"function"==typeof define&&define.amd?define(["exports"],n):n(e.async=e.async||{})}(this,function(r){"use strict";function i(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i-1&&e%1==0&&e<=L}function D(e){return null!=e&&O(e.length)&&!function(e){if(!s(e))return!1;var t=B(e);return t==C||t==N||t==P||t==R}(e)}var F={};function q(){}function H(e){return function(){if(null!==e){var t=e;e=null,t.apply(this,arguments)}}}var z="function"==typeof Symbol&&Symbol.iterator,K=function(e){return z&&e[z]&&e[z]()};function V(e){return null!=e&&"object"==typeof e}var G="[object Arguments]";function W(e){return V(e)&&B(e)==G}var Y=Object.prototype,X=Y.hasOwnProperty,Z=Y.propertyIsEnumerable,J=W(function(){return arguments}())?W:function(e){return V(e)&&X.call(e,"callee")&&!Z.call(e,"callee")},$=Array.isArray;var Q="object"==typeof r&&r&&!r.nodeType&&r,ee=Q&&"object"==typeof t&&t&&!t.nodeType&&t,te=ee&&ee.exports===Q?A.Buffer:void 0,re=(te?te.isBuffer:void 0)||function(){return!1},ne=9007199254740991,ie=/^(?:0|[1-9]\d*)$/;function oe(e,t){return!!(t=null==t?ne:t)&&("number"==typeof e||ie.test(e))&&e>-1&&e%1==0&&e2&&(n=i(arguments,1)),t){var c={};Fe(o,function(e,t){c[t]=e}),c[e]=n,s=!0,u=Object.create(null),r(t,c)}else o[e]=n,Le(u[e]||[],function(e){e()}),d()});a++;var c=v(t[t.length-1]);t.length>1?c(o,n):c(n)}(e,t)})}function d(){if(0===c.length&&0===a)return r(null,o);for(;c.length&&a=0&&r.push(n)}),r}Fe(e,function(t,r){if(!$(t))return l(r,[t]),void f.push(r);var n=t.slice(0,t.length-1),i=n.length;if(0===i)return l(r,t),void f.push(r);h[r]=i,Le(n,function(o){if(!e[o])throw new Error("async.auto task `"+r+"` has a non-existent dependency `"+o+"` in "+n.join(", "));!function(e,t){var r=u[e];r||(r=u[e]=[]);r.push(t)}(o,function(){0===--i&&l(r,t)})})}),function(){var e,t=0;for(;f.length;)e=f.pop(),t++,Le(p(e),function(e){0==--h[e]&&f.push(e)});if(t!==n)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),d()};function Ke(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r=n?e:function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n-1;);return r}(i,o),function(e,t){for(var r=e.length;r--&&He(t,e[r],0)>-1;);return r}(i,o)+1).join("")}var ht=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,lt=/,/,dt=/(=.+)?(\s*)$/,pt=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;function bt(e,t){var r={};Fe(e,function(e,t){var n,i,o=m(e),a=!o&&1===e.length||o&&0===e.length;if($(e))n=e.slice(0,-1),e=e[e.length-1],r[t]=n.concat(n.length>0?s:e);else if(a)r[t]=e;else{if(n=i=(i=(i=(i=(i=e).toString().replace(pt,"")).match(ht)[2].replace(" ",""))?i.split(lt):[]).map(function(e){return ft(e.replace(dt,""))}),0===e.length&&!o&&0===n.length)throw new Error("autoInject task functions require explicit parameters.");o||n.pop(),r[t]=n.concat(s)}function s(t,r){var i=Ke(n,function(e){return t[e]});i.push(r),v(e).apply(null,i)}}),ze(r,t)}function yt(){this.head=this.tail=null,this.length=0}function mt(e,t){e.length=1,e.head=e.tail=t}function vt(e,t,r){if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var n=v(e),i=0,o=[],a=!1;function s(e,t,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(f.started=!0,$(e)||(e=[e]),0===e.length&&f.idle())return l(function(){f.drain()});for(var n=0,i=e.length;n0&&o.splice(s,1),a.callback.apply(a,arguments),null!=t&&f.error(t,a.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()}}var c=!1,f={_tasks:new yt,concurrency:t,payload:r,saturated:q,unsaturated:q,buffer:t/4,empty:q,drain:q,error:q,started:!1,paused:!1,push:function(e,t){s(e,!1,t)},kill:function(){f.drain=q,f._tasks.empty()},unshift:function(e,t){s(e,!0,t)},remove:function(e){f._tasks.remove(e)},process:function(){if(!c){for(c=!0;!f.paused&&i2&&(o=i(arguments,1)),n[t]=o,r(e)})},function(e){r(e,n)})}function br(e,t){pr(Ie,e,t)}function yr(e,t,r){pr(Ee(t),e,r)}var mr=function(e,t){var r=v(e);return vt(function(e,t){r(e[0],t)},t,1)},vr=function(e,t){var r=mr(e,t);return r.push=function(e,t,n){if(null==n&&(n=q),"function"!=typeof n)throw new Error("task callback must be a function");if(r.started=!0,$(e)||(e=[e]),0===e.length)return l(function(){r.drain()});t=t||0;for(var i=r._tasks.head;i&&t>=i.priority;)i=i.next;for(var o=0,a=e.length;on?1:0}je(e,function(e,t){n(e,function(r,n){if(r)return t(r);t(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);r(null,Ke(t.sort(i),Zt("value")))})}function Nr(e,t,r){var n=v(e);return a(function(i,o){var a,s=!1;i.push(function(){s||(o.apply(null,arguments),clearTimeout(a))}),a=setTimeout(function(){var t=e.name||"anonymous",n=new Error('Callback function "'+t+'" timed out.');n.code="ETIMEDOUT",r&&(n.info=r),s=!0,o(n)},t),n.apply(null,i)})}var Rr=Math.ceil,Lr=Math.max;function Or(e,t,r,n){var i=v(r);Ce(function(e,t,r,n){for(var i=-1,o=Lr(Rr((t-e)/(r||1)),0),a=Array(o);o--;)a[n?o:++i]=e,e+=r;return a}(0,e,1),t,i,n)}var Dr=ke(Or,1/0),Fr=ke(Or,1);function qr(e,t,r,n){arguments.length<=3&&(n=r,r=t,t=$(e)?[]:{}),n=H(n||q);var i=v(r);Ie(e,function(e,r,n){i(t,e,r,n)},function(e){n(e,t)})}function Hr(e,t){var r,n=null;t=t||q,Kt(e,function(e,t){v(e)(function(e,o){r=arguments.length>2?i(arguments,1):o,n=e,t(!e)})},function(){t(n,r)})}function zr(e){return function(){return(e.unmemoized||e).apply(null,arguments)}}function Kr(e,t,r){r=Ae(r||q);var n=v(t);if(!e())return r(null);var o=function(t){if(t)return r(t);if(e())return n(o);var a=i(arguments,1);r.apply(null,[null].concat(a))};n(o)}function Vr(e,t,r){Kr(function(){return!e.apply(this,arguments)},t,r)}var Gr=function(e,t){if(t=H(t||q),!$(e))return t(new Error("First argument to waterfall must be an array of functions"));if(!e.length)return t();var r=0;function n(t){var n=v(e[r++]);t.push(Ae(o)),n.apply(null,t)}function o(o){if(o||r===e.length)return t.apply(null,arguments);n(i(arguments,1))}n([])},Wr={apply:o,applyEach:Be,applyEachSeries:Re,asyncify:d,auto:ze,autoInject:bt,cargo:gt,compose:Et,concat:St,concatLimit:kt,concatSeries:Mt,constant:It,detect:Bt,detectLimit:Pt,detectSeries:Ct,dir:Rt,doDuring:Lt,doUntil:Dt,doWhilst:Ot,during:Ft,each:Ht,eachLimit:zt,eachOf:Ie,eachOfLimit:xe,eachOfSeries:wt,eachSeries:Kt,ensureAsync:Vt,every:Wt,everyLimit:Yt,everySeries:Xt,filter:er,filterLimit:tr,filterSeries:rr,forever:nr,groupBy:or,groupByLimit:ir,groupBySeries:ar,log:sr,map:je,mapLimit:Ce,mapSeries:Ne,mapValues:cr,mapValuesLimit:ur,mapValuesSeries:fr,memoize:lr,nextTick:dr,parallel:br,parallelLimit:yr,priorityQueue:vr,queue:mr,race:gr,reduce:_t,reduceRight:wr,reflect:_r,reflectAll:Ar,reject:xr,rejectLimit:kr,rejectSeries:Sr,retry:Ir,retryable:Tr,seq:At,series:Ur,setImmediate:l,some:jr,someLimit:Br,someSeries:Pr,sortBy:Cr,timeout:Nr,times:Dr,timesLimit:Or,timesSeries:Fr,transform:qr,tryEach:Hr,unmemoize:zr,until:Vr,waterfall:Gr,whilst:Kr,all:Wt,allLimit:Yt,allSeries:Xt,any:jr,anyLimit:Br,anySeries:Pr,find:Bt,findLimit:Pt,findSeries:Ct,forEach:Ht,forEachSeries:Kt,forEachLimit:zt,forEachOf:Ie,forEachOfSeries:wt,forEachOfLimit:xe,inject:_t,foldl:_t,foldr:wr,select:er,selectLimit:tr,selectSeries:rr,wrapSync:d};r.default=Wr,r.apply=o,r.applyEach=Be,r.applyEachSeries=Re,r.asyncify=d,r.auto=ze,r.autoInject=bt,r.cargo=gt,r.compose=Et,r.concat=St,r.concatLimit=kt,r.concatSeries=Mt,r.constant=It,r.detect=Bt,r.detectLimit=Pt,r.detectSeries=Ct,r.dir=Rt,r.doDuring=Lt,r.doUntil=Dt,r.doWhilst=Ot,r.during=Ft,r.each=Ht,r.eachLimit=zt,r.eachOf=Ie,r.eachOfLimit=xe,r.eachOfSeries=wt,r.eachSeries=Kt,r.ensureAsync=Vt,r.every=Wt,r.everyLimit=Yt,r.everySeries=Xt,r.filter=er,r.filterLimit=tr,r.filterSeries=rr,r.forever=nr,r.groupBy=or,r.groupByLimit=ir,r.groupBySeries=ar,r.log=sr,r.map=je,r.mapLimit=Ce,r.mapSeries=Ne,r.mapValues=cr,r.mapValuesLimit=ur,r.mapValuesSeries=fr,r.memoize=lr,r.nextTick=dr,r.parallel=br,r.parallelLimit=yr,r.priorityQueue=vr,r.queue=mr,r.race=gr,r.reduce=_t,r.reduceRight=wr,r.reflect=_r,r.reflectAll=Ar,r.reject=xr,r.rejectLimit=kr,r.rejectSeries=Sr,r.retry=Ir,r.retryable=Tr,r.seq=At,r.series=Ur,r.setImmediate=l,r.some=jr,r.someLimit=Br,r.someSeries=Pr,r.sortBy=Cr,r.timeout=Nr,r.times=Dr,r.timesLimit=Or,r.timesSeries=Fr,r.transform=qr,r.tryEach=Hr,r.unmemoize=zr,r.until=Vr,r.waterfall=Gr,r.whilst=Kr,r.all=Wt,r.allLimit=Yt,r.allSeries=Xt,r.any=jr,r.anyLimit=Br,r.anySeries=Pr,r.find=Bt,r.findLimit=Pt,r.findSeries=Ct,r.forEach=Ht,r.forEachSeries=Kt,r.forEachLimit=zt,r.forEachOf=Ie,r.forEachOfSeries=wt,r.forEachOfLimit=xe,r.inject=_t,r.foldl=_t,r.foldr=wr,r.select=er,r.selectLimit=tr,r.selectSeries=rr,r.wrapSync=d,Object.defineProperty(r,"__esModule",{value:!0})})}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257}],22:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r,a){(0,n.default)(t)(e,(0,i.default)((0,o.default)(r)),a)};var n=a(e("./internal/eachOfLimit")),i=a(e("./internal/withoutIndex")),o=a(e("./internal/wrapAsync"));function a(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./internal/eachOfLimit":29,"./internal/withoutIndex":39,"./internal/wrapAsync":40}],23:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r){((0,n.default)(e)?l:d)(e,(0,f.default)(t),r)};var n=h(e("lodash/isArrayLike")),i=h(e("./internal/breakLoop")),o=h(e("./eachOfLimit")),a=h(e("./internal/doLimit")),s=h(e("lodash/noop")),u=h(e("./internal/once")),c=h(e("./internal/onlyOnce")),f=h(e("./internal/wrapAsync"));function h(e){return e&&e.__esModule?e:{default:e}}function l(e,t,r){r=(0,u.default)(r||s.default);var n=0,o=0,a=e.length;function f(e,t){e?r(e):++o!==a&&t!==i.default||r(null)}for(0===a&&r(null);n2&&(n=(0,o.default)(arguments,1)),s[t]=n,r(e)})},function(e){r(e,s)})};var n=s(e("lodash/noop")),i=s(e("lodash/isArrayLike")),o=s(e("./slice")),a=s(e("./wrapAsync"));function s(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./slice":38,"./wrapAsync":40,"lodash/isArrayLike":221,"lodash/noop":229}],37:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.hasNextTick=r.hasSetImmediate=void 0,r.fallback=c,r.wrap=f;var n,i=e("./slice"),o=(n=i)&&n.__esModule?n:{default:n};var a,s=r.hasSetImmediate="function"==typeof setImmediate&&setImmediate,u=r.hasNextTick="object"==typeof t&&"function"==typeof t.nextTick;function c(e){setTimeout(e,0)}function f(e){return function(t){var r=(0,o.default)(arguments,1);e(function(){t.apply(null,r)})}}a=s?setImmediate:u?t.nextTick:c,r.default=f(a)}).call(this,e("_process"))},{"./slice":38,_process:257}],38:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i0,"Expected a maximum number of retry greater than 0 but got %s.",e),this.maxNumberOfRetry_=e},o.prototype.backoff=function(e){i.checkState(-1===this.timeoutID_,"Backoff in progress."),this.backoffNumber_===this.maxNumberOfRetry_?(this.emit("fail",e),this.reset()):(this.backoffDelay_=this.backoffStrategy_.next(),this.timeoutID_=setTimeout(this.handlers.backoff,this.backoffDelay_),this.emit("backoff",this.backoffNumber_,this.backoffDelay_,e))},o.prototype.onBackoff_=function(){this.timeoutID_=-1,this.emit("ready",this.backoffNumber_,this.backoffDelay_),this.backoffNumber_++},o.prototype.reset=function(){this.backoffNumber_=0,this.backoffStrategy_.reset(),clearTimeout(this.timeoutID_),this.timeoutID_=-1},t.exports=o},{events:157,precond:253,util:333}],47:[function(e,t,r){var n=e("events"),i=e("precond"),o=e("util"),a=e("./backoff"),s=e("./strategy/fibonacci");function u(e,t,r){n.EventEmitter.call(this),i.checkIsFunction(e,"Expected fn to be a function."),i.checkIsArray(t,"Expected args to be an array."),i.checkIsFunction(r,"Expected callback to be a function."),this.function_=e,this.arguments_=t,this.callback_=r,this.lastResult_=[],this.numRetries_=0,this.backoff_=null,this.strategy_=null,this.failAfter_=-1,this.retryPredicate_=u.DEFAULT_RETRY_PREDICATE_,this.state_=u.State_.PENDING}o.inherits(u,n.EventEmitter),u.State_={PENDING:0,RUNNING:1,COMPLETED:2,ABORTED:3},u.DEFAULT_RETRY_PREDICATE_=function(e){return!0},u.prototype.isPending=function(){return this.state_==u.State_.PENDING},u.prototype.isRunning=function(){return this.state_==u.State_.RUNNING},u.prototype.isCompleted=function(){return this.state_==u.State_.COMPLETED},u.prototype.isAborted=function(){return this.state_==u.State_.ABORTED},u.prototype.setStrategy=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.strategy_=e,this},u.prototype.retryIf=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.retryPredicate_=e,this},u.prototype.getLastResult=function(){return this.lastResult_.concat()},u.prototype.getNumRetries=function(){return this.numRetries_},u.prototype.failAfter=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.failAfter_=e,this},u.prototype.abort=function(){this.isCompleted()||this.isAborted()||(this.isRunning()&&this.backoff_.reset(),this.state_=u.State_.ABORTED,this.lastResult_=[new Error("Backoff aborted.")],this.emit("abort"),this.doCallback_())},u.prototype.start=function(e){i.checkState(!this.isAborted(),"FunctionCall is aborted."),i.checkState(this.isPending(),"FunctionCall already started.");var t=this.strategy_||new s;this.backoff_=e?e(t):new a(t),this.backoff_.on("ready",this.doCall_.bind(this,!0)),this.backoff_.on("fail",this.doCallback_.bind(this)),this.backoff_.on("backoff",this.handleBackoff_.bind(this)),this.failAfter_>0&&this.backoff_.failAfter(this.failAfter_),this.state_=u.State_.RUNNING,this.doCall_(!1)},u.prototype.doCall_=function(e){e&&this.numRetries_++;var t=["call"].concat(this.arguments_);n.EventEmitter.prototype.emit.apply(this,t);var r=this.handleFunctionCallback_.bind(this);this.function_.apply(null,this.arguments_.concat(r))},u.prototype.doCallback_=function(){this.callback_.apply(null,this.lastResult_)},u.prototype.handleFunctionCallback_=function(){if(!this.isAborted()){var e=Array.prototype.slice.call(arguments);this.lastResult_=e,n.EventEmitter.prototype.emit.apply(this,["callback"].concat(e));var t=e[0];t&&this.retryPredicate_(t)?this.backoff_.backoff(t):(this.state_=u.State_.COMPLETED,this.doCallback_())}},u.prototype.handleBackoff_=function(e,t,r){this.emit("backoff",e,t,r)},t.exports=u},{"./backoff":46,"./strategy/fibonacci":49,events:157,precond:253,util:333}],48:[function(e,t,r){var n=e("util"),i=e("precond"),o=e("./strategy");function a(e){o.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay(),this.factor_=a.DEFAULT_FACTOR,e&&void 0!==e.factor&&(i.checkArgument(e.factor>1,"Exponential factor should be greater than 1 but got %s.",e.factor),this.factor_=e.factor)}n.inherits(a,o),a.DEFAULT_FACTOR=2,a.prototype.next_=function(){return this.backoffDelay_=Math.min(this.nextBackoffDelay_,this.getMaxDelay()),this.nextBackoffDelay_=this.backoffDelay_*this.factor_,this.backoffDelay_},a.prototype.reset_=function(){this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()},t.exports=a},{"./strategy":50,precond:253,util:333}],49:[function(e,t,r){var n=e("util"),i=e("./strategy");function o(e){i.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}n.inherits(o,i),o.prototype.next_=function(){var e=Math.min(this.nextBackoffDelay_,this.getMaxDelay());return this.nextBackoffDelay_+=this.backoffDelay_,this.backoffDelay_=e,e},o.prototype.reset_=function(){this.nextBackoffDelay_=this.getInitialDelay(),this.backoffDelay_=0},t.exports=o},{"./strategy":50,util:333}],50:[function(e,t,r){e("events"),e("util");function n(e){return null!=e}function i(e){if(n((e=e||{}).initialDelay)&&e.initialDelay<1)throw new Error("The initial timeout must be greater than 0.");if(n(e.maxDelay)&&e.maxDelay<1)throw new Error("The maximal timeout must be greater than 0.");if(this.initialDelay_=e.initialDelay||100,this.maxDelay_=e.maxDelay||1e4,this.maxDelay_<=this.initialDelay_)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");if(n(e.randomisationFactor)&&(e.randomisationFactor<0||e.randomisationFactor>1))throw new Error("The randomisation factor must be between 0 and 1.");this.randomisationFactor_=e.randomisationFactor||0}i.prototype.getMaxDelay=function(){return this.maxDelay_},i.prototype.getInitialDelay=function(){return this.initialDelay_},i.prototype.next=function(){var e=this.next_(),t=1+Math.random()*this.randomisationFactor_;return Math.round(e*t)},i.prototype.next_=function(){throw new Error("BackoffStrategy.next_() unimplemented.")},i.prototype.reset=function(){this.reset_()},i.prototype.reset_=function(){throw new Error("BackoffStrategy.reset_() unimplemented.")},t.exports=i},{events:157,util:333}],51:[function(e,t,r){"use strict";r.byteLength=function(e){return 3*e.length/4-c(e)},r.toByteArray=function(e){var t,r,n,a,s,u=e.length;a=c(e),s=new o(3*u/4-a),r=a>0?u-4:u;var f=0;for(t=0;t>16&255,s[f++]=n>>8&255,s[f++]=255&n;2===a?(n=i[e.charCodeAt(t)]<<2|i[e.charCodeAt(t+1)]>>4,s[f++]=255&n):1===a&&(n=i[e.charCodeAt(t)]<<10|i[e.charCodeAt(t+1)]<<4|i[e.charCodeAt(t+2)]>>2,s[f++]=n>>8&255,s[f++]=255&n);return s},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o="",a=[],s=0,u=r-i;su?u:s+16383));1===i?(t=e[r-1],o+=n[t>>2],o+=n[t<<4&63],o+="=="):2===i&&(t=(e[r-2]<<8)+e[r-1],o+=n[t>>10],o+=n[t>>4&63],o+=n[t<<2&63],o+="=");return a.push(o),a.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function f(e,t,r){for(var i,o,a=[],s=t;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],52:[function(e,t,r){var n=e("safe-buffer").Buffer;t.exports={check:function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))},decode:function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");var r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},encode:function(e,t){var r=e.length,i=t.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(i>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+r]=2,o[5+r]=t.length,t.copy(o,6+r),o}}},{"safe-buffer":290}],53:[function(e,t,r){!function(t,r){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var a;"object"==typeof t?t.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{a=e("buffer").Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:55}],54:[function(e,t,r){var n;function i(e){this.rand=e}if(t.exports=function(e){return n||(n=new i(null)),n.generate(e)},t.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^t[m++],a=c[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^t[m++],s=c[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^t[m++],u=c[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^t[m++],d=o,p=a,b=s,y=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^t[m++],a=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^t[m++],s=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[m++],u=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^t[m++],[o>>>=0,a>>>=0,s>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],u=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,u=0;u<256;++u){var c=s^s<<1^s<<2^s<<3^s<<4;c=c>>>8^255&c^99,r[a]=c,n[c]=a;var f=e[a],h=e[f],l=e[h],d=257*e[c]^16843008*c;i[0][a]=d<<24|d>>>8,i[1][a]=d<<16|d>>>16,i[2][a]=d<<8|d>>>24,i[3][a]=d,d=16843009*l^65537*h^257*f^16843008*a,o[0][c]=d<<24|d>>>8,o[1][c]=d<<16|d>>>16,o[2][c]=d<<8|d>>>24,o[3][c]=d,0===a?a=s=1:(a=f^e[e[e[l^f]]],s^=e[e[s]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(e){this._key=i(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a],a^=s[o/t|0]<<24):t>6&&o%t==4&&(a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a]),i[o]=i[o-t]^a}for(var c=[],f=0;f>>24]]^u.INV_SUB_MIX[1][u.SBOX[l>>>16&255]]^u.INV_SUB_MIX[2][u.SBOX[l>>>8&255]]^u.INV_SUB_MIX[3][u.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},c.prototype.encryptBlockRaw=function(e){return a(e=i(e),this._keySchedule,u.SUB_MIX,u.SBOX,this._nRounds)},c.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=n.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},c.prototype.decryptBlock=function(e){var t=(e=i(e))[1];e[1]=e[3],e[3]=t;var r=a(e,this._invKeySchedule,u.INV_SUB_MIX,u.INV_SBOX,this._nRounds),o=n.allocUnsafe(16);return o.writeUInt32BE(r[0],0),o.writeUInt32BE(r[3],4),o.writeUInt32BE(r[2],8),o.writeUInt32BE(r[1],12),o},c.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},t.exports.AES=c},{"safe-buffer":290}],57:[function(e,t,r){var n=e("./aes"),i=e("safe-buffer").Buffer,o=e("cipher-base"),a=e("inherits"),s=e("./ghash"),u=e("buffer-xor"),c=e("./incr32");function f(e,t,r,a){o.call(this);var u=i.alloc(4,0);this._cipher=new n.AES(t);var f=this._cipher.encryptBlock(u);this._ghash=new s(f),r=function(e,t,r){if(12===t.length)return e._finID=i.concat([t,i.from([0,0,0,1])]),i.concat([t,i.from([0,0,0,2])]);var n=new s(r),o=t.length,a=o%16;n.update(t),a&&(a=16-a,n.update(i.alloc(a,0))),n.update(i.alloc(8,0));var u=8*o,f=i.alloc(8);f.writeUIntBE(u,0,8),n.update(f),e._finID=n.state;var h=i.from(e._finID);return c(h),h}(this,r,f),this._prev=i.from(r),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=a,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}a(f,o),f.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=i.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},f.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=u(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var n=Math.min(e.length,t.length),i=0;i16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},h.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(e,t){var r=o[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(t,!1,r.key,r.iv);return l(e,n.key,n.iv)},r.createDecipheriv=l},{"./aes":56,"./authCipher":57,"./modes":69,"./streamCipher":72,"cipher-base":86,evp_bytestokey:158,inherits:180,"safe-buffer":290}],60:[function(e,t,r){var n=e("./modes"),i=e("./authCipher"),o=e("safe-buffer").Buffer,a=e("./streamCipher"),s=e("cipher-base"),u=e("./aes"),c=e("evp_bytestokey");function f(e,t,r){s.call(this),this._cache=new l,this._cipher=new u.AES(t),this._prev=o.from(r),this._mode=e,this._autopadding=!0}e("inherits")(f,s),f.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get();)r=this._mode.encrypt(this,t),n.push(r);return o.concat(n)};var h=o.alloc(16,16);function l(){this.cache=o.allocUnsafe(0)}function d(e,t,r){var s=n[e.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=o.from(t)),t.length!==s.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=o.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new a(s.module,t,r):"auth"===s.type?new i(s.module,t,r):new f(s.module,t,r)}f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(h))throw this._cipher.scrub(),new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},l.prototype.add=function(e){this.cache=o.concat([this.cache,e])},l.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},l.prototype.flush=function(){for(var e=16-this.cache.length,t=o.allocUnsafe(e),r=-1;++r>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function a(e){this.h=e,this.state=n.alloc(16,0),this.cache=n.allocUnsafe(0)}a.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=o(i)},a.prototype.update=function(e){var t;for(this.cache=n.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},a.prototype.final=function(e,t){return this.cache.length&&this.ghash(n.concat([this.cache,i],16)),this.ghash(o([0,e,0,t])),this.state},t.exports=a},{"safe-buffer":290}],62:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],63:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":83}],64:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("buffer-xor");function o(e,t,r){var o=t.length,a=i(t,e._cache);return e._cache=e._cache.slice(o),e._prev=n.concat([e._prev,r?t:a]),a}r.encrypt=function(e,t,r){for(var i,a=n.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=n.allocUnsafe(0)),!(e._cache.length<=t.length)){a=n.concat([a,o(e,t,r)]);break}i=e._cache.length,a=n.concat([a,o(e,t.slice(0,i),r)]),t=t.slice(i)}return a}},{"buffer-xor":83,"safe-buffer":290}],65:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t,r){for(var n,i,a=-1,s=0;++a<8;)n=t&1<<7-a?128:0,s+=(128&(i=e._cipher.encryptBlock(e._prev)[0]^n))>>a%8,e._prev=o(e._prev,r?n:i);return s}function o(e,t){var r=e.length,i=-1,o=n.allocUnsafe(e.length);for(e=n.concat([e,n.from([t])]);++i>7;return o}r.encrypt=function(e,t,r){for(var o=t.length,a=n.allocUnsafe(o),s=-1;++s=0||!r.umod(e.prime1)||!r.umod(e.prime2);)r=new n(i(t));return r}t.exports=o,o.getr=a}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84,randombytes:270}],77:[function(e,t,r){t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":78}],78:[function(e,t,r){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],79:[function(e,t,r){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],80:[function(e,t,r){(function(r){var n=e("create-hash"),i=e("stream"),o=e("inherits"),a=e("./sign"),s=e("./verify"),u=e("./algorithms.json");function c(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function f(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function h(e){return new c(e)}function l(e){return new f(e)}Object.keys(u).forEach(function(e){u[e].id=new r(u[e].id,"hex"),u[e.toLowerCase()]=u[e]}),o(c,i.Writable),c.prototype._write=function(e,t,r){this._hash.update(e),r()},c.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},c.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),n=a(r,e,this._hashType,this._signType,this._tag);return t?n.toString(t):n},o(f,i.Writable),f.prototype._write=function(e,t,r){this._hash.update(e),r()},f.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},f.prototype.verify=function(e,t,n){"string"==typeof t&&(t=new r(t,n)),this.end();var i=this._hash.digest();return s(t,i,e,this._signType,this._tag)},t.exports={Sign:h,Verify:l,createSign:h,createVerify:l}}).call(this,e("buffer").Buffer)},{"./algorithms.json":78,"./sign":81,"./verify":82,buffer:84,"create-hash":91,inherits:180,stream:311}],81:[function(e,t,r){(function(r){var n=e("create-hmac"),i=e("browserify-rsa"),o=e("elliptic").ec,a=e("bn.js"),s=e("parse-asn1"),u=e("./curves.json");function c(e,t,i,o){if((e=new r(e.toArray())).length0&&r.ishrn(n),r}function h(e,t,i){var o,a;do{for(o=new r(0);8*o.length=t)throw new Error("invalid sig")}t.exports=function(e,t,u,c,f){var h=o(u);if("ec"===h.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var n=a[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),s=r.data.subjectPrivateKey.data;return o.verify(t,e,s)}(e,t,h)}if("dsa"===h.type){if("dsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var i=r.data.p,a=r.data.q,u=r.data.g,c=r.data.pub_key,f=o.signature.decode(e,"der"),h=f.s,l=f.r;s(h,a),s(l,a);var d=n.mont(i),p=h.invm(a);return 0===u.toRed(d).redPow(new n(t).mul(p).mod(a)).fromRed().mul(c.toRed(d).redPow(l.mul(p).mod(a)).fromRed()).mod(i).mod(a).cmp(l)}(e,t,h)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");t=r.concat([f,t]);for(var l=h.modulus.byteLength(),d=[1],p=0;t.length+d.length+2o)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=s.prototype,t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(e)}return u(e,t,r)}function u(e,t,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return F(e)?function(e,t,r){if(t<0||e.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function d(e,t){if(s.isBuffer(e))return e.length;if(q(e)||F(e))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return O(e).length;default:if(n)return L(e).length;t=(""+t).toLowerCase(),n=!0}}function p(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var o,a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var f=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function x(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return x(this,t,r);case"ascii":return S(this,t,r);case"latin1":case"binary":return M(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},s.prototype.compare=function(e,t,r,n,i){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),u=Math.min(o,a),c=this.slice(n,i),f=e.slice(t,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return m(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return g(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function S(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,r,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function B(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function C(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,8),i.write(e,t,r,n,52,8),r+8}s.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},s.prototype.readUInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeFloatLE=function(e,t,r){return P(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return P(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return C(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return C(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(e){return n.toByteArray(function(e){if((e=e.trim().replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function F(e){return e instanceof ArrayBuffer||null!=e&&null!=e.constructor&&"ArrayBuffer"===e.constructor.name&&"number"==typeof e.byteLength}function q(e){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(e)}function H(e){return e!=e}},{"base64-js":51,ieee754:178}],85:[function(e,t,r){t.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],86:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("stream").Transform,o=e("string_decoder").StringDecoder;function a(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(a,i),a.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},a.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},a.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},a.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},t.exports=a},{inherits:180,"safe-buffer":290,stream:311,string_decoder:317}],87:[function(e,t,r){(function(e){var r=function(){"use strict";function t(e,t){return null!=t&&e instanceof t}var r,n,i;try{r=Map}catch(e){r=function(){}}try{n=Set}catch(e){n=function(){}}try{i=Promise}catch(e){i=function(){}}function o(a,u,c,f,h){"object"==typeof u&&(c=u.depth,f=u.prototype,h=u.includeNonEnumerable,u=u.circular);var l=[],d=[],p=void 0!==e;return void 0===u&&(u=!0),void 0===c&&(c=1/0),function a(c,b){if(null===c)return null;if(0===b)return c;var y,m;if("object"!=typeof c)return c;if(t(c,r))y=new r;else if(t(c,n))y=new n;else if(t(c,i))y=new i(function(e,t){c.then(function(t){e(a(t,b-1))},function(e){t(a(e,b-1))})});else if(o.__isArray(c))y=[];else if(o.__isRegExp(c))y=new RegExp(c.source,s(c)),c.lastIndex&&(y.lastIndex=c.lastIndex);else if(o.__isDate(c))y=new Date(c.getTime());else{if(p&&e.isBuffer(c))return y=e.allocUnsafe?e.allocUnsafe(c.length):new e(c.length),c.copy(y),y;t(c,Error)?y=Object.create(c):void 0===f?(m=Object.getPrototypeOf(c),y=Object.create(m)):(y=Object.create(f),m=f)}if(u){var v=l.indexOf(c);if(-1!=v)return d[v];l.push(c),d.push(y)}for(var g in t(c,r)&&c.forEach(function(e,t){var r=a(t,b-1),n=a(e,b-1);y.set(r,n)}),t(c,n)&&c.forEach(function(e){var t=a(e,b-1);y.add(t)}),c){var w;m&&(w=Object.getOwnPropertyDescriptor(m,g)),w&&null==w.set||(y[g]=a(c[g],b-1))}if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(c);for(g=0;g<_.length;g++){var A=_[g];(!(x=Object.getOwnPropertyDescriptor(c,A))||x.enumerable||h)&&(y[A]=a(c[A],b-1),x.enumerable||Object.defineProperty(y,A,{enumerable:!1}))}}if(h){var E=Object.getOwnPropertyNames(c);for(g=0;g>>2),a=0,s=0;a>5]|=128<>>9<<4)]=t;for(var r=1732584193,n=-271733879,i=-1732584194,o=271733878,h=0;h>>32-s,r);var a,s}function a(e,t,r,n,i,a,s){return o(t&r|~t&n,e,t,i,a,s)}function s(e,t,r,n,i,a,s){return o(t&n|r&~n,e,t,i,a,s)}function u(e,t,r,n,i,a,s){return o(t^r^n,e,t,i,a,s)}function c(e,t,r,n,i,a,s){return o(r^(t|~n),e,t,i,a,s)}function f(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}t.exports=function(e){return n(e,i)}},{"./make-hash":92}],94:[function(e,t,r){"use strict";var n=e("inherits"),i=e("./legacy"),o=e("cipher-base"),a=e("safe-buffer").Buffer,s=e("create-hash/md5"),u=e("ripemd160"),c=e("sha.js"),f=a.alloc(128);function h(e,t){o.call(this,"digest"),"string"==typeof t&&(t=a.from(t));var r="sha512"===e||"sha384"===e?128:64;(this._alg=e,this._key=t,t.length>r)?t=("rmd160"===e?new u:c(e)).update(t).digest():t.lengths?t=e(t):t.length-1};f.prototype.append=function(e,t){e=s(e),t=u(t);var r=this.map[e];this.map[e]=r?r+","+t:t},f.prototype.delete=function(e){delete this.map[s(e)]},f.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},f.prototype.set=function(e,t){this.map[s(e)]=u(t)},f.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},f.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),c(e)},f.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),c(e)},f.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),c(e)},t.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);var o=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},b.call(y.prototype),b.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:0,statusText:""});return e.type="error",e};var a=[301,302,303,307,308];v.redirect=function(e,t){if(-1===a.indexOf(t))throw new RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},e.Headers=f,e.Request=y,e.Response=v,e.fetch=function(e,r){return new Promise(function(n,i){var o=new y(e,r),a=new XMLHttpRequest;a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new v(i,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&t.blob&&(a.responseType="blob"),o.headers.forEach(function(e,t){a.setRequestHeader(t,e)}),a.send(void 0===o._bodyInit?null:o._bodyInit)})},e.fetch.polyfill=!0}function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function u(e){return"string"!=typeof e&&(e=String(e)),e}function c(e){var r={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t.iterable&&(r[Symbol.iterator]=function(){return r}),r}function f(e){this.map={},e instanceof f?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function h(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function l(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function d(e){var t=new FileReader,r=l(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(t.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(t.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(t.arrayBuffer&&t.blob&&n(e))this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!t.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(e)&&!i(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=p(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},t.blob&&(this.blob=function(){var e=h(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var e,t,r,n=h(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=l(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function v(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}}(void 0!==e?e:this)}).call(n,void 0);var i=n.fetch;i.Response=n.Response,i.Request=n.Request,i.Headers=n.Headers;"object"==typeof t&&t.exports&&(t.exports=i,t.exports.default=i)},{}],97:[function(e,t,r){"use strict";r.randomBytes=r.rng=r.pseudoRandomBytes=r.prng=e("randombytes"),r.createHash=r.Hash=e("create-hash"),r.createHmac=r.Hmac=e("create-hmac");var n=e("browserify-sign/algos"),i=Object.keys(n),o=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(i);r.getHashes=function(){return o};var a=e("pbkdf2");r.pbkdf2=a.pbkdf2,r.pbkdf2Sync=a.pbkdf2Sync;var s=e("browserify-cipher");r.Cipher=s.Cipher,r.createCipher=s.createCipher,r.Cipheriv=s.Cipheriv,r.createCipheriv=s.createCipheriv,r.Decipher=s.Decipher,r.createDecipher=s.createDecipher,r.Decipheriv=s.Decipheriv,r.createDecipheriv=s.createDecipheriv,r.getCiphers=s.getCiphers,r.listCiphers=s.listCiphers;var u=e("diffie-hellman");r.DiffieHellmanGroup=u.DiffieHellmanGroup,r.createDiffieHellmanGroup=u.createDiffieHellmanGroup,r.getDiffieHellman=u.getDiffieHellman,r.createDiffieHellman=u.createDiffieHellman,r.DiffieHellman=u.DiffieHellman;var c=e("browserify-sign");r.createSign=c.createSign,r.Sign=c.Sign,r.createVerify=c.createVerify,r.Verify=c.Verify,r.createECDH=e("create-ecdh");var f=e("public-encrypt");r.publicEncrypt=f.publicEncrypt,r.privateEncrypt=f.privateEncrypt,r.publicDecrypt=f.publicDecrypt,r.privateDecrypt=f.privateDecrypt;var h=e("randomfill");r.randomFill=h.randomFill,r.randomFillSync=h.randomFillSync,r.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))},r.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},{"browserify-cipher":73,"browserify-sign":80,"browserify-sign/algos":77,"create-ecdh":90,"create-hash":91,"create-hmac":94,"diffie-hellman":105,pbkdf2:247,"public-encrypt":259,randombytes:270,randomfill:271}],98:[function(e,t,r){"use strict";var n=new RegExp("%[a-f0-9]{2}","gi"),i=new RegExp("(%[a-f0-9]{2})+","gi");function o(e,t){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],o(r),o(n))}function a(e){try{return decodeURIComponent(e)}catch(i){for(var t=e.match(n),r=1;r0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];r=a.r28shl(r,s),i=a.r28shl(i,s),a.pc2(r,i,e.keys,o)}},u.prototype._update=function(e,t,r,n){var i=this._desState,o=a.readUInt32BE(e,t),s=a.readUInt32BE(e,t+4);a.ip(o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,s,i.tmp,0):this._decrypt(i,o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],a.writeUInt32BE(r,o,n),a.writeUInt32BE(r,s,n+4)},u.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,o=l}a.rip(s,o,n,i)},u.prototype._decrypt=function(e,t,r,n,i){for(var o=r,s=t,u=e.keys.length-2;u>=0;u-=2){var c=e.keys[u],f=e.keys[u+1];a.expand(o,e.tmp,0),c^=e.tmp[0],f^=e.tmp[1];var h=a.substitute(c,f),l=o;o=(s^a.permute(h))>>>0,s=l}a.rip(o,s,n,i)}},{"../des":99,inherits:180,"minimalistic-assert":234}],103:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits"),o=e("../des"),a=o.Cipher,s=o.DES;function u(e){a.call(this,e);var t=new function(e,t){n.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),i=t.slice(8,16),o=t.slice(16,24);this.ciphers="encrypt"===e?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=t}i(u,a),t.exports=u,u.create=function(e){return new u(e)},u.prototype._update=function(e,t,r,n){var i=this._edeState;i.ciphers[0]._update(e,t,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},u.prototype._pad=s.prototype._pad,u.prototype._unpad=s.prototype._unpad},{"../des":99,inherits:180,"minimalistic-assert":234}],104:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,n){for(var i=0,o=0,a=6;a>=0;a-=2){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>>s+a&1}for(a=6;a>=0;a-=2){for(s=1;s<=25;s+=8)o<<=1,o|=t>>>s+a&1;for(s=1;s<=25;s+=8)o<<=1,o|=e>>>s+a&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(e,t,r,n){for(var i=0,o=0,a=0;a<4;a++)for(var s=24;s>=0;s-=8)i<<=1,i|=t>>>s+a&1,i<<=1,i|=e>>>s+a&1;for(a=4;a<8;a++)for(s=24;s>=0;s-=8)o<<=1,o|=t>>>s+a&1,o<<=1,o|=e>>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(e,t,r,n){for(var i=0,o=0,a=7;a>=5;a--){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+a&1}for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(a=1;a<=3;a++){for(s=0;s<=24;s+=8)o<<=1,o|=t>>s+a&1;for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1}for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,i){for(var o=0,a=0,s=n.length>>>1,u=0;u>>n[u]&1;for(u=s;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=a>>>0},r.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var n=e.toString(2);n.lengthe;)r.ishrn(1);if(r.isEven()&&r.iadd(s),r.testn(1)||r.iadd(u),t.cmp(u)){if(!t.cmp(c))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&m(p)&&m(r)&&a.test(p)&&a.test(r))return r}}},{"bn.js":53,"miller-rabin":233,randombytes:270}],108:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],109:[function(e,t,r){"use strict";var n=r;n.version=e("../package.json").version,n.utils=e("./elliptic/utils"),n.rand=e("brorand"),n.curve=e("./elliptic/curve"),n.curves=e("./elliptic/curves"),n.ec=e("./elliptic/ec"),n.eddsa=e("./elliptic/eddsa")},{"../package.json":124,"./elliptic/curve":112,"./elliptic/curves":115,"./elliptic/ec":116,"./elliptic/eddsa":119,"./elliptic/utils":123,brorand:54}],110:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.getNAF,a=i.getJSF,s=i.assert;function u(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){s(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=u;t--)c=(c<<1)+n[t];a.push(c)}for(var f=this.jpoint(null,null,null),h=this.jpoint(null,null,null),l=i;l>0;l--){for(u=0;u=0;c--){for(t=0;c>=0&&0===a[c];c--)t++;if(c>=0&&t++,u=u.dblp(t),c<0)break;var f=a[c];s(0!==f),u="affine"===e.type?f>0?u.mixedAdd(i[f-1>>1]):u.mixedAdd(i[-f-1>>1].neg()):f>0?u.add(i[f-1>>1]):u.add(i[-f-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){for(var s=this._wnafT1,u=this._wnafT2,c=this._wnafT3,f=0,h=0;h=1;h-=2){var d=h-1,p=h;if(1===s[d]&&1===s[p]){var b=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(b[1]=t[d].add(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].add(t[p].neg())):(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],m=a(r[d],r[p]);f=Math.max(m[0].length,f),c[d]=new Array(f),c[p]=new Array(f);for(var v=0;v=0;h--){for(var E=0;h>=0;){var x=!0;for(v=0;v=0&&E++,_=_.dblp(E),h<0)break;for(v=0;v0?k=u[v][S-1>>1]:S<0&&(k=u[v][-S-1>>1].neg()),_="affine"===k.type?_.mixedAdd(k):_.add(k))}}for(h=0;h=Math.ceil((e.bitLength()+1)/t.step)},c.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},f.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},f.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(r),s=n.redSub(t),u=i.redMul(a),c=o.redMul(s),f=i.redMul(s),h=a.redMul(o);return this.curve.point(u,c,h,f)},f.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var a=(c=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(a.redSub(this.curve.two)),t=a.redMul(c.redSub(o)),r=a.redSqr().redSub(a).redSub(a);else{var s=this.z.redSqr(),u=a.redSub(s).redISub(s);e=n.redSub(i).redISub(o).redMul(u),t=a.redMul(c.redSub(o)),r=a.redMul(u)}}else{var c=i.redAdd(o);s=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=c.redSub(s).redSub(s);e=this.curve._mulC(n.redISub(c)).redMul(u),t=this.curve._mulC(c).redMul(i.redISub(o)),r=c.redMul(u)}return this.curve.point(e,t,r)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},f.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=i.redSub(n),s=i.redAdd(n),u=r.redAdd(t),c=o.redMul(a),f=s.redMul(u),h=o.redMul(u),l=a.redMul(s);return this.curve.point(c,f,l,h)},f.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),c=i.redAdd(s),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),h=n.redMul(u).redMul(f);return this.curve.twisted?(t=n.redMul(c).redMul(a.redSub(this.curve._mulA(o))),r=u.redMul(c)):(t=n.redMul(c).redMul(a.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(h,t,r)},f.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},f.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},f.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},f.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},f.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()},f.prototype.getY=function(){return this.normalize(),this.y.fromRed()},f.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},f.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}return!1},f.prototype.toP=f.prototype.normalize,f.prototype.mixedAdd=f.prototype.add},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],112:[function(e,t,r){"use strict";var n=r;n.base=e("./base"),n.short=e("./short"),n.mont=e("./mont"),n.edwards=e("./edwards")},{"./base":110,"./edwards":111,"./mont":113,"./short":114}],113:[function(e,t,r){"use strict";var n=e("../curve"),i=e("bn.js"),o=e("inherits"),a=n.base,s=e("../../elliptic").utils;function u(e){a.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,r){a.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(u,a),t.exports=u,u.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},o(c,a.BasePoint),u.prototype.decodePoint=function(e,t){return this.point(s.toArray(e,t),1)},u.prototype.point=function(e,t){return new c(this,e,t)},u.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=i.redMul(n),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},c.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],114:[function(e,t,r){"use strict";var n=e("../curve"),i=e("../../elliptic"),o=e("bn.js"),a=e("inherits"),s=n.base,u=i.utils.assert;function c(e){s.call(this,"short",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function f(e,t,r,n){s.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new o(t,16),this.y=new o(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function h(e,t,r,n){s.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new o(0)):(this.x=new o(t,16),this.y=new o(r,16),this.z=new o(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}a(c,s),t.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new o(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new o(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?r=i[0]:(r=i[1],u(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new o(e.a,16),b:new o(e.b,16)}}):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:o.mont(e),r=new o(2).toRed(t).redInvm(),n=r.redNeg(),i=new o(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,r,n,i,a,s,u,c,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=e,d=this.n.clone(),p=new o(1),b=new o(0),y=new o(0),m=new o(1),v=0;0!==l.cmpn(0);){var g=d.div(l);c=d.sub(g.mul(l)),f=y.sub(g.mul(p));var w=m.sub(g.mul(b));if(!n&&c.cmp(h)<0)t=u.neg(),r=p,n=c.neg(),i=f;else if(n&&2==++v)break;u=c,d=l,l=c,y=p,p=f,m=b,b=w}a=c.neg(),s=f;var _=n.sqr().add(i.sqr());return a.sqr().add(s.sqr()).cmp(_)>=0&&(a=t,s=r),n.negative&&(n=n.neg(),i=i.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:n,b:i},{a:a,b:s}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(c).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},f.prototype.isInfinity=function(){return this.inf},f.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},f.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},f.prototype.getX=function(){return this.x.fromRed()},f.prototype.getY=function(){return this.y.fromRed()},f.prototype.mul=function(e){return e=new o(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},f.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},f.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},f.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},f.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},a(h,s.BasePoint),c.prototype.jpoint=function(e,t,r){return new h(this,e,t,r)},h.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},h.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},h.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),f=c.redMul(s),h=n.redMul(c),l=u.redSqr().redIAdd(f).redISub(h).redISub(h),d=u.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(l,d,p)},h.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),f=r.redMul(u),h=s.redSqr().redIAdd(c).redISub(f).redISub(f),l=s.redMul(f.redISub(h)).redISub(i.redMul(c)),d=this.z.redMul(a);return this.curve.jpoint(h,l,d)},h.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}return!1},h.prototype.inspect=function(){return this.isInfinity()?"":""},h.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],115:[function(e,t,r){"use strict";var n,i=r,o=e("hash.js"),a=e("../elliptic"),s=a.utils.assert;function u(e){"short"===e.type?this.curve=new a.curve.short(e):"edwards"===e.type?this.curve=new a.curve.edwards(e):this.curve=new a.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=e("./precomputed/secp256k1")}catch(e){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"../elliptic":109,"./precomputed/secp256k1":122,"hash.js":162}],116:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("hmac-drbg"),o=e("../../elliptic"),a=o.utils.assert,s=e("./key"),u=e("./signature");function c(e){if(!(this instanceof c))return new c(e);"string"==typeof e&&(a(o.curves.hasOwnProperty(e),"Unknown curve "+e),e=o.curves[e]),e instanceof o.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=c,c.prototype.keyPair=function(e){return new s(this,e)},c.prototype.keyFromPrivate=function(e,t){return s.fromPrivate(this,e,t)},c.prototype.keyFromPublic=function(e,t){return s.fromPublic(this,e,t)},c.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||o.rand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),a=this.n.sub(new n(2));;){var s=new n(t.generate(r));if(!(s.cmp(a)>0))return s.iaddn(1),this.keyFromPrivate(s)}},c.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},c.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),c=e.toArray("be",a),f=new i({hash:this.hash,entropy:s,nonce:c,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(f.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var m=d.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),v^=1),new u({r:y,s:m,recoveryParam:v})}}}}}},c.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new u(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,c=a.invm(this.n),f=c.mul(e).umod(this.n),h=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(f,r.getPublic(),h)).isInfinity()&&s.eqXToP(o):!(s=this.g.mulAdd(f,r.getPublic(),h)).isInfinity()&&0===s.getX().umod(this.n).cmp(o)},c.prototype.recoverPubKey=function(e,t,r,i){a((3&r)===r,"The recovery param is more than two bits"),t=new u(t,i);var o=this.n,s=new n(e),c=t.r,f=t.s,h=1&r,l=r>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");c=l?this.curve.pointFromX(c.add(this.curve.n),h):this.curve.pointFromX(c,h);var d=t.r.invm(o),p=o.sub(s).mul(d).umod(o),b=f.mul(d).umod(o);return this.g.mulAdd(p,c,b)},c.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new u(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":109,"./key":117,"./signature":118,"bn.js":53,"hmac-drbg":174}],117:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils.assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../../elliptic":109,"bn.js":53}],118:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new function(){this.place=0};if(48!==e[r.place++])return!1;if(s(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=s(e,r),a=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var u=s(e,r);if(e.length!==u+r.place)return!1;var c=e.slice(r.place,u+r.place);return 0===a[0]&&128&a[1]&&(a=a.slice(1)),0===c[0]&&128&c[1]&&(c=c.slice(1)),this.r=new n(a),this.s=new n(c),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=u(t),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),a=[48];return c(a,o.length),a=a.concat(o),i.encode(a,e)}},{"../../elliptic":109,"bn.js":53}],119:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("../../elliptic"),o=i.utils,a=o.assert,s=o.parseBytes,u=e("./key"),c=e("./signature");function f(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}t.exports=f,f.prototype.sign=function(e,t){e=s(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),u=n.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(e,t,r){e=s(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var s=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,c=t.andln(3)+i&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!=(s=e.andln(7)+n&7)&&5!==s||2!==c?u:-u,r[0].push(o),a=0==(1&c)?0:3!=(s=t.andln(7)+i&7)&&5!==s||2!==u?c:-c,r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},{"bn.js":53,"minimalistic-assert":234,"minimalistic-crypto-utils":235}],124:[function(e,t,r){t.exports={_from:"elliptic@^6.0.0",_id:"elliptic@6.4.0",_inBundle:!1,_integrity:"sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=",_location:"/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.0.0",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.0.0",saveSpec:null,fetchSpec:"^6.0.0"},_requiredBy:["/browserify-sign","/create-ecdh"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",_shasum:"cac9af8762c85836187003c8dfe193e5e2eae5df",_spec:"elliptic@^6.0.0",_where:"/Users/alexvlasov/Blockchain/web3swift_jsproxy/node_modules/browserify-sign",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.4.0"}},{}],125:[function(e,t,r){"use strict";const n=e("ethjs-util");function i(e){let t=n.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}t.exports={incrementHexNumber:function(e){return i(n.intToHex(parseInt(e,16)+1))},formatHex:i}},{"ethjs-util":155}],126:[function(e,t,r){const n=e("eth-query"),i=e("events"),o=e("pify"),a=e("./hexUtils"),s=a.incrementHexNumber,u=1e3,c=60*u;t.exports=class extends i{constructor(e={}){if(super(),!e.provider)throw new Error("RpcBlockTracker - no provider specified.");this._provider=e.provider,this._query=new n(e.provider),this._pollingInterval=e.pollingInterval||4*u,this._syncingTimeout=e.syncingTimeout||1*c,this._trackingBlock=null,this._trackingBlockTimestamp=null,this._currentBlock=null,this._isRunning=!1,this._performSync=this._performSync.bind(this),this._handleNewBlockNotification=this._handleNewBlockNotification.bind(this)}getTrackingBlock(){return this._trackingBlock}getCurrentBlock(){return this._currentBlock}async awaitCurrentBlock(){return this._currentBlock?this._currentBlock:(await new Promise(e=>this.once("latest",e)),this._currentBlock)}async start(e={}){this._isRunning||(this._isRunning=!0,e.fromBlock?await this._setTrackingBlock(await this._fetchBlockByNumber(e.fromBlock)):await this._setTrackingBlock(await this._fetchLatestBlock()),this._provider.on?await this._initSubscription():this._performSync().catch(e=>{e&&console.error(e)}))}async stop(){this._isRunning=!1,this._provider.on&&await this._removeSubscription()}async _setTrackingBlock(e){if(this._trackingBlock&&this._trackingBlock.hash===e.hash)return;const t=this._trackingBlockTimestamp,r=Date.now();t&&r-t>this._syncingTimeout?(this._trackingBlockTimestamp=null,await this._warpToLatest()):(this._trackingBlock=e,this._trackingBlockTimestamp=r,this.emit("block",e))}async _setCurrentBlock(e){if(this._currentBlock&&this._currentBlock.hash===e.hash)return;const t=this._currentBlock;this._currentBlock=e,this.emit("latest",e),this.emit("sync",{newBlock:e,oldBlock:t})}async _warpToLatest(){await this._setTrackingBlock(await this._fetchLatestBlock())}async _pollForNextBlock(){setTimeout(()=>this._performSync(),this._pollingInterval)}async _performSync(){if(!this._isRunning)return;const e=this.getTrackingBlock();if(!e)throw new Error("RpcBlockTracker - tracking block is missing");const t=s(e.number);try{const r=await this._fetchBlockByNumber(t);r?(await this._setTrackingBlock(r),this._performSync()):(await this._setCurrentBlock(e),this._pollForNextBlock())}catch(t){t.message.includes("index out of range")||t.message.includes("Couldn't find block by reference")?(await this._setCurrentBlock(e),this._pollForNextBlock()):(console.error(t),this._pollForNextBlock())}}async _handleNewBlockNotification(e,t){t.id==this._subscriptionId&&(e&&(this.emit("error",e),await this._removeSubscription()),await this._setTrackingBlock(await this._fetchBlockByNumber(t.result.number)))}async _initSubscription(){this._provider.on("data",this._handleNewBlockNotification);let e=await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_subscribe",params:["newHeads"]});this._subscriptionId=e.result}async _removeSubscription(){if(!this._subscriptionId)throw new Error("Not subscribed.");this._provider.removeListener("data",this._handleNewBlockNotification),await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_unsubscribe",params:[this._subscriptionId]}),delete this._subscriptionId}_fetchLatestBlock(){return o(this._query.getBlockByNumber).call(this._query,"latest",!0)}_fetchBlockByNumber(e){const t=a.formatHex(e);return o(this._query.getBlockByNumber).call(this._query,t,!0)}}},{"./hexUtils":125,"eth-query":135,events:157,pify:252}],127:[function(e,t,r){(function(t){var n=e("js-sha3").keccak_256,i=e("idna-uts46-hx");function o(e){return e?i.toUnicode(e,{useStd3ASCII:!0,transitional:!1}):e}r.hash=function(e){for(var r="",i=0;i<32;i++)r+="00";if(name=o(e),name){var a=name.split(".");for(i=a.length-1;i>=0;i--){var s=n(a[i]);r=n(new t(r+s,"hex"))}}return"0x"+r},r.normalize=o}).call(this,e("buffer").Buffer)},{buffer:84,"idna-uts46-hx":177,"js-sha3":128}],128:[function(e,t,r){(function(e,r){!function(){"use strict";var n="object"==typeof window?window:{};!n.JS_SHA3_NO_NODE_JS&&"object"==typeof e&&e.versions&&e.versions.node&&(n=r);for(var i=!n.JS_SHA3_NO_COMMON_JS&&"object"==typeof t&&t.exports,o="0123456789abcdef".split(""),a=[0,8,16,24],s=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],u=[224,256,384,512],c=["hex","buffer","arrayBuffer","array"],f=function(e,t,r){return function(n){return new _(e,t,e).update(n)[r]()}},h=function(e,t,r){return function(n,i){return new _(e,t,i).update(n)[r]()}},l=function(e,t){var r=f(e,t,"hex");r.create=function(){return new _(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}_.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,o=this.blocks,s=this.byteCount,u=this.blockCount,c=0,f=this.s;c>2]|=e[c]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(o[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=s){for(this.start=r-s,this.block=o[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+o[15&e]+o[e>>12&15]+o[e>>8&15]+o[e>>20&15]+o[e>>16&15]+o[e>>28&15]+o[e>>24&15];s%t==0&&(A(r),a=0)}return i&&(e=r[a],i>0&&(u+=o[e>>4&15]+o[15&e]),i>1&&(u+=o[e>>12&15]+o[e>>8&15]),i>2&&(u+=o[e>>20&15]+o[e>>16&15])),u},_.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&A(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var A=function(e){var t,r,n,i,o,a,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],a=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(a<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|a>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=a^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=s[n],e[1]^=s[n+1]};if(i)t.exports=p;else for(y=0;y{setTimeout(t,e)})}function c(e){const t=e.toString();return s.some(e=>t.includes(e))}async function f(e,t,r){const{fetchUrl:n,fetchParams:a}=h({network:e,req:t}),s=await o(n,a),u=await s.text();if(!s.ok)switch(s.status){case 405:throw new i.MethodNotFound;case 418:throw l("Request is being rate limited.");case 503:case 504:throw function(){let e="Gateway timeout. The request took too long to process. ";return e+="This can happen when querying logs over too wide a block range.",l("Gateway timeout. The request took too long to process. This can happen when querying logs over too wide a block range.")}();default:throw l(u)}if("eth_getBlockByNumber"===t.method&&"Not Found"===u)return void(r.result=null);const c=JSON.parse(u);r.result=c.result,r.error=c.error}function h({network:e,req:t}){const r=function(e){return{id:e.id,jsonrpc:e.jsonrpc,method:e.method,params:e.params}}(t),{method:n,params:i}=r,o={};let s=`https://api.infura.io/v1/jsonrpc/${e}`;if(a.includes(n))o.method="POST",o.headers={Accept:"application/json","Content-Type":"application/json"},o.body=JSON.stringify(r);else{o.method="GET",s+=`/${n}?params=${encodeURIComponent(JSON.stringify(i))}`}return{fetchUrl:s,fetchParams:o}}function l(e){const t=new Error(e);return new i.InternalError(t)}t.exports=function(e={}){const t=e.network||"mainnet",r=e.maxAttempts||5;if(!r)throw new Error(`Invalid value for 'maxAttempts': "${r}" (${typeof r})`);return n(async(e,n,i)=>{for(let i=1;i<=r;i++)try{await f(t,e,n);break}catch(e){if(!c(e))throw e;const t=r-i;if(!t){const t=`InfuraProvider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,r=new Error(t);throw r}await u(1e3)}})},t.exports.fetchConfigFromReq=h},{"cross-fetch":96,"json-rpc-engine/src/createAsyncMiddleware":187,"json-rpc-error":189}],131:[function(e,t,r){t.exports=function(e){return{sendAsync:e.handle.bind(e)}}},{}],132:[function(e,t,r){var n=function(e,t){for(var r=[],n=0;n>6|192);else{if(i>55295&&i<56320){if(++n==e.length)return null;var o=e.charCodeAt(n);if(o<56320||o>57343)return null;r+=t((i=65536+((1023&i)<<10)+(1023&o))>>18|240),r+=t(i>>12&63|128)}else r+=t(i>>12|224);r+=t(i>>6&63|128)}r+=t(63&i|128)}}return r},toString:function(e){for(var t="",r=0,o=i(e);r127){if(a>191&&a<224){if(r>=o)return null;a=(31&a)<<6|63&n(e,r)}else if(a>223&&a<240){if(r+1>=o)return null;a=(15&a)<<12|(63&n(e,r))<<6|63&n(e,++r)}else{if(!(a>239&&a<248))return null;if(r+2>=o)return null;a=(7&a)<<18|(63&n(e,r))<<12|(63&n(e,++r))<<6|63&n(e,++r)}++r}if(a<=65535)t+=String.fromCharCode(a);else{if(!(a<=1114111))return null;a-=65536,t+=String.fromCharCode(a>>10|55296),t+=String.fromCharCode(1023&a|56320)}}return t},fromNumber:function(e){var t=e.toString(16);return t.length%2==0?"0x"+t:"0x0"+t},toNumber:function(e){return parseInt(e.slice(2),16)},fromNat:function(e){return"0x0"===e?"0x":e.length%2==0?e:"0x0"+e.slice(2)},toNat:function(e){return"0"===e[2]?"0x"+e.slice(3):e},fromArray:a,toArray:o,fromUint8Array:function(e){return a([].slice.call(e,0))},toUint8Array:function(e){return new Uint8Array(o(e))}}},{"./array.js":132}],134:[function(e,t,r){var n="0123456789abcdef".split(""),i=[1,256,65536,16777216],o=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],s=function(e){var t,r,n,i,o,s,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=a[n],e[1]^=a[n+1]},u=function(e){return function(t){var r;if("0x"===t.slice(0,2)){r=[];for(var a=2,u=t.length;a>2]|=t[d]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|63&r)<=57344?(u[y>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<=c){for(e.start=y-c,e.block=u[f],y=0;y>2]|=i[3&y],e.lastByteIndex===c)for(u[0]=u[f],y=1;y>4&15]+n[15&p]+n[p>>12&15]+n[p>>8&15]+n[p>>20&15]+n[p>>16&15]+n[p>>28&15]+n[p>>24&15];m%f==0&&(s(l),y=0)}return"0x"+b}(function(e){return{blocks:[],reset:!0,block:0,start:0,blockCount:1600-(e<<1)>>5,outputBlocks:e>>5,s:(t=[0,0,0,0,0,0,0,0,0,0],[].concat(t,t,t,t,t))};var t}(e),r)}};t.exports={keccak256:u(256),keccak512:u(512),keccak256s:u(256),keccak512s:u(512)}},{}],135:[function(e,t,r){const n=e("xtend"),i=e("json-rpc-random-id")();function o(e){this.currentProvider=e}function a(e){return function(){var t=[].slice.call(arguments),r=t.pop();this.sendAsync({method:e,params:t},r)}}function s(e,t){return function(){var r=[].slice.call(arguments),n=r.pop();r.lengtho)throw new Error("Elements exceed array size: "+o);for(d in h=[],e=e.slice(0,e.lastIndexOf("[")),"string"==typeof t&&(t=JSON.parse(t)),t)h.push(l(e,t[d]));if("dynamic"===o){var p=l("uint256",t.length);h.unshift(p)}return r.concat(h)}if("bytes"===e)return t=new r(t),h=r.concat([l("uint256",t.length),t]),t.length%32!=0&&(h=r.concat([h,n.zeros(32-t.length%32)])),h;if(e.startsWith("bytes")){if((o=s(e))<1||o>32)throw new Error("Invalid bytes width: "+o);return n.setLengthRight(t,32)}if(e.startsWith("uint")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid uint width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied uint exceeds width: "+o+" vs "+a.bitLength());if(a<0)throw new Error("Supplied uint is negative");return a.toArrayLike(r,"be",32)}if(e.startsWith("int")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid int width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied int exceeds width: "+o+" vs "+a.bitLength());return a.toTwos(256).toArrayLike(r,"be",32)}if(e.startsWith("ufixed")){if(o=u(e),(a=f(t))<0)throw new Error("Supplied ufixed is negative");return l("uint256",a.mul(new i(2).pow(new i(o[1]))))}if(e.startsWith("fixed"))return o=u(e),l("int256",f(t).mul(new i(2).pow(new i(o[1]))));throw new Error("Unsupported or invalid type: "+e)}function d(e,t,n){var o,a,s,u;if("string"==typeof e&&(e=p(e)),"address"===e.name)return d(e.rawType,t,n).toArrayLike(r,"be",20).toString("hex");if("bool"===e.name)return d(e.rawType,t,n).toString()===new i(1).toString();if("string"===e.name){var c=d(e.rawType,t,n);return new r(c,"utf8").toString()}if(e.isArray){for(s=[],o=e.size,"dynamic"===e.size&&(o=d("uint256",t,n=d("uint256",t,n).toNumber()).toNumber(),n+=32),u=0;ue.size)throw new Error("Decoded int exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("int")){if((a=new i(t.slice(n,n+32),16,"be").fromTwos(256)).bitLength()>e.size)throw new Error("Decoded uint exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("ufixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("uint256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}if(e.name.startsWith("fixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("int256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}throw new Error("Unsupported or invalid type: "+e.name)}function p(e){var t,r,n;if(y(e)){t=c(e);var i=e.slice(0,e.lastIndexOf("["));return i=p(i),r={isArray:!0,name:e,size:t,memoryUsage:"dynamic"===t?32:i.memoryUsage*t,subArray:i}}switch(e){case"address":n="uint160";break;case"bool":n="uint8";break;case"string":n="bytes"}if(r={rawType:n,name:e,memoryUsage:32},e.startsWith("bytes")&&"bytes"!==e||e.startsWith("uint")||e.startsWith("int")?r.size=s(e):(e.startsWith("ufixed")||e.startsWith("fixed"))&&(r.size=u(e)),e.startsWith("bytes")&&"bytes"!==e&&(r.size<1||r.size>32))throw new Error("Invalid bytes width: "+r.size);if((e.startsWith("uint")||e.startsWith("int"))&&(r.size%8||r.size<8||r.size>256))throw new Error("Invalid int/uint width: "+r.size);return r}function b(e){return"string"===e||"bytes"===e||"dynamic"===c(e)}function y(e){return e.lastIndexOf("]")===e.length-1}function m(e,t){return e.startsWith("address")||e.startsWith("bytes")?"0x"+t.toString("hex"):t.toString()}o.eventID=function(e,t){var i=e+"("+t.map(a).join(",")+")";return n.sha3(new r(i))},o.methodID=function(e,t){return o.eventID(e,t).slice(0,4)},o.rawEncode=function(e,t){var n=[],i=[],o=0;e.forEach(function(e){if(y(e)){var t=c(e);o+="dynamic"!==t?32*t:32}else o+=32});for(var s=0;s32)throw new Error("Invalid bytes width: "+i);u.push(n.setLengthRight(l,i))}else if(h.startsWith("uint")){if((i=s(h))%8||i<8||i>256)throw new Error("Invalid uint width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied uint exceeds width: "+i+" vs "+o.bitLength());u.push(o.toArrayLike(r,"be",i/8))}else{if(!h.startsWith("int"))throw new Error("Unsupported or invalid type: "+h);if((i=s(h))%8||i<8||i>256)throw new Error("Invalid int width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied int exceeds width: "+i+" vs "+o.bitLength());u.push(o.toTwos(i).toArrayLike(r,"be",i/8))}}return r.concat(u)},o.soliditySHA3=function(e,t){return n.sha3(o.solidityPack(e,t))},o.soliditySHA256=function(e,t){return n.sha256(o.solidityPack(e,t))},o.solidityRIPEMD160=function(e,t){return n.ripemd160(o.solidityPack(e,t),!0)},o.fromSerpent=function(e){for(var t,r=[],n=0;n="0"&&t<="9");)o+=e[a]-"0",a++;n=a-1,r.push(o)}else if("i"===i)r.push("int256");else{if("a"!==i)throw new Error("Unsupported or invalid type: "+i);r.push("int256[]")}}return r},o.toSerpent=function(e){for(var t=[],r=0;r0){var r=this.raw.slice();this.v=this._chainId,this.r=0,this.s=0,t=this.raw,this.raw=r}else t=this.raw.slice(0,6);return n.rlphash(t)},e.prototype.getChainId=function(){return this._chainId},e.prototype.getSenderAddress=function(){if(this._from)return this._from;var e=this.getSenderPublicKey();return this._from=n.publicToAddress(e),this._from},e.prototype.getSenderPublicKey=function(){if(!(this._senderPubKey&&this._senderPubKey.length||this.verifySignature()))throw new Error("Invalid Signature");return this._senderPubKey},e.prototype.verifySignature=function(){var e=this.hash(!1);if(this._homestead&&1===new o(this.s).cmp(a))return!1;try{var t=n.bufferToInt(this.v);this._chainId>0&&(t-=2*this._chainId+8),this._senderPubKey=n.ecrecover(e,t,this.r,this.s)}catch(e){return!1}return!!this._senderPubKey},e.prototype.sign=function(e){var t=this.hash(!1),r=n.ecsign(t,e);this._chainId>0&&(r.v+=2*this._chainId+8),Object.assign(this,r)},e.prototype.getDataFee=function(){for(var e=this.raw[5],t=new o(0),r=0;r0&&t.push(["gas limit is too low. Need at least "+this.getBaseFee()]),void 0===e||!1===e?0===t.length:t.join(" ")},e}();t.exports=s}).call(this,e("buffer").Buffer)},{buffer:84,"ethereum-common/params.json":137,"ethereumjs-util":141}],141:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("keccak"),o=e("secp256k1"),a=e("assert"),s=e("rlp"),u=e("bn.js"),c=e("create-hash"),f=e("safe-buffer").Buffer;Object.assign(r,e("ethjs-util")),r.MAX_INTEGER=new u("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16),r.TWO_POW256=new u("10000000000000000000000000000000000000000000000000000000000000000",16),r.KECCAK256_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",r.SHA3_NULL_S=r.KECCAK256_NULL_S,r.KECCAK256_NULL=f.from(r.KECCAK256_NULL_S,"hex"),r.SHA3_NULL=r.KECCAK256_NULL,r.KECCAK256_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",r.SHA3_RLP_ARRAY_S=r.KECCAK256_RLP_ARRAY_S,r.KECCAK256_RLP_ARRAY=f.from(r.KECCAK256_RLP_ARRAY_S,"hex"),r.SHA3_RLP_ARRAY=r.KECCAK256_RLP_ARRAY,r.KECCAK256_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",r.SHA3_RLP_S=r.KECCAK256_RLP_S,r.KECCAK256_RLP=f.from(r.KECCAK256_RLP_S,"hex"),r.SHA3_RLP=r.KECCAK256_RLP,r.BN=u,r.rlp=s,r.secp256k1=o,r.zeros=function(e){return f.allocUnsafe(e).fill(0)},r.zeroAddress=function(){var e=r.zeros(20);return r.bufferToHex(e)},r.setLengthLeft=r.setLength=function(e,t,n){var i=r.zeros(t);return e=r.toBuffer(e),n?e.length0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e},r.toBuffer=function(e){if(!f.isBuffer(e))if(Array.isArray(e))e=f.from(e);else if("string"==typeof e)e=r.isHexString(e)?f.from(r.padToEven(r.stripHexPrefix(e)),"hex"):f.from(e);else if("number"==typeof e)e=r.intToBuffer(e);else if(null==e)e=f.allocUnsafe(0);else if(u.isBN(e))e=e.toArrayLike(f);else{if(!e.toArray)throw new Error("invalid type");e=f.from(e.toArray())}return e},r.bufferToInt=function(e){return new u(r.toBuffer(e)).toNumber()},r.bufferToHex=function(e){return"0x"+(e=r.toBuffer(e)).toString("hex")},r.fromSigned=function(e){return new u(e).fromTwos(256)},r.toUnsigned=function(e){return f.from(e.toTwos(256).toArray())},r.keccak=function(e,t){return e=r.toBuffer(e),t||(t=256),i("keccak"+t).update(e).digest()},r.keccak256=function(e){return r.keccak(e)},r.sha3=r.keccak,r.sha256=function(e){return e=r.toBuffer(e),c("sha256").update(e).digest()},r.ripemd160=function(e,t){e=r.toBuffer(e);var n=c("rmd160").update(e).digest();return!0===t?r.setLength(n,32):n},r.rlphash=function(e){return r.keccak(s.encode(e))},r.isValidPrivate=function(e){return o.privateKeyVerify(e)},r.isValidPublic=function(e,t){return 64===e.length?o.publicKeyVerify(f.concat([f.from([4]),e])):!!t&&o.publicKeyVerify(e)},r.pubToAddress=r.publicToAddress=function(e,t){return e=r.toBuffer(e),t&&64!==e.length&&(e=o.publicKeyConvert(e,!1).slice(1)),a(64===e.length),r.keccak(e).slice(-20)};var h=r.privateToPublic=function(e){return e=r.toBuffer(e),o.publicKeyCreate(e,!1).slice(1)};r.importPublic=function(e){return 64!==(e=r.toBuffer(e)).length&&(e=o.publicKeyConvert(e,!1).slice(1)),e},r.ecsign=function(e,t){var r=o.sign(e,t),n={};return n.r=r.signature.slice(0,32),n.s=r.signature.slice(32,64),n.v=r.recovery+27,n},r.hashPersonalMessage=function(e){var t=r.toBuffer("Ethereum Signed Message:\n"+e.length.toString());return r.keccak(f.concat([t,e]))},r.ecrecover=function(e,t,n,i){var a=f.concat([r.setLength(n,32),r.setLength(i,32)],64),s=t-27;if(0!==s&&1!==s)throw new Error("Invalid signature v value");var u=o.recover(e,a,s);return o.publicKeyConvert(u,!1).slice(1)},r.toRpcSig=function(e,t,n){if(27!==e&&28!==e)throw new Error("Invalid recovery id");return r.bufferToHex(f.concat([r.setLengthLeft(t,32),r.setLengthLeft(n,32),r.toBuffer(e-27)]))},r.fromRpcSig=function(e){if(65!==(e=r.toBuffer(e)).length)throw new Error("Invalid signature length");var t=e[64];return t<27&&(t+=27),{v:t,r:e.slice(0,32),s:e.slice(32,64)}},r.privateToAddress=function(e){return r.publicToAddress(h(e))},r.isValidAddress=function(e){return/^0x[0-9a-fA-F]{40}$/.test(e)},r.isZeroAddress=function(e){return r.zeroAddress()===r.addHexPrefix(e)},r.toChecksumAddress=function(e){e=r.stripHexPrefix(e).toLowerCase();for(var t=r.keccak(e).toString("hex"),n="0x",i=0;i=8?n+=e[i].toUpperCase():n+=e[i];return n},r.isValidChecksumAddress=function(e){return r.isValidAddress(e)&&r.toChecksumAddress(e)===e},r.generateAddress=function(e,t){return e=r.toBuffer(e),t=(t=new u(t)).isZero()?null:f.from(t.toArray()),r.rlphash([e,t]).slice(-20)},r.isPrecompiled=function(e){var t=r.unpad(e);return 1===t.length&&t[0]>=1&&t[0]<=8},r.addHexPrefix=function(e){return"string"!=typeof e?e:r.isHexPrefixed(e)?e:"0x"+e},r.isValidSignature=function(e,t,r,n){var i=new u("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16),o=new u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16);return 32===t.length&&32===r.length&&((27===e||28===e)&&(t=new u(t),r=new u(r),!(t.isZero()||t.gt(o)||r.isZero()||r.gt(o))&&(!1!==n||1!==new u(r).cmp(i))))},r.baToJSON=function(e){if(f.isBuffer(e))return"0x"+e.toString("hex");if(e instanceof Array){for(var t=[],n=0;n=i.length,"The field "+t.name+" must not have more "+t.length+" bytes")):t.allowZero&&0===i.length||!t.length||a(t.length===i.length,"The field "+t.name+" must have byte length of "+t.length),e.raw[n]=i}e._fields.push(t.name),Object.defineProperty(e,t.name,{enumerable:!0,configurable:!0,get:i,set:o}),t.default&&(e[t.name]=t.default),t.alias&&Object.defineProperty(e,t.alias,{enumerable:!1,configurable:!0,set:o,get:i})}),i)if("string"==typeof i&&(i=f.from(r.stripHexPrefix(i),"hex")),f.isBuffer(i)&&(i=s.decode(i)),Array.isArray(i)){if(i.length>e._fields.length)throw new Error("wrong number of fields in data");i.forEach(function(t,n){e[e._fields[n]]=r.toBuffer(t)})}else{if("object"!==(void 0===i?"undefined":n(i)))throw new Error("invalid data");var o=Object.keys(i);t.forEach(function(t){-1!==o.indexOf(t.name)&&(e[t.name]=i[t.name]),-1!==o.indexOf(t.alias)&&(e[t.alias]=i[t.alias])})}}},{assert:19,"bn.js":53,"create-hash":91,"ethjs-util":155,keccak:195,rlp:289,"safe-buffer":290,secp256k1:295}],142:[function(e,t,r){arguments[4][128][0].apply(r,arguments)},{_process:257,dup:128}],143:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var a=e("./address"),s=e("./bignumber"),u=e("./bytes"),c=e("./utf8"),f=e("./properties"),h=o(e("./errors")),l=new RegExp(/^bytes([0-9]*)$/),d=new RegExp(/^(u?int)([0-9]*)$/),p=new RegExp(/^(.*)\[([0-9]*)\]$/);r.defaultCoerceFunc=function(e,t){var r=e.match(d);return r&&parseInt(r[2])<=48?t.toNumber():t};var b=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"),y=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function m(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}function v(e,t){function r(t){throw new Error('unexpected character "'+e[t]+'" at position '+t+' in "'+e+'"')}for(var n={type:"",name:"",state:{allowType:!0}},i=n,o=0;o1){var i=r[1].match(b);if(""!=i[1].trim()||""!=i[3].trim())throw new Error("unexpected tokens");L(i[2]).forEach(function(e){t.outputs.push(v(e))})}return t}(e.trim()));throw new Error("unknown signature")};var w=function(){return function(e,t,r,n,i){this.coerceFunc=e,this.name=t,this.type=r,this.localName=n,this.dynamic=i}}(),_=function(e){function t(t){var r=e.call(this,t.coerceFunc,t.name,t.type,void 0,t.dynamic)||this;return f.defineReadOnly(r,"coder",t),r}return i(t,e),t.prototype.encode=function(e){return this.coder.encode(e)},t.prototype.decode=function(e,t){return this.coder.decode(e,t)},t}(w),A=function(e){function t(t,r){return e.call(this,t,"null","",r,!1)||this}return i(t,e),t.prototype.encode=function(e){return u.arrayify([])},t.prototype.decode=function(e,t){if(t>e.length)throw new Error("invalid null");return{consumed:0,value:this.coerceFunc("null",void 0)}},t}(w),E=function(e){function t(t,r,n,i){var o=this,a=(n?"int":"uint")+8*r;return(o=e.call(this,t,a,a,i,!1)||this).size=r,o.signed=n,o}return i(t,e),t.prototype.encode=function(e){try{var t=s.bigNumberify(e);return t=t.toTwos(8*this.size).maskn(8*this.size),this.signed&&(t=t.fromTwos(8*this.size).toTwos(256)),u.padZeros(u.arrayify(t),32)}catch(t){h.throwError("invalid number value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:e})}return null},t.prototype.decode=function(e,t){e.length32)throw new Error;t.set(r)}catch(t){h.throwError("invalid "+this.name+" value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:t.value||e})}return t},t.prototype.decode=function(e,t){return e.length=0?n:"")+"]",s=-1===n||r.dynamic;return(o=e.call(this,t,"array",a,i,s)||this).coder=r,o.length=n,o}return i(t,e),t.prototype.encode=function(e){Array.isArray(e)||h.throwError("expected array value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:"array",value:e});var t=this.length,r=new Uint8Array(0);-1===t&&(t=e.length,r=x.encode(t)),h.checkArgumentCount(t,e.length,"in coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i256||i%8!=0)&&h.throwError("invalid "+r[1]+" bit length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new E(e,i/8,"int"===r[1],t.name);if(r=t.type.match(l))return(0===(i=parseInt(r[1]))||i>32)&&h.throwError("invalid bytes length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new S(e,i,t.name);if(r=t.type.match(p)){var i=parseInt(r[2]||"-1");return(t=f.jsonCopy(t)).type=r[1],new N(e,D(e,t),i,t.name)}return"tuple"===t.type.substring(0,5)?function(e,t,r){t||(t=[]);var n=[];return t.forEach(function(t){n.push(D(e,t))}),new R(e,n,r)}(e,t.components,t.name):""===t.type?new A(e,t.name):(h.throwError("invalid type",h.INVALID_ARGUMENT,{arg:"type",value:t.type}),null)}var F=function(){function e(t){h.checkNew(this,e),t||(t=r.defaultCoerceFunc),f.defineReadOnly(this,"coerceFunc",t)}return e.prototype.encode=function(e,t){e.length!==t.length&&h.throwError("types/values length mismatch",h.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):e,r.push(D(this.coerceFunc,t))},this),u.hexlify(new R(this.coerceFunc,r,"_").encode(t))},e.prototype.decode=function(e,t){var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):f.jsonCopy(e),r.push(D(this.coerceFunc,t))},this),new R(this.coerceFunc,r,"_").decode(u.arrayify(t),0).value},e}();r.AbiCoder=F,r.defaultAbiCoder=new F},{"./address":144,"./bignumber":145,"./bytes":146,"./errors":147,"./properties":149,"./utf8":152}],144:[function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var i=n(e("bn.js")),o=e("./bytes"),a=e("./keccak256"),s=e("./rlp"),u=e("./errors");function c(e){"string"==typeof e&&e.match(/^0x[0-9A-Fa-f]{40}$/)||u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=o.arrayify(a.keccak256(r));for(var i=0;i<40;i+=2)r[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(15&r[i>>1])>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}for(var f={},h=0;h<10;h++)f[String(h)]=String(h);for(h=0;h<26;h++)f[String.fromCharCode(65+h)]=String(10+h);var l,d=Math.floor((l=9007199254740991,Math.log10?Math.log10(l):Math.log(l)/Math.LN10));function p(e){e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00";var t="";for(e.split("").forEach(function(e){t+=f[e]});t.length>=d;){var r=t.substring(0,d);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function b(e){var t=null;if("string"!=typeof e&&u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e}),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=c(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&u.throwError("bad address checksum",u.INVALID_ARGUMENT,{arg:"address",value:e});else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==p(e)&&u.throwError("bad icap checksum",u.INVALID_ARGUMENT,{arg:"address",value:e}),t=new i.default.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=c("0x"+t)}else u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});return t}r.getAddress=b,r.getIcapAddress=function(e){for(var t=new i.default.BN(b(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+p("XE00"+t)+t},r.getContractAddress=function(e){if(!e.from)throw new Error("missing from address");var t=e.nonce;return b("0x"+a.keccak256(s.encode([b(e.from),o.stripZeros(o.hexlify(t))])).substring(26))}},{"./bytes":146,"./errors":147,"./keccak256":148,"./rlp":150,"bn.js":53}],145:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=o(e("bn.js")),u=e("./bytes"),c=e("./properties"),f=e("./types"),h=a(e("./errors")),l=new s.default.BN(-1);function d(e){var t=e.toString(16);return"-"===t[0]?t.length%2==0?"-0x0"+t.substring(1):"-0x"+t.substring(1):t.length%2==1?"0x0"+t:"0x"+t}function p(e){return m(e)._bn}function b(e){return new y(d(e))}var y=function(e){function t(r){var n=e.call(this)||this;if(h.checkNew(n,t),"string"==typeof r)u.isHexString(r)?("0x"==r&&(r="0x0"),c.defineReadOnly(n,"_hex",r)):"-"===r[0]&&u.isHexString(r.substring(1))?c.defineReadOnly(n,"_hex",r):r.match(/^-?[0-9]*$/)?(""==r&&(r="0"),c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))):h.throwError("invalid BigNumber string value",h.INVALID_ARGUMENT,{arg:"value",value:r});else if("number"==typeof r){parseInt(String(r))!==r&&h.throwError("underflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"underflow",value:r,outputValue:parseInt(String(r))});try{c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}}else r instanceof t?c.defineReadOnly(n,"_hex",r._hex):r.toHexString?c.defineReadOnly(n,"_hex",d(p(r.toHexString()))):u.isArrayish(r)?c.defineReadOnly(n,"_hex",d(new s.default.BN(u.hexlify(r).substring(2),16))):h.throwError("invalid BigNumber value",h.INVALID_ARGUMENT,{arg:"value",value:r});return n}return i(t,e),Object.defineProperty(t.prototype,"_bn",{get:function(){return"-"===this._hex[0]?new s.default.BN(this._hex.substring(3),16).mul(l):new s.default.BN(this._hex.substring(2),16)},enumerable:!0,configurable:!0}),t.prototype.fromTwos=function(e){return b(this._bn.fromTwos(e))},t.prototype.toTwos=function(e){return b(this._bn.toTwos(e))},t.prototype.add=function(e){return b(this._bn.add(p(e)))},t.prototype.sub=function(e){return b(this._bn.sub(p(e)))},t.prototype.div=function(e){return m(e).isZero()&&h.throwError("division by zero",h.NUMERIC_FAULT,{operation:"divide",fault:"division by zero"}),b(this._bn.div(p(e)))},t.prototype.mul=function(e){return b(this._bn.mul(p(e)))},t.prototype.mod=function(e){return b(this._bn.mod(p(e)))},t.prototype.pow=function(e){return b(this._bn.pow(p(e)))},t.prototype.maskn=function(e){return b(this._bn.maskn(e))},t.prototype.eq=function(e){return this._bn.eq(p(e))},t.prototype.lt=function(e){return this._bn.lt(p(e))},t.prototype.lte=function(e){return this._bn.lte(p(e))},t.prototype.gt=function(e){return this._bn.gt(p(e))},t.prototype.gte=function(e){return this._bn.gte(p(e))},t.prototype.isZero=function(){return this._bn.isZero()},t.prototype.toNumber=function(){try{return this._bn.toNumber()}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}return null},t.prototype.toString=function(){return this._bn.toString(10)},t.prototype.toHexString=function(){return this._hex},t}(f.BigNumber);function m(e){return e instanceof y?e:new y(e)}r.bigNumberify=m,r.ConstantNegativeOne=m(-1),r.ConstantZero=m(0),r.ConstantOne=m(1),r.ConstantTwo=m(2),r.ConstantWeiPerEther=m("1000000000000000000")},{"./bytes":146,"./errors":147,"./properties":149,"./types":151,"bn.js":53}],146:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./errors");function i(e){return!!e._bn}function o(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return new Uint8Array(Array.prototype.slice.apply(e,t))},e)}function a(e){if(!e||parseInt(String(e.length))!=e.length||"string"==typeof e)return!1;for(var t=0;t=256||parseInt(String(r))!=r)return!1}return!0}function s(e){if(null==e&&n.throwError("cannot convert null value to array",n.INVALID_ARGUMENT,{arg:"value",value:e}),i(e)&&(e=e.toHexString()),"string"==typeof e){var t=e.match(/^(0x)?[0-9a-fA-F]*$/);t||n.throwError("invalid hexidecimal string",n.INVALID_ARGUMENT,{arg:"value",value:e}),"0x"!==t[1]&&n.throwError("hex string must have 0x prefix",n.INVALID_ARGUMENT,{arg:"value",value:e}),(e=e.substring(2)).length%2&&(e="0"+e);for(var r=[],s=0;s>4]+f[15&u])}return"0x"+o.join("")}return n.throwError("invalid hexlify value",null,{arg:"value",value:e}),"never"}function l(e,t){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length<2*t+2;)e="0x0"+e.substring(2);return e}function d(e){var t,r=0,i="0x",o="0x";if((t=e)&&null!=t.r&&null!=t.s){null==e.v&&null==e.recoveryParam&&n.throwError("at least on of recoveryParam or v must be specified",n.INVALID_ARGUMENT,{argument:"signature",value:e}),i=l(e.r,32),o=l(e.s,32),"string"==typeof(r=e.v)&&(r=parseInt(r,16));var a=e.recoveryParam;null==a&&null!=e.v&&(a=1-r%2),r=27+a}else{var u=s(e);if(65!==u.length)throw new Error("invalid signature");i=h(u.slice(0,32)),o=h(u.slice(32,64)),27!==(r=u[64])&&28!==r&&(r=27+r%2)}return{r:i,s:o,recoveryParam:r-27,v:r}}r.hexlify=h,r.hexDataLength=function(e){return c(e)&&e.length%2==0?(e.length-2)/2:null},r.hexDataSlice=function(e,t,r){return c(e)||n.throwError("invalid hex data",n.INVALID_ARGUMENT,{arg:"value",value:e}),e.length%2!=0&&n.throwError("hex data length must be even",n.INVALID_ARGUMENT,{arg:"value",value:e}),t=2+2*t,null!=r?"0x"+e.substring(t,t+2*r):"0x"+e.substring(t)},r.hexStripZeros=function(e){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length>3&&"0x0"===e.substring(0,3);)e="0x"+e.substring(3);return e},r.hexZeroPad=l,r.splitSignature=d,r.joinSignature=function(e){return h(u([(e=d(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}},{"./errors":147}],147:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.MISSING_NEW="MISSING_NEW",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.NUMERIC_FAULT="NUMERIC_FAULT",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION";var n=!1,i=!1;function o(e,t,n){if(i)throw new Error("unknown error");t||(t=r.UNKNOWN_ERROR),n||(n={});var o=[];Object.keys(n).forEach(function(e){try{o.push(e+"="+JSON.stringify(n[e]))}catch(t){o.push(e+"="+JSON.stringify(n[e].toString()))}});var a=e;o.length&&(e+=" ("+o.join(", ")+")");var s=new Error(e);throw s.reason=a,s.code=t,Object.keys(n).forEach(function(e){s[e]=n[e]}),s}r.throwError=o,r.checkNew=function(e,t){e instanceof t||o("missing new",r.MISSING_NEW,{name:t.name})},r.checkArgumentCount=function(e,t,n){n||(n=""),et&&o("too many arguments"+n,r.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})},r.setCensorship=function(e,t){n&&o("error censorship permanent",r.UNSUPPORTED_OPERATION,{operation:"setCersorship"}),i=!!e,n=!!t}},{}],148:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("js-sha3"),i=e("./bytes");r.keccak256=function(e){return"0x"+n.keccak_256(i.arrayify(e))}},{"./bytes":146,"js-sha3":142}],149:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defineReadOnly=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})},r.defineFrozen=function(e,t,r){var n=JSON.stringify(r);Object.defineProperty(e,t,{enumerable:!0,get:function(){return JSON.parse(n)}})},r.resolveProperties=function(e){var t={},r=[];return Object.keys(e).forEach(function(n){var i=e[n];i instanceof Promise?r.push(i.then(function(e){return t[n]=e,null})):t[n]=i}),Promise.all(r).then(function(){return t})},r.shallowCopy=function(e){var t={};for(var r in e)t[r]=e[r];return t},r.jsonCopy=function(e){return JSON.parse(JSON.stringify(e))}},{}],150:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./bytes");function i(e){for(var t=[];e;)t.unshift(255&e),e>>=8;return t}function o(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function s(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(r=e[t]-247)>e.length)throw new Error("too short");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("to short");return a(e,t,t+1+r,r+i)}if(e[t]>=192){if(t+1+(i=e[t]-192)>e.length)throw new Error("invalid rlp data");return a(e,t,t+1,i)}if(e[t]>=184){var r;if(t+1+(r=e[t]-183)>e.length)throw new Error("invalid rlp data");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("invalid rlp data");return{consumed:1+r+i,result:n.hexlify(e.slice(t+1+r,t+1+r+i))}}if(e[t]>=128){var i;if(t+1+(i=e[t]-128)>e.length)throw new Error("invlaid rlp data");return{consumed:1+i,result:n.hexlify(e.slice(t+1,t+1+i))}}return{consumed:1,result:n.hexlify(e[t])}}r.encode=function(e){return n.hexlify(function e(t){if(Array.isArray(t)){var r=[];return t.forEach(function(t){r=r.concat(e(t))}),r.length<=55?(r.unshift(192+r.length),r):((o=i(r.length)).unshift(247+o.length),o.concat(r))}var o,a=Array.prototype.slice.call(n.arrayify(t));return 1===a.length&&a[0]<=127?a:a.length<=55?(a.unshift(128+a.length),a):((o=i(a.length)).unshift(183+o.length),o.concat(a))}(e))},r.decode=function(e){var t=n.arrayify(e),r=s(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}},{"./bytes":146}],151:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=function(){return function(){}}();r.BigNumber=n;var i=function(){return function(){}}();r.Indexed=i;var o=function(){return function(){}}();r.MinimalProvider=o;var a=function(){return function(){}}();r.Signer=a;var s=function(){return function(){}}();r.HDNode=s},{}],152:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,i=e("./bytes");!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(n=r.UnicodeNormalizationForm||(r.UnicodeNormalizationForm={})),r.toUtf8Bytes=function(e,t){void 0===t&&(t=n.current),t!=n.current&&(e=e.normalize(t));for(var r=[],o=0,a=0;a>6|192,r[o++]=63&s|128):55296==(64512&s)&&a+1>18|240,r[o++]=s>>12&63|128,r[o++]=s>>6&63|128,r[o++]=63&s|128):(r[o++]=s>>12|224,r[o++]=s>>6&63|128,r[o++]=63&s|128)}return i.arrayify(r)},r.toUtf8String=function(e){e=i.arrayify(e);for(var t="",r=0;r>7!=0){if(n>>6!=2){var o=null;if(n>>5==6)o=1;else if(n>>4==14)o=2;else if(n>>3==30)o=3;else if(n>>2==62)o=4;else{if(n>>1!=126)continue;o=5}if(r+o>e.length){for(;r>6==2;r++);if(r!=e.length)continue;return t}var a,s=n&(1<<8-o-1)-1;for(a=0;a>6!=2)break;s=s<<6|63&u}a==o?s<=65535?t+=String.fromCharCode(s):(s-=65536,t+=String.fromCharCode(55296+(s>>10&1023),56320+(1023&s))):r--}}else t+=String.fromCharCode(n)}return t}},{"./bytes":146}],153:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("number-to-bn"),o=new n(0),a=new n(-1),s={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",Gwei:"1000000000",shannon:"1000000000",nanoether:"1000000000",nano:"1000000000",szabo:"1000000000000",microether:"1000000000000",micro:"1000000000000",finney:"1000000000000000",milliether:"1000000000000000",milli:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"};function u(e){var t=e?e.toLowerCase():"ether",r=s[t];if("string"!=typeof r)throw new Error("[ethjs-unit] the unit provided "+e+" doesn't exists, please use the one of the following units "+JSON.stringify(s,null,2));return new n(r,10)}function c(e){if("string"==typeof e){if(!e.match(/^-?[0-9.]+$/))throw new Error("while converting number to string, invalid number value '"+e+"', should be a number matching (^-?[0-9.]+).");return e}if("number"==typeof e)return String(e);if("object"==typeof e&&e.toString&&(e.toTwos||e.dividedToIntegerBy))return e.toPrecision?String(e.toPrecision()):e.toString(10);throw new Error("while converting number to string, invalid number value '"+e+"' type "+typeof e+".")}t.exports={unitMap:s,numberToString:c,getValueOfUnit:u,fromWei:function(e,t,r){var n=i(e),c=n.lt(o),f=u(t),h=s[t].length-1||1,l=r||{};c&&(n=n.mul(a));for(var d=n.mod(f).toString(10);d.length2)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal points");var l=h[0],d=h[1];if(l||(l="0"),d||(d="0"),d.length>o)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal places");for(;d.length=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{}],155:[function(e,t,r){(function(r){"use strict";var n=e("is-hex-prefixed"),i=e("strip-hex-prefix");function o(e){var t=e;if("string"!=typeof t)throw new Error("[ethjs-util] while padding to even, value must be string, is currently "+typeof t+", while padToEven.");return t.length%2&&(t="0"+t),t}function a(e){return"0x"+e.toString(16)}t.exports={arrayContainsArray:function(e,t,r){if(!0!==Array.isArray(e))throw new Error("[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '"+typeof e+"'");if(!0!==Array.isArray(t))throw new Error("[ethjs-util] method arrayContainsArray requires input 'subset' to be an array got type '"+typeof t+"'");return t[Boolean(r)?"some":"every"](function(t){return e.indexOf(t)>=0})},intToBuffer:function(e){var t=a(e);return new r(o(t.slice(2)),"hex")},getBinarySize:function(e){if("string"!=typeof e)throw new Error("[ethjs-util] while getting binary size, method getBinarySize requires input 'str' to be type String, got '"+typeof e+"'.");return r.byteLength(e,"utf8")},isHexPrefixed:n,stripHexPrefix:i,padToEven:o,intToHex:a,fromAscii:function(e){for(var t="",r=0;r0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var r,n,a,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(r=this._events[e]).length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=a;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){n=s;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],158:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("md5.js");t.exports=function(e,t,r,o){if(n.isBuffer(e)||(e=n.from(e,"binary")),t&&(n.isBuffer(t)||(t=n.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var a=r/8,s=n.alloc(a),u=n.alloc(o||0),c=n.alloc(0);a>0||o>0;){var f=new i;f.update(c),f.update(e),t&&f.update(t),c=f.digest();var h=0;if(a>0){var l=s.length-a;h=Math.min(a,c.length),c.copy(s,l,0,h),a-=h}if(h0){var d=u.length-o,p=Math.min(o,c.length-h);c.copy(u,d,h,h+p),o-=p}}return c.fill(0),{key:s,iv:u}}},{"md5.js":231,"safe-buffer":290}],159:[function(e,t,r){"use strict";var n=e("is-callable"),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.exports=function(e,t,r){if(!n(t))throw new TypeError("iterator must be a function");var a;arguments.length>=3&&(a=r),"[object Array]"===i.call(e)?function(e,t,r){for(var n=0,i=e.length;n=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},i.prototype._update=function(e){throw new Error("_update is not implemented")},i.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();return void 0!==e&&(t=t.toString(e)),t},i.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=i}).call(this,e("buffer").Buffer)},{buffer:84,inherits:180,stream:311}],162:[function(e,t,r){var n=r;n.utils=e("./hash/utils"),n.common=e("./hash/common"),n.sha=e("./hash/sha"),n.ripemd=e("./hash/ripemd"),n.hmac=e("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":163,"./hash/hmac":164,"./hash/ripemd":165,"./hash/sha":166,"./hash/utils":173}],163:[function(e,t,r){"use strict";var n=e("./utils"),i=e("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},{"../utils":173}],173:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits");function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function s(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=i,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,a=255&i;o?r.push(o,a):r.push(a)}else for(n=0;n>>0}return a},r.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},r.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},r.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},r.sum64_lo=function(e,t,r,n){return t+n>>>0},r.sum64_4_hi=function(e,t,r,n,i,o,a,s){var u=0,c=t;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},r.sum64_5_hi=function(e,t,r,n,i,o,a,s,u,c){var f=0,h=t;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,n,i,o,a,s,u,c){return t+n+o+s+c>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:180,"minimalistic-assert":234}],174:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("minimalistic-crypto-utils"),o=e("minimalistic-assert");function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}t.exports=a,a.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},a.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length\\$%@ءؤة\"'^|~⦅⦆・ゥャ¢£¬¦¥₩│←↑→↓■○𐐨𐐩𐐪𐐫𐐬𐐭𐐮𐐯𐐰𐐱𐐲𐐳𐐴𐐵𐐶𐐷𐐸𐐹𐐺𐐻𐐼𐐽𐐾𐐿𐑀𐑁𐑂𐑃𐑄𐑅𐑆𐑇𐑈𐑉𐑊𐑋𐑌𐑍𐑎𐑏𐓘𐓙𐓚𐓛𐓜𐓝𐓞𐓟𐓠𐓡𐓢𐓣𐓤𐓥𐓦𐓧𐓨𐓩𐓪𐓫𐓬𐓭𐓮𐓯𐓰𐓱𐓲𐓳𐓴𐓵𐓶𐓷𐓸𐓹𐓺𐓻𐳀𐳁𐳂𐳃𐳄𐳅𐳆𐳇𐳈𐳉𐳊𐳋𐳌𐳍𐳎𐳏𐳐𐳑𐳒𐳓𐳔𐳕𐳖𐳗𐳘𐳙𐳚𐳛𐳜𐳝𐳞𐳟𐳠𐳡𐳢𐳣𐳤𐳥𐳦𐳧𐳨𐳩𐳪𐳫𐳬𐳭𐳮𐳯𐳰𐳱𐳲𑣀𑣁𑣂𑣃𑣄𑣅𑣆𑣇𑣈𑣉𑣊𑣋𑣌𑣍𑣎𑣏𑣐𑣑𑣒𑣓𑣔𑣕𑣖𑣗𑣘𑣙𑣚𑣛𑣜𑣝𑣞𑣟ıȷ∇∂𞤢𞤣𞤤𞤥𞤦𞤧𞤨𞤩𞤪𞤫𞤬𞤭𞤮𞤯𞤰𞤱𞤲𞤳𞤴𞤵𞤶𞤷𞤸𞤹𞤺𞤻𞤼𞤽𞤾𞤿𞥀𞥁𞥂𞥃ٮڡٯ字双多解交映無前後再新初終販声吹演投捕遊指禁空合満申割営配得可丽丸乁𠄢你侻倂偺備像㒞𠘺兔兤具𠔜㒹內𠕋冗冤仌冬𩇟刃㓟刻剆剷㔕包匆卉博即卽卿𠨬灰及叟𠭣叫叱吆咞吸呈周咢哶唐啓啣善喫喳嗂圖圗噑噴壮城埴堍型堲報墬𡓤売壷夆夢奢𡚨𡛪姬娛娧姘婦㛮嬈嬾𡧈寃寘寳𡬘寿将㞁屠峀岍𡷤嵃𡷦嵮嵫嵼巡巢㠯巽帨帽幩㡢𢆃㡼庰庳庶𪎒𢌱舁弢㣇𣊸𦇚形彫㣣徚忍志忹悁㤺㤜𢛔惇慈慌慺憲憤憯懞戛扝抱拔捐𢬌挽拼捨掃揤𢯱搢揅掩㨮摩摾撝摷㩬敬𣀊旣書晉㬙㬈㫤冒冕最暜肭䏙朡杞杓𣏃㭉柺枅桒𣑭梎栟椔楂榣槪檨𣚣櫛㰘次𣢧歔㱎歲殟殻𣪍𡴋𣫺汎𣲼沿泍汧洖派浩浸涅𣴞洴港湮㴳滇𣻑淹潮𣽞𣾎濆瀹瀛㶖灊災灷炭𠔥煅𤉣熜爨牐𤘈犀犕𤜵𤠔獺王㺬玥㺸瑇瑜璅瓊㼛甤𤰶甾𤲒𢆟瘐𤾡𤾸𥁄㿼䀈𥃳𥃲𥄙𥄳眞真瞋䁆䂖𥐝硎䃣𥘦𥚚𥛅秫䄯穊穏𥥼𥪧䈂𥮫篆築䈧𥲀糒䊠糨糣紀𥾆絣䌁緇縂繅䌴𦈨𦉇䍙𦋙罺𦌾羕翺𦓚𦔣聠𦖨聰𣍟䏕育脃䐋脾媵𦞧𦞵𣎓𣎜舄辞䑫芑芋芝劳花芳芽苦𦬼茝荣莭茣莽菧荓菊菌菜𦰶𦵫𦳕䔫蓱蓳蔖𧏊蕤𦼬䕝䕡𦾱𧃒䕫虐虧虩蚩蚈蜎蛢蜨蝫螆蟡蠁䗹衠𧙧裗裞䘵裺㒻𧢮𧥦䚾䛇誠𧲨貫賁贛起𧼯𠠄跋趼跰𠣞軔𨗒𨗭邔郱鄑𨜮鄛鈸鋗鋘鉼鏹鐕𨯺開䦕閷𨵷䧦雃嶲霣𩅅𩈚䩮䩶韠𩐊䪲𩒖頩𩖶飢䬳餩馧駂駾䯎𩬰鱀鳽䳎䳭鵧𪃎䳸𪄅𪈎𪊑䵖黾鼅鼏鼖𪘀",mapChar:function(r){return r>=196608?r>=917760&&r<=917999?18874368:0:e[t[r>>4]][15&r]}}},"function"==typeof define&&define.amd?define([],function(){return i()}):"object"==typeof r?t.exports=i():n.uts46_map=i()},{}],177:[function(e,t,r){var n,i;n=this,i=function(e,t){function r(r,n,i){for(var o=[],a=e.ucs2.decode(r),s=0;s>23,l=f>>21&3,d=f>>5&65535,p=31&f,b=t.mapStr.substr(d,p);if(0===l||n&&1&h)throw new Error("Illegal char "+c);1===l?o.push(b):2===l?o.push(i?b:c):3===l&&o.push(c)}return o.join("").normalize("NFC")}function n(t,n,o){void 0===o&&(o=!1);var a=r(t,o,n).split(".");return(a=a.map(function(t){return t.startsWith("xn--")?i(t=e.decode(t.substring(4)),o,!1):i(t,o,n),t})).join(".")}function i(e,n,i){if("-"===e[2]&&"-"===e[3])throw new Error("Failed to validate "+e);if(e.startsWith("-")||e.endsWith("-"))throw new Error("Failed to validate "+e);if(e.includes("."))throw new Error("Failed to validate "+e);if(r(e,n,i)!==e)throw new Error("Failed to validate "+e);var o=e.codePointAt(0);if(t.mapChar(o)&2<<23)throw new Error("Label contains illegal character: "+o)}return{toUnicode:function(e,t){return void 0===t&&(t={}),n(e,!1,"useStd3ASCII"in t&&t.useStd3ASCII)},toAscii:function(t,r){void 0===r&&(r={});var i,o=!("transitional"in r)||r.transitional,a="useStd3ASCII"in r&&r.useStd3ASCII,s="verifyDnsLength"in r&&r.verifyDnsLength,u=n(t,o,a).split(".").map(e.toASCII),c=u.join(".");if(s){if(c.length<1||c.length>253)throw new Error("DNS name has wrong length: "+c);for(i=0;i63)throw new Error("DNS label has wrong length: "+f)}}return c}}},"function"==typeof define&&define.amd?define(["punycode","./idna-map"],function(e,t){return i(e,t)}):"object"==typeof r?t.exports=i(e("punycode"),e("./idna-map")):n.uts46=i(n.punycode,n.idna_map)},{"./idna-map":176,punycode:265}],178:[function(e,t,r){r.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,f=-7,h=r?i-1:0,l=r?-1:1,d=e[t+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=s;f>0;o=256*o+e[t+h],h+=l,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+e[t+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=c}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var a,s,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(a++,u/=2),a+h>=f?(s=0,a=f):a+h>=1?(s=(t*u-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;e[r+d]=255&a,d+=p,a/=256,c-=8);e[r+d-p]|=128*b}},{}],179:[function(e,t,r){var n=[].indexOf;t.exports=function(e,t){if(n)return e.indexOf(t);for(var r=0;r-32e3)throw new Error("Invalid error code");if(!(this instanceof f))return new f(e);i.call(this,"Server error",e)};n(f,i),i.ParseError=o,i.InvalidRequest=a,i.MethodNotFound=s,i.InvalidParams=u,i.InternalError=c,i.ServerError=f,t.exports=i},{inherits:180}],191:[function(e,t,r){t.exports=function(e){var t=(e=e||{}).max||Number.MAX_SAFE_INTEGER,r=void 0!==e.start?e.start:Math.floor(Math.random()*t);return function(){return r%=t,r++}}},{}],192:[function(e,t,r){r.parse=e("./lib/parse"),r.stringify=e("./lib/stringify")},{"./lib/parse":193,"./lib/stringify":194}],193:[function(e,t,r){var n,i,o,a,s={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},u=function(e){throw{name:"SyntaxError",message:e,at:n,text:o}},c=function(e){return e&&e!==i&&u("Expected '"+e+"' instead of '"+i+"'"),i=o.charAt(n),n+=1,i},f=function(){var e,t="";for("-"===i&&(t="-",c("-"));i>="0"&&i<="9";)t+=i,c();if("."===i)for(t+=".";c()&&i>="0"&&i<="9";)t+=i;if("e"===i||"E"===i)for(t+=i,c(),"-"!==i&&"+"!==i||(t+=i,c());i>="0"&&i<="9";)t+=i,c();if(e=+t,isFinite(e))return e;u("Bad number")},h=function(){var e,t,r,n="";if('"'===i)for(;c();){if('"'===i)return c(),n;if("\\"===i)if(c(),"u"===i){for(r=0,t=0;t<4&&(e=parseInt(c(),16),isFinite(e));t+=1)r=16*r+e;n+=String.fromCharCode(r)}else{if("string"!=typeof s[i])break;n+=s[i]}else n+=i}u("Bad string")},l=function(){for(;i&&i<=" ";)c()};a=function(){switch(l(),i){case"{":return function(){var e,t={};if("{"===i){if(c("{"),l(),"}"===i)return c("}"),t;for(;i;){if(e=h(),l(),c(":"),Object.hasOwnProperty.call(t,e)&&u('Duplicate key "'+e+'"'),t[e]=a(),l(),"}"===i)return c("}"),t;c(","),l()}}u("Bad object")}();case"[":return function(){var e=[];if("["===i){if(c("["),l(),"]"===i)return c("]"),e;for(;i;){if(e.push(a()),l(),"]"===i)return c("]"),e;c(","),l()}}u("Bad array")}();case'"':return h();case"-":return f();default:return i>="0"&&i<="9"?f():function(){switch(i){case"t":return c("t"),c("r"),c("u"),c("e"),!0;case"f":return c("f"),c("a"),c("l"),c("s"),c("e"),!1;case"n":return c("n"),c("u"),c("l"),c("l"),null}u("Unexpected '"+i+"'")}()}},t.exports=function(e,t){var r;return o=e,n=0,i=" ",r=a(),l(),i&&u("Syntax error"),"function"==typeof t?function e(r,n){var i,o,a=r[n];if(a&&"object"==typeof a)for(i in a)Object.prototype.hasOwnProperty.call(a,i)&&(void 0!==(o=e(a,i))?a[i]=o:delete a[i]);return t.call(r,n,a)}({"":r},""):r}},{}],194:[function(e,t,r){var n,i,o,a=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,s={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function u(e){return a.lastIndex=0,a.test(e)?'"'+e.replace(a,function(e){var t=s[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}t.exports=function(e,t,r){var a;if(n="",i="","number"==typeof r)for(a=0;a>>31),p=l^(a<<1|o>>>31),b=e[0]^d,y=e[1]^p,m=e[10]^d,v=e[11]^p,g=e[20]^d,w=e[21]^p,_=e[30]^d,A=e[31]^p,E=e[40]^d,x=e[41]^p;d=r^(s<<1|u>>>31),p=i^(u<<1|s>>>31);var k=e[2]^d,S=e[3]^p,M=e[12]^d,I=e[13]^p,T=e[22]^d,U=e[23]^p,j=e[32]^d,B=e[33]^p,P=e[42]^d,C=e[43]^p;d=o^(c<<1|f>>>31),p=a^(f<<1|c>>>31);var N=e[4]^d,R=e[5]^p,L=e[14]^d,O=e[15]^p,D=e[24]^d,F=e[25]^p,q=e[34]^d,H=e[35]^p,z=e[44]^d,K=e[45]^p;d=s^(h<<1|l>>>31),p=u^(l<<1|h>>>31);var V=e[6]^d,G=e[7]^p,W=e[16]^d,Y=e[17]^p,X=e[26]^d,Z=e[27]^p,J=e[36]^d,$=e[37]^p,Q=e[46]^d,ee=e[47]^p;d=c^(r<<1|i>>>31),p=f^(i<<1|r>>>31);var te=e[8]^d,re=e[9]^p,ne=e[18]^d,ie=e[19]^p,oe=e[28]^d,ae=e[29]^p,se=e[38]^d,ue=e[39]^p,ce=e[48]^d,fe=e[49]^p,he=b,le=y,de=v<<4|m>>>28,pe=m<<4|v>>>28,be=g<<3|w>>>29,ye=w<<3|g>>>29,me=A<<9|_>>>23,ve=_<<9|A>>>23,ge=E<<18|x>>>14,we=x<<18|E>>>14,_e=k<<1|S>>>31,Ae=S<<1|k>>>31,Ee=I<<12|M>>>20,xe=M<<12|I>>>20,ke=T<<10|U>>>22,Se=U<<10|T>>>22,Me=B<<13|j>>>19,Ie=j<<13|B>>>19,Te=P<<2|C>>>30,Ue=C<<2|P>>>30,je=R<<30|N>>>2,Be=N<<30|R>>>2,Pe=L<<6|O>>>26,Ce=O<<6|L>>>26,Ne=F<<11|D>>>21,Re=D<<11|F>>>21,Le=q<<15|H>>>17,Oe=H<<15|q>>>17,De=K<<29|z>>>3,Fe=z<<29|K>>>3,qe=V<<28|G>>>4,He=G<<28|V>>>4,ze=Y<<23|W>>>9,Ke=W<<23|Y>>>9,Ve=X<<25|Z>>>7,Ge=Z<<25|X>>>7,We=J<<21|$>>>11,Ye=$<<21|J>>>11,Xe=ee<<24|Q>>>8,Ze=Q<<24|ee>>>8,Je=te<<27|re>>>5,$e=re<<27|te>>>5,Qe=ne<<20|ie>>>12,et=ie<<20|ne>>>12,tt=ae<<7|oe>>>25,rt=oe<<7|ae>>>25,nt=se<<8|ue>>>24,it=ue<<8|se>>>24,ot=ce<<14|fe>>>18,at=fe<<14|ce>>>18;e[0]=he^~Ee&Ne,e[1]=le^~xe&Re,e[10]=qe^~Qe&be,e[11]=He^~et&ye,e[20]=_e^~Pe&Ve,e[21]=Ae^~Ce&Ge,e[30]=Je^~de&ke,e[31]=$e^~pe&Se,e[40]=je^~ze&tt,e[41]=Be^~Ke&rt,e[2]=Ee^~Ne&We,e[3]=xe^~Re&Ye,e[12]=Qe^~be&Me,e[13]=et^~ye&Ie,e[22]=Pe^~Ve&nt,e[23]=Ce^~Ge&it,e[32]=de^~ke&Le,e[33]=pe^~Se&Oe,e[42]=ze^~tt&me,e[43]=Ke^~rt&ve,e[4]=Ne^~We&ot,e[5]=Re^~Ye&at,e[14]=be^~Me&De,e[15]=ye^~Ie&Fe,e[24]=Ve^~nt&ge,e[25]=Ge^~it&we,e[34]=ke^~Le&Xe,e[35]=Se^~Oe&Ze,e[44]=tt^~me&Te,e[45]=rt^~ve&Ue,e[6]=We^~ot&he,e[7]=Ye^~at&le,e[16]=Me^~De&qe,e[17]=Ie^~Fe&He,e[26]=nt^~ge&_e,e[27]=it^~we&Ae,e[36]=Le^~Xe&Je,e[37]=Oe^~Ze&$e,e[46]=me^~Te&je,e[47]=ve^~Ue&Be,e[8]=ot^~he&Ee,e[9]=at^~le&xe,e[18]=De^~qe&Qe,e[19]=Fe^~He&et,e[28]=ge^~_e&Pe,e[29]=we^~Ae&Ce,e[38]=Xe^~Je&de,e[39]=Ze^~$e&pe,e[48]=Te^~je&ze,e[49]=Ue^~Be&Ke,e[0]^=n[2*t],e[1]^=n[2*t+1]}}},{}],200:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("./keccak-state-unroll");function o(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}o.prototype.initialize=function(e,t){for(var r=0;r<50;++r)this.state[r]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},o.prototype.absorb=function(e){for(var t=0;t>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(i.p1600(this.state),this.count=0);return t},o.prototype.copy=function(e){for(var t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},t.exports=o},{"./keccak-state-unroll":199,"safe-buffer":290}],201:[function(e,t,r){var n=e("./_root").Symbol;t.exports=n},{"./_root":217}],202:[function(e,t,r){var n=e("./_baseTimes"),i=e("./isArguments"),o=e("./isArray"),a=e("./isBuffer"),s=e("./_isIndex"),u=e("./isTypedArray"),c=Object.prototype.hasOwnProperty;t.exports=function(e,t){var r=o(e),f=!r&&i(e),h=!r&&!f&&a(e),l=!r&&!f&&!h&&u(e),d=r||f||h||l,p=d?n(e.length,String):[],b=p.length;for(var y in e)!t&&!c.call(e,y)||d&&("length"==y||h&&("offset"==y||"parent"==y)||l&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||s(y,b))||p.push(y);return p}},{"./_baseTimes":207,"./_isIndex":211,"./isArguments":219,"./isArray":220,"./isBuffer":222,"./isTypedArray":227}],203:[function(e,t,r){var n=e("./_Symbol"),i=e("./_getRawTag"),o=e("./_objectToString"),a="[object Null]",s="[object Undefined]",u=n?n.toStringTag:void 0;t.exports=function(e){return null==e?void 0===e?s:a:u&&u in Object(e)?i(e):o(e)}},{"./_Symbol":201,"./_getRawTag":210,"./_objectToString":215}],204:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isObjectLike"),o="[object Arguments]";t.exports=function(e){return i(e)&&n(e)==o}},{"./_baseGetTag":203,"./isObjectLike":226}],205:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isLength"),o=e("./isObjectLike"),a={};a["[object Float32Array]"]=a["[object Float64Array]"]=a["[object Int8Array]"]=a["[object Int16Array]"]=a["[object Int32Array]"]=a["[object Uint8Array]"]=a["[object Uint8ClampedArray]"]=a["[object Uint16Array]"]=a["[object Uint32Array]"]=!0,a["[object Arguments]"]=a["[object Array]"]=a["[object ArrayBuffer]"]=a["[object Boolean]"]=a["[object DataView]"]=a["[object Date]"]=a["[object Error]"]=a["[object Function]"]=a["[object Map]"]=a["[object Number]"]=a["[object Object]"]=a["[object RegExp]"]=a["[object Set]"]=a["[object String]"]=a["[object WeakMap]"]=!1,t.exports=function(e){return o(e)&&i(e.length)&&!!a[n(e)]}},{"./_baseGetTag":203,"./isLength":224,"./isObjectLike":226}],206:[function(e,t,r){var n=e("./_isPrototype"),i=e("./_nativeKeys"),o=Object.prototype.hasOwnProperty;t.exports=function(e){if(!n(e))return i(e);var t=[];for(var r in Object(e))o.call(e,r)&&"constructor"!=r&&t.push(r);return t}},{"./_isPrototype":212,"./_nativeKeys":213}],207:[function(e,t,r){t.exports=function(e,t){for(var r=-1,n=Array(e);++r-1&&e%1==0&&e-1&&e%1==0&&e<=n}},{}],225:[function(e,t,r){t.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},{}],226:[function(e,t,r){t.exports=function(e){return null!=e&&"object"==typeof e}},{}],227:[function(e,t,r){var n=e("./_baseIsTypedArray"),i=e("./_baseUnary"),o=e("./_nodeUtil"),a=o&&o.isTypedArray,s=a?i(a):n;t.exports=s},{"./_baseIsTypedArray":205,"./_baseUnary":208,"./_nodeUtil":214}],228:[function(e,t,r){var n=e("./_arrayLikeKeys"),i=e("./_baseKeys"),o=e("./isArrayLike");t.exports=function(e){return o(e)?n(e):i(e)}},{"./_arrayLikeKeys":202,"./_baseKeys":206,"./isArrayLike":221}],229:[function(e,t,r){t.exports=function(){}},{}],230:[function(e,t,r){t.exports=function(){return!1}},{}],231:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base"),o=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function s(e,t){return e<>>32-t}function u(e,t,r,n,i,o,a){return s(e+(t&r|~t&n)+i+o|0,a)+t|0}function c(e,t,r,n,i,o,a){return s(e+(t&n|r&~n)+i+o|0,a)+t|0}function f(e,t,r,n,i,o,a){return s(e+(t^r^n)+i+o|0,a)+t|0}function h(e,t,r,n,i,o,a){return s(e+(r^(t|~n))+i+o|0,a)+t|0}n(a,i),a.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,a=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,a=u(a,r=u(r,n,i,a,e[0],3614090360,7),n,i,e[1],3905402710,12),r,n,e[2],606105819,17),a,r,e[3],3250441966,22),i=u(i,a=u(a,r=u(r,n,i,a,e[4],4118548399,7),n,i,e[5],1200080426,12),r,n,e[6],2821735955,17),a,r,e[7],4249261313,22),i=u(i,a=u(a,r=u(r,n,i,a,e[8],1770035416,7),n,i,e[9],2336552879,12),r,n,e[10],4294925233,17),a,r,e[11],2304563134,22),i=u(i,a=u(a,r=u(r,n,i,a,e[12],1804603682,7),n,i,e[13],4254626195,12),r,n,e[14],2792965006,17),a,r,e[15],1236535329,22),i=c(i,a=c(a,r=c(r,n,i,a,e[1],4129170786,5),n,i,e[6],3225465664,9),r,n,e[11],643717713,14),a,r,e[0],3921069994,20),i=c(i,a=c(a,r=c(r,n,i,a,e[5],3593408605,5),n,i,e[10],38016083,9),r,n,e[15],3634488961,14),a,r,e[4],3889429448,20),i=c(i,a=c(a,r=c(r,n,i,a,e[9],568446438,5),n,i,e[14],3275163606,9),r,n,e[3],4107603335,14),a,r,e[8],1163531501,20),i=c(i,a=c(a,r=c(r,n,i,a,e[13],2850285829,5),n,i,e[2],4243563512,9),r,n,e[7],1735328473,14),a,r,e[12],2368359562,20),i=f(i,a=f(a,r=f(r,n,i,a,e[5],4294588738,4),n,i,e[8],2272392833,11),r,n,e[11],1839030562,16),a,r,e[14],4259657740,23),i=f(i,a=f(a,r=f(r,n,i,a,e[1],2763975236,4),n,i,e[4],1272893353,11),r,n,e[7],4139469664,16),a,r,e[10],3200236656,23),i=f(i,a=f(a,r=f(r,n,i,a,e[13],681279174,4),n,i,e[0],3936430074,11),r,n,e[3],3572445317,16),a,r,e[6],76029189,23),i=f(i,a=f(a,r=f(r,n,i,a,e[9],3654602809,4),n,i,e[12],3873151461,11),r,n,e[15],530742520,16),a,r,e[2],3299628645,23),i=h(i,a=h(a,r=h(r,n,i,a,e[0],4096336452,6),n,i,e[7],1126891415,10),r,n,e[14],2878612391,15),a,r,e[5],4237533241,21),i=h(i,a=h(a,r=h(r,n,i,a,e[12],1700485571,6),n,i,e[3],2399980690,10),r,n,e[10],4293915773,15),a,r,e[1],2240044497,21),i=h(i,a=h(a,r=h(r,n,i,a,e[8],1873313359,6),n,i,e[15],4264355552,10),r,n,e[6],2734768916,15),a,r,e[13],1309151649,21),i=h(i,a=h(a,r=h(r,n,i,a,e[4],4149444226,6),n,i,e[11],3174756917,10),r,n,e[2],718787259,15),a,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+a|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=a}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":232,inherits:180}],232:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("stream").Transform;function o(e){i.call(this),this._block=n.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}e("inherits")(o,i),o.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},o.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},o.prototype.update=function(e,t){if(function(e,t){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");n.isBuffer(e)||(e=n.from(e,t));for(var r=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},{inherits:180,"safe-buffer":290,stream:311}],233:[function(e,t,r){var n=e("bn.js"),i=e("brorand");function o(e){this.rand=e||new i.Rand}t.exports=o,o.create=function(e){return new o(e)},o.prototype._randbelow=function(e){var t=e.bitLength(),r=Math.ceil(t/8);do{var i=new n(this.rand.generate(r))}while(i.cmp(e)>=0);return i},o.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},o.prototype.test=function(e,t,r){var i=e.bitLength(),o=n.mont(e),a=new n(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var s=e.subn(1),u=0;!s.testn(u);u++);for(var c=e.shrn(u),f=s.toRed(o);t>0;t--){var h=this._randrange(new n(2),s);r&&r(h);var l=h.toRed(o).redPow(c);if(0!==l.cmp(a)&&0!==l.cmp(f)){for(var d=1;d0;t--){var f=this._randrange(new n(2),a),h=e.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(u);if(0!==l.cmp(o)&&0!==l.cmp(c)){for(var d=1;d>8,a=255&i;o?r.push(o,a):r.push(a)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},{}],236:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],237:[function(e,t,r){var n=e("bn.js"),i=e("strip-hex-prefix");t.exports=function(e){if("string"==typeof e||"number"==typeof e){var t=new n(1),r=String(e).toLowerCase().trim(),o="0x"===r.substr(0,2)||"-0x"===r.substr(0,3),a=i(r);if("-"===a.substr(0,1)&&(a=i(a.slice(1)),t=new n(-1,10)),!(a=""===a?"0":a).match(/^-?[0-9]+$/)&&a.match(/^[0-9A-Fa-f]+$/)||a.match(/^[a-fA-F]+$/)||!0===o&&a.match(/^[0-9A-Fa-f]+$/))return new n(a,16).mul(t);if((a.match(/^-?[0-9]+$/)||""===a)&&!1===o)return new n(a,10).mul(t)}else if("object"==typeof e&&e.toString&&!e.pop&&!e.push&&e.toString(10).match(/^-?[0-9]+$/)&&(e.mul||e.dividedToIntegerBy))return new n(e.toString(10),10);throw new Error("[number-to-bn] while converting number "+JSON.stringify(e)+" to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.")}},{"bn.js":236,"strip-hex-prefix":318}],238:[function(e,t,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,a,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),u=1;u0;)if(q+=r,r=e.charAt(o++),4===H?(N+=String.fromCharCode(parseInt(q,16)),H=0,c=o-1):H++,!r)break e;if('"'===r&&!L){D=F.pop()||p,N+=e.substring(c,o-1);break}if(!("\\"!==r||L||(L=!0,N+=e.substring(c,o-1),r=e.charAt(o++))))break;if(L){if(L=!1,"n"===r?N+="\n":"r"===r?N+="\r":"t"===r?N+="\t":"f"===r?N+="\f":"b"===r?N+="\b":"u"===r?(H=1,q=""):N+=r,r=e.charAt(o++),c=o-1,r)continue;break}h.lastIndex=o;var l=h.exec(e);if(!l){o=e.length+1,N+=e.substring(c,o-1);break}if(o=l.index+1,!(r=e.charAt(l.index))){N+=e.substring(c,o-1);break}}continue;case A:if(!r)continue;if("r"!==r)return W("Invalid true started with t"+r);D=E;continue;case E:if(!r)continue;if("u"!==r)return W("Invalid true started with tr"+r);D=x;continue;case x:if(!r)continue;if("e"!==r)return W("Invalid true started with tru"+r);a(!0),u(),D=F.pop()||p;continue;case k:if(!r)continue;if("a"!==r)return W("Invalid false started with f"+r);D=S;continue;case S:if(!r)continue;if("l"!==r)return W("Invalid false started with fa"+r);D=M;continue;case M:if(!r)continue;if("s"!==r)return W("Invalid false started with fal"+r);D=I;continue;case I:if(!r)continue;if("e"!==r)return W("Invalid false started with fals"+r);a(!1),u(),D=F.pop()||p;continue;case T:if(!r)continue;if("u"!==r)return W("Invalid null started with n"+r);D=U;continue;case U:if(!r)continue;if("l"!==r)return W("Invalid null started with nu"+r);D=j;continue;case j:if(!r)continue;if("l"!==r)return W("Invalid null started with nul"+r);a(null),u(),D=F.pop()||p;continue;case B:if("."!==r)return W("Leading zero not followed by .");R+=r,D=P;continue;case P:if(-1!=="0123456789".indexOf(r))R+=r;else if("."===r){if(-1!==R.indexOf("."))return W("Invalid number has two dots");R+=r}else if("e"===r||"E"===r){if(-1!==R.indexOf("e")||-1!==R.indexOf("E"))return W("Invalid number has two exponential");R+=r}else if("+"===r||"-"===r){if("e"!==n&&"E"!==n)return W("Invalid symbol in number");R+=r}else R&&(a(parseFloat(R)),u(),R=""),o--,D=F.pop()||p;continue;default:return W("Unknown state: "+D)}K>=C&&(X=0,N!==s&&N.length>f&&(W("Max buffer length exceeded: textNode"),X=Math.max(X,N.length)),R.length>f&&(W("Max buffer length exceeded: numberNode"),X=Math.max(X,R.length)),C=f-X+K);var X}),e(ce).on(function(){if(D==d)return a({}),u(),void(O=!0);D===p&&0===z||W("Unexpected end");N!==s&&(a(N),u(),N=s);O=!0})}var C,N,R,L,O,D,F,q,H,z,K,V=(C=d(function(e){return e.unshift(/^/),(t=RegExp(e.map(f("source")).join(""))).exec.bind(t);var t}),L=C(N=/(\$?)/,/([\w-_]+|\*)/,R=/(?:{([\w ]*?)})?/),O=C(N,/\["([^"]+)"\]/,R),D=C(N,/\[(\d+|\*)\]/,R),F=C(N,/()/,/{([\w ]*?)}/),q=C(/\.\./),H=C(/\./),z=C(N,/!/),K=C(/$/),function(e){return e(h(L,O,D,F),q,H,z,K)});function G(e,t){return{key:e,node:t}}var W=f("key"),Y=f("node"),X={};function Z(e){var t=e(ee).emit,r=e(te).emit,n=e(ae).emit,o=e(oe).emit;function a(e,t,r){Y(x(e))[t]=r}function s(e,r,n){e&&a(e,r,n);var i=A(G(r,n),e);return t(i),i}var u={};return u[le]=function(e,t){if(!e)return n(t),s(e,X,t);var r=function(e,t){var r=Y(x(e));return m(i,r)?s(e,v(r),t):e}(e,t),o=k(r),u=W(x(r));return a(o,u,t),A(G(u,t),o)},u[de]=function(e){return r(e),k(e)||o(Y(x(e)))},u[he]=s,u}var J=V(function(e,t,r,n,i){var a=1,s=2,f=3,l=c(W,x),d=c(Y,x);function b(e,t){return!!t[a]?p(e,x):e}function m(e){if(e==y)return y;return p(function(e){return l(e)!=X},c(e,k))}function g(){return function(e){return l(e)==X}}function w(e,t,r,n,i){var o=e(r);if(o){var a=function(e,t,r){return U(function(e,t){return t(e,r)},t,e)}(t,n,o);return i(r.substr(v(o[0])),a)}}function A(e,t){return u(w,e,t)}var E=h(A(e,M(b,function(e,t){var r=t[f];return r?p(c(u(_,S(r.split(/\W+/))),d),e):e},function(e,t){var r=t[s];return p(r&&"*"!=r?function(e){return l(e)==r}:y,e)},m)),A(t,M(function(e){if(e==y)return y;var t=g(),r=e,n=m(function(e){return i(e)}),i=h(t,r,n);return i})),A(r,M()),A(n,M(b,g)),A(i,M(function(e){return function(t){var r=e(t);return!0===r?x(t):r}})),function(e){throw o('"'+e+'" could not be tokenised')});function I(e,t){return t}function T(e,t){return E(e,t,e?T:I)}return function(e){try{return T(e,y)}catch(t){throw o('Could not compile "'+e+'" because '+t.message)}}});function $(e,t,r){var n,i;function o(e){return function(t){return t.id==e}}return{on:function(r,o){var a={listener:r,id:o||r};return t&&t.emit(e,r,a.id),n=A(a,n),i=A(r,i),this},emit:function(){!function e(t,r){t&&(x(t).apply(null,r),e(k(t),r))}(i,arguments)},un:function(t){var a;n=j(n,o(t),function(e){a=e}),a&&(i=j(i,function(e){return e==a.listener}),r&&r.emit(e,a.listener,a.id))},listeners:function(){return i},hasListener:function(e){return w(function e(t,r){return r&&(t(x(r))?x(r):e(t,k(r)))}(e?o(e):y,n))}}}var Q=1,ee=Q++,te=Q++,re=Q++,ne=Q++,ie="fail",oe=Q++,ae=Q++,se="start",ue="data",ce="end",fe=Q++,he=Q++,le=Q++,de=Q++;function pe(e,t,r){try{var n=a.parse(t)}catch(e){}return{statusCode:e,body:t,jsonBody:n,thrown:r}}function be(e,t){var r={node:e(te),path:e(ee)};function n(t,r,n){var i=e(t).emit;r.on(function(e){var t=n(e);!1!==t&&function(e,t,r){var n=B(r);e(t,I(k(T(W,n))),I(T(Y,n)))}(i,Y(t),e)},t),e("removeListener").on(function(n){n==t&&(e(n).listeners()||r.un(t))})}e("newListener").on(function(e){var i=/(node|path):(.*)/.exec(e);if(i){var o=r[i[1]];o.hasListener(e)||n(e,o,t(i[2]))}})}function ye(e,t){var r,n=/^(node|path):./,i=e(oe),o=e(ne).emit,a=e(re).emit,s=d(function(t,i){if(r[t])l(i,r[t]);else{var o=e(t),a=i[0];n.test(t)?c(o,a):o.on(a)}return r});function c(e,t,n){n=n||t;var i=f(t);return e.on(function(){var t=!1;r.forget=function(){t=!0},l(arguments,i),delete r.forget,t&&e.un(n)},n),r}function f(e){return function(){try{return e.apply(r,arguments)}catch(e){setTimeout(function(){throw e})}}}function h(t,r,n){var i;i="node"==t?function(e){return function(){var t=e.apply(this,arguments);w(t)&&(t==ge.drop?o():a(t))}}(n):n,c(function(t,r){return e(t+":"+r)}(t,r),i,n)}function p(e,t,n){return g(t)?h(e,t,n):function(e,t){for(var r in t)h(e,r,t[r])}(e,t),r}return e(ae).on(function(e){var t;r.root=(t=e,function(){return t})}),e(se).on(function(e,t){r.header=function(e){return e?t[e]:t}}),r={on:s,addListener:s,removeListener:function(t,n,o){if("done"==t)i.un(n);else if("node"==t||"path"==t)e.un(t+":"+n,o);else{var a=n;e(t).un(a)}return r},emit:e.emit,node:u(p,"node"),path:u(p,"path"),done:u(c,i),start:u(function(t,n){return e(t).on(f(n),n),r},se),fail:e(ie).on,abort:e(fe).emit,header:b,root:b,source:t}}function me(t,r,n,i,o){var a=function(){var e={},t=n("newListener"),r=n("removeListener");function n(n){return e[n]=$(n,t,r)}function i(t){return e[t]||n(t)}return["emit","on","un"].forEach(function(e){i[e]=d(function(t,r){l(r,i(t)[e])})}),i}();return r&&function(t,r,n,i,o,a,c){"use strict";var f=t(ue).emit,h=t(ie).emit,l=0,d=!0;function p(){var e=r.responseText,t=e.substr(l);t&&f(t),l=v(e)}t(fe).on(function(){r.onreadystatechange=null,r.abort()}),"onprogress"in r&&(r.onprogress=p),r.onreadystatechange=function(){function e(){try{d&&t(se).emit(r.status,(e=r.getAllResponseHeaders(),n={},e&&e.split("\r\n").forEach(function(e){var t=e.indexOf(": ");n[e.substring(0,t)]=e.substring(t+2)}),n)),d=!1}catch(e){}var e,n}switch(r.readyState){case 2:case 3:return e();case 4:e(),2==String(r.status)[0]?(p(),t(ce).emit()):h(pe(r.status,r.responseText))}};try{for(var b in r.open(n,i,!0),a)r.setRequestHeader(b,a[b]);(function(e,t){function r(t){return t.port||{"http:":80,"https:":443}[t.protocol||e.protocol]}return!!(t.protocol&&t.protocol!=e.protocol||t.host&&t.host!=e.host||t.host&&r(t)!=r(e))})(e.location,function(e){var t=/(\w+:)?(?:\/\/)([\w.-]+)?(?::(\d+))?\/?/.exec(e)||[];return{protocol:t[1]||"",host:t[2]||"",port:t[3]||""}}(i))||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.withCredentials=c,r.send(o)}catch(t){e.setTimeout(u(h,pe(s,s,t)),0)}}(a,new XMLHttpRequest,t,r,n,i,o),P(a),function(e,t){"use strict";var r,n={};function i(e){return function(t){r=e(r,t)}}for(var o in t)e(o).on(i(t[o]),n);e(re).on(function(e){var t=x(r),n=W(t),i=k(r);i&&(Y(x(i))[n]=e)}),e(ne).on(function(){var e=x(r),t=W(e),n=k(r);n&&delete Y(x(n))[t]}),e(fe).on(function(){for(var r in t)e(r).un(n)})}(a,Z(a)),be(a,J),ye(a,r)}function ve(e,t,r,n,i,o,s){return i=i?a.parse(a.stringify(i)):{},n?g(n)||(n=a.stringify(n),i["Content-Type"]=i["Content-Type"]||"application/json"):n=null,e(r||"GET",function(e,t){return!1===t&&(-1==e.indexOf("?")?e+="?":e+="&",e+="_="+(new Date).getTime()),e}(t,s),n,i,o||!1)}function ge(e){var t=M("resume","pause","pipe"),r=u(_,t);return e?r(e)||g(e)?ve(me,e):ve(me,e.url,e.method,e.body,e.headers,e.withCredentials,e.cached):me()}ge.drop=function(){return ge.drop},"function"==typeof define&&define.amd?define("oboe",[],function(){return ge}):"object"==typeof r?t.exports=ge:e.oboe=ge}(function(){try{return window}catch(e){return self}}(),Object,Array,Error,JSON)},{}],240:[function(e,t,r){r.endianness=function(){return"LE"},r.hostname=function(){return"undefined"!=typeof location?location.hostname:""},r.loadavg=function(){return[]},r.uptime=function(){return 0},r.freemem=function(){return Number.MAX_VALUE},r.totalmem=function(){return Number.MAX_VALUE},r.cpus=function(){return[]},r.type=function(){return"Browser"},r.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},r.networkInterfaces=r.getNetworkInterfaces=function(){return{}},r.arch=function(){return"javascript"},r.platform=function(){return"browser"},r.tmpdir=r.tmpDir=function(){return"/tmp"},r.EOL="\n",r.homedir=function(){return"/"}},{}],241:[function(e,t,r){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],242:[function(e,t,r){"use strict";var n=e("asn1.js");r.certificate=e("./certificate");var i=n.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});r.RSAPrivateKey=i;var o=n.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});r.RSAPublicKey=o;var a=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())});r.PublicKey=a;var s=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),u=n.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(s),this.key("subjectPrivateKey").octstr())});r.PrivateKey=u;var c=n.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});r.EncryptedPrivateKey=c;var f=n.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});r.DSAPrivateKey=f,r.DSAparam=n.define("DSAparam",function(){this.int()});var h=n.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(l),this.key("publicKey").optional().explicit(1).bitstr())});r.ECPrivateKey=h;var l=n.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});r.signature=n.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},{"./certificate":243,"asn1.js":5}],243:[function(e,t,r){"use strict";var n=e("asn1.js"),i=n.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),o=n.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),a=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional())}),s=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())}),u=n.define("RelativeDistinguishedName",function(){this.setof(o)}),c=n.define("RDNSequence",function(){this.seqof(u)}),f=n.define("Name",function(){this.choice({rdnSequence:this.use(c)})}),h=n.define("Validity",function(){this.seq().obj(this.key("notBefore").use(i),this.key("notAfter").use(i))}),l=n.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),d=n.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int(),this.key("serialNumber").int(),this.key("signature").use(a),this.key("issuer").use(f),this.key("validity").use(h),this.key("subject").use(f),this.key("subjectPublicKeyInfo").use(s),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(l).optional())}),p=n.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(a),this.key("signatureValue").bitstr())});t.exports=p},{"asn1.js":5}],244:[function(e,t,r){(function(r){var n=/Proc-Type: 4,ENCRYPTED\n\r?DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\n\r?\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?/m,i=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n/m,o=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?-----END \1-----$/m,a=e("evp_bytestokey"),s=e("browserify-aes");t.exports=function(e,t){var u,c=e.toString(),f=c.match(n);if(f){var h="aes"+f[1],l=new r(f[2],"hex"),d=new r(f[3].replace(/\r?\n/g,""),"base64"),p=a(t,l.slice(0,8),parseInt(f[1],10)).key,b=[],y=s.createDecipheriv(h,p,l);b.push(y.update(d)),b.push(y.final()),u=r.concat(b)}else{var m=c.match(o);u=new r(m[2].replace(/\r?\n/g,""),"base64")}return{tag:c.match(i)[1],data:u}}}).call(this,e("buffer").Buffer)},{"browserify-aes":58,buffer:84,evp_bytestokey:158}],245:[function(e,t,r){(function(r){var n=e("./asn1"),i=e("./aesid.json"),o=e("./fixProc"),a=e("browserify-aes"),s=e("pbkdf2");function u(e){var t;"object"!=typeof e||r.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=new r(e));var u,c,f=o(e,t),h=f.tag,l=f.data;switch(h){case"CERTIFICATE":c=n.certificate.decode(l,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(c||(c=n.PublicKey.decode(l,"der")),u=c.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPublicKey.decode(c.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return c.subjectPrivateKey=c.subjectPublicKey,{type:"ec",data:c};case"1.2.840.10040.4.1":return c.algorithm.params.pub_key=n.DSAparam.decode(c.subjectPublicKey.data,"der"),{type:"dsa",data:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"ENCRYPTED PRIVATE KEY":l=function(e,t){var n=e.algorithm.decrypt.kde.kdeparams.salt,o=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),u=i[e.algorithm.decrypt.cipher.algo.join(".")],c=e.algorithm.decrypt.cipher.iv,f=e.subjectPrivateKey,h=parseInt(u.split("-")[1],10)/8,l=s.pbkdf2Sync(t,n,o,h),d=a.createDecipheriv(u,l,c),p=[];return p.push(d.update(f)),p.push(d.final()),r.concat(p)}(l=n.EncryptedPrivateKey.decode(l,"der"),t);case"PRIVATE KEY":switch(u=(c=n.PrivateKey.decode(l,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPrivateKey.decode(c.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:c.algorithm.curve,privateKey:n.ECPrivateKey.decode(c.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return c.algorithm.params.priv_key=n.DSAparam.decode(c.subjectPrivateKey,"der"),{type:"dsa",params:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"RSA PUBLIC KEY":return n.RSAPublicKey.decode(l,"der");case"RSA PRIVATE KEY":return n.RSAPrivateKey.decode(l,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:n.DSAPrivateKey.decode(l,"der")};case"EC PRIVATE KEY":return{curve:(l=n.ECPrivateKey.decode(l,"der")).parameters.value,privateKey:l.privateKey};default:throw new Error("unknown key type "+h)}}t.exports=u,u.signature=n.signature}).call(this,e("buffer").Buffer)},{"./aesid.json":241,"./asn1":242,"./fixProc":244,"browserify-aes":58,buffer:84,pbkdf2:247}],246:[function(e,t,r){var n=e("trim"),i=e("for-each");t.exports=function(e){if(!e)return{};var t={};return i(n(e).split("\n"),function(e){var r,i=e.indexOf(":"),o=n(e.slice(0,i)).toLowerCase(),a=n(e.slice(i+1));void 0===t[o]?t[o]=a:(r=t[o],"[object Array]"===Object.prototype.toString.call(r)?t[o].push(a):t[o]=[t[o],a])}),t}},{"for-each":159,trim:324}],247:[function(e,t,r){r.pbkdf2=e("./lib/async"),r.pbkdf2Sync=e("./lib/sync")},{"./lib/async":248,"./lib/sync":251}],248:[function(e,t,r){(function(r,n){var i,o=e("./precondition"),a=e("./default-encoding"),s=e("./sync"),u=e("safe-buffer").Buffer,c=n.crypto&&n.crypto.subtle,f={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},h=[];function l(e,t,r,n,i){return c.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then(function(e){return c.deriveBits({name:"PBKDF2",salt:t,iterations:r,hash:{name:i}},e,n<<3)}).then(function(e){return u.from(e)})}t.exports=function(e,t,d,p,b,y){if(u.isBuffer(e)||(e=u.from(e,a)),u.isBuffer(t)||(t=u.from(t,a)),o(d,p),"function"==typeof b&&(y=b,b=void 0),"function"!=typeof y)throw new Error("No callback provided to pbkdf2");var m=f[(b=b||"sha1").toLowerCase()];if(!m||"function"!=typeof n.Promise)return r.nextTick(function(){var r;try{r=s(e,t,d,p,b)}catch(e){return y(e)}y(null,r)});!function(e,t){e.then(function(e){r.nextTick(function(){t(null,e)})},function(e){r.nextTick(function(){t(e)})})}(function(e){if(n.process&&!n.process.browser)return Promise.resolve(!1);if(!c||!c.importKey||!c.deriveBits)return Promise.resolve(!1);if(void 0!==h[e])return h[e];var t=l(i=i||u.alloc(8),i,10,128,e).then(function(){return!0}).catch(function(){return!1});return h[e]=t,t}(m).then(function(r){return r?l(e,t,d,p,m):s(e,t,d,p,b)}),y)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-encoding":249,"./precondition":250,"./sync":251,_process:257,"safe-buffer":290}],249:[function(e,t,r){(function(e){var r;e.browser?r="utf-8":r=parseInt(e.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary";t.exports=r}).call(this,e("_process"))},{_process:257}],250:[function(e,t,r){var n=Math.pow(2,30)-1;t.exports=function(e,t){if("number"!=typeof e)throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if("number"!=typeof t)throw new TypeError("Key length not a number");if(t<0||t>n||t!=t)throw new TypeError("Bad key length")}},{}],251:[function(e,t,r){var n=e("create-hash/md5"),i=e("ripemd160"),o=e("sha.js"),a=e("./precondition"),s=e("./default-encoding"),u=e("safe-buffer").Buffer,c=u.alloc(128),f={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function h(e,t,r){var a=function(e){return"rmd160"===e||"ripemd160"===e?i:"md5"===e?n:function(t){return o(e).update(t).digest()}}(e),s="sha512"===e||"sha384"===e?128:64;t.length>s?t=a(t):t.length1)for(var r=1;rp||new a(t).cmp(d.modulus)>=0)throw new Error("decryption error");l=f?c(new a(t),d):s(t,d);var b=new r(p-l.length);if(b.fill(0),l=r.concat([b,l],p),4===h)return function(e,t){e.modulus;var n=e.modulus.byteLength(),a=(t.length,u("sha1").update(new r("")).digest()),s=a.length;if(0!==t[0])throw new Error("decryption error");var c=t.slice(1,s+1),f=t.slice(s+1),h=o(c,i(f,s)),l=o(f,i(h,n-s-1));if(function(e,t){e=new r(e),t=new r(t);var n=0,i=e.length;e.length!==t.length&&(n++,i=Math.min(e.length,t.length));var o=-1;for(;++o=t.length){o++;break}var a=t.slice(2,i-1);t.slice(i-1,i);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;a.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,l,f);if(3===h)return l;throw new Error("unknown padding")}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245}],262:[function(e,t,r){(function(r){var n=e("parse-asn1"),i=e("randombytes"),o=e("create-hash"),a=e("./mgf"),s=e("./xor"),u=e("bn.js"),c=e("./withPublic"),f=e("browserify-rsa");t.exports=function(e,t,h){var l;l=e.padding?e.padding:h?1:4;var d,p=n(e);if(4===l)d=function(e,t){var n=e.modulus.byteLength(),c=t.length,f=o("sha1").update(new r("")).digest(),h=f.length,l=2*h;if(c>n-l-2)throw new Error("message too long");var d=new r(n-c-l-2);d.fill(0);var p=n-h-1,b=i(h),y=s(r.concat([f,d,new r([1]),t],p),a(b,p)),m=s(b,a(y,h));return new u(r.concat([new r([0]),m,y],n))}(p,t);else if(1===l)d=function(e,t,n){var o,a=t.length,s=e.modulus.byteLength();if(a>s-11)throw new Error("message too long");n?(o=new r(s-a-3)).fill(255):o=function(e,t){var n,o=new r(e),a=0,s=i(2*e),u=0;for(;a=0)throw new Error("data too long for modulus")}return h?f(d,p):c(d,p)}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245,randombytes:270}],263:[function(e,t,r){(function(r){var n=e("bn.js");t.exports=function(e,t){return new r(e.toRed(n.mont(t.modulus)).redPow(new n(t.publicExponent)).fromRed().toArray())}}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84}],264:[function(e,t,r){t.exports=function(e,t){for(var r=e.length,n=-1;++n= 0x80 (not a basic code point)","invalid-input":"Invalid input"},A=f-h,E=Math.floor,x=String.fromCharCode;function k(e){throw new RangeError(_[e])}function S(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function M(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+S((e=e.replace(w,".")).split("."),t).join(".")}function I(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=x((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=x(e)}).join("")}function U(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function j(e,t,r){var n=0;for(e=r?E(e/p):e>>1,e+=E(e/t);e>A*l>>1;n+=f)e=E(e/A);return E(n+(A+1)*e/(e+d))}function B(e){var t,r,n,i,o,a,s,u,d,p,v,g=[],w=e.length,_=0,A=y,x=b;for((r=e.lastIndexOf(m))<0&&(r=0),n=0;n=128&&k("not-basic"),g.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=w&&k("invalid-input"),((u=(v=e.charCodeAt(i++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:f)>=f||u>E((c-_)/a))&&k("overflow"),_+=u*a,!(u<(d=s<=x?h:s>=x+l?l:s-x));s+=f)a>E(c/(p=f-d))&&k("overflow"),a*=p;x=j(_-o,t=g.length+1,0==o),E(_/t)>c-A&&k("overflow"),A+=E(_/t),_%=t,g.splice(_++,0,A)}return T(g)}function P(e){var t,r,n,i,o,a,s,u,d,p,v,g,w,_,A,S=[];for(g=(e=I(e)).length,t=y,r=0,o=b,a=0;a=t&&vE((c-r)/(w=n+1))&&k("overflow"),r+=(s-t)*w,t=s,a=0;ac&&k("overflow"),v==t){for(u=r,d=f;!(u<(p=d<=o?h:d>=o+l?l:d-o));d+=f)A=u-p,_=f-p,S.push(x(U(p+A%_,0))),u=E(A/_);S.push(x(U(u,0))),o=j(r,w,n==i),r=0,++n}++r,++t}return S.join("")}if(s={version:"1.4.1",ucs2:{decode:I,encode:T},decode:B,encode:P,toASCII:function(e){return M(e,function(e){return g.test(e)?"xn--"+P(e):e})},toUnicode:function(e){return M(e,function(e){return v.test(e)?B(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return s});else if(i&&o)if(t.exports==i)o.exports=s;else for(u in s)s.hasOwnProperty(u)&&(i[u]=s[u]);else n.punycode=s}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],266:[function(e,t,r){"use strict";var n=e("strict-uri-encode"),i=e("object-assign"),o=e("decode-uri-component");function a(e,t){return t.encode?t.strict?n(e):encodeURIComponent(e):e}function s(e){var t=e.indexOf("?");return-1===t?"":e.slice(t+1)}function u(e,t){var r=function(e){var t;switch(e.arrayFormat){case"index":return function(e,r,n){t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return function(e,r,n){t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};default:return function(e,t,r){void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t=i({arrayFormat:"none"},t)),n=Object.create(null);return"string"!=typeof e?n:(e=e.trim().replace(/^[?#&]/,""))?(e.split("&").forEach(function(e){var t=e.replace(/\+/g," ").split("="),i=t.shift(),a=t.length>0?t.join("="):void 0;a=void 0===a?null:o(a),r(o(i),a,n)}),Object.keys(n).sort().reduce(function(e,t){var r=n[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=function e(t){return Array.isArray(t)?t.sort():"object"==typeof t?e(Object.keys(t)).sort(function(e,t){return Number(e)-Number(t)}).map(function(e){return t[e]}):t}(r):e[t]=r,e},Object.create(null))):n}r.extract=s,r.parse=u,r.stringify=function(e,t){!1===(t=i({encode:!0,strict:!0,arrayFormat:"none"},t)).sort&&(t.sort=function(){});var r=function(e){switch(e.arrayFormat){case"index":return function(t,r,n){return null===r?[a(t,e),"[",n,"]"].join(""):[a(t,e),"[",a(n,e),"]=",a(r,e)].join("")};case"bracket":return function(t,r){return null===r?a(t,e):[a(t,e),"[]=",a(r,e)].join("")};default:return function(t,r){return null===r?a(t,e):[a(t,e),"=",a(r,e)].join("")}}}(t);return e?Object.keys(e).sort(t.sort).map(function(n){var i=e[n];if(void 0===i)return"";if(null===i)return a(n,t);if(Array.isArray(i)){var o=[];return i.slice().forEach(function(e){void 0!==e&&o.push(r(n,e,o.length))}),o.join("&")}return a(n,t)+"="+a(i,t)}).filter(function(e){return e.length>0}).join("&"):""},r.parseUrl=function(e,t){return{url:e.split("?")[0]||"",query:u(s(e),t)}}},{"decode-uri-component":98,"object-assign":238,"strict-uri-encode":316}],267:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&",r=r||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(a,d)?i(a[d])?a[d].push(p):a[d]=[a[d],p]:a[d]=p}return a};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],268:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,s){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),function(a){var s=encodeURIComponent(n(a))+r;return i(e[a])?o(e[a],function(e){return s+encodeURIComponent(n(e))}).join(t):s+encodeURIComponent(n(e[a]))}).join(t):s?encodeURIComponent(n(s))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n65536)throw new Error("requested too many random bytes");var a=new n.Uint8Array(e);e>0&&o.getRandomValues(a);var s=i.from(a.buffer);if("function"==typeof t)return r.nextTick(function(){t(null,s)});return s}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,"safe-buffer":290}],271:[function(e,t,r){(function(t,n){"use strict";function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=e("safe-buffer"),a=e("randombytes"),s=o.Buffer,u=o.kMaxLength,c=n.crypto||n.msCrypto,f=Math.pow(2,32)-1;function h(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>f||e<0)throw new TypeError("offset must be a uint32");if(e>u||e>t)throw new RangeError("offset out of range")}function l(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>f||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>u)throw new RangeError("buffer too small")}function d(e,r,n,i){if(t.browser){var o=e.buffer,s=new Uint8Array(o,r,n);return c.getRandomValues(s),i?void t.nextTick(function(){i(null,e)}):e}if(!i)return a(n).copy(e,r),e;a(n,function(t,n){if(t)return i(t);n.copy(e,r),i(null,e)})}c&&c.getRandomValues||!t.browser?(r.randomFill=function(e,t,r,i){if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)i=t,t=0,r=e.length;else if("function"==typeof r)i=r,r=e.length-t;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return h(t,e.length),l(r,t,e.length),d(e,t,r,i)},r.randomFillSync=function(e,t,r){void 0===t&&(t=0);if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');h(t,e.length),void 0===r&&(r=e.length-t);return l(r,t,e.length),d(e,t,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,randombytes:270,"safe-buffer":290}],272:[function(e,t,r){t.exports=window.crypto},{}],273:[function(e,t,r){t.exports=e("crypto")},{crypto:272}],274:[function(e,t,r){t.exports=function(t,r){var n=e("./crypto.js"),i="function"==typeof r;if(t>65536){if(!i)throw new Error("Requested too many random bytes.");r(new Error("Requested too many random bytes."))}if(void 0!==n&&n.randomBytes){if(!i)return"0x"+n.randomBytes(t).toString("hex");n.randomBytes(t,function(e,t){e?r(u):r(null,"0x"+t.toString("hex"))})}else{var o;if(void 0!==n?o=n:"undefined"!=typeof msCrypto&&(o=msCrypto),o&&o.getRandomValues){var a=o.getRandomValues(new Uint8Array(t)),s="0x"+Array.from(a).map(function(e){return e.toString(16)}).join("");if(!i)return s;r(null,s)}else{var u=new Error('No "crypto" object available. This Browser doesn\'t support generating secure random bytes.');if(!i)throw u;r(u)}}}},{"./crypto.js":273}],275:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":276}],276:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick,i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=h;var o=e("core-util-is");o.inherits=e("inherits");var a=e("./_stream_readable"),s=e("./_stream_writable");o.inherits(h,a);for(var u=i(s.prototype),c=0;c0?("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),n?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):_(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?_(e,a,t,!1):S(e,a)):_(e,a,t,!1))):n||(a.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=A?e=A:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(d("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i(k,e):k(e))}function k(e){d("emit readable"),e.emit("readable"),U(e)}function S(e,t){t.readingMore||(t.readingMore=!0,i(M,e,t))}function M(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=c.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,a),0===(e-=a)){a===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function B(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i(P,t,e))}function P(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function C(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return d("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?B(this):x(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&B(this),null;var n,i=t.needReadable;return d("need readable",i),(0===t.length||t.length-e0?j(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&B(this)),null!==n&&this.emit("data",n),n},g.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},g.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,d("pipe count=%d opts=%j",o.pipesCount,t);var u=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?f:g;function c(t,r){d("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,d("cleanup"),e.removeListener("close",m),e.removeListener("finish",v),e.removeListener("drain",h),e.removeListener("error",y),e.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",g),n.removeListener("data",b),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||h())}function f(){d("onend"),e.end()}o.endEmitted?i(u):n.once("end",u),e.on("unpipe",c);var h=function(e){return function(){var t=e._readableState;d("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,U(e))}}(n);e.on("drain",h);var l=!1;var p=!1;function b(t){d("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==C(o.pipes,e))&&!l&&(d("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(t){d("onerror",t),g(),e.removeListener("error",y),0===s(e,"error")&&e.emit("error",t)}function m(){e.removeListener("finish",v),g()}function v(){d("onfinish"),e.removeListener("close",m),g()}function g(){d("unpipe"),n.unpipe(e)}return n.on("data",b),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?a(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",y),e.once("close",m),e.once("finish",v),e.emit("pipe",n),o.flowing||(d("pipe resume"),n.resume()),e},g.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:i;m.WritableState=y;var u=e("core-util-is");u.inherits=e("inherits");var c={deprecate:e("util-deprecate")},f=e("./internal/streams/stream"),h=e("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=e("./internal/streams/destroy");function b(){}function y(t,r){a=a||e("./_stream_duplex"),t=t||{};var n=r instanceof a;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var u=t.highWaterMark,c=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=u||0===u?u:n&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===t.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,o=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,o){--t.pendingcb,r?(i(o,n),i(E,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(o(n),e._writableState.errorEmitted=!0,e.emit("error",n),E(e,t))}(e,r,n,t,o);else{var a=_(r);a||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),n?s(g,e,r,a,o):g(e,r,a,o)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function m(t){if(a=a||e("./_stream_duplex"),!(d.call(m,this)||this instanceof a))return new m(t);this._writableState=new y(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),f.call(this)}function v(e,t,r,n,i,o,a){t.writelen=n,t.writecb=a,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function g(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),E(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),a=t.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,v(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,h=r.callback;if(v(e,t,!1,t.objectMode?1:c.length,c,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function A(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),E(e,t)})}function E(e,t){var r=_(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,i(A,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}u.inherits(m,f),y.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(y.prototype,"buffer",{get:c.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===m&&(e&&e._writableState instanceof y)}})):d=function(e){return e instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(e,t,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=e,h.isBuffer(n)||n instanceof l);return s&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof r&&(r=b),o.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),i(t,r)}(this,r):(s||function(e,t,r,n){var o=!0,a=!1;return null===r?a=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),i(n,a),o=!1),o}(this,o,e,r))&&(o.pendingcb++,a=function(e,t,r,n,i,o){if(!r){var a=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,r));return t}(t,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=t.objectMode?1:n.length;t.length+=s;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},m.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,E(e,t),r&&(t.finished?i(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),m.prototype.destroy=p.destroy,m.prototype._undestroy=p.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":276,"./internal/streams/destroy":282,"./internal/streams/stream":283,_process:257,"core-util-is":89,inherits:180,"process-nextick-args":256,"safe-buffer":290,"util-deprecate":330}],281:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,i,o=n.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,r=o,i=s,t.copy(r,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":290,util:55}],282:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick;function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var r=this,o=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return o||a?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||n(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n(i,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":256}],283:[function(e,t,r){t.exports=e("events").EventEmitter},{events:157}],284:[function(e,t,r){t.exports=e("./readable").PassThrough},{"./readable":285}],285:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":276,"./lib/_stream_passthrough.js":277,"./lib/_stream_readable.js":278,"./lib/_stream_transform.js":279,"./lib/_stream_writable.js":280}],286:[function(e,t,r){t.exports=e("./readable").Transform},{"./readable":285}],287:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":280}],288:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base");function o(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function a(e,t){return e<>>32-t}function s(e,t,r,n,i,o,s,u){return a(e+(t^r^n)+o+s|0,u)+i|0}function u(e,t,r,n,i,o,s,u){return a(e+(t&r|~t&n)+o+s|0,u)+i|0}function c(e,t,r,n,i,o,s,u){return a(e+((t|~r)^n)+o+s|0,u)+i|0}function f(e,t,r,n,i,o,s,u){return a(e+(t&n|r&~n)+o+s|0,u)+i|0}function h(e,t,r,n,i,o,s,u){return a(e+(t^(r|~n))+o+s|0,u)+i|0}n(o,i),o.prototype._update=function(){for(var e=new Array(16),t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,o=this._d,l=this._e;l=s(l,r=s(r,n,i,o,l,e[0],0,11),n,i=a(i,10),o,e[1],0,14),n=s(n=a(n,10),i=s(i,o=s(o,l,r,n,i,e[2],0,15),l,r=a(r,10),n,e[3],0,12),o,l=a(l,10),r,e[4],0,5),o=s(o=a(o,10),l=s(l,r=s(r,n,i,o,l,e[5],0,8),n,i=a(i,10),o,e[6],0,7),r,n=a(n,10),i,e[7],0,9),r=s(r=a(r,10),n=s(n,i=s(i,o,l,r,n,e[8],0,11),o,l=a(l,10),r,e[9],0,13),i,o=a(o,10),l,e[10],0,14),i=s(i=a(i,10),o=s(o,l=s(l,r,n,i,o,e[11],0,15),r,n=a(n,10),i,e[12],0,6),l,r=a(r,10),n,e[13],0,7),l=u(l=a(l,10),r=s(r,n=s(n,i,o,l,r,e[14],0,9),i,o=a(o,10),l,e[15],0,8),n,i=a(i,10),o,e[7],1518500249,7),n=u(n=a(n,10),i=u(i,o=u(o,l,r,n,i,e[4],1518500249,6),l,r=a(r,10),n,e[13],1518500249,8),o,l=a(l,10),r,e[1],1518500249,13),o=u(o=a(o,10),l=u(l,r=u(r,n,i,o,l,e[10],1518500249,11),n,i=a(i,10),o,e[6],1518500249,9),r,n=a(n,10),i,e[15],1518500249,7),r=u(r=a(r,10),n=u(n,i=u(i,o,l,r,n,e[3],1518500249,15),o,l=a(l,10),r,e[12],1518500249,7),i,o=a(o,10),l,e[0],1518500249,12),i=u(i=a(i,10),o=u(o,l=u(l,r,n,i,o,e[9],1518500249,15),r,n=a(n,10),i,e[5],1518500249,9),l,r=a(r,10),n,e[2],1518500249,11),l=u(l=a(l,10),r=u(r,n=u(n,i,o,l,r,e[14],1518500249,7),i,o=a(o,10),l,e[11],1518500249,13),n,i=a(i,10),o,e[8],1518500249,12),n=c(n=a(n,10),i=c(i,o=c(o,l,r,n,i,e[3],1859775393,11),l,r=a(r,10),n,e[10],1859775393,13),o,l=a(l,10),r,e[14],1859775393,6),o=c(o=a(o,10),l=c(l,r=c(r,n,i,o,l,e[4],1859775393,7),n,i=a(i,10),o,e[9],1859775393,14),r,n=a(n,10),i,e[15],1859775393,9),r=c(r=a(r,10),n=c(n,i=c(i,o,l,r,n,e[8],1859775393,13),o,l=a(l,10),r,e[1],1859775393,15),i,o=a(o,10),l,e[2],1859775393,14),i=c(i=a(i,10),o=c(o,l=c(l,r,n,i,o,e[7],1859775393,8),r,n=a(n,10),i,e[0],1859775393,13),l,r=a(r,10),n,e[6],1859775393,6),l=c(l=a(l,10),r=c(r,n=c(n,i,o,l,r,e[13],1859775393,5),i,o=a(o,10),l,e[11],1859775393,12),n,i=a(i,10),o,e[5],1859775393,7),n=f(n=a(n,10),i=f(i,o=c(o,l,r,n,i,e[12],1859775393,5),l,r=a(r,10),n,e[1],2400959708,11),o,l=a(l,10),r,e[9],2400959708,12),o=f(o=a(o,10),l=f(l,r=f(r,n,i,o,l,e[11],2400959708,14),n,i=a(i,10),o,e[10],2400959708,15),r,n=a(n,10),i,e[0],2400959708,14),r=f(r=a(r,10),n=f(n,i=f(i,o,l,r,n,e[8],2400959708,15),o,l=a(l,10),r,e[12],2400959708,9),i,o=a(o,10),l,e[4],2400959708,8),i=f(i=a(i,10),o=f(o,l=f(l,r,n,i,o,e[13],2400959708,9),r,n=a(n,10),i,e[3],2400959708,14),l,r=a(r,10),n,e[7],2400959708,5),l=f(l=a(l,10),r=f(r,n=f(n,i,o,l,r,e[15],2400959708,6),i,o=a(o,10),l,e[14],2400959708,8),n,i=a(i,10),o,e[5],2400959708,6),n=h(n=a(n,10),i=f(i,o=f(o,l,r,n,i,e[6],2400959708,5),l,r=a(r,10),n,e[2],2400959708,12),o,l=a(l,10),r,e[4],2840853838,9),o=h(o=a(o,10),l=h(l,r=h(r,n,i,o,l,e[0],2840853838,15),n,i=a(i,10),o,e[5],2840853838,5),r,n=a(n,10),i,e[9],2840853838,11),r=h(r=a(r,10),n=h(n,i=h(i,o,l,r,n,e[7],2840853838,6),o,l=a(l,10),r,e[12],2840853838,8),i,o=a(o,10),l,e[2],2840853838,13),i=h(i=a(i,10),o=h(o,l=h(l,r,n,i,o,e[10],2840853838,12),r,n=a(n,10),i,e[14],2840853838,5),l,r=a(r,10),n,e[1],2840853838,12),l=h(l=a(l,10),r=h(r,n=h(n,i,o,l,r,e[3],2840853838,13),i,o=a(o,10),l,e[8],2840853838,14),n,i=a(i,10),o,e[11],2840853838,11),n=h(n=a(n,10),i=h(i,o=h(o,l,r,n,i,e[6],2840853838,8),l,r=a(r,10),n,e[15],2840853838,5),o,l=a(l,10),r,e[13],2840853838,6),o=a(o,10);var d=this._a,p=this._b,b=this._c,y=this._d,m=this._e;m=h(m,d=h(d,p,b,y,m,e[5],1352829926,8),p,b=a(b,10),y,e[14],1352829926,9),p=h(p=a(p,10),b=h(b,y=h(y,m,d,p,b,e[7],1352829926,9),m,d=a(d,10),p,e[0],1352829926,11),y,m=a(m,10),d,e[9],1352829926,13),y=h(y=a(y,10),m=h(m,d=h(d,p,b,y,m,e[2],1352829926,15),p,b=a(b,10),y,e[11],1352829926,15),d,p=a(p,10),b,e[4],1352829926,5),d=h(d=a(d,10),p=h(p,b=h(b,y,m,d,p,e[13],1352829926,7),y,m=a(m,10),d,e[6],1352829926,7),b,y=a(y,10),m,e[15],1352829926,8),b=h(b=a(b,10),y=h(y,m=h(m,d,p,b,y,e[8],1352829926,11),d,p=a(p,10),b,e[1],1352829926,14),m,d=a(d,10),p,e[10],1352829926,14),m=f(m=a(m,10),d=h(d,p=h(p,b,y,m,d,e[3],1352829926,12),b,y=a(y,10),m,e[12],1352829926,6),p,b=a(b,10),y,e[6],1548603684,9),p=f(p=a(p,10),b=f(b,y=f(y,m,d,p,b,e[11],1548603684,13),m,d=a(d,10),p,e[3],1548603684,15),y,m=a(m,10),d,e[7],1548603684,7),y=f(y=a(y,10),m=f(m,d=f(d,p,b,y,m,e[0],1548603684,12),p,b=a(b,10),y,e[13],1548603684,8),d,p=a(p,10),b,e[5],1548603684,9),d=f(d=a(d,10),p=f(p,b=f(b,y,m,d,p,e[10],1548603684,11),y,m=a(m,10),d,e[14],1548603684,7),b,y=a(y,10),m,e[15],1548603684,7),b=f(b=a(b,10),y=f(y,m=f(m,d,p,b,y,e[8],1548603684,12),d,p=a(p,10),b,e[12],1548603684,7),m,d=a(d,10),p,e[4],1548603684,6),m=f(m=a(m,10),d=f(d,p=f(p,b,y,m,d,e[9],1548603684,15),b,y=a(y,10),m,e[1],1548603684,13),p,b=a(b,10),y,e[2],1548603684,11),p=c(p=a(p,10),b=c(b,y=c(y,m,d,p,b,e[15],1836072691,9),m,d=a(d,10),p,e[5],1836072691,7),y,m=a(m,10),d,e[1],1836072691,15),y=c(y=a(y,10),m=c(m,d=c(d,p,b,y,m,e[3],1836072691,11),p,b=a(b,10),y,e[7],1836072691,8),d,p=a(p,10),b,e[14],1836072691,6),d=c(d=a(d,10),p=c(p,b=c(b,y,m,d,p,e[6],1836072691,6),y,m=a(m,10),d,e[9],1836072691,14),b,y=a(y,10),m,e[11],1836072691,12),b=c(b=a(b,10),y=c(y,m=c(m,d,p,b,y,e[8],1836072691,13),d,p=a(p,10),b,e[12],1836072691,5),m,d=a(d,10),p,e[2],1836072691,14),m=c(m=a(m,10),d=c(d,p=c(p,b,y,m,d,e[10],1836072691,13),b,y=a(y,10),m,e[0],1836072691,13),p,b=a(b,10),y,e[4],1836072691,7),p=u(p=a(p,10),b=u(b,y=c(y,m,d,p,b,e[13],1836072691,5),m,d=a(d,10),p,e[8],2053994217,15),y,m=a(m,10),d,e[6],2053994217,5),y=u(y=a(y,10),m=u(m,d=u(d,p,b,y,m,e[4],2053994217,8),p,b=a(b,10),y,e[1],2053994217,11),d,p=a(p,10),b,e[3],2053994217,14),d=u(d=a(d,10),p=u(p,b=u(b,y,m,d,p,e[11],2053994217,14),y,m=a(m,10),d,e[15],2053994217,6),b,y=a(y,10),m,e[0],2053994217,14),b=u(b=a(b,10),y=u(y,m=u(m,d,p,b,y,e[5],2053994217,6),d,p=a(p,10),b,e[12],2053994217,9),m,d=a(d,10),p,e[2],2053994217,12),m=u(m=a(m,10),d=u(d,p=u(p,b,y,m,d,e[13],2053994217,9),b,y=a(y,10),m,e[9],2053994217,12),p,b=a(b,10),y,e[7],2053994217,5),p=s(p=a(p,10),b=u(b,y=u(y,m,d,p,b,e[10],2053994217,15),m,d=a(d,10),p,e[14],2053994217,8),y,m=a(m,10),d,e[12],0,8),y=s(y=a(y,10),m=s(m,d=s(d,p,b,y,m,e[15],0,5),p,b=a(b,10),y,e[10],0,12),d,p=a(p,10),b,e[4],0,9),d=s(d=a(d,10),p=s(p,b=s(b,y,m,d,p,e[1],0,12),y,m=a(m,10),d,e[5],0,5),b,y=a(y,10),m,e[8],0,14),b=s(b=a(b,10),y=s(y,m=s(m,d,p,b,y,e[7],0,6),d,p=a(p,10),b,e[6],0,8),m,d=a(d,10),p,e[2],0,13),m=s(m=a(m,10),d=s(d,p=s(p,b,y,m,d,e[13],0,6),b,y=a(y,10),m,e[14],0,5),p,b=a(b,10),y,e[0],0,15),p=s(p=a(p,10),b=s(b,y=s(y,m,d,p,b,e[3],0,13),m,d=a(d,10),p,e[9],0,11),y,m=a(m,10),d,e[11],0,11),y=a(y,10);var v=this._b+i+y|0;this._b=this._c+o+m|0,this._c=this._d+l+d|0,this._d=this._e+r+p|0,this._e=this._a+n+b|0,this._a=v},o.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=o}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":161,inherits:180}],289:[function(e,t,r){const n=e("assert"),i=e("safe-buffer").Buffer;function o(e,t){if("00"===e.slice(0,2))throw new Error("invalid RLP: extra zeros");return parseInt(e,t)}function a(e,t){if(e<56)return i.from([e+t]);var r=u(e),n=u(t+55+r.length/2);return i.from(n+r,"hex")}function s(e){return"0x"===e.slice(0,2)}function u(e){var t=e.toString(16);return t.length%2&&(t="0"+t),t}function c(e){if(!i.isBuffer(e))if("string"==typeof e)e=s(e)?i.from(((r="string"!=typeof(n=e)?n:s(n)?n.slice(2):n).length%2&&(r="0"+r),r),"hex"):i.from(e);else if("number"==typeof e)e?(t=u(e),e=i.from(t,"hex")):e=i.from([]);else if(null==e)e=i.from([]);else{if(!e.toArray)throw new Error("invalid type");e=i.from(e.toArray())}var t,r,n;return e}r.encode=function(e){if(e instanceof Array){for(var t=[],n=0;nt.length)throw new Error("invalid rlp: total length is larger than the data");if(0===(s=t.slice(n,h)).length)throw new Error("invalid rlp, List has a invalid length");for(;s.length;)u=e(s),c.push(u.data),s=u.remainder;return{data:c,remainder:t.slice(h)}}(e=c(e));return t?r:(n.equal(r.remainder.length,0,"invalid remainder"),r.data)},r.getLength=function(e){if(!e||0===e.length)return i.from([]);var t=(e=c(e))[0];if(t<=127)return e.length;if(t<=183)return t-127;if(t<=191)return t-182;if(t<=247)return t-191;var r=t-246;return r+o(e.slice(1,r).toString("hex"),16)}},{assert:19,"safe-buffer":290}],290:[function(e,t,r){var n=e("buffer"),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function a(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,r),r.Buffer=a),o(i,a),a.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:84}],291:[function(e,t,r){const n=e("util"),i=e("events/");var o="object"==typeof Reflect?Reflect:null,a=o&&"function"==typeof o.apply?o.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};function s(){i.call(this)}function u(e,t,r){try{a(e,t,r)}catch(e){setTimeout(()=>{throw e})}}t.exports=s,n.inherits(s,i),s.prototype.emit=function(e){for(var t=[],r=1;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var s=i[e];if(void 0===s)return!1;if("function"==typeof s)u(s,this,t);else{var c=s.length,f=function(e,t){for(var r=new Array(t),n=0;n0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=function(){for(var e=[],t=0;t0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var c=u.length,f=p(u,c);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return l(this,e,!0)},s.prototype.rawListeners=function(e){return l(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},{}],293:[function(e,t,r){t.exports=e("scryptsy")},{scryptsy:294}],294:[function(e,t,r){(function(r){var n=e("pbkdf2").pbkdf2Sync,i=2147483647;function o(e,t,n,i,o){if(r.isBuffer(e)&&r.isBuffer(n))e.copy(n,i,t,t+o);else for(;o--;)n[i++]=e[t++]}t.exports=function(e,t,a,s,u,c,f){if(0===a||0!=(a&a-1))throw Error("N must be > 0 and a power of 2");if(a>i/128/s)throw Error("Parameter N is too large");if(s>i/128/u)throw Error("Parameter r is too large");var h,l=new r(256*s),d=new r(128*s*a),p=new Int32Array(16),b=new Int32Array(16),y=new r(64),m=n(e,t,1,128*u*s,"sha256");if(f){var v=u*a*2,g=0;h=function(){++g%1e3==0&&f({current:g,total:v,percent:g/v*100})}}for(var w=0;w>>32-t}function x(e){var t;for(t=0;t<16;t++)p[t]=(255&e[4*t+0])<<0,p[t]|=(255&e[4*t+1])<<8,p[t]|=(255&e[4*t+2])<<16,p[t]|=(255&e[4*t+3])<<24;for(o(p,0,b,0,16),t=8;t>0;t-=2)b[4]^=E(b[0]+b[12],7),b[8]^=E(b[4]+b[0],9),b[12]^=E(b[8]+b[4],13),b[0]^=E(b[12]+b[8],18),b[9]^=E(b[5]+b[1],7),b[13]^=E(b[9]+b[5],9),b[1]^=E(b[13]+b[9],13),b[5]^=E(b[1]+b[13],18),b[14]^=E(b[10]+b[6],7),b[2]^=E(b[14]+b[10],9),b[6]^=E(b[2]+b[14],13),b[10]^=E(b[6]+b[2],18),b[3]^=E(b[15]+b[11],7),b[7]^=E(b[3]+b[15],9),b[11]^=E(b[7]+b[3],13),b[15]^=E(b[11]+b[7],18),b[1]^=E(b[0]+b[3],7),b[2]^=E(b[1]+b[0],9),b[3]^=E(b[2]+b[1],13),b[0]^=E(b[3]+b[2],18),b[6]^=E(b[5]+b[4],7),b[7]^=E(b[6]+b[5],9),b[4]^=E(b[7]+b[6],13),b[5]^=E(b[4]+b[7],18),b[11]^=E(b[10]+b[9],7),b[8]^=E(b[11]+b[10],9),b[9]^=E(b[8]+b[11],13),b[10]^=E(b[9]+b[8],18),b[12]^=E(b[15]+b[14],7),b[13]^=E(b[12]+b[15],9),b[14]^=E(b[13]+b[12],13),b[15]^=E(b[14]+b[13],18);for(t=0;t<16;++t)p[t]=b[t]+p[t];for(t=0;t<16;t++){var r=4*t;e[r+0]=p[t]>>0&255,e[r+1]=p[t]>>8&255,e[r+2]=p[t]>>16&255,e[r+3]=p[t]>>24&255}}function k(e,t,r,n,i){for(var o=0;o=r)throw RangeError(n)}}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":181}],297:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("bip66"),o=n.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),a=n.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(e,t,r){var i=n.from(r?o:a);return e.copy(i,r?8:9),t.copy(i,r?181:214),i},r.privateKeyImport=function(e){var t=e.length,r=0;if(!(t2||t1?e[r+n-2]<<8:0);if(!(t<(r+=n)+i||t32||t1&&0===t[o]&&!(128&t[o+1]);--r,++o);for(var a=n.concat([n.from([0]),e.s]),s=33,u=0;s>1&&0===a[u]&&!(128&a[u+1]);--s,++u);return i.encode(t.slice(o),a.slice(u))},r.signatureImport=function(e){var t=n.alloc(32,0),r=n.alloc(32,0);try{var o=i.decode(e);if(33===o.r.length&&0===o.r[0]&&(o.r=o.r.slice(1)),o.r.length>32)throw new Error("R length is too long");if(33===o.s.length&&0===o.s[0]&&(o.s=o.s.slice(1)),o.s.length>32)throw new Error("S length is too long")}catch(e){return}return o.r.copy(t,32-o.r.length),o.s.copy(r,32-o.s.length),{r:t,s:r}},r.signatureImportLax=function(e){var t=n.alloc(32,0),r=n.alloc(32,0),i=e.length,o=0;if(48===e[o++]){var a=e[o++];if(!(128&a&&(o+=a-128)>i)&&2===e[o++]){var s=e[o++];if(128&s){if(o+(a=s-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(s=0;a>0;o+=1,a-=1)s=(s<<8)+e[o]}if(!(s>i-o)){var u=o;if(o+=s,2===e[o++]){var c=e[o++];if(128&c){if(o+(a=c-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(c=0;a>0;o+=1,a-=1)c=(c<<8)+e[o]}if(!(c>i-o)){var f=o;for(o+=c;s>0&&0===e[u];s-=1,u+=1);if(!(s>32)){var h=e.slice(u,u+s);for(h.copy(t,32-h.length);c>0&&0===e[f];c-=1,f+=1);if(!(c>32)){var l=e.slice(f,f+c);return l.copy(r,32-l.length),{r:t,s:r}}}}}}}}}},{bip66:52,"safe-buffer":290}],298:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("create-hash"),o=e("bn.js"),a=e("elliptic").ec,s=e("../messages.json"),u=new a("secp256k1"),c=u.curve;function f(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new o(t);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),u.keyPair({pub:{x:r,y:n}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new o(t),i=new o(r);if(n.cmp(c.p)>=0||i.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),i=i.toRed(c.red),(6===e||7===e)&&i.isOdd()!==(7===e))return null;var a=n.redSqr().redIMul(n);return i.redSqr().redISub(a.redIAdd(c.b)).isZero()?u.keyPair({pub:{x:n,y:i}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}r.privateKeyVerify=function(e){var t=new o(e);return t.cmp(c.n)<0&&!t.isZero()},r.privateKeyExport=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.privateKeyNegate=function(e){var t=new o(e);return t.isZero()?n.alloc(32):c.n.sub(t).umod(c.n).toArrayLike(n,"be",32)},r.privateKeyModInverse=function(e){var t=new o(e);if(t.cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(c.n).toArrayLike(n,"be",32)},r.privateKeyTweakAdd=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new o(e)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(n,"be",32)},r.privateKeyTweakMul=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new o(e)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(n,"be",32)},r.publicKeyCreate=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.publicKeyConvert=function(e,t){var r=f(e);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return n.from(r.getPublic(t,!0))},r.publicKeyVerify=function(e){return null!==f(e)},r.publicKeyTweakAdd=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return n.from(c.g.mul(t).add(i.pub).encode(!0,r))},r.publicKeyTweakMul=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return n.from(i.pub.mul(t).encode(!0,r))},r.publicKeyCombine=function(e,t){for(var r=new Array(e.length),i=0;i=0||r.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var i=n.from(e);return 1===r.cmp(u.nh)&&c.n.sub(r).toArrayLike(n,"be",32).copy(i,32),i},r.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new o(t).cmp(c.n)>=0||new o(r).cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},r.signatureImport=function(e){var t=new o(e.r);t.cmp(c.n)>=0&&(t=new o(0));var r=new o(e.s);return r.cmp(c.n)>=0&&(r=new o(0)),n.concat([t.toArrayLike(n,"be",32),r.toArrayLike(n,"be",32)])},r.sign=function(e,t,r,i){if("function"==typeof r){var a=r;r=function(r){var u=a(e,t,null,i,r);if(!n.isBuffer(u)||32!==u.length)throw new Error(s.ECDSA_SIGN_FAIL);return new o(u)}}var f=new o(t);if(f.cmp(c.n)>=0||f.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var h=u.sign(e,t,{canonical:!0,k:r,pers:i});return{signature:n.concat([h.r.toArrayLike(n,"be",32),h.s.toArrayLike(n,"be",32)]),recovery:h.recoveryParam}},r.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},i=new o(n.r),a=new o(n.s);if(i.cmp(c.n)>=0||a.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===a.cmp(u.nh)||i.isZero()||a.isZero())return!1;var h=f(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return u.verify(e,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(e,t,r,i){var a={r:t.slice(0,32),s:t.slice(32,64)},f=new o(a.r),h=new o(a.s);if(f.cmp(c.n)>=0||h.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(f.isZero()||h.isZero())throw new Error;var l=u.recoverPubKey(e,a,r);return n.from(l.encode(!0,i))}catch(e){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(e,t){var n=r.ecdhUnsafe(e,t,!0);return i("sha256").update(n).digest()},r.ecdhUnsafe=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var a=new o(t);if(a.cmp(c.n)>=0||a.isZero())throw new Error(s.ECDH_FAIL);return n.from(i.pub.mul(a).encode(!0,r))}},{"../messages.json":300,"bn.js":53,"create-hash":91,elliptic:109,"safe-buffer":290}],299:[function(e,t,r){"use strict";var n=e("./assert"),i=e("./der"),o=e("./messages.json");function a(e,t){return void 0===e?t:(n.isBoolean(e,o.COMPRESSED_TYPE_INVALID),e)}t.exports=function(e){return{privateKeyVerify:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0);var s=e.privateKeyExport(t,r);return i.privateKeyExport(t,s,r)},privateKeyImport:function(t){if(n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),(t=i.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakAdd(t,r,i)},publicKeyTweakMul:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakMul(t,r,i)},publicKeyCombine:function(t,r){n.isArray(t,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(t,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=2&&("function"==typeof arguments[1]?r.task=arguments[1]:r.n=arguments[1]);var n=r.task;if(r.task=function(){n(t.leave)},t.current+r.n-e>t.capacity)return 1===e&&(t.current--,t.firstHere=!1),t.queue.push(r);t.current+=r.n-e,r.task(t.leave),1===e&&(t.firstHere=!1)},leave:function(e){if(e=e||1,t.current-=e,t.queue.length){var r=t.queue[0];r.n+t.current>t.capacity||(t.queue.shift(),t.current+=r.n,i(r.task))}else if(t.current<0)throw new Error("leave called too many times.")},available:function(e){return e=e||1,t.current+e<=t.capacity}};return t}void 0!==e&&e&&"function"==typeof e.nextTick&&(i=e.nextTick),"object"==typeof r?t.exports=o:"function"==typeof define&&define.amd?define(function(){return o}):n.semaphore=o}(this)}).call(this,e("_process"))},{_process:257}],302:[function(e,t,r){"use strict";t.exports="function"==typeof setImmediate?setImmediate:function(){var e=[].slice.apply(arguments);e.splice(1,0,0),setTimeout.apply(null,e)}},{}],303:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t){this._block=n.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}i.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=n.from(e,t));for(var r=this._block,i=this._blockSize,o=e.length,a=this._len,s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},{"safe-buffer":290}],304:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":305,"./sha1":306,"./sha224":307,"./sha256":308,"./sha384":309,"./sha512":310}],305:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((t=n)<<5|t>>>27)+f(d,i,o,s)+u+r[l]+a[d];u=s,s=o,o=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],306:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function h(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=(t=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=c(n)+h(p,i,o,s)+u+r[d]+a[p]|0;u=s,s=o,o=f(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],307:[function(e,t,r){var n=e("inherits"),i=e("./sha256"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}n(u,i),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=u},{"./hash":303,"./sha256":308,inherits:180,"safe-buffer":290}],308:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function l(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(u,i),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,m=0;m<16;++m)r[m]=e.readInt32BE(4*m);for(;m<64;++m)r[m]=0|(((t=r[m-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[m-7]+d(r[m-15])+r[m-16];for(var v=0;v<64;++v){var g=y+l(u)+c(u,p,b)+a[v]+r[v]|0,w=h(n)+f(n,i,o)|0;y=b,b=p,p=u,u=s+g|0,s=o,o=i,i=n,n=g+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},u.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],309:[function(e,t,r){var n=e("inherits"),i=e("./sha512"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}n(u,i),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=u},{"./hash":303,"./sha512":310,inherits:180,"safe-buffer":290}],310:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function l(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function y(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function m(e,t){return e>>>0>>0?1:0}n(u,i),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,s=0|this._eh,u=0|this._fh,v=0|this._gh,g=0|this._hh,w=0|this._al,_=0|this._bl,A=0|this._cl,E=0|this._dl,x=0|this._el,k=0|this._fl,S=0|this._gl,M=0|this._hl,I=0;I<32;I+=2)t[I]=e.readInt32BE(4*I),t[I+1]=e.readInt32BE(4*I+4);for(;I<160;I+=2){var T=t[I-30],U=t[I-30+1],j=d(T,U),B=p(U,T),P=b(T=t[I-4],U=t[I-4+1]),C=y(U,T),N=t[I-14],R=t[I-14+1],L=t[I-32],O=t[I-32+1],D=B+R|0,F=j+N+m(D,B)|0;F=(F=F+P+m(D=D+C|0,C)|0)+L+m(D=D+O|0,O)|0,t[I]=F,t[I+1]=D}for(var q=0;q<160;q+=2){F=t[q],D=t[q+1];var H=f(r,n,i),z=f(w,_,A),K=h(r,w),V=h(w,r),G=l(s,x),W=l(x,s),Y=a[q],X=a[q+1],Z=c(s,u,v),J=c(x,k,S),$=M+W|0,Q=g+G+m($,M)|0;Q=(Q=(Q=Q+Z+m($=$+J|0,J)|0)+Y+m($=$+X|0,X)|0)+F+m($=$+D|0,D)|0;var ee=V+z|0,te=K+H+m(ee,V)|0;g=v,M=S,v=u,S=k,u=s,k=x,s=o+Q+m(x=E+$|0,E)|0,o=i,E=A,i=n,A=_,n=r,_=w,r=Q+te+m(w=$+ee|0,$)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+A|0,this._dl=this._dl+E|0,this._el=this._el+x|0,this._fl=this._fl+k|0,this._gl=this._gl+S|0,this._hl=this._hl+M|0,this._ah=this._ah+r+m(this._al,w)|0,this._bh=this._bh+n+m(this._bl,_)|0,this._ch=this._ch+i+m(this._cl,A)|0,this._dh=this._dh+o+m(this._dl,E)|0,this._eh=this._eh+s+m(this._el,x)|0,this._fh=this._fh+u+m(this._fl,k)|0,this._gh=this._gh+v+m(this._gl,S)|0,this._hh=this._hh+g+m(this._hl,M)|0},u.prototype._hash=function(){var e=o.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],311:[function(e,t,r){t.exports=i;var n=e("events").EventEmitter;function i(){n.call(this)}e("inherits")(i,n),i.Readable=e("readable-stream/readable.js"),i.Writable=e("readable-stream/writable.js"),i.Duplex=e("readable-stream/duplex.js"),i.Transform=e("readable-stream/transform.js"),i.PassThrough=e("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,e.end())}function u(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(f(),0===n.listenerCount(this,"error"))throw e}function f(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),e.removeListener("close",f)}return r.on("error",c),e.on("error",c),r.on("end",f),r.on("close",f),e.on("close",f),e.emit("pipe",r),e}},{events:157,inherits:180,"readable-stream/duplex.js":275,"readable-stream/passthrough.js":284,"readable-stream/readable.js":285,"readable-stream/transform.js":286,"readable-stream/writable.js":287}],312:[function(e,t,r){(function(t){var n=e("./lib/request"),i=e("./lib/response"),o=e("xtend"),a=e("builtin-status-codes"),s=e("url"),u=r;u.request=function(e,r){e="string"==typeof e?s.parse(e):o(e);var i=-1===t.location.protocol.search(/^https?:$/)?"http:":"",a=e.protocol||i,u=e.hostname||e.host,c=e.port,f=e.path||"/";u&&-1!==u.indexOf(":")&&(u="["+u+"]"),e.url=(u?a+"//"+u:"")+(c?":"+c:"")+f,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var h=new n(e);return r&&h.on("response",r),h},u.get=function(e,t){var r=u.request(e,t);return r.end(),r},u.ClientRequest=n,u.IncomingMessage=i,u.Agent=function(){},u.Agent.defaultMaxSockets=4,u.STATUS_CODES=a,u.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/request":314,"./lib/response":315,"builtin-status-codes":85,url:327,xtend:423}],313:[function(e,t,r){(function(e){r.fetch=s(e.fetch)&&s(e.ReadableStream),r.writableStream=s(e.WritableStream),r.abortController=s(e.AbortController),r.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),r.blobConstructor=!0}catch(e){}var t;function n(){if(void 0!==t)return t;if(e.XMLHttpRequest){t=new e.XMLHttpRequest;try{t.open("GET",e.XDomainRequest?"/":"https://example.com")}catch(e){t=null}}else t=null;return t}function i(e){var t=n();if(!t)return!1;try{return t.responseType=e,t.responseType===e}catch(e){}return!1}var o=void 0!==e.ArrayBuffer,a=o&&s(e.ArrayBuffer.prototype.slice);function s(e){return"function"==typeof e}r.arraybuffer=r.fetch||o&&i("arraybuffer"),r.msstream=!r.fetch&&a&&i("ms-stream"),r.mozchunkedarraybuffer=!r.fetch&&o&&i("moz-chunked-arraybuffer"),r.overrideMimeType=r.fetch||!!n()&&s(n().overrideMimeType),r.vbArray=s(e.VBArray),t=null}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],314:[function(e,t,r){(function(r,n,i){var o=e("./capability"),a=e("inherits"),s=e("./response"),u=e("readable-stream"),c=e("to-arraybuffer"),f=s.IncomingMessage,h=s.readyStates;var l=t.exports=function(e){var t,r=this;u.Writable.call(r),r._opts=e,r._body=[],r._headers={},e.auth&&r.setHeader("Authorization","Basic "+new i(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){r.setHeader(t,e.headers[t])});var n=!0;if("disable-fetch"===e.mode||"requestTimeout"in e&&!o.abortController)n=!1,t=!0;else if("prefer-streaming"===e.mode)t=!1;else if("allow-wrong-content-type"===e.mode)t=!o.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");t=!0}r._mode=function(e,t){return o.fetch&&t?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&e?"arraybuffer":o.vbArray&&e?"text:vbarray":"text"}(t,n),r.on("finish",function(){r._onFinish()})};a(l,u.Writable),l.prototype.setHeader=function(e,t){var r=e.toLowerCase();-1===d.indexOf(r)&&(this._headers[r]={name:e,value:t})},l.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},l.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},l.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,a=e._headers,s=null;"GET"!==t.method&&"HEAD"!==t.method&&(s=o.arraybuffer?c(i.concat(e._body)):o.blobConstructor?new n.Blob(e._body.map(function(e){return c(e)}),{type:(a["content-type"]||{}).value||""}):i.concat(e._body).toString());var u=[];if(Object.keys(a).forEach(function(e){var t=a[e].name,r=a[e].value;Array.isArray(r)?r.forEach(function(e){u.push([t,e])}):u.push([t,r])}),"fetch"===e._mode){var f=null;if(o.abortController){var l=new AbortController;f=l.signal,e._fetchAbortController=l,"requestTimeout"in t&&0!==t.requestTimeout&&n.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},t.requestTimeout)}n.fetch(e._opts.url,{method:e._opts.method,headers:u,body:s||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin",signal:f}).then(function(t){e._fetchResponse=t,e._connect()},function(t){e.emit("error",t)})}else{var d=e._xhr=new n.XMLHttpRequest;try{d.open(e._opts.method,e._opts.url,!0)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}"responseType"in d&&(d.responseType=e._mode.split(":")[0]),"withCredentials"in d&&(d.withCredentials=!!t.withCredentials),"text"===e._mode&&"overrideMimeType"in d&&d.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in t&&(d.timeout=t.requestTimeout,d.ontimeout=function(){e.emit("requestTimeout")}),u.forEach(function(e){d.setRequestHeader(e[0],e[1])}),e._response=null,d.onreadystatechange=function(){switch(d.readyState){case h.LOADING:case h.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(d.onprogress=function(){e._onXHRProgress()}),d.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{d.send(s)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}}}},l.prototype._onXHRProgress=function(){(function(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}})(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},l.prototype._connect=function(){var e=this;e._destroyed||(e._response=new f(e._xhr,e._fetchResponse,e._mode),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},l.prototype._write=function(e,t,r){this._body.push(e),r()},l.prototype.abort=l.prototype.destroy=function(){this._destroyed=!0,this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},l.prototype.end=function(e,t,r){"function"==typeof e&&(r=e,e=void 0),u.Writable.prototype.end.call(this,e,t,r)},l.prototype.flushHeaders=function(){},l.prototype.setTimeout=function(){},l.prototype.setNoDelay=function(){},l.prototype.setSocketKeepAlive=function(){};var d=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,"./response":315,_process:257,buffer:84,inherits:180,"readable-stream":285,"to-arraybuffer":323}],315:[function(e,t,r){(function(t,n,i){var o=e("./capability"),a=e("inherits"),s=e("readable-stream"),u=r.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},c=r.IncomingMessage=function(e,r,n){var a=this;if(s.Readable.call(a),a._mode=n,a.headers={},a.rawHeaders=[],a.trailers={},a.rawTrailers=[],a.on("end",function(){t.nextTick(function(){a.emit("close")})}),"fetch"===n){if(a._fetchResponse=r,a.url=r.url,a.statusCode=r.status,a.statusMessage=r.statusText,r.headers.forEach(function(e,t){a.headers[t.toLowerCase()]=e,a.rawHeaders.push(t,e)}),o.writableStream){var u=new WritableStream({write:function(e){return new Promise(function(t,r){a._destroyed||(a.push(new i(e))?t():a._resumeFetch=t)})},close:function(){a._destroyed||a.push(null)},abort:function(e){a._destroyed||a.emit("error",e)}});try{return void r.body.pipeTo(u)}catch(e){}}var c=r.body.getReader();!function e(){c.read().then(function(t){a._destroyed||(t.done?a.push(null):(a.push(new i(t.value)),e()))}).catch(function(e){a._destroyed||a.emit("error",e)})}()}else{if(a._xhr=e,a._pos=0,a.url=e.responseURL,a.statusCode=e.status,a.statusMessage=e.statusText,e.getAllResponseHeaders().split(/\r?\n/).forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var r=t[1].toLowerCase();"set-cookie"===r?(void 0===a.headers[r]&&(a.headers[r]=[]),a.headers[r].push(t[2])):void 0!==a.headers[r]?a.headers[r]+=", "+t[2]:a.headers[r]=t[2],a.rawHeaders.push(t[1],t[2])}}),a._charset="x-user-defined",!o.overrideMimeType){var f=a.rawHeaders["mime-type"];if(f){var h=f.match(/;\s*charset=([^;])(;|$)/);h&&(a._charset=h[1].toLowerCase())}a._charset||(a._charset="utf-8")}}};a(c,s.Readable),c.prototype._read=function(){var e=this._resumeFetch;e&&(this._resumeFetch=null,e())},c.prototype._onXHRProgress=function(){var e=this,t=e._xhr,r=null;switch(e._mode){case"text:vbarray":if(t.readyState!==u.DONE)break;try{r=new n.VBArray(t.responseBody).toArray()}catch(e){}if(null!==r){e.push(new i(r));break}case"text":try{r=t.responseText}catch(t){e._mode="text:vbarray";break}if(r.length>e._pos){var o=r.substr(e._pos);if("x-user-defined"===e._charset){for(var a=new i(o.length),s=0;se._pos&&(e.push(new i(new Uint8Array(c.result.slice(e._pos)))),e._pos=c.result.byteLength)},c.onload=function(){e.push(null)},c.readAsArrayBuffer(r)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,_process:257,buffer:84,inherits:180,"readable-stream":285}],316:[function(e,t,r){"use strict";t.exports=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}},{}],317:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=f,this.end=h,t=3;break;default:return this.write=l,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:-1}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�".repeat(r);if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�".repeat(r+1);if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�".repeat(r+2)}}(this,e,t);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function l(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}r.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":290}],318:[function(e,t,r){var n=e("is-hex-prefixed");t.exports=function(e){return"string"!=typeof e?e:n(e)?e.slice(2):e}},{"is-hex-prefixed":185}],319:[function(e,t,r){var n=function(){throw"This swarm.js function isn't available on the browser."},i={readFile:n},o={download:n,safeDownloadArchived:n,directoryTree:n},a={platform:n,arch:n},s={join:n,slice:n},u={spawn:n},c={lookup:n},f=e("xhr-request-promise"),h=e("eth-lib/lib/bytes"),l=e("./swarm-hash.js"),d=e("./pick.js"),p=e("./swarm");t.exports=p({fsp:i,files:o,os:a,path:s,child_process:u,defaultArchives:{},mimetype:c,request:f,downloadUrl:null,bytes:h,hash:l,pick:d})},{"./pick.js":320,"./swarm":322,"./swarm-hash.js":321,"eth-lib/lib/bytes":133,"xhr-request-promise":411}],320:[function(e,t,r){var n=function(e){return function(){return new Promise(function(t,r){var n=function(r){var n={},i=r.target.files.length,o=0;[].map.call(r.target.files,function(r){var a=new FileReader;a.onload=function(a){var s=new Uint8Array(a.target.result);if("directory"===e){var u=r.webkitRelativePath;n[u.slice(u.indexOf("/")+1)]={type:"text/plain",data:s},++o===i&&t(n)}else if("file"===e){var c=r.webkitRelativePath;t({type:mimetype.lookup(c),data:s})}else t(s)},a.readAsArrayBuffer(r)})},i=void 0;"directory"===e?((i=document.createElement("input")).addEventListener("change",n),i.type="file",i.webkitdirectory=!0,i.mozdirectory=!0,i.msdirectory=!0,i.odirectory=!0,i.directory=!0):((i=document.createElement("input")).addEventListener("change",n),i.type="file");var o=document.createEvent("MouseEvents");o.initEvent("click",!0,!1),i.dispatchEvent(o)})}};t.exports={data:n("data"),file:n("file"),directory:n("directory")}},{}],321:[function(e,t,r){var n=e("eth-lib/lib/hash").keccak256,i=e("eth-lib/lib/bytes"),o=function(e,t){var r=i.reverse(i.pad(6,i.fromNumber(e))),o=i.flatten([r,"0x0000",t]);return n(o).slice(2)};t.exports=function e(t){"string"==typeof t&&"0x"!==t.slice(0,2)?t=i.fromString(t):"string"!=typeof t&&void 0!==t.length&&(t=i.fromUint8Array(t));var r=i.length(t);if(r<=4096)return o(r,t);for(var n=4096;128*n0){var a=i.join(r,o);n.push(g(e)(t[o])(a))}return Promise.all(n).then(function(){return r})})}}},_=function(e){return function(t){return u(e+"/bzzr:/",{body:"string"==typeof t?L(t):t,method:"POST"})}},A=function(e){return function(t){return function(r){return function(n){return function i(o){var a="/"===r[0]?r:"/"+r,s=e+"/bzz:/"+t+a,c={method:"PUT",headers:{"Content-Type":n.type},body:n.data};return u(s,c).then(function(e){if(-1!==e.indexOf("error"))throw e;return e}).catch(function(e){return o>0&&i(o-1)})}(3)}}}},E=function(e){return function(t){return k(e)({"":t})}},x=function(e){return function(r){return t.readFile(r).then(function(t){return E(e)({type:a.lookup(r),data:t})})}},k=function(e){return function(t){return _(e)("{}").then(function(r){return Object.keys(t).reduce(function(r,n){return r.then(function(r){return function(n){return A(e)(n)(r)(t[r])}}(n))},Promise.resolve(r))})}},S=function(e){return function(r){return t.readFile(r).then(_(e))}},M=function(e){return function(n){return function(i){return r.directoryTree(i).then(function(e){return Promise.all(e.map(function(e){return t.readFile(e)})).then(function(t){var r=e.map(function(e){return e.slice(i.length)}),n=e.map(function(e){return a.lookup(e)||"text/plain"});return d(r)(t.map(function(e,t){return{type:n[t],data:e}}))})}).then(function(e){return(t=n?{"":e[n]}:{},function(e){var r={};for(var n in t)r[n]=t[n];for(var i in e)r[i]=e[i];return r})(e);var t}).then(k(e))}}},I=function(e){return function(t){if("data"===t.pick)return l.data().then(_(e));if("file"===t.pick)return l.file().then(E(e));if("directory"===t.pick)return l.directory().then(k(e));if(t.path)switch(t.kind){case"data":return S(e)(t.path);case"file":return x(e)(t.path);case"directory":return M(e)(t.defaultFile)(t.path)}else{if(t.length||"string"==typeof t)return _(e)(t);if(t instanceof Object)return k(e)(t)}return Promise.reject(new Error("Bad arguments"))}},T=function(e){return function(t){return function(r){return C(e)(t).then(function(n){return n?r?w(e)(t)(r):v(e)(t):r?g(e)(t)(r):b(e)(t)})}}},U=function(e,t){var i=n.platform().replace("win32","windows")+"-"+("x64"===n.arch()?"amd64":"386"),o=(t||s)[i],a=c+o.archive+".tar.gz",u=o.archiveMD5,f=o.binaryMD5;return r.safeDownloadArchived(a)(u)(f)(e)},j=function(e){return new Promise(function(t,r){var n=o.spawn,i=function(e){return function(t){return-1!==(""+t).indexOf(e)}},a=e.account,s=e.password,u=e.dataDir,c=e.ensApi,f=e.privateKey,h=0,l=n(e.binPath,["--bzzaccount",a||f,"--datadir",u,"--ens-api",c]),d=function(e){0===h&&i("Passphrase")(e)?setTimeout(function(){h=1,l.stdin.write(s+"\n")},500):i("Swarm http proxy started")(e)&&(h=2,clearTimeout(p),t(l))};l.stdout.on("data",d),l.stderr.on("data",d);var p=setTimeout(function(){return r(new Error("Couldn't start swarm process."))},2e4)})},B=function(e){return new Promise(function(t,r){e.stderr.removeAllListeners("data"),e.stdout.removeAllListeners("data"),e.stdin.removeAllListeners("error"),e.removeAllListeners("error"),e.removeAllListeners("exit"),e.kill("SIGINT");var n=setTimeout(function(){return e.kill("SIGKILL")},8e3);e.once("close",function(){clearTimeout(n),t()})})},P=function(e){return _(e)("test").then(function(e){return"c9a99c7d326dcc6316f32fe2625b311f6dc49a175e6877681ded93137d3569e7"===e}).catch(function(){return!1})},C=function(e){return function(t){return b(e)(t).then(function(e){try{return!!JSON.parse(R(e)).entries}catch(e){return!1}})}},N=function(e){return function(t,r,n,i,o){var a;return void 0!==t&&(a=e(t)),void 0!==r&&(a=e(r)),void 0!==n&&(a=e(n)),void 0!==i&&(a=e(i)),void 0!==o&&(a=e(o)),a}},R=function(e){return f.toString(f.fromUint8Array(e))},L=function(e){return f.toUint8Array(f.fromString(e))},O=function(e){return{download:function(t,r){return T(e)(t)(r)},downloadData:N(b(e)),downloadDataToDisk:N(g(e)),downloadDirectory:N(v(e)),downloadDirectoryToDisk:N(w(e)),downloadEntries:N(y(e)),downloadRoutes:N(m(e)),isAvailable:function(){return P(e)},upload:function(t){return I(e)(t)},uploadData:N(_(e)),uploadFile:N(E(e)),uploadFileFromDisk:N(E(e)),uploadDataFromDisk:N(S(e)),uploadDirectory:N(k(e)),uploadDirectoryFromDisk:N(M(e)),uploadToManifest:N(A(e)),pick:l,hash:h,fromString:L,toString:R}};return{at:O,local:function(e){return function(t){return P("http://localhost:8500").then(function(r){return r?t(O("http://localhost:8500")).then(function(){}):U(e.binPath,e.archives).onData(function(t){return(e.onProgress||function(){})(t.length)}).then(function(){return j(e)}).then(function(e){return t(O("http://localhost:8500")).then(function(){return e})}).then(B)})}},download:T,downloadBinary:U,downloadData:b,downloadDataToDisk:g,downloadDirectory:v,downloadDirectoryToDisk:w,downloadEntries:y,downloadRoutes:m,isAvailable:P,startProcess:j,stopProcess:B,upload:I,uploadData:_,uploadDataFromDisk:S,uploadFile:E,uploadFileFromDisk:x,uploadDirectory:k,uploadDirectoryFromDisk:M,uploadToManifest:A,pick:l,hash:h,fromString:L,toString:R}}},{}],323:[function(e,t,r){var n=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(n.isBuffer(e)){for(var t=new Uint8Array(e.length),r=e.length,i=0;i=0&&t<=A};function k(e){return function(t,r,n,i){r=m(r,i,4);var o=!x(t)&&y.keys(t),a=(o||t).length,s=e>0?0:a-1;return arguments.length<3&&(n=t[o?o[s]:s],s+=e),function(t,r,n,i,o,a){for(;o>=0&&o=0},y.invoke=function(e,t){var r=u.call(arguments,2),n=y.isFunction(t);return y.map(e,function(e){var i=n?t:e[t];return null==i?i:i.apply(e,r)})},y.pluck=function(e,t){return y.map(e,y.property(t))},y.where=function(e,t){return y.filter(e,y.matcher(t))},y.findWhere=function(e,t){return y.find(e,y.matcher(t))},y.max=function(e,t,r){var n,i,o=-1/0,a=-1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;so&&(o=n);else t=v(t,r),y.each(e,function(e,r,n){((i=t(e,r,n))>a||i===-1/0&&o===-1/0)&&(o=e,a=i)});return o},y.min=function(e,t,r){var n,i,o=1/0,a=1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;sn||void 0===r)return 1;if(r0?0:i-1;o>=0&&o0?a=o>=0?o:Math.max(o+s,a):s=o>=0?Math.min(o+1,s):o+s+1;else if(r&&o&&s)return n[o=r(n,i)]===i?o:-1;if(i!=i)return(o=t(u.call(n,a,s),y.isNaN))>=0?o+a:-1;for(o=e>0?a:s-1;o>=0&&ot?(a&&(clearTimeout(a),a=null),s=c,o=e.apply(n,i),a||(n=i=null)):a||!1===r.trailing||(a=setTimeout(u,f)),o}},y.debounce=function(e,t,r){var n,i,o,a,s,u=function(){var c=y.now()-a;c=0?n=setTimeout(u,t-c):(n=null,r||(s=e.apply(o,i),n||(o=i=null)))};return function(){o=this,i=arguments,a=y.now();var c=r&&!n;return n||(n=setTimeout(u,t)),c&&(s=e.apply(o,i),o=i=null),s}},y.wrap=function(e,t){return y.partial(t,e)},y.negate=function(e){return function(){return!e.apply(this,arguments)}},y.compose=function(){var e=arguments,t=e.length-1;return function(){for(var r=t,n=e[t].apply(this,arguments);r--;)n=e[r].call(this,n);return n}},y.after=function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},y.before=function(e,t){var r;return function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=null),r}},y.once=y.partial(y.before,2);var j=!{toString:null}.propertyIsEnumerable("toString"),B=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];function P(e,t){var r=B.length,n=e.constructor,i=y.isFunction(n)&&n.prototype||o,a="constructor";for(y.has(e,a)&&!y.contains(t,a)&&t.push(a);r--;)(a=B[r])in e&&e[a]!==i[a]&&!y.contains(t,a)&&t.push(a)}y.keys=function(e){if(!y.isObject(e))return[];if(l)return l(e);var t=[];for(var r in e)y.has(e,r)&&t.push(r);return j&&P(e,t),t},y.allKeys=function(e){if(!y.isObject(e))return[];var t=[];for(var r in e)t.push(r);return j&&P(e,t),t},y.values=function(e){for(var t=y.keys(e),r=t.length,n=Array(r),i=0;i":">",'"':""","'":"'","`":"`"},R=y.invert(N),L=function(e){var t=function(t){return e[t]},r="(?:"+y.keys(e).join("|")+")",n=RegExp(r),i=RegExp(r,"g");return function(e){return e=null==e?"":""+e,n.test(e)?e.replace(i,t):e}};y.escape=L(N),y.unescape=L(R),y.result=function(e,t,r){var n=null==e?void 0:e[t];return void 0===n&&(n=r),y.isFunction(n)?n.call(e):n};var O=0;y.uniqueId=function(e){var t=++O+"";return e?e+t:t},y.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var D=/(.)^/,F={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},q=/\\|'|\r|\n|\u2028|\u2029/g,H=function(e){return"\\"+F[e]};y.template=function(e,t,r){!t&&r&&(t=r),t=y.defaults({},t,y.templateSettings);var n=RegExp([(t.escape||D).source,(t.interpolate||D).source,(t.evaluate||D).source].join("|")+"|$","g"),i=0,o="__p+='";e.replace(n,function(t,r,n,a,s){return o+=e.slice(i,s).replace(q,H),i=s+t.length,r?o+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":n?o+="'+\n((__t=("+n+"))==null?'':__t)+\n'":a&&(o+="';\n"+a+"\n__p+='"),t}),o+="';\n",t.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{var a=new Function(t.variable||"obj","_",o)}catch(e){throw e.source=o,e}var s=function(e){return a.call(this,e,y)},u=t.variable||"obj";return s.source="function("+u+"){\n"+o+"}",s},y.chain=function(e){var t=y(e);return t._chain=!0,t};var z=function(e,t){return e._chain?y(t).chain():t};y.mixin=function(e){y.each(y.functions(e),function(t){var r=y[t]=e[t];y.prototype[t]=function(){var e=[this._wrapped];return s.apply(e,arguments),z(this,r.apply(y,e))}})},y.mixin(y),y.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=i[e];y.prototype[e]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==e&&"splice"!==e||0!==r.length||delete r[0],z(this,r)}}),y.each(["concat","join","slice"],function(e){var t=i[e];y.prototype[e]=function(){return z(this,t.apply(this._wrapped,arguments))}}),y.prototype.value=function(){return this._wrapped},y.prototype.valueOf=y.prototype.toJSON=y.prototype.value,y.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return y})}).call(this)},{}],326:[function(e,t,r){t.exports=function(e,t){if(t){t=(t=t.trim().replace(/^(\?|#|&)/,""))?"?"+t:t;var r=e.split(/[\?\#]/),n=r[0];t&&/\:\/\/[^\/]*$/.test(n)&&(n+="/");var i=e.match(/(\#.*)$/);e=n+t,i&&(e+=i[0])}return e}},{}],327:[function(e,t,r){"use strict";var n=e("punycode"),i=e("./util");function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}r.parse=g,r.resolve=function(e,t){return g(e,!1,!0).resolve(t)},r.resolveObject=function(e,t){return e?g(e,!1,!0).resolveObject(t):t},r.format=function(e){i.isString(e)&&(e=g(e));return e instanceof o?e.format():o.prototype.format.call(e)},r.Url=o;var a=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=e("querystring");function g(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o127?P+="x":P+=B[C];if(!P.match(d)){var R=U.slice(0,M),L=U.slice(M+1),O=B.match(p);O&&(R.push(O[1]),L.unshift(O[2])),L.length&&(g="/"+L.join(".")+g),this.hostname=R.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),T||(this.hostname=n.toASCII(this.hostname));var D=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+D,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==g[0]&&(g="/"+g))}if(!b[A])for(M=0,j=f.length;M0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift());return r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!E.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var k=E.slice(-1)[0],S=(r.host||e.host||E.length>1)&&("."===k||".."===k)||""===k,M=0,I=E.length;I>=0;I--)"."===(k=E[I])?E.splice(I,1):".."===k?(E.splice(I,1),M++):M&&(E.splice(I,1),M--);if(!_&&!A)for(;M--;M)E.unshift("..");!_||""===E[0]||E[0]&&"/"===E[0].charAt(0)||E.unshift(""),S&&"/"!==E.join("/").substr(-1)&&E.push("");var T,U=""===E[0]||E[0]&&"/"===E[0].charAt(0);x&&(r.hostname=r.host=U?"":E.length?E.shift():"",(T=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift()));return(_=_||r.host&&E.length)&&!U&&E.unshift(""),E.length?r.pathname=E.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":328,punycode:265,querystring:269}],328:[function(e,t,r){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],329:[function(e,t,r){(function(e){!function(n){var i="object"==typeof r&&r,o="object"==typeof t&&t&&t.exports==i&&t,a="object"==typeof e&&e;a.global!==a&&a.window!==a||(n=a);var s,u,c,f=String.fromCharCode;function h(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i=55296&&e<=57343)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value")}function d(e,t){return f(e>>t&63|128)}function p(e){if(0==(4294967168&e))return f(e);var t="";return 0==(4294965248&e)?t=f(e>>6&31|192):0==(4294901760&e)?(l(e),t=f(e>>12&15|224),t+=d(e,6)):0==(4292870144&e)&&(t=f(e>>18&7|240),t+=d(e,12),t+=d(e,6)),t+=f(63&e|128)}function b(){if(c>=u)throw Error("Invalid byte index");var e=255&s[c];if(c++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function y(){var e,t;if(c>u)throw Error("Invalid byte index");if(c==u)return!1;if(e=255&s[c],c++,0==(128&e))return e;if(192==(224&e)){if((t=(31&e)<<6|b())>=128)return t;throw Error("Invalid continuation byte")}if(224==(240&e)){if((t=(15&e)<<12|b()<<6|b())>=2048)return l(t),t;throw Error("Invalid continuation byte")}if(240==(248&e)&&(t=(15&e)<<18|b()<<12|b()<<6|b())>=65536&&t<=1114111)return t;throw Error("Invalid UTF-8 detected")}var m={version:"2.0.0",encode:function(e){for(var t=h(e),r=t.length,n=-1,i="";++n65535&&(i+=f((t-=65536)>>>10&1023|55296),t=56320|1023&t),i+=f(t);return i}(r)}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return m});else if(i&&!i.nodeType)if(o)o.exports=m;else{var v={}.hasOwnProperty;for(var g in m)v.call(m,g)&&(i[g]=m[g])}else n.utf8=m}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],330:[function(e,t,r){(function(e){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],331:[function(e,t,r){arguments[4][180][0].apply(r,arguments)},{dup:180}],332:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],333:[function(e,t,r){(function(t,n){var i=/%[sdj%]/g;r.format=function(e){if(!m(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(t)?n.showHidden=t:t&&r._extend(n,t),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,e,n.depth)}function u(e,t){var r=s.styles[t];return r?"["+s.colors[r][0]+"m"+e+"["+s.colors[r][1]+"m":e}function c(e,t){return e}function f(e,t,n){if(e.customInspect&&t&&E(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return m(i)||(i=f(e,i,n)),i}var o=function(e,t){if(v(t))return e.stylize("undefined","undefined");if(m(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(y(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(b(t))return e.stylize("null","null")}(e,t);if(o)return o;var a=Object.keys(t),s=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),A(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return h(t);if(0===a.length){if(E(t)){var u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","special")}if(g(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(_(t))return e.stylize(Date.prototype.toString.call(t),"date");if(A(t))return h(t)}var c,w="",x=!1,k=["{","}"];(d(t)&&(x=!0,k=["[","]"]),E(t))&&(w=" [Function"+(t.name?": "+t.name:"")+"]");return g(t)&&(w=" "+RegExp.prototype.toString.call(t)),_(t)&&(w=" "+Date.prototype.toUTCString.call(t)),A(t)&&(w=" "+h(t)),0!==a.length||x&&0!=t.length?n<0?g(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=x?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(c,w,k)):k[0]+w+k[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),M(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=b(r)?f(e,u.value,null):f(e,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n")):s=e.stylize("[Circular]","special")),v(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function b(e){return null===e}function y(e){return"number"==typeof e}function m(e){return"string"==typeof e}function v(e){return void 0===e}function g(e){return w(e)&&"[object RegExp]"===x(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===x(e)}function A(e){return w(e)&&("[object Error]"===x(e)||e instanceof Error)}function E(e){return"function"==typeof e}function x(e){return Object.prototype.toString.call(e)}function k(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(v(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=t.pid;a[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else a[e]=function(){};return a[e]},r.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(e){return null==e},r.isNumber=y,r.isString=m,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=v,r.isRegExp=g,r.isObject=w,r.isDate=_,r.isError=A,r.isFunction=E,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[k(e.getHours()),k(e.getMinutes()),k(e.getSeconds())].join(":"),[e.getDate(),S[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":332,_process:257,inherits:331}],334:[function(require,module,exports){var indexOf=require("indexof"),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},c.prototype.getCall=function(e){return n.isFunction(this.call)?this.call(e):this.call},c.prototype.extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},c.prototype.validateArgs=function(e){if(e.length!==this.params)throw i.InvalidNumberOfParams(e.length,this.params,this.name)},c.prototype.formatInput=function(e){var t=this;return this.inputFormatter?this.inputFormatter.map(function(r,n){return r?r.call(t,e[n]):e[n]}):e},c.prototype.formatOutput=function(e){var t=this;return n.isArray(e)?e.map(function(e){return t.outputFormatter&&e?t.outputFormatter(e):e}):this.outputFormatter&&e?this.outputFormatter(e):e},c.prototype.toPayload=function(e){var t=this.getCall(e),r=this.extractCallback(e),n=this.formatInput(e);this.validateArgs(n);var i={method:t,params:n,callback:r};return this.transformPayload&&(i=this.transformPayload(i)),i},c.prototype._confirmTransaction=function(e,t,r){var i=this,f=!1,h=!0,l=0,d=0,p=null,b="",y=n.isObject(r.params[0])&&r.params[0].gas?r.params[0].gas:null,m=n.isObject(r.params[0])&&r.params[0].data&&r.params[0].from&&!r.params[0].to,v=[new c({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:o.outputTransactionReceiptFormatter}),new c({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[o.inputAddressFormatter,o.inputDefaultBlockNumberFormatter]}),new u({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:o.outputBlockFormatter}}})],g={};n.each(v,function(e){e.attachToObject(g),e.requestManager=i.requestManager});var w=function(r,n,o,u,c){if(!o)return c||(c={unsubscribe:function(){clearInterval(p)}}),(r?s.resolve(r):g.getTransactionReceipt(t)).catch(function(t){c.unsubscribe(),f=!0,a._fireError({message:"Failed to check for transaction receipt:",data:t},e.eventEmitter,e.reject)}).then(function(t){if(!t||!t.blockHash)throw new Error("Receipt missing or blockHash null");return i.extraFormatters&&i.extraFormatters.receiptFormatter&&(t=i.extraFormatters.receiptFormatter(t)),e.eventEmitter.listeners("confirmation").length>0&&(void 0!==r&&0===d||e.eventEmitter.emit("confirmation",d,t),h=!1,25===++d&&(c.unsubscribe(),e.eventEmitter.removeAllListeners())),t}).then(function(t){if(m&&!f){if(!t.contractAddress)return h&&(c.unsubscribe(),f=!0),void a._fireError(new Error("The transaction receipt didn't contain a contract address."),e.eventEmitter,e.reject);g.getCode(t.contractAddress,function(r,n){n&&(n.length>2?(e.eventEmitter.emit("receipt",t),i.extraFormatters&&i.extraFormatters.contractDeployFormatter?e.resolve(i.extraFormatters.contractDeployFormatter(t)):e.resolve(t),h&&e.eventEmitter.removeAllListeners()):a._fireError(new Error("The contract code couldn't be stored, please check your gas limit."),e.eventEmitter,e.reject),h&&c.unsubscribe(),f=!0)})}return t}).then(function(t){m||f||(t.outOfGas||y&&y===t.gasUsed||!0!==t.status&&"0x1"!==t.status&&void 0!==t.status?(b=JSON.stringify(t,null,2),!1===t.status||"0x0"===t.status?a._fireError(new Error("Transaction has been reverted by the EVM:\n"+b),e.eventEmitter,e.reject):a._fireError(new Error("Transaction ran out of gas. Please provide more gas:\n"+b),e.eventEmitter,e.reject)):(e.eventEmitter.emit("receipt",t),e.resolve(t),h&&e.eventEmitter.removeAllListeners()),h&&c.unsubscribe(),f=!0)}).catch(function(){l++,n?l-1>=750&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject)):l-1>=50&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject))});c.unsubscribe(),f=!0,a._fireError({message:"Failed to subscribe to new newBlockHeaders to confirm the transaction receipts.",data:o},e.eventEmitter,e.reject)},_=function(e){n.isFunction(this.requestManager.provider.on)?g.subscribe("newBlockHeaders",w.bind(null,e,!1)):p=setInterval(w.bind(null,e,!0),1e3)}.bind(this);g.getTransactionReceipt(t).then(function(t){t&&t.blockHash?(e.eventEmitter.listeners("confirmation").length>0&&_(t),w(t,!1)):f||_()}).catch(function(){f||_()})};var f=function(e,t){return n.isNumber(e)?t.wallet[e]:n.isObject(e)&&e.address&&e.privateKey?e:t.wallet[e.toLowerCase()]};c.prototype.buildCall=function(){var e=this,t="eth_sendTransaction"===e.call||"eth_sendRawTransaction"===e.call,r=function(){var r=s(!t),i=e.toPayload(Array.prototype.slice.call(arguments)),o=function(n,o){try{o=e.formatOutput(o)}catch(e){n=e}if(o instanceof Error&&(n=o),n)return n.error&&(n=n.error),a._fireError(n,r.eventEmitter,r.reject,i.callback);i.callback&&i.callback(null,o),t?(r.eventEmitter.emit("transactionHash",o),e._confirmTransaction(r,o,i)):n||r.resolve(o)},u=function(t){var r=n.extend({},i,{method:"eth_sendRawTransaction",params:[t.rawTransaction]});e.requestManager.send(r,o)},h=function(e,t){var i;if(t&&t.accounts&&t.accounts.wallet&&t.accounts.wallet.length)if("eth_sendTransaction"===e.method){var a=e.params[0];if((i=f(n.isObject(a)?a.from:null,t.accounts))&&i.privateKey)return t.accounts.signTransaction(n.omit(a,"from"),i.privateKey).then(u)}else if("eth_sign"===e.method){var s=e.params[1];if((i=f(e.params[0],t.accounts))&&i.privateKey){var c=t.accounts.sign(s,i.privateKey);return e.callback&&e.callback(null,c.signature),void r.resolve(c.signature)}}return t.requestManager.send(e,o)};t&&n.isObject(i.params[0])&&void 0===i.params[0].gasPrice?new c({name:"getGasPrice",call:"eth_gasPrice",params:0}).createFunction(e.requestManager)(function(t,r){r&&(i.params[0].gasPrice=r),h(i,e)}):h(i,e);return r.eventEmitter};return r.method=e,r.request=this.request.bind(this),r},c.prototype.request=function(){var e=this.toPayload(Array.prototype.slice.call(arguments));return e.format=this.formatOutput.bind(this),e},t.exports=c},{underscore:325,"web3-core-helpers":338,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-utils":403}],340:[function(e,t,r){"use strict";var n=e("eventemitter3"),i=e("any-promise"),o=function(e){var t,r,o=new i(function(){t=arguments[0],r=arguments[1]});if(e)return{resolve:t,reject:r,eventEmitter:o};var a=new n;return o._events=a._events,o.emit=a.emit,o.on=a.on,o.once=a.once,o.off=a.off,o.listeners=a.listeners,o.addListener=a.addListener,o.removeListener=a.removeListener,o.removeAllListeners=a.removeAllListeners,{resolve:t,reject:r,eventEmitter:o}};o.resolve=function(e){var t=o(!0);return t.resolve(e),t.eventEmitter},t.exports=o},{"any-promise":2,eventemitter3:156}],341:[function(e,t,r){"use strict";var n=e("./jsonrpc"),i=e("web3-core-helpers").errors,o=function(e){this.requestManager=e,this.requests=[]};o.prototype.add=function(e){this.requests.push(e)},o.prototype.execute=function(){var e=this.requests;this.requestManager.sendBatch(e,function(t,r){r=r||[],e.map(function(e,t){return r[t]||{}}).forEach(function(t,r){if(e[r].callback){if(t&&t.error)return e[r].callback(i.ErrorResponse(t));if(!n.isValidResponse(t))return e[r].callback(i.InvalidResponse(t));try{e[r].callback(null,e[r].format?e[r].format(t.result):t.result)}catch(t){e[r].callback(t)}}})})},t.exports=o},{"./jsonrpc":344,"web3-core-helpers":338}],342:[function(e,t,r){"use strict";var n=null,i=window;void 0!==i.ethereumProvider?n=i.ethereumProvider:void 0!==i.web3&&i.web3.currentProvider&&(i.web3.currentProvider.sendAsync&&(i.web3.currentProvider.send=i.web3.currentProvider.sendAsync,delete i.web3.currentProvider.sendAsync),!i.web3.currentProvider.on&&i.web3.currentProvider.connection&&"ipcProviderWrapper"===i.web3.currentProvider.connection.constructor.name&&(i.web3.currentProvider.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.connection.on("data",function(e){var r="";e=e.toString();try{r=JSON.parse(e)}catch(r){return t(new Error("Couldn't parse response data"+e))}r.id||-1===r.method.indexOf("_subscription")||t(null,r)});break;default:this.connection.on(e,t)}}),n=i.web3.currentProvider),t.exports=n},{}],343:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("./jsonrpc.js"),a=e("./batch.js"),s=e("./givenProvider.js"),u=function e(t){this.provider=null,this.providers=e.providers,this.setProvider(t),this.subscriptions={}};u.givenProvider=s,u.providers={WebsocketProvider:e("web3-providers-ws"),HttpProvider:e("web3-providers-http"),IpcProvider:e("web3-providers-ipc")},u.prototype.setProvider=function(e,t){var r=this;if(e&&"string"==typeof e&&this.providers)if(/^http(s)?:\/\//i.test(e))e=new this.providers.HttpProvider(e);else if(/^ws(s)?:\/\//i.test(e))e=new this.providers.WebsocketProvider(e);else if(e&&"object"==typeof t&&"function"==typeof t.connect)e=new this.providers.IpcProvider(e,t);else if(e)throw new Error("Can't autodetect provider for \""+e+'"');this.provider&&this.provider.connected&&this.clearSubscriptions(),this.provider=e||null,this.provider&&this.provider.on&&this.provider.on("data",function(e,t){(e=e||t).method&&r.subscriptions[e.params.subscription]&&r.subscriptions[e.params.subscription].callback&&r.subscriptions[e.params.subscription].callback(null,e.params.result)})},u.prototype.send=function(e,t){if(t=t||function(){},!this.provider)return t(i.InvalidProvider());var r=o.toPayload(e.method,e.params);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,n){return n&&n.id&&r.id!==n.id?t(new Error('Wrong response id "'+n.id+'" (expected: "'+r.id+'") in '+JSON.stringify(r))):e?t(e):n&&n.error?t(i.ErrorResponse(n)):o.isValidResponse(n)?void t(null,n.result):t(i.InvalidResponse(n))})},u.prototype.sendBatch=function(e,t){if(!this.provider)return t(i.InvalidProvider());var r=o.toBatchPayload(e);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,r){return e?t(e):n.isArray(r)?void t(null,r):t(i.InvalidResponse(r))})},u.prototype.addSubscription=function(e,t,r,n){if(!this.provider.on)throw new Error("The provider doesn't support subscriptions: "+this.provider.constructor.name);this.subscriptions[e]={callback:n,type:r,name:t}},u.prototype.removeSubscription=function(e,t){this.subscriptions[e]&&(this.send({method:this.subscriptions[e].type+"_unsubscribe",params:[e]},t),delete this.subscriptions[e])},u.prototype.clearSubscriptions=function(e){var t=this;Object.keys(this.subscriptions).forEach(function(r){e&&"syncing"===t.subscriptions[r].name||t.removeSubscription(r)}),this.provider.reset&&this.provider.reset()},t.exports={Manager:u,BatchManager:a}},{"./batch.js":341,"./givenProvider.js":342,"./jsonrpc.js":344,underscore:325,"web3-core-helpers":338,"web3-providers-http":398,"web3-providers-ipc":399,"web3-providers-ws":400}],344:[function(e,t,r){"use strict";var n={messageId:0,toPayload:function(e,t){if(!e)throw new Error('JSONRPC method should be specified for params: "'+JSON.stringify(t)+'"!');return n.messageId++,{jsonrpc:"2.0",id:n.messageId,method:e,params:t||[]}},isValidResponse:function(e){return Array.isArray(e)?e.every(t):t(e);function t(e){return!(!e||e.error||"2.0"!==e.jsonrpc||"number"!=typeof e.id&&"string"!=typeof e.id||void 0===e.result)}},toBatchPayload:function(e){return e.map(function(e){return n.toPayload(e.method,e.params)})}};t.exports=n},{}],345:[function(e,t,r){"use strict";var n=e("./subscription.js"),i=function(e){this.name=e.name,this.type=e.type,this.subscriptions=e.subscriptions||{},this.requestManager=null};i.prototype.setRequestManager=function(e){this.requestManager=e},i.prototype.attachToObject=function(e){var t=this.buildCall(),r=this.name.split(".");r.length>1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},i.prototype.buildCall=function(){var e=this;return function(){e.subscriptions[arguments[0]]||console.warn("Subscription "+JSON.stringify(arguments[0])+" doesn't exist. Subscribing anyway.");var t=new n({subscription:e.subscriptions[arguments[0]],requestManager:e.requestManager,type:e.type});return t.subscribe.apply(t,arguments)}},t.exports={subscriptions:i,subscription:n}},{"./subscription.js":346}],346:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("eventemitter3");function a(e){o.call(this),this.id=null,this.callback=n.identity,this.arguments=null,this._reconnectIntervalId=null,this.options={subscription:e.subscription,type:e.type,requestManager:e.requestManager}}a.prototype=Object.create(o.prototype),a.prototype.constructor=a,a.prototype._extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},a.prototype._validateArgs=function(e){var t=this.options.subscription;if(t||(t={}),t.params||(t.params=0),e.length!==t.params)throw i.InvalidNumberOfParams(e.length,t.params+1,e[0])},a.prototype._formatInput=function(e){var t=this.options.subscription;return t&&t.inputFormatter?t.inputFormatter.map(function(t,r){return t?t(e[r]):e[r]}):e},a.prototype._formatOutput=function(e){var t=this.options.subscription;return t&&t.outputFormatter&&e?t.outputFormatter(e):e},a.prototype._toPayload=function(e){var t=[];if(this.callback=this._extractCallback(e)||n.identity,this.subscriptionMethod||(this.subscriptionMethod=e.shift(),this.options.subscription.subscriptionName&&(this.subscriptionMethod=this.options.subscription.subscriptionName)),this.arguments||(this.arguments=this._formatInput(e),this._validateArgs(this.arguments),e=[]),t.push(this.subscriptionMethod),t=t.concat(this.arguments),e.length)throw new Error("Only a callback is allowed as parameter on an already instantiated subscription.");return{method:this.options.type+"_subscribe",params:t}},a.prototype.unsubscribe=function(e){this.options.requestManager.removeSubscription(this.id,e),this.id=null,this.removeAllListeners(),clearInterval(this._reconnectIntervalId)},a.prototype.subscribe=function(){var e=this,t=Array.prototype.slice.call(arguments),r=this._toPayload(t);if(!r)return this;if(!this.options.requestManager.provider){var i=new Error("No provider set.");return this.callback(i,null,this),this.emit("error",i),this}if(!this.options.requestManager.provider.on){var o=new Error("The current provider doesn't support subscriptions: "+this.options.requestManager.provider.constructor.name);return this.callback(o,null,this),this.emit("error",o),this}return this.id&&this.unsubscribe(),this.options.params=r.params[1],"logs"===r.params[0]&&n.isObject(r.params[1])&&r.params[1].hasOwnProperty("fromBlock")&&isFinite(r.params[1].fromBlock)&&this.options.requestManager.send({method:"eth_getLogs",params:[r.params[1]]},function(t,r){t?(e.callback(t,null,e),e.emit("error",t)):r.forEach(function(t){var r=e._formatOutput(t);e.callback(null,r,e),e.emit("data",r)})}),"object"==typeof r.params[1]&&delete r.params[1].fromBlock,this.options.requestManager.send(r,function(t,i){!t&&i?(e.id=i,e.options.requestManager.addSubscription(e.id,r.params[0],e.options.type,function(t,r){t?(e.options.requestManager.removeSubscription(e.id),e.options.requestManager.provider.once&&(e._reconnectIntervalId=setInterval(function(){e.options.requestManager.provider.reconnect&&e.options.requestManager.provider.reconnect()},500),e.options.requestManager.provider.once("connect",function(){clearInterval(e._reconnectIntervalId),e.subscribe(e.callback)})),e.emit("error",t),e.callback(t,null,e)):(n.isArray(r)||(r=[r]),r.forEach(function(t){var r=e._formatOutput(t);if(n.isFunction(e.options.subscription.subscriptionHandler))return e.options.subscription.subscriptionHandler.call(e,r);e.emit("data",r),e.callback(null,r,e)}))})):(e.callback(t,null,e),e.emit("error",t))}),this},t.exports=a},{eventemitter3:156,underscore:325,"web3-core-helpers":338}],347:[function(e,t,r){"use strict";var n=e("web3-core-helpers").formatters,i=e("web3-core-method"),o=e("web3-utils");t.exports=function(e){var t=function(t){var r;return t.property?(e[t.property]||(e[t.property]={}),r=e[t.property]):r=e,t.methods&&t.methods.forEach(function(t){t instanceof i||(t=new i(t)),t.attachToObject(r),t.setRequestManager(e._requestManager)}),e};return t.formatters=n,t.utils=o,t.Method=i,t}},{"web3-core-helpers":338,"web3-core-method":339,"web3-utils":403}],348:[function(e,t,r){"use strict";var n=e("web3-core-requestmanager"),i=e("./extend.js");t.exports={packageInit:function(e,t){if(t=Array.prototype.slice.call(t),!e)throw new Error('You need to instantiate using the "new" keyword.');Object.defineProperty(e,"currentProvider",{get:function(){return e._provider},set:function(t){return e.setProvider(t)},enumerable:!0,configurable:!0}),t[0]&&t[0]._requestManager?e._requestManager=new n.Manager(t[0].currentProvider):(e._requestManager=new n.Manager,e._requestManager.setProvider(t[0],t[1])),e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers,e._provider=e._requestManager.provider,e.setProvider||(e.setProvider=function(t,r){return e._requestManager.setProvider(t,r),e._provider=e._requestManager.provider,!0}),e.BatchRequest=n.BatchManager.bind(null,e._requestManager),e.extend=i(e)},addProviders:function(e){e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers}}},{"./extend.js":347,"web3-core-requestmanager":343}],349:[function(e,t,r){var n=e("underscore"),i=e("web3-utils"),o=new(0,e("ethers/utils/abi-coder").AbiCoder)(function(e,t){return!e.match(/^u?int/)||n.isArray(t)||n.isObject(t)&&"BN"===t.constructor.name?t:t.toString()});function a(){}var s=function(){};s.prototype.encodeFunctionSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e).slice(0,10)},s.prototype.encodeEventSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e)},s.prototype.encodeParameter=function(e,t){return this.encodeParameters([e],[t])},s.prototype.encodeParameters=function(e,t){return o.encode(this.mapTypes(e),t)},s.prototype.mapTypes=function(e){var t=this,r=[];return e.forEach(function(e){if(t.isSimplifiedStructFormat(e)){var n=Object.keys(e)[0];r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}else r.push(e)}),r},s.prototype.isSimplifiedStructFormat=function(e){return"object"==typeof e&&void 0===e.components&&void 0===e.name},s.prototype.mapStructNameAndType=function(e){var t="tuple";return e.indexOf("[]")>-1&&(t="tuple[]",e=e.slice(0,-2)),{type:t,name:e}},s.prototype.mapStructToCoderFormat=function(e){var t=this,r=[];return Object.keys(e).forEach(function(n){"object"!=typeof e[n]?r.push({name:n,type:e[n]}):r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}),r},s.prototype.encodeFunctionCall=function(e,t){return this.encodeFunctionSignature(e)+this.encodeParameters(e.inputs,t).replace("0x","")},s.prototype.decodeParameter=function(e,t){return this.decodeParameters([e],t)[0]},s.prototype.decodeParameters=function(e,t){if(!t||"0x"===t||"0X"===t)throw new Error("Returned values aren't valid, did it run Out of Gas?");var r=o.decode(this.mapTypes(e),"0x"+t.replace(/0x/i,"")),i=new a;return i.__length__=0,e.forEach(function(e,t){var o=r[i.__length__];o="0x"===o?null:o,i[t]=o,n.isObject(e)&&e.name&&(i[e.name]=o),i.__length__++}),i},s.prototype.decodeLog=function(e,t,r){var i=this;r=n.isArray(r)?r:[r],t=t||"";var o=[],s=[],u=0;e.forEach(function(e,t){e.indexed?(s[t]=["bool","int","uint","address","fixed","ufixed"].find(function(t){return-1!==e.type.indexOf(t)})?i.decodeParameter(e.type,r[u]):r[u],u++):o[t]=e});var c=t,f=c?this.decodeParameters(o,c):[],h=new a;return h.__length__=0,e.forEach(function(e,t){h[t]="string"===e.type?"":null,void 0!==f[t]&&(h[t]=f[t]),void 0!==s[t]&&(h[t]=s[t]),e.name&&(h[e.name]=h[t]),h.__length__++}),h};var u=new s;t.exports=u},{"ethers/utils/abi-coder":143,underscore:325,"web3-utils":403}],350:[function(e,t,r){(function(r){var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=e("./bytes"),o=e("./nat"),a=e("elliptic"),s=(e("./rlp"),new a.ec("secp256k1")),u=e("./hash"),c=u.keccak256,f=u.keccak256s,h=function(e){for(var t=f(e.slice(2)),r="0x",n=0;n<40;n++)r+=parseInt(t[n+2],16)>7?e[n+2].toUpperCase():e[n+2];return r},l=function(e){var t=new r(e.slice(2),"hex"),n="0x"+s.keyFromPrivate(t).getPublic(!1,"hex").slice(2),i=c(n);return{address:h("0x"+i.slice(-40)),privateKey:e}},d=function(e){var t=n(e,3),r=t[0],o=i.pad(32,t[1]),a=i.pad(32,t[2]);return i.flatten([o,a,r])},p=function(e){return[i.slice(64,i.length(e),e),i.slice(0,32,e),i.slice(32,64,e)]},b=function(e){return function(t,n){var a=s.keyFromPrivate(new r(n.slice(2),"hex")).sign(new r(t.slice(2),"hex"),{canonical:!0});return d([o.fromString(i.fromNumber(e+a.recoveryParam)),i.pad(32,i.fromNat("0x"+a.r.toString(16))),i.pad(32,i.fromNat("0x"+a.s.toString(16)))])}},y=b(27);t.exports={create:function(e){var t=c(i.concat(i.random(32),e||i.random(32))),r=i.concat(i.concat(i.random(32),t),i.random(32)),n=c(r);return l(n)},toChecksum:h,fromPrivate:l,sign:y,makeSigner:b,recover:function(e,t){var n=p(t),o={v:i.toNumber(n[0]),r:n[1].slice(2),s:n[2].slice(2)},a="0x"+s.recoverPubKey(new r(e.slice(2),"hex"),o,o.v<2?o.v:1-o.v%2).encode("hex",!1).slice(2),u=c(a);return h("0x"+u.slice(-40))},encodeSignature:d,decodeSignature:p}}).call(this,e("buffer").Buffer)},{"./bytes":352,"./hash":353,"./nat":354,"./rlp":355,buffer:84,elliptic:109}],351:[function(e,t,r){arguments[4][132][0].apply(r,arguments)},{dup:132}],352:[function(e,t,r){arguments[4][133][0].apply(r,arguments)},{"./array.js":351,dup:133}],353:[function(e,t,r){arguments[4][134][0].apply(r,arguments)},{dup:134}],354:[function(e,t,r){var n=e("bn.js"),i=e("./bytes"),o=function(e){return new n(e.slice(2),16)},a=function(e){var t="0x"+("0x"===e.slice(0,2)?new n(e.slice(2),16):new n(e,10)).toString("hex");return"0x0"===t?"0x":t},s=function(e){return"string"==typeof e?/^0x/.test(e)?e:"0x"+e:"0x"+new n(e).toString("hex")},u=function(e){return o(e).toNumber()},c=function(e){return function(t,r){return"0x"+o(t)[e](o(r)).toString("hex")}},f=c("add"),h=c("mul"),l=c("div"),d=c("sub");t.exports={toString:function(e){return o(e).toString(10)},fromString:a,toNumber:u,fromNumber:s,toEther:function(e){return u(l(e,a("10000000000")))/1e8},fromEther:function(e){return h(s(Math.floor(1e8*e)),a("10000000000"))},toUint256:function(e){return i.pad(32,e)},add:f,mul:h,div:l,sub:d}},{"./bytes":352,"bn.js":53}],355:[function(e,t,r){t.exports={encode:function(e){var t=function(e){return(t=e.toString(16)).length%2==0?t:"0"+t;var t},r=function(e,r){return e<56?t(r+e):t(r+t(e).length/2+55)+t(e)};return"0x"+function e(t){if("string"==typeof t){var n=t.slice(2);return(2!=n.length||n>="80"?r(n.length/2,128):"")+n}var i=t.map(e).join("");return r(i.length/2,192)+i}(e)},decode:function(e){var t=2,r=function(){if(t>=e.length)throw"";var r=e.slice(t,t+2);return r<"80"?(t+=2,"0x"+r):r<"c0"?i():o()},n=function(){var r=parseInt(e.slice(t,t+=2),16)%64;return r<56?r:parseInt(e.slice(t,t+=2*(r-55)),16)},i=function(){var r=n();return"0x"+e.slice(t,t+=2*r)},o=function(){for(var e=2*n()+t,i=[];t>>((3&t)<<3)&255;return i}}t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],357:[function(e,t,r){for(var n=e("./rng"),i=[],o={},a=0;a<256;a++)i[a]=(a+256).toString(16).substr(1),o[i[a]]=a;function s(e,t){var r=t||0,n=i;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var u=n(),c=[1|u[0],u[1],u[2],u[3],u[4],u[5]],f=16383&(u[6]<<8|u[7]),h=0,l=0;function d(e,t,r){var i=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||n)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var a=0;a<16;a++)t[i+a]=o[a];return t||s(o)}var p=d;p.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:f,a=void 0!==e.msecs?e.msecs:(new Date).getTime(),u=void 0!==e.nsecs?e.nsecs:l+1,d=a-h+(u-l)/1e4;if(d<0&&void 0===e.clockseq&&(o=o+1&16383),(d<0||a>h)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");h=a,l=u,f=o;var p=(1e4*(268435455&(a+=122192928e5))+u)%4294967296;i[n++]=p>>>24&255,i[n++]=p>>>16&255,i[n++]=p>>>8&255,i[n++]=255&p;var b=a/4294967296*1e4&268435455;i[n++]=b>>>8&255,i[n++]=255&b,i[n++]=b>>>24&15|16,i[n++]=b>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var y=e.node||c,m=0;m<6;m++)i[n+m]=y[m];return t||s(i)},p.v4=d,p.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=o[e])});i<16;)t[n+i++]=0;return t},p.unparse=s,t.exports=p},{"./rng":356}],358:[function(e,t,r){(function(r,n){"use strict";var i=e("underscore"),o=e("web3-core"),a=e("web3-core-method"),s=e("any-promise"),u=e("eth-lib/lib/account"),c=e("eth-lib/lib/hash"),f=e("eth-lib/lib/rlp"),h=e("eth-lib/lib/nat"),l=e("eth-lib/lib/bytes"),d=e(void 0===r?"crypto-browserify":"crypto"),p=e("scrypt.js"),b=e("uuid"),y=e("web3-utils"),m=e("web3-core-helpers"),v=function(e){return i.isUndefined(e)||i.isNull(e)},g=function(e){for(;e&&e.startsWith("0x0");)e="0x"+e.slice(3);return e},w=function(e){return e.length%2==1&&(e=e.replace("0x","0x0")),e},_=function(){var e=this;o.packageInit(this,arguments),delete this.BatchRequest,delete this.extend;var t=[new a({name:"getId",call:"net_version",params:0,outputFormatter:y.hexToNumber}),new a({name:"getGasPrice",call:"eth_gasPrice",params:0}),new a({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[function(e){if(y.isAddress(e))return e;throw new Error("Address "+e+' is not a valid address to get the "transactionCount".')},function(){return"latest"}]})];this._ethereumCall={},i.each(t,function(t){t.attachToObject(e._ethereumCall),t.setRequestManager(e._requestManager)}),this.wallet=new A(this)};function A(e){this._accounts=e,this.length=0,this.defaultKeyName="web3js_wallet"}_.prototype._addAccountFunctions=function(e){var t=this;return e.signTransaction=function(r,n){return t.signTransaction(r,e.privateKey,n)},e.sign=function(r){return t.sign(r,e.privateKey)},e.encrypt=function(r,n){return t.encrypt(e.privateKey,r,n)},e},_.prototype.create=function(e){return this._addAccountFunctions(u.create(e||y.randomHex(32)))},_.prototype.privateKeyToAccount=function(e){return this._addAccountFunctions(u.fromPrivate(e))},_.prototype.signTransaction=function(e,t,r){var n,o=!1;if(r=r||function(){},!e)return o=new Error("No transaction object given!"),r(o),s.reject(o);function a(e){if(e.gas||e.gasLimit||(o=new Error('"gas" is missing')),(e.nonce<0||e.gas<0||e.gasPrice<0||e.chainId<0)&&(o=new Error("Gas, gasPrice, nonce or chainId is lower than 0")),o)return r(o),s.reject(o);try{var i=e=m.formatters.inputCallFormatter(e);i.to=e.to||"0x",i.data=e.data||"0x",i.value=e.value||"0x",i.chainId=y.numberToHex(e.chainId);var a=f.encode([l.fromNat(i.nonce),l.fromNat(i.gasPrice),l.fromNat(i.gas),i.to.toLowerCase(),l.fromNat(i.value),i.data,l.fromNat(i.chainId||"0x1"),"0x","0x"]),d=c.keccak256(a),p=u.makeSigner(2*h.toNumber(i.chainId||"0x1")+35)(c.keccak256(a),t),b=f.decode(a).slice(0,6).concat(u.decodeSignature(p));b[6]=w(g(b[6])),b[7]=w(g(b[7])),b[8]=w(g(b[8]));var v=f.encode(b),_=f.decode(v);n={messageHash:d,v:g(_[6]),r:g(_[7]),s:g(_[8]),rawTransaction:v}}catch(e){return r(e),s.reject(e)}return r(null,n),n}return void 0!==e.nonce&&void 0!==e.chainId&&void 0!==e.gasPrice?s.resolve(a(e)):s.all([v(e.chainId)?this._ethereumCall.getId():e.chainId,v(e.gasPrice)?this._ethereumCall.getGasPrice():e.gasPrice,v(e.nonce)?this._ethereumCall.getTransactionCount(this.privateKeyToAccount(t).address):e.nonce]).then(function(t){if(v(t[0])||v(t[1])||v(t[2]))throw new Error('One of the values "chainId", "gasPrice", or "nonce" couldn\'t be fetched: '+JSON.stringify(t));return a(i.extend(e,{chainId:t[0],gasPrice:t[1],nonce:t[2]}))})},_.prototype.recoverTransaction=function(e){var t=f.decode(e),r=u.encodeSignature(t.slice(6,9)),n=l.toNumber(t[6]),i=n<35?[]:[l.fromNumber(n-35>>1),"0x","0x"],o=t.slice(0,6).concat(i),a=f.encode(o);return u.recover(c.keccak256(a),r)},_.prototype.hashMessage=function(e){var t=y.isHexStrict(e)?y.hexToBytes(e):e,r=n.from(t),i="Ethereum Signed Message:\n"+t.length,o=n.from(i),a=n.concat([o,r]);return c.keccak256s(a)},_.prototype.sign=function(e,t){var r=this.hashMessage(e),n=u.sign(r,t),i=u.decodeSignature(n);return{message:e,messageHash:r,v:i[0],r:i[1],s:i[2],signature:n}},_.prototype.recover=function(e,t,r){var n=[].slice.apply(arguments);return i.isObject(e)?this.recover(e.messageHash,u.encodeSignature([e.v,e.r,e.s]),!0):(r||(e=this.hashMessage(e)),n.length>=4?(r=n.slice(-1)[0],r=!!i.isBoolean(r)&&!!r,this.recover(e,u.encodeSignature(n.slice(1,4)),r)):u.recover(e,t))},_.prototype.decrypt=function(e,t,r){if(!i.isString(t))throw new Error("No password given.");var o,a,s=i.isObject(e)?e:JSON.parse(r?e.toLowerCase():e);if(3!==s.version)throw new Error("Not a valid V3 wallet");if("scrypt"===s.crypto.kdf)a=s.crypto.kdfparams,o=p(new n(t),new n(a.salt,"hex"),a.n,a.r,a.p,a.dklen);else{if("pbkdf2"!==s.crypto.kdf)throw new Error("Unsupported key derivation scheme");if("hmac-sha256"!==(a=s.crypto.kdfparams).prf)throw new Error("Unsupported parameters to PBKDF2");o=d.pbkdf2Sync(new n(t),new n(a.salt,"hex"),a.c,a.dklen,"sha256")}var u=new n(s.crypto.ciphertext,"hex");if(y.sha3(n.concat([o.slice(16,32),u])).replace("0x","")!==s.crypto.mac)throw new Error("Key derivation failed - possibly wrong password");var c=d.createDecipheriv(s.crypto.cipher,o.slice(0,16),new n(s.crypto.cipherparams.iv,"hex")),f="0x"+n.concat([c.update(u),c.final()]).toString("hex");return this.privateKeyToAccount(f)},_.prototype.encrypt=function(e,t,r){var i,o=this.privateKeyToAccount(e),a=(r=r||{}).salt||d.randomBytes(32),s=r.iv||d.randomBytes(16),u=r.kdf||"scrypt",c={dklen:r.dklen||32,salt:a.toString("hex")};if("pbkdf2"===u)c.c=r.c||262144,c.prf="hmac-sha256",i=d.pbkdf2Sync(new n(t),a,c.c,c.dklen,"sha256");else{if("scrypt"!==u)throw new Error("Unsupported kdf");c.n=r.n||8192,c.r=r.r||8,c.p=r.p||1,i=p(new n(t),a,c.n,c.r,c.p,c.dklen)}var f=d.createCipheriv(r.cipher||"aes-128-ctr",i.slice(0,16),s);if(!f)throw new Error("Unsupported cipher");var h=n.concat([f.update(new n(o.privateKey.replace("0x",""),"hex")),f.final()]),l=y.sha3(n.concat([i.slice(16,32),new n(h,"hex")])).replace("0x","");return{version:3,id:b.v4({random:r.uuid||d.randomBytes(16)}),address:o.address.toLowerCase().replace("0x",""),crypto:{ciphertext:h.toString("hex"),cipherparams:{iv:s.toString("hex")},cipher:r.cipher||"aes-128-ctr",kdf:u,kdfparams:c,mac:l.toString("hex")}}},A.prototype._findSafeIndex=function(e){return e=e||0,i.has(this,e)?this._findSafeIndex(e+1):e},A.prototype._currentIndexes=function(){return Object.keys(this).map(function(e){return parseInt(e)}).filter(function(e){return e<9e20})},A.prototype.create=function(e,t){for(var r=0;r=2?t.slice(2):t;var r=h.decodeParameters(e,t);return 1===r.__length__?r[0]:(delete r.__length__,r)},l.prototype.deploy=function(e,t){if((e=e||{}).arguments=e.arguments||[],!(e=this._getOrSetDefaultOptions(e)).data)return a._fireError(new Error('No "data" specified in neither the given options, nor the default options.'),null,null,t);var r=n.find(this.options.jsonInterface,function(e){return"constructor"===e.type})||{};return r.signature="constructor",this._createTxObject.apply({method:r,parent:this,deployData:e.data,_ethAccounts:this.constructor._ethAccounts},e.arguments)},l.prototype._generateEventOptions=function(){var e=Array.prototype.slice.call(arguments),t=this._getCallback(e),r=n.isObject(e[e.length-1])?e.pop():{},i=n.isString(e[0])?e[0]:"allevents";if(!(i="allevents"===i.toLowerCase()?{name:"ALLEVENTS",jsonInterface:this.options.jsonInterface}:this.options.jsonInterface.find(function(e){return"event"===e.type&&(e.name===i||e.signature==="0x"+i.replace("0x",""))})))throw new Error('Event "'+i.name+"\" doesn't exist in this contract.");if(!a.isAddress(this.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return{params:this._encodeEventABI(i,r),event:i,callback:t}},l.prototype.clone=function(){return new this.constructor(this.options.jsonInterface,this.options.address,this.options)},l.prototype.once=function(e,t,r){var i=Array.prototype.slice.call(arguments);if(!(r=this._getCallback(i)))throw new Error("Once requires a callback as the second parameter.");t&&delete t.fromBlock,this._on(e,t,function(e,t,i){i.unsubscribe(),n.isFunction(r)&&r(e,t,i)})},l.prototype._on=function(){var e=this._generateEventOptions.apply(this,arguments);this._checkListener("newListener",e.event.name,e.callback),this._checkListener("removeListener",e.event.name,e.callback);var t=new s({subscription:{params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event),subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},type:"eth",requestManager:this._requestManager});return t.subscribe("logs",e.params,e.callback||function(){}),t},l.prototype.getPastEvents=function(){var e=this._generateEventOptions.apply(this,arguments),t=new o({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event)});t.setRequestManager(this._requestManager);var r=t.buildCall();return t=null,r(e.params,e.callback)},l.prototype._createTxObject=function(){var e=Array.prototype.slice.call(arguments),t={};if("function"===this.method.type&&(t.call=this.parent._executeMethod.bind(t,"call"),t.call.request=this.parent._executeMethod.bind(t,"call",!0)),t.send=this.parent._executeMethod.bind(t,"send"),t.send.request=this.parent._executeMethod.bind(t,"send",!0),t.encodeABI=this.parent._encodeMethodABI.bind(t),t.estimateGas=this.parent._executeMethod.bind(t,"estimate"),e&&this.method.inputs&&e.length!==this.method.inputs.length){if(this.nextMethod)return this.nextMethod.apply(null,e);throw c.InvalidNumberOfParams(e.length,this.method.inputs.length,this.method.name)}return t.arguments=e||[],t._method=this.method,t._parent=this.parent,t._ethAccounts=this.parent.constructor._ethAccounts||this._ethAccounts,this.deployData&&(t._deployData=this.deployData),t},l.prototype._processExecuteArguments=function(e,t){var r={};if(r.type=e.shift(),r.callback=this._parent._getCallback(e),"call"===r.type&&!0!==e[e.length-1]&&(n.isString(e[e.length-1])||isFinite(e[e.length-1]))&&(r.defaultBlock=e.pop()),r.options=n.isObject(e[e.length-1])?e.pop():{},r.generateRequest=!0===e[e.length-1]&&e.pop(),r.options=this._parent._getOrSetDefaultOptions(r.options),r.options.data=this.encodeABI(),!this._deployData&&!a.isAddress(this._parent.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return this._deployData||(r.options.to=this._parent.options.address),r.options.data?r:a._fireError(new Error("Couldn't find a matching contract method, or the number of parameters is wrong."),t.eventEmitter,t.reject,r.callback)},l.prototype._executeMethod=function(){var e=this,t=this._parent._processExecuteArguments.call(this,Array.prototype.slice.call(arguments),r),r=f("send"!==t.type),i=e.constructor._ethAccounts||e._ethAccounts;if(t.generateRequest){var s={params:[u.inputCallFormatter.call(this._parent,t.options)],callback:t.callback};return"call"===t.type?(s.params.push(u.inputDefaultBlockNumberFormatter.call(this._parent,t.defaultBlock)),s.method="eth_call",s.format=this._parent._decodeMethodReturn.bind(null,this._method.outputs)):s.method="eth_sendTransaction",s}switch(t.type){case"estimate":return new o({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[u.inputCallFormatter],outputFormatter:a.hexToNumber,requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.callback);case"call":return new o({name:"call",call:"eth_call",params:2,inputFormatter:[u.inputCallFormatter,u.inputDefaultBlockNumberFormatter],outputFormatter:function(t){return e._parent._decodeMethodReturn(e._method.outputs,t)},requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.defaultBlock,t.callback);case"send":if(!a.isAddress(t.options.from))return a._fireError(new Error('No "from" address specified in neither the given options, nor the default options.'),r.eventEmitter,r.reject,t.callback);if(n.isBoolean(this._method.payable)&&!this._method.payable&&t.options.value&&t.options.value>0)return a._fireError(new Error("Can not send value to non-payable contract method or constructor"),r.eventEmitter,r.reject,t.callback);var c={receiptFormatter:function(t){if(n.isArray(t.logs)){var r=n.map(t.logs,function(t){return e._parent._decodeEventABI.call({name:"ALLEVENTS",jsonInterface:e._parent.options.jsonInterface},t)});t.events={};var i=0;r.forEach(function(e){e.event?t.events[e.event]?Array.isArray(t.events[e.event])?t.events[e.event].push(e):t.events[e.event]=[t.events[e.event],e]:t.events[e.event]=e:(t.events[i]=e,i++)}),delete t.logs}return t},contractDeployFormatter:function(t){var r=e._parent.clone();return r.options.address=t.contractAddress,r}};return new o({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[u.inputTransactionFormatter],requestManager:e._parent._requestManager,accounts:e.constructor._ethAccounts||e._ethAccounts,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock,extraFormatters:c}).createFunction()(t.options,t.callback)}},t.exports=l},{underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-utils":403}],360:[function(e,t,r){"use strict";var n=e("./config"),i=e("./contracts/Registry"),o=e("./lib/ResolverMethodHandler");function a(e){this.eth=e}Object.defineProperty(a.prototype,"registry",{get:function(){return new i(this)},enumerable:!0}),Object.defineProperty(a.prototype,"resolverMethodHandler",{get:function(){return new o(this.registry)},enumerable:!0}),a.prototype.resolver=function(e){return this.registry.resolver(e)},a.prototype.getAddress=function(e,t){return this.resolverMethodHandler.method(e,"addr",[]).call(t)},a.prototype.setAddress=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setAddr",[t]).send(r,n)},a.prototype.getPubkey=function(e,t){return this.resolverMethodHandler.method(e,"pubkey",[],t).call(t)},a.prototype.setPubkey=function(e,t,r,n,i){return this.resolverMethodHandler.method(e,"setPubkey",[t,r]).send(n,i)},a.prototype.getContent=function(e,t){return this.resolverMethodHandler.method(e,"content",[]).call(t)},a.prototype.setContent=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setContent",[t]).send(r,n)},a.prototype.getMultihash=function(e,t){return this.resolverMethodHandler.method(e,"multihash",[]).call(t)},a.prototype.setMultihash=function(e,t,r,n){return this.resolverMethodHandler.method(e,"multihash",[t]).send(r,n)},a.prototype.checkNetwork=function(){var e=this;return e.eth.getBlock("latest").then(function(t){var r=new Date/1e3-t.timestamp;if(r>3600)throw new Error("Network not synced; last block was "+r+" seconds ago");return e.eth.net.getNetworkType()}).then(function(e){var t=n.addresses[e];if(void 0===t)throw new Error("ENS is not supported on network "+e);return t})},t.exports=a},{"./config":361,"./contracts/Registry":362,"./lib/ResolverMethodHandler":364}],361:[function(e,t,r){"use strict";t.exports={addresses:{main:"0x314159265dD8dbb310642f98f50C066173C1259b",ropsten:"0x112234455c3a32fd11230c42e7bccd4a84e02010",rinkeby:"0xe7410170f87102df0055eb195163a03b7f2bff4a"}}},{}],362:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-eth-contract"),o=e("eth-ens-namehash"),a=e("web3-core-promievent"),s=e("../ressources/ABI/Registry"),u=e("../ressources/ABI/Resolver");function c(e){var t=this;this.ens=e,this.contract=e.checkNetwork().then(function(e){var r=new i(s,e);return r.setProvider(t.ens.eth.currentProvider),r})}c.prototype.owner=function(e,t){var r=new a(!0);return this.contract.then(function(i){i.methods.owner(o.hash(e)).call().then(function(e){r.resolve(e),n.isFunction(t)&&t(e)}).catch(function(e){r.reject(e),n.isFunction(t)&&t(e)})}),r.eventEmitter},c.prototype.resolver=function(e){var t=this;return this.contract.then(function(t){return t.methods.resolver(o.hash(e)).call()}).then(function(e){var r=new i(u,e);return r.setProvider(t.ens.eth.currentProvider),r})},t.exports=c},{"../ressources/ABI/Registry":365,"../ressources/ABI/Resolver":366,"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340,"web3-eth-contract":359}],363:[function(e,t,r){"use strict";var n=e("./ENS");t.exports=n},{"./ENS":360}],364:[function(e,t,r){"use strict";var n=e("web3-core-promievent"),i=e("eth-ens-namehash"),o=e("underscore");function a(e){this.registry=e}a.prototype.method=function(e,t,r,n){return{call:this.call.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this}),send:this.send.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this})}},a.prototype.call=function(e){var t=this,r=new n,i=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){t.parent.handleCall(r,n.methods[t.methodName],i,e)}).catch(function(e){r.reject(e)}),r.eventEmitter},a.prototype.send=function(e,t){var r=this,i=new n,o=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){r.parent.handleSend(i,n.methods[r.methodName],o,e,t)}).catch(function(e){i.reject(e)}),i.eventEmitter},a.prototype.handleCall=function(e,t,r,n){return t.apply(this,r).call().then(function(t){e.resolve(t),o.isFunction(n)&&n(t)}).catch(function(t){e.reject(t),o.isFunction(n)&&n(t)}),e},a.prototype.handleSend=function(e,t,r,n,i){return t.apply(this,r).send(n).on("transactionHash",function(t){e.eventEmitter.emit("transactionHash",t)}).on("confirmation",function(t,r){e.eventEmitter.emit("confirmation",t,r)}).on("receipt",function(t){e.eventEmitter.emit("receipt",t),e.resolve(t),o.isFunction(i)&&i(t)}).on("error",function(t){e.eventEmitter.emit("error",t),e.reject(t),o.isFunction(i)&&i(t)}),e},a.prototype.prepareArguments=function(e,t){var r=i.hash(e);return t.length>0?(t.unshift(r),t):[r]},t.exports=a},{"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340}],365:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"resolver",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"owner",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"label",type:"bytes32"},{name:"owner",type:"address"}],name:"setSubnodeOwner",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"ttl",type:"uint64"}],name:"setTTL",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"ttl",outputs:[{name:"",type:"uint64"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"resolver",type:"address"}],name:"setResolver",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"owner",type:"address"}],name:"setOwner",outputs:[],payable:!1,type:"function"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"label",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"NewOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"resolver",type:"address"}],name:"NewResolver",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"ttl",type:"uint64"}],name:"NewTTL",type:"event"}]},{}],366:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"interfaceID",type:"bytes4"}],name:"supportsInterface",outputs:[{name:"",type:"bool"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"},{name:"contentTypes",type:"uint256"}],name:"ABI",outputs:[{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes"}],name:"setMultihash",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"multihash",outputs:[{name:"",type:"bytes"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"setPubkey",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"content",outputs:[{name:"ret",type:"bytes32"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"addr",outputs:[{name:"ret",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],name:"setABI",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"name",outputs:[{name:"ret",type:"string"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"name",type:"string"}],name:"setName",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes32"}],name:"setContent",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"pubkey",outputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"addr",type:"address"}],name:"setAddr",outputs:[],payable:!1,type:"function"},{inputs:[{name:"ensAddr",type:"address"}],payable:!1,type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"a",type:"address"}],name:"AddrChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"hash",type:"bytes32"}],name:"ContentChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"name",type:"string"}],name:"NameChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"contentType",type:"uint256"}],name:"ABIChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"x",type:"bytes32"},{indexed:!1,name:"y",type:"bytes32"}],name:"PubkeyChanged",type:"event"}]},{}],367:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],368:[function(e,t,r){"use strict";var n=e("web3-utils"),i=e("bn.js"),o=function(e){var t="A".charCodeAt(0),r="Z".charCodeAt(0);return(e=(e=e.toUpperCase()).substr(4)+e.substr(0,4)).split("").map(function(e){var n=e.charCodeAt(0);return n>=t&&n<=r?n-t+10:e}).join("")},a=function(e){for(var t,r=e;r.length>2;)t=r.slice(0,9),r=parseInt(t,10)%97+r.slice(t.length);return parseInt(r,10)%97},s=function(e){this._iban=e};s.toAddress=function(e){if(!(e=new s(e)).isDirect())throw new Error("IBAN is indirect and can't be converted");return e.toAddress()},s.toIban=function(e){return s.fromAddress(e).toString()},s.fromAddress=function(e){if(!n.isAddress(e))throw new Error("Provided address is not a valid address: "+e);e=e.replace("0x","").replace("0X","");var t=function(e,t){for(var r=e;r.length<2*t;)r="0"+r;return r}(new i(e,16).toString(36),15);return s.fromBban(t.toUpperCase())},s.fromBban=function(e){var t=("0"+(98-a(o("XE00"+e)))).slice(-2);return new s("XE"+t+e)},s.createIndirect=function(e){return s.fromBban("ETH"+e.institution+e.identifier)},s.isValid=function(e){return new s(e).isValid()},s.prototype.isValid=function(){return/^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban)&&1===a(o(this._iban))},s.prototype.isDirect=function(){return 34===this._iban.length||35===this._iban.length},s.prototype.isIndirect=function(){return 20===this._iban.length},s.prototype.checksum=function(){return this._iban.substr(2,2)},s.prototype.institution=function(){return this.isIndirect()?this._iban.substr(7,4):""},s.prototype.client=function(){return this.isIndirect()?this._iban.substr(11):""},s.prototype.toAddress=function(){if(this.isDirect()){var e=this._iban.substr(4),t=new i(e,36);return n.toChecksumAddress(t.toString(16,20))}return""},s.prototype.toString=function(){return this._iban},t.exports=s},{"bn.js":367,"web3-utils":403}],369:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=e("web3-net"),s=e("web3-core-helpers").formatters,u=function(){var e=this;n.packageInit(this,arguments),this.net=new a(this.currentProvider);var t=null,r="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return t},set:function(e){return e&&(t=o.toChecksumAddress(s.inputAddressFormatter(e))),u.forEach(function(e){e.defaultAccount=t}),e},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return r},set:function(e){return r=e,u.forEach(function(e){e.defaultBlock=r}),e},enumerable:!0});var u=[new i({name:"getAccounts",call:"personal_listAccounts",params:0,outputFormatter:o.toChecksumAddress}),new i({name:"newAccount",call:"personal_newAccount",params:1,inputFormatter:[null],outputFormatter:o.toChecksumAddress}),new i({name:"unlockAccount",call:"personal_unlockAccount",params:3,inputFormatter:[s.inputAddressFormatter,null,null]}),new i({name:"lockAccount",call:"personal_lockAccount",params:1,inputFormatter:[s.inputAddressFormatter]}),new i({name:"importRawKey",call:"personal_importRawKey",params:2}),new i({name:"sendTransaction",call:"personal_sendTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"signTransaction",call:"personal_signTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"sign",call:"personal_sign",params:3,inputFormatter:[s.inputSignFormatter,s.inputAddressFormatter,null]}),new i({name:"ecRecover",call:"personal_ecRecover",params:2,inputFormatter:[s.inputSignFormatter,null]})];u.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};n.addProviders(u),t.exports=u},{"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-net":372,"web3-utils":403}],370:[function(e,t,r){"use strict";var n=e("underscore");t.exports=function(e){var t,r=this;return this.net.getId().then(function(e){return t=e,r.getBlock(0)}).then(function(r){var i="private";return"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"===r.hash&&1===t&&(i="main"),"0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303"===r.hash&&2===t&&(i="morden"),"0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"===r.hash&&3===t&&(i="ropsten"),"0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177"===r.hash&&4===t&&(i="rinkeby"),"0xa3c565fc15c7478862d50ccd6561e3c06b24cc509bf388941c25ea985ce32cb9"===r.hash&&42===t&&(i="kovan"),n.isFunction(e)&&e(null,i),i}).catch(function(t){if(!n.isFunction(e))throw t;e(t)})}},{underscore:325}],371:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core"),o=e("web3-core-helpers"),a=e("web3-core-subscriptions").subscriptions,s=e("web3-core-method"),u=e("web3-utils"),c=e("web3-net"),f=e("web3-eth-ens"),h=e("web3-eth-personal"),l=e("web3-eth-contract"),d=e("web3-eth-iban"),p=e("web3-eth-accounts"),b=e("web3-eth-abi"),y=e("./getNetworkType.js"),m=o.formatters,v=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},g=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},w=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},_=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},A=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"},E=function(){var e=this;i.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments),e.personal.setProvider.apply(e,arguments),e.accounts.setProvider.apply(e,arguments),e.Contract.setProvider(e.currentProvider,e.accounts)};var r=null,o="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return r},set:function(t){return t&&(r=u.toChecksumAddress(m.inputAddressFormatter(t))),e.Contract.defaultAccount=r,e.personal.defaultAccount=r,k.forEach(function(e){e.defaultAccount=r}),t},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return o},set:function(t){return o=t,e.Contract.defaultBlock=o,e.personal.defaultBlock=o,k.forEach(function(e){e.defaultBlock=o}),t},enumerable:!0}),this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new c(this.currentProvider),this.net.getNetworkType=y.bind(this),this.accounts=new p(this.currentProvider),this.personal=new h(this.currentProvider),this.personal.defaultAccount=this.defaultAccount;var E=this,x=function(){l.apply(this,arguments);var e=this,t=E.setProvider;E.setProvider=function(){t.apply(E,arguments),i.packageInit(e,[E.currentProvider])}};x.setProvider=function(){l.setProvider.apply(this,arguments)},(x.prototype=Object.create(l.prototype)).constructor=x,this.Contract=x,this.Contract.defaultAccount=this.defaultAccount,this.Contract.defaultBlock=this.defaultBlock,this.Contract.setProvider(this.currentProvider,this.accounts),this.Iban=d,this.abi=b,this.ens=new f(this);var k=[new s({name:"getNodeInfo",call:"web3_clientVersion"}),new s({name:"getProtocolVersion",call:"eth_protocolVersion",params:0}),new s({name:"getCoinbase",call:"eth_coinbase",params:0}),new s({name:"isMining",call:"eth_mining",params:0}),new s({name:"getHashrate",call:"eth_hashrate",params:0,outputFormatter:u.hexToNumber}),new s({name:"isSyncing",call:"eth_syncing",params:0,outputFormatter:m.outputSyncingFormatter}),new s({name:"getGasPrice",call:"eth_gasPrice",params:0,outputFormatter:m.outputBigNumberFormatter}),new s({name:"getAccounts",call:"eth_accounts",params:0,outputFormatter:u.toChecksumAddress}),new s({name:"getBlockNumber",call:"eth_blockNumber",params:0,outputFormatter:u.hexToNumber}),new s({name:"getBalance",call:"eth_getBalance",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:m.outputBigNumberFormatter}),new s({name:"getStorageAt",call:"eth_getStorageAt",params:3,inputFormatter:[m.inputAddressFormatter,u.numberToHex,m.inputDefaultBlockNumberFormatter]}),new s({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"getBlock",call:v,params:2,inputFormatter:[m.inputBlockNumberFormatter,function(e){return!!e}],outputFormatter:m.outputBlockFormatter}),new s({name:"getUncle",call:w,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputBlockFormatter}),new s({name:"getBlockTransactionCount",call:_,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getBlockUncleCount",call:A,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getTransaction",call:"eth_getTransactionByHash",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionFromBlock",call:g,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionReceiptFormatter}),new s({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"sendSignedTransaction",call:"eth_sendRawTransaction",params:1,inputFormatter:[null]}),new s({name:"signTransaction",call:"eth_signTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sign",call:"eth_sign",params:2,inputFormatter:[m.inputSignFormatter,m.inputAddressFormatter],transformPayload:function(e){return e.params.reverse(),e}}),new s({name:"call",call:"eth_call",params:2,inputFormatter:[m.inputCallFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[m.inputCallFormatter],outputFormatter:u.hexToNumber}),new s({name:"submitWork",call:"eth_submitWork",params:3}),new s({name:"getWork",call:"eth_getWork",params:0}),new s({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter}),new a({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:m.outputBlockFormatter},pendingTransactions:{subscriptionName:"newPendingTransactions",params:0},logs:{params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter,subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},syncing:{params:0,outputFormatter:m.outputSyncingFormatter,subscriptionHandler:function(e){var t=this;!0!==this._isSyncing?(this._isSyncing=!0,this.emit("changed",t._isSyncing),n.isFunction(this.callback)&&this.callback(null,t._isSyncing,this),setTimeout(function(){t.emit("data",e),n.isFunction(t.callback)&&t.callback(null,e,t)},0)):(this.emit("data",e),n.isFunction(t.callback)&&this.callback(null,e,this),clearTimeout(this._isSyncingTimeout),this._isSyncingTimeout=setTimeout(function(){e.currentBlock>e.highestBlock-200&&(t._isSyncing=!1,t.emit("changed",t._isSyncing),n.isFunction(t.callback)&&t.callback(null,t._isSyncing,t))},500))}}}})];k.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager,e.accounts),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};i.addProviders(E),t.exports=E},{"./getNetworkType.js":370,underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-eth-accounts":358,"web3-eth-contract":359,"web3-eth-ens":363,"web3-eth-iban":368,"web3-eth-personal":369,"web3-net":372,"web3-utils":403}],372:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=function(){var e=this;n.packageInit(this,arguments),[new i({name:"getId",call:"net_version",params:0,outputFormatter:o.hexToNumber}),new i({name:"isListening",call:"net_listening",params:0}),new i({name:"getPeerCount",call:"net_peerCount",params:0,outputFormatter:o.hexToNumber})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(a),t.exports=a},{"web3-core":348,"web3-core-method":339,"web3-utils":403}],373:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits,o=e("ethereumjs-util"),a=e("eth-block-tracker"),s=e("async/map"),u=e("async/eachSeries"),c=e("./util/stoplight.js");e("./util/rpc-cache-utils.js"),e("./util/create-payload.js");function f(e){const t=this;n.call(t),t.setMaxListeners(30),e=e||{};const r={sendAsync:t._handleAsync.bind(t)},i=e.blockTrackerProvider||r;t._blockTracker=e.blockTracker||new a({provider:i,pollingInterval:e.pollingInterval||4e3}),t._blockTracker.on("block",e=>{const r=function(e){return{number:o.toBuffer(e.number),hash:o.toBuffer(e.hash),parentHash:o.toBuffer(e.parentHash),nonce:o.toBuffer(e.nonce),mixHash:o.toBuffer(e.mixHash),sha3Uncles:o.toBuffer(e.sha3Uncles),logsBloom:o.toBuffer(e.logsBloom),transactionsRoot:o.toBuffer(e.transactionsRoot),stateRoot:o.toBuffer(e.stateRoot),receiptsRoot:o.toBuffer(e.receiptRoot||e.receiptsRoot),miner:o.toBuffer(e.miner),difficulty:o.toBuffer(e.difficulty),totalDifficulty:o.toBuffer(e.totalDifficulty),size:o.toBuffer(e.size),extraData:o.toBuffer(e.extraData),gasLimit:o.toBuffer(e.gasLimit),gasUsed:o.toBuffer(e.gasUsed),timestamp:o.toBuffer(e.timestamp),transactions:e.transactions}}(e);t._setCurrentBlock(r)}),t._blockTracker.on("block",t.emit.bind(t,"rawBlock")),t._blockTracker.on("sync",t.emit.bind(t,"sync")),t._blockTracker.on("latest",t.emit.bind(t,"latest")),t._ready=new c,t._blockTracker.once("block",()=>{t._ready.go()}),t.currentBlock=null,t._providers=[]}t.exports=f,i(f,n),f.prototype.start=function(e=function(){}){this._blockTracker.start().then(e).catch(e)},f.prototype.stop=function(){this._blockTracker.stop()},f.prototype.addProvider=function(e){this._providers.push(e),e.setEngine(this)},f.prototype.send=function(e){throw new Error("Web3ProviderEngine does not support synchronous requests.")},f.prototype.sendAsync=function(e,t){const r=this;r._ready.await(function(){Array.isArray(e)?s(e,r._handleAsync.bind(r),t):r._handleAsync(e,t)})},f.prototype._handleAsync=function(e,t){var r=this,n=-1,i=null,o=null,a=[];function s(r,n){o=r,i=n,u(a,function(e,t){e?e(o,i,t):t()},function(){var r={id:e.id,jsonrpc:e.jsonrpc,result:i};null!=o?(r.error={message:o.stack||o.message||o,code:-32e3},t(o,r)):t(null,r)})}!function t(i){n+=1;a.unshift(i);if(n>=r._providers.length)s(new Error('Request for method "'+e.method+'" not handled by any subprovider. Please check your subprovider configuration to ensure this method is handled.'));else try{var o=r._providers[n];o.handleRequest(e,t,s)}catch(e){s(e)}}()},f.prototype._setCurrentBlock=function(e){this.currentBlock=e,this.emit("block",e)}},{"./util/create-payload.js":391,"./util/rpc-cache-utils.js":394,"./util/stoplight.js":396,"async/eachSeries":25,"async/map":41,"eth-block-tracker":126,"ethereumjs-util":141,events:157,util:333}],374:[function(e,t,r){var n="undefined"!=typeof JSON?JSON:e("jsonify");t.exports=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var r=t.space||"";"number"==typeof r&&(r=Array(r+1).join(" "));var a,s="boolean"==typeof t.cycles&&t.cycles,u=t.replacer||function(e,t){return t},c=t.cmp&&(a=t.cmp,function(e){return function(t,r){var n={key:t,value:e[t]},i={key:r,value:e[r]};return a(n,i)}}),f=[];return function e(t,a,h,l){var d=r?"\n"+new Array(l+1).join(r):"",p=r?": ":":";if(h&&h.toJSON&&"function"==typeof h.toJSON&&(h=h.toJSON()),void 0!==(h=u.call(t,a,h))){if("object"!=typeof h||null===h)return n.stringify(h);if(i(h)){for(var b=[],y=0;y dist/ProviderEngine.js","bundle-zero":"browserify -s ZeroClientProvider -e zero.js -t [ babelify --presets [ es2015 ] ] > dist/ZeroClientProvider.js",prepublish:"npm run build && npm run bundle",test:"node test/index.js"},version:"14.1.0"}},{}],376:[function(e,t,r){const n=e("util").inherits,i=e("ethereumjs-util"),o=i.BN,a=e("clone"),s=e("../util/rpc-cache-utils.js"),u=e("../util/stoplight.js"),c=e("./subprovider.js");function f(e){e=e||{},this._ready=new u,this.strategies={perma:new l({eth_getTransactionByHash:p,eth_getTransactionReceipt:p}),block:new d(this),fork:new d(this)}}function h(){var e=this;e.cache={};var t=setInterval(function(){e.cache={}},6e5);t.unref&&t.unref()}function l(e){this.strategy=new h,this.conditionals=e}function d(){this.cache={}}function p(e){if(!e)return!1;if(!e.blockHash)return!1;var t;return(t=e.blockHash,new o(i.toBuffer(t))).gt(new o(0))}t.exports=f,n(f,c),f.prototype.setEngine=function(e){const t=this;function r(e){var r=t.currentBlock;t.currentBlock=e,r&&(t.strategies.block.cacheRollOff(r),t.strategies.fork.cacheRollOff(r))}t.engine=e,e.once("block",function(n){t.currentBlock=n,t._ready.go(),e.on("block",r)})},f.prototype.handleRequest=function(e,t,r){const n=this;return e.skipCache?t():"eth_getBlockByNumber"===e.method&&"latest"===e.params[0]?t():void n._ready.await(function(){n._handleRequest(e,t,r)})},f.prototype._handleRequest=function(e,t,r){const n=this;var o=s.cacheTypeForPayload(e),a=this.strategies[o];if(!a)return t();if(!a.canCache(e))return t();var u,c=s.blockTagForPayload(e);c||(c="latest"),u="earliest"===c?"0x00":"latest"===c?i.bufferToHex(n.currentBlock.number):c,a.hitCheck(e,u,r,function(){t(function(t,r,n){if(t)return n();a.cacheResult(e,r,u,n)})})},h.prototype.hitCheck=function(e,t,r,n){var i,o,u,c,f=s.cacheIdentifierForPayload(e),h=this.cache[f];return h&&(i=t,o=h.blockNumber,u=parseInt(i,16),c=parseInt(o,16),(u===c?0:u>c?1:-1)>=0)?r(null,a(h.result)):n()},h.prototype.cacheResult=function(e,t,r,n){var i=s.cacheIdentifierForPayload(e);if(t){var o=a(t);this.cache[i]={blockNumber:r,result:o}}n()},h.prototype.canCache=function(e){return s.canCache(e)},l.prototype.hitCheck=function(e,t,r,n){return this.strategy.hitCheck(e,t,r,n)},l.prototype.cacheResult=function(e,t,r,n){var i=this.conditionals[e.method];i?i(t)?this.strategy.cacheResult(e,t,r,n):n():this.strategy.cacheResult(e,t,r,n)},l.prototype.canCache=function(e){return this.strategy.canCache(e)},d.prototype.getBlockCacheForPayload=function(e,t){const r=Number.parseInt(t,16);let n=this.cache[r];if(!n){const e={};this.cache[r]=e,n=e}return n},d.prototype.hitCheck=function(e,t,r,n){var i=this.getBlockCacheForPayload(e,t);if(!i)return n();var o=i[s.cacheIdentifierForPayload(e)];return o?r(null,o):n()},d.prototype.cacheResult=function(e,t,r,n){t&&(this.getBlockCacheForPayload(e,r)[s.cacheIdentifierForPayload(e)]=t);n()},d.prototype.canCache=function(e){return!!s.canCache(e)&&"pending"!==s.blockTagForPayload(e)},d.prototype.cacheRollOff=function(e){const t=this,r=i.bufferToHex(e.number),n=Number.parseInt(r,16);Object.keys(t.cache).map(Number).filter(e=>e<=n).forEach(e=>delete t.cache[e])}},{"../util/rpc-cache-utils.js":394,"../util/stoplight.js":396,"./subprovider.js":387,clone:87,"ethereumjs-util":141,util:333}],377:[function(e,t,r){const n=e("util").inherits,i=e("xtend"),o=e("./fixture.js"),a=e("../package.json").version;function s(e){var t=i({web3_clientVersion:"ProviderEngine/v"+a+"/javascript",net_listening:!0,eth_hashrate:"0x00",eth_mining:!1},e=e||{});o.call(this,t)}t.exports=s,n(s,o)},{"../package.json":375,"./fixture.js":380,util:333,xtend:423}],378:[function(e,t,r){const n=e("cross-fetch"),i=e("util").inherits,o=e("async/retry"),a=e("async/waterfall"),s=e("async/asyncify"),u=e("json-rpc-error"),c=e("promise-to-callback"),f=e("../util/create-payload.js"),h=e("./subprovider.js"),l=["Gateway timeout","ETIMEDOUT","SyntaxError"];function d(e){this.rpcUrl=e.rpcUrl,this.originHttpHeaderKey=e.originHttpHeaderKey}function p(e){const t=e.toString();return l.some(e=>t.includes(e))}t.exports=d,i(d,h),d.prototype.handleRequest=function(e,t,r){const n=this,i=e.origin,a=f(e);delete a.origin;const s={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(a)};n.originHttpHeaderKey&&i&&(s.headers[n.originHttpHeaderKey]=i),o({times:5,interval:1e3,errorFilter:p},e=>n._submitRequest(s,e),(e,t)=>{if(e&&p(e)){const t=`FetchSubprovider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,n=new Error(t);return r(n)}return r(e,t)})},d.prototype._submitRequest=function(e,t){const r=this.rpcUrl;c(n(r,e))((e,r)=>{if(e)return t(e);a([function(e){switch(r.status){case 405:return e(new u.MethodNotFound);case 418:return e(function(){const e=new Error("Request is being rate limited.");return new u.InternalError(e)}());case 503:case 504:return e(function(){let e="Gateway timeout. The request took too long to process. ";const t=new Error(e+="This can happen when querying logs over too wide a block range.");return new u.InternalError(t)}());default:return e()}},e=>c(r.text())(e),s(e=>JSON.parse(e)),function(e,t){if(200!==r.status)return t(new u.InternalError(e));if(e.error)return t(new u.InternalError(e.error));t(null,e.result)}],t)})}},{"../util/create-payload.js":391,"./subprovider.js":387,"async/asyncify":20,"async/retry":43,"async/waterfall":44,"cross-fetch":96,"json-rpc-error":189,"promise-to-callback":258,util:333}],379:[function(e,t,r){const n=e("async"),i=e("util").inherits,o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/stoplight.js"),u=e("events").EventEmitter;function c(e){e=e||{};const t=this;t.filterIndex=0,t.filters={},t.filterDestroyHandlers={},t.asyncBlockHandlers={},t.asyncPendingBlockHandlers={},t._ready=new s,t._ready.setMaxListeners(e.maxFilters||25),t._ready.go(),t.pendingBlockTimeout=e.pendingBlockTimeout||4e3,t.checkForPendingBlocksActive=!1,setTimeout(function(){t.engine.on("block",function(e){t._ready.stop();var r=v(t.asyncBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,function(e){e&&console.error(e),t._ready.go()})})})}function f(e){u.apply(this),this.type="block",this.engine=e.engine,this.blockNumber=e.blockNumber,this.updates=[]}function h(e){u.apply(this),this.type="log",this.fromBlock=void 0!==e.fromBlock?e.fromBlock:"latest",this.toBlock=void 0!==e.toBlock?e.toBlock:"latest";var t=e.address&&(Array.isArray(e.address)?e.address:[e.address]);this.address=t&&t.map(d),this.topics=e.topics||[],this.updates=[],this.allResults=[]}function l(){u.apply(this),this.type="pendingTx",this.updates=[],this.allResults=[]}function d(e){return"0x"===e.slice(0,2)?e:"0x"+e}function p(e){return o.intToHex(e)}function b(e){return Number(e)}function y(e){return function(e){let t=o.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}(e.toString("hex"))}function m(e){return e&&-1===["earliest","latest","pending"].indexOf(e)}function v(e){return Object.keys(e).map(function(t){return e[t]})}t.exports=c,i(c,a),c.prototype.handleRequest=function(e,t,r){const n=this;switch(e.method){case"eth_newBlockFilter":return void n.newBlockFilter(r);case"eth_newPendingTransactionFilter":return n.newPendingTransactionFilter(r),void n.checkForPendingBlocks();case"eth_newFilter":return void n.newLogFilter(e.params[0],r);case"eth_getFilterChanges":return void n._ready.await(function(){n.getFilterChanges(e.params[0],r)});case"eth_getFilterLogs":return void n._ready.await(function(){n.getFilterLogs(e.params[0],r)});case"eth_uninstallFilter":return void n._ready.await(function(){n.uninstallFilter(e.params[0],r)});default:return void t()}},c.prototype.newBlockFilter=function(e){const t=this;t._getBlockNumber(function(r,n){if(r)return e(r);var i=new f({blockNumber:n}),o=i.update.bind(i);t.engine.on("block",o);t.filterIndex++,t.filters[t.filterIndex]=i,t.filterDestroyHandlers[t.filterIndex]=function(){t.engine.removeListener("block",o)};var a=p(t.filterIndex);e(null,a)})},c.prototype.newLogFilter=function(e,t){const r=this;r._getBlockNumber(function(n,i){if(n)return t(n);var o=new h(e),a=o.update.bind(o);r.filterIndex++,r.asyncBlockHandlers[r.filterIndex]=function(e,t){r._logsForBlock(e,function(e,r){if(e)return t(e);a(r),t()})},r.filters[r.filterIndex]=o;var s=p(r.filterIndex);t(null,s)})},c.prototype.newPendingTransactionFilter=function(e){const t=this;var r=new l,n=r.update.bind(r);t.filterIndex++,t.asyncPendingBlockHandlers[t.filterIndex]=function(e,r){t._txHashesForBlock(e,function(e,t){if(e)return r(e);n(t),r()})},t.filters[t.filterIndex]=r,e(null,p(t.filterIndex))},c.prototype.getFilterChanges=function(e,t){var r=Number.parseInt(e,16),n=this.filters[r];if(n||console.warn("FilterSubprovider - no filter with that id:",e),!n)return t(null,[]);var i=n.getChanges();n.clearChanges(),t(null,i)},c.prototype.getFilterLogs=function(e,t){const r=this;var n=Number.parseInt(e,16),i=r.filters[n];if(i||console.warn("FilterSubprovider - no filter with that id:",e),!i)return t(null,[]);if("log"===i.type)r.emitPayload({method:"eth_getLogs",params:[{fromBlock:i.fromBlock,toBlock:i.toBlock,address:i.address,topics:i.topics}]},function(e,r){if(e)return t(e);t(null,r.result)});else{t(null,[])}},c.prototype.uninstallFilter=function(e,t){var r=Number.parseInt(e,16);if(this.filters[r]){this.filters[r].removeAllListeners();var n=this.filterDestroyHandlers[r];delete this.filters[r],delete this.asyncBlockHandlers[r],delete this.asyncPendingBlockHandlers[r],delete this.filterDestroyHandlers[r],n&&n(),t(null,!0)}else t(null,!1)},c.prototype.checkForPendingBlocks=function(){const e=this;e.checkForPendingBlocksActive||!!Object.keys(e.asyncPendingBlockHandlers).length&&(e.checkForPendingBlocksActive=!0,e.emitPayload({method:"eth_getBlockByNumber",params:["pending",!0]},function(t,r){if(t)return e.checkForPendingBlocksActive=!1,void console.error(t);e.onNewPendingBlock(r.result,function(t){t&&console.error(t),e.checkForPendingBlocksActive=!1,setTimeout(e.checkForPendingBlocks.bind(e),e.pendingBlockTimeout)})}))},c.prototype.onNewPendingBlock=function(e,t){var r=v(this.asyncPendingBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,t)},c.prototype._getBlockNumber=function(e){e(null,y(this.engine.currentBlock.number))},c.prototype._logsForBlock=function(e,t){var r=y(e.number);this.emitPayload({method:"eth_getLogs",params:[{fromBlock:r,toBlock:r}]},function(e,r){return e?t(e):r.error?t(r.error):void t(null,r.result)})},c.prototype._txHashesForBlock=function(e,t){var r=e.transactions;if(0===r.length)return t(null,[]);"string"==typeof r[0]?t(null,r):t(null,r.map(e=>e.hash))},i(f,u),f.prototype.update=function(e){var t="0x"+e.hash.toString("hex");this.updates.push(t),this.emit("data",e)},f.prototype.getChanges=function(){return this.updates},f.prototype.clearChanges=function(){this.updates=[]},i(h,u),h.prototype.validateLog=function(e){return!(m(this.fromBlock)&&b(this.fromBlock)>=b(e.blockNumber))&&(!(m(this.toBlock)&&b(this.toBlock)<=b(e.blockNumber))&&(!(this.address&&!this.address.map(e=>e.toLowerCase()).includes(e.address.toLowerCase()))&&this.topics.reduce(function(t,r,n){if(!t)return!1;if(!r)return!0;var i=e.topics[n];return!!i&&(Array.isArray(r)?r:[r]).filter(function(e){return i.toLowerCase()===e.toLowerCase()}).length>0},!0)))},h.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateLog(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},h.prototype.getChanges=function(){return this.updates},h.prototype.getAllResults=function(){return this.allResults},h.prototype.clearChanges=function(){this.updates=[]},i(l,u),l.prototype.validateUnique=function(e){return-1===this.allResults.indexOf(e)},l.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateUnique(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},l.prototype.getChanges=function(){return this.updates},l.prototype.getAllResults=function(){return this.allResults},l.prototype.clearChanges=function(){this.updates=[]}},{"../util/stoplight.js":396,"./subprovider.js":387,async:21,"ethereumjs-util":141,events:157,util:333}],380:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){e=e||{},this.staticResponses=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){var n=this.staticResponses[e.method];"function"==typeof n?n(e,t,r):void 0!==n?setTimeout(()=>r(null,n)):t()}},{"./subprovider.js":387,util:333}],381:[function(e,t,r){const n=e("async/waterfall"),i=e("async/parallel"),o=e("util").inherits,a=e("ethereumjs-util"),s=e("eth-sig-util"),u=e("xtend"),c=e("semaphore"),f=e("./subprovider.js"),h=e("../util/estimate-gas.js"),l=/^[0-9A-Fa-f]+$/g;function d(e){this.nonceLock=c(1),e.getAccounts&&(this.getAccounts=e.getAccounts),e.processTransaction&&(this.processTransaction=e.processTransaction),e.processMessage&&(this.processMessage=e.processMessage),e.processPersonalMessage&&(this.processPersonalMessage=e.processPersonalMessage),e.processTypedMessage&&(this.processTypedMessage=e.processTypedMessage),this.approveTransaction=e.approveTransaction||this.autoApprove,this.approveMessage=e.approveMessage||this.autoApprove,this.approvePersonalMessage=e.approvePersonalMessage||this.autoApprove,this.approveTypedMessage=e.approveTypedMessage||this.autoApprove,e.signTransaction&&(this.signTransaction=e.signTransaction||y("signTransaction")),e.signMessage&&(this.signMessage=e.signMessage||y("signMessage")),e.signPersonalMessage&&(this.signPersonalMessage=e.signPersonalMessage||y("signPersonalMessage")),e.signTypedMessage&&(this.signTypedMessage=e.signTypedMessage||y("signTypedMessage")),e.recoverPersonalSignature&&(this.recoverPersonalSignature=e.recoverPersonalSignature),e.publishTransaction&&(this.publishTransaction=e.publishTransaction)}function p(e){return e.toLowerCase()}function b(e){return"string"==typeof e&&("0x"===e.slice(0,2)&&e.slice(2).match(l))}function y(e){return function(t,r){r(new Error('ProviderEngine - HookedWalletSubprovider - Must provide "'+e+'" fn in constructor options'))}}t.exports=d,o(d,f),d.prototype.handleRequest=function(e,t,r){const i=this;let o,s,c,f,h;switch(i._parityRequests={},i._parityRequestCount=0,e.method){case"eth_coinbase":return void i.getAccounts(function(e,t){if(e)return r(e);let n=t[0]||null;r(null,n)});case"eth_accounts":return void i.getAccounts(function(e,t){if(e)return r(e);r(null,t)});case"eth_sendTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processTransaction(o,e)],r);case"eth_signTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processSignTransaction(o,e)],r);case"eth_sign":return h=e.params[0],f=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateMessage(s,e),e=>i.processMessage(s,e)],r);case"personal_sign":const l=e.params[0];if(function(e){const t=a.addHexPrefix(e);return!a.isValidAddress(t)&&b(e)}(e.params[1])&&function(e){const t=a.addHexPrefix(e);return a.isValidAddress(t)}(l)){let t="The eth_personalSign method requires params ordered ";t+="[message, address]. This was previously handled incorrectly, ",t+="and has been corrected automatically. ",t+="Please switch this param order for smooth behavior in the future.",console.warn(t),h=e.params[0],f=e.params[1]}else f=e.params[0],h=e.params[1];return c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validatePersonalMessage(s,e),e=>i.processPersonalMessage(s,e)],r);case"personal_ecRecover":f=e.params[0];let d=e.params[1];return c=e.params[2]||{},s=u(c,{sig:d,data:f}),void i.recoverPersonalSignature(s,r);case"eth_signTypedData":return f=e.params[0],h=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateTypedMessage(s,e),e=>i.processTypedMessage(s,e)],r);case"parity_postTransaction":return o=e.params[0],void i.parityPostTransaction(o,r);case"parity_postSign":return h=e.params[0],f=e.params[1],void i.parityPostSign(h,f,r);case"parity_checkRequest":const p=e.params[0];return void i.parityCheckRequest(p,r);case"parity_defaultAccount":return void i.getAccounts(function(e,t){if(e)return r(e);const n=t[0]||null;r(null,n)});default:return void t()}},d.prototype.getAccounts=function(e){e(null,[])},d.prototype.processTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeAndSubmitTx(e,t)],t)},d.prototype.processSignTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeTx(e,t)],t)},d.prototype.processMessage=function(e,t){const r=this;n([t=>r.approveMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signMessage(e,t)],t)},d.prototype.processPersonalMessage=function(e,t){const r=this;n([t=>r.approvePersonalMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signPersonalMessage(e,t)],t)},d.prototype.processTypedMessage=function(e,t){const r=this;n([t=>r.approveTypedMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signTypedMessage(e,t)],t)},d.prototype.autoApprove=function(e,t){t(null,!0)},d.prototype.checkApproval=function(e,t,r){r(t?null:new Error("User denied "+e+" signature."))},d.prototype.parityPostTransaction=function(e,t){const r=this,n=`0x${r._parityRequestCount.toString(16)}`;r._parityRequestCount++,r.emitPayload({method:"eth_sendTransaction",params:[e]},function(e,t){if(e)return void(r._parityRequests[n]={error:e});const i=t.result;r._parityRequests[n]=i}),t(null,n)},d.prototype.parityPostSign=function(e,t,r){const n=this,i=`0x${n._parityRequestCount.toString(16)}`;n._parityRequestCount++,n.emitPayload({method:"eth_sign",params:[e,t]},function(e,t){if(e)return void(n._parityRequests[i]={error:e});const r=t.result;n._parityRequests[i]=r}),r(null,i)},d.prototype.parityCheckRequest=function(e,t){const r=this._parityRequests[e]||null;return r?r.error?t(r.error):void t(null,r):t(null,null)},d.prototype.recoverPersonalSignature=function(e,t){let r;try{r=s.recoverPersonalSignature(e)}catch(e){return t(e)}t(null,r)},d.prototype.validateTransaction=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign transaction."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign transaction for this address: "${e.from}"`))})},d.prototype.validateMessage=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign message."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validatePersonalMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign personal message.")):void 0===e.data?t(new Error("Undefined message - message required to sign personal message.")):b(e.data)?void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))}):t(new Error("HookedWalletSubprovider - validateMessage - message was not encoded as hex."))},d.prototype.validateTypedMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign typed data.")):void 0===e.data?t(new Error("Undefined data - message required to sign typed data.")):void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validateSender=function(e,t){if(!e)return t(null,!1);this.getAccounts(function(r,n){if(r)return t(r);const i=-1!==n.map(p).indexOf(e.toLowerCase());t(null,i)})},d.prototype.finalizeAndSubmitTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r),r.publishTransaction.bind(r)],function(e,n){if(r.nonceLock.leave(),e)return t(e);t(null,n)})})},d.prototype.finalizeTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r)],function(n,i){if(r.nonceLock.leave(),n)return t(n);t(null,{raw:i,tx:e})})})},d.prototype.publishTransaction=function(e,t){this.emitPayload({method:"eth_sendRawTransaction",params:[e]},function(e,r){if(e)return t(e);t(null,r.result)})},d.prototype.fillInTxExtras=function(e,t){const r=this,n=e.from,o={};void 0===e.gasPrice&&(o.gasPrice=r.emitPayload.bind(r,{method:"eth_gasPrice",params:[]})),void 0===e.nonce&&(o.nonce=r.emitPayload.bind(r,{method:"eth_getTransactionCount",params:[n,"pending"]})),void 0===e.gas&&(o.gas=h.bind(null,r.engine,function(e){return{from:e.from,to:e.to,value:e.value,data:e.data,gas:e.gas,gasPrice:e.gasPrice,nonce:e.nonce}}(e))),i(o,function(r,n){if(r)return t(r);const i={};n.gasPrice&&(i.gasPrice=n.gasPrice.result),n.nonce&&(i.nonce=n.nonce.result),n.gas&&(i.gas=n.gas),t(null,u(e,i))})}},{"../util/estimate-gas.js":392,"./subprovider.js":387,"async/parallel":42,"async/waterfall":44,"eth-sig-util":136,"ethereumjs-util":141,semaphore:301,util:333,xtend:423}],382:[function(e,t,r){const n=e("../util/rpc-cache-utils.js").cacheIdentifierForPayload,i=e("./subprovider.js");t.exports=class extends i{constructor(e){super(),this.inflightRequests={}}addEngine(e){this.engine=e}handleRequest(e,t,r){const i=n(e,{includeBlockRef:!0});if(!i)return t();let o=this.inflightRequests[i];o?o.push(r):(o=[],this.inflightRequests[i]=o,t((e,t,r)=>{delete this.inflightRequests[i],o.forEach(r=>r(e,t)),r(e,t)}))}}},{"../util/rpc-cache-utils.js":394,"./subprovider.js":387}],383:[function(e,t,r){const n=e("eth-json-rpc-infura/src/createProvider"),i=e("./provider.js");t.exports=class extends i{constructor(e={}){super(n(e))}}},{"./provider.js":385,"eth-json-rpc-infura/src/createProvider":129}],384:[function(e,t,r){(function(r){const n=e("util").inherits,i=e("ethereumjs-tx"),o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/rpc-cache-utils").blockTagForPayload;function u(e){this.nonceCache={}}t.exports=u,n(u,a),u.prototype.handleRequest=function(e,t,n){const a=this;switch(e.method){case"eth_getTransactionCount":var u=s(e),c=e.params[0].toLowerCase(),f=a.nonceCache[c];return void("pending"===u?f?n(null,f):t(function(e,t,r){if(e)return r();void 0===a.nonceCache[c]&&(a.nonceCache[c]=t),r()}):t());case"eth_sendRawTransaction":return void t(function(t,n,s){if(t)return s();var u=e.params[0],c=(o.stripHexPrefix(u),new r(o.stripHexPrefix(u),"hex"),new i(new r(o.stripHexPrefix(u),"hex"))),f="0x"+c.getSenderAddress().toString("hex").toLowerCase(),h=o.bufferToInt(c.nonce),l=(++h).toString(16);l.length%2&&(l="0"+l),l="0x"+l,a.nonceCache[f]=l,s()});default:return void t()}}}).call(this,e("buffer").Buffer)},{"../util/rpc-cache-utils":394,"./subprovider.js":387,buffer:84,"ethereumjs-tx":140,"ethereumjs-util":141,util:333}],385:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){if(!e)throw new Error("ProviderSubprovider - no provider specified");if(!e.sendAsync)throw new Error("ProviderSubprovider - specified provider does not have a sendAsync method");this.provider=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){this.provider.sendAsync(e,function(e,t){return e?r(e):t.error?r(new Error(t.error.message)):void r(null,t.result)})}},{"./subprovider.js":387,util:333}],386:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js"),o=(e("xtend"),e("ethereumjs-util"));function a(e){}t.exports=a,n(a,i),a.prototype.handleRequest=function(e,t,r){var n=e.params[0];if("object"==typeof n&&!Array.isArray(n)){var i=function(e){return s.reduce(function(t,r){return r in e&&(Array.isArray(e[r])?t[r]=e[r].map(function(e){return u(e)}):t[r]=u(e[r])),t},{})}(n);e.params[0]=i}t()};var s=["from","to","value","data","gas","gasPrice","nonce","fromBlock","toBlock","address","topics"];function u(e){switch(e){case"latest":case"pending":case"earliest":return e;default:return"string"==typeof e?o.addHexPrefix(e.toLowerCase()):e}}},{"./subprovider.js":387,"ethereumjs-util":141,util:333,xtend:423}],387:[function(e,t,r){const n=e("../util/create-payload.js");function i(){}t.exports=i,i.prototype.setEngine=function(e){const t=this;t.engine=e,e.on("block",function(e){t.currentBlock=e})},i.prototype.handleRequest=function(e,t,r){throw new Error("Subproviders should override `handleRequest`.")},i.prototype.emitPayload=function(e,t){this.engine.sendAsync(n(e),t)}},{"../util/create-payload.js":391}],388:[function(e,t,r){const n=e("events").EventEmitter,i=e("./filters.js"),o=e("../util/rpc-hex-encoding.js"),a=e("util").inherits,s=e("ethereumjs-util");function u(e){e=e||{},n.apply(this,Array.prototype.slice.call(arguments)),i.apply(this,[e]),this.subscriptions={}}a(u,i),Object.assign(u.prototype,n.prototype),u.prototype.constructor=u,u.prototype.eth_subscribe=function(e,t){const r=this;let n=()=>{},i=e.params[0];switch(i){case"logs":let o=e.params[1];n=r.newLogFilter.bind(r,o);break;case"newPendingTransactions":n=r.newPendingTransactionFilter.bind(r);break;case"newHeads":n=r.newBlockFilter.bind(r);break;case"syncing":default:return void t(new Error("unsupported subscription type"))}n(function(e,n){if(e)return t(e);const o=Number.parseInt(n,16);r.subscriptions[o]=i,r.filters[o].on("data",function(e){Array.isArray(e)||(e=[e]);var t=r._notificationHandler.bind(r,n,i);e.forEach(t),r.filters[o].clearChanges()}),"newPendingTransactions"===i&&r.checkForPendingBlocks(),t(null,n)})},u.prototype.eth_unsubscribe=function(e,t){const r=this;let n=e.params[0];const i=Number.parseInt(n,16);if(r.subscriptions[i]){r.subscriptions[i];r.uninstallFilter(n,function(e,n){delete r.subscriptions[i],t(e,n)})}else t(new Error(`Subscription ID ${n} not found.`))},u.prototype._notificationHandler=function(e,t,r){const n=this;"newHeads"===t&&(r=n._notificationResultFromBlock(r)),n.emit("data",null,{jsonrpc:"2.0",method:"eth_subscription",params:{subscription:e,result:r}})},u.prototype._notificationResultFromBlock=function(e){return{hash:s.bufferToHex(e.hash),parentHash:s.bufferToHex(e.parentHash),sha3Uncles:s.bufferToHex(e.sha3Uncles),miner:s.bufferToHex(e.miner),stateRoot:s.bufferToHex(e.stateRoot),transactionsRoot:s.bufferToHex(e.transactionsRoot),receiptsRoot:s.bufferToHex(e.receiptsRoot),logsBloom:s.bufferToHex(e.logsBloom),difficulty:o.intToQuantityHex(s.bufferToInt(e.difficulty)),number:o.intToQuantityHex(s.bufferToInt(e.number)),gasLimit:o.intToQuantityHex(s.bufferToInt(e.gasLimit)),gasUsed:o.intToQuantityHex(s.bufferToInt(e.gasUsed)),nonce:e.nonce?s.bufferToHex(e.nonce):null,mixHash:s.bufferToHex(e.mixHash),timestamp:o.intToQuantityHex(s.bufferToInt(e.timestamp)),extraData:s.bufferToHex(e.extraData)}},u.prototype.handleRequest=function(e,t,r){switch(e.method){case"eth_subscribe":this.eth_subscribe(e,r);break;case"eth_unsubscribe":this.eth_unsubscribe(e,r);break;default:i.prototype.handleRequest.apply(this,Array.prototype.slice.call(arguments))}},t.exports=u},{"../util/rpc-hex-encoding.js":395,"./filters.js":379,"ethereumjs-util":141,events:157,util:333}],389:[function(e,t,r){(function(r){const n=e("backoff"),i=e("events"),o=(e("util").inherits,r.WebSocket||e("ws")),a=e("./subprovider"),s=e("../util/create-payload");class u extends a{constructor({rpcUrl:e,debug:t,origin:r}){super(),i.call(this),Object.defineProperties(this,{_backoff:{value:n.exponential({randomisationFactor:.2,maxDelay:5e3})},_connectTime:{value:null,writable:!0},_log:{value:t?(...e)=>console.info.apply(console,["[WSProvider]",...e]):()=>{}},_origin:{value:r},_pendingRequests:{value:new Map},_socket:{value:null,writable:!0},_unhandledRequests:{value:[]},_url:{value:e}}),this._handleSocketClose=this._handleSocketClose.bind(this),this._handleSocketMessage=this._handleSocketMessage.bind(this),this._handleSocketOpen=this._handleSocketOpen.bind(this),this._backoff.on("ready",()=>{this._openSocket()}),this._openSocket()}handleRequest(e,t,r){if(!this._socket||this._socket.readyState!==o.OPEN)return this._unhandledRequests.push(Array.from(arguments)),void this._log("Socket not open. Request queued.");this._pendingRequests.set(e.id,[e,r]);const n=s(e);delete n.origin,this._socket.send(JSON.stringify(n)),this._log(`Sent: ${n.method} #${n.id}`)}_handleSocketClose({reason:e,code:t}){this._log(`Socket closed, code ${t} (${e||"no reason"})`),this._connectTime&&Date.now()-this._connectTime>5e3&&this._backoff.reset(),this._socket.removeEventListener("close",this._handleSocketClose),this._socket.removeEventListener("message",this._handleSocketMessage),this._socket.removeEventListener("open",this._handleSocketOpen),this._socket=null,this._backoff.backoff()}_handleSocketMessage(e){let t;try{t=JSON.parse(e.data)}catch(e){return void this._log("Received a message that is not valid JSON:",t)}if(void 0===t.id)return this.emit("data",null,t);if(!this._pendingRequests.has(t.id))return;const[r,n]=this._pendingRequests.get(t.id);if(this._pendingRequests.delete(t.id),this._log(`Received: ${r.method} #${t.id}`),t.error)return n(new Error(t.error.message));n(null,t.result)}_handleSocketOpen(){this._log("Socket open."),this._connectTime=Date.now(),this._pendingRequests.forEach(([e,t])=>{this._unhandledRequests.push([e,null,t])}),this._pendingRequests.clear(),this._unhandledRequests.splice(0,this._unhandledRequests.length).forEach(e=>{this.handleRequest.apply(this,e)})}_openSocket(){this._log("Opening socket..."),this._socket=new o(this._url,null,{origin:this._origin}),this._socket.addEventListener("close",this._handleSocketClose),this._socket.addEventListener("message",this._handleSocketMessage),this._socket.addEventListener("open",this._handleSocketOpen)}}Object.assign(u.prototype,i.prototype),t.exports=u}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util/create-payload":391,"./subprovider":387,backoff:45,events:157,util:333,ws:55}],390:[function(e,t,r){t.exports=function(e,t){if(!e)throw t||"Assertion failed"}},{}],391:[function(e,t,r){const n=e("./random-id.js"),i=e("xtend");t.exports=function(e){return i({id:n(),jsonrpc:"2.0",params:[]},e)}},{"./random-id.js":393,xtend:423}],392:[function(e,t,r){const n=e("./create-payload.js");t.exports=function(e,t,r){e.sendAsync(n({method:"eth_estimateGas",params:[t]}),function(e,t){if(e)return"no contract code at given address"===e.message?r(null,"0xcf08"):r(e);r(null,t.result)})}},{"./create-payload.js":391}],393:[function(e,t,r){const n=3;t.exports=function(){var e=(new Date).getTime()*Math.pow(10,n),t=Math.floor(Math.random()*Math.pow(10,n));return e+t}},{}],394:[function(e,t,r){const n=e("json-stable-stringify");function i(e){return"never"!==s(e)}function o(e){var t=a(e);return t>=e.params.length?e.params:"eth_getBlockByNumber"===e.method?e.params.slice(1):e.params.slice(0,t)}function a(e){switch(e.method){case"eth_getStorageAt":return 2;case"eth_getBalance":case"eth_getCode":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":return 1;case"eth_getBlockByNumber":return 0;default:return}}function s(e){switch(e.method){case"web3_clientVersion":case"web3_sha3":case"eth_protocolVersion":case"eth_getBlockTransactionCountByHash":case"eth_getUncleCountByBlockHash":case"eth_getCode":case"eth_getBlockByHash":case"eth_getTransactionByHash":case"eth_getTransactionByBlockHashAndIndex":case"eth_getTransactionReceipt":case"eth_getUncleByBlockHashAndIndex":case"eth_getCompilers":case"eth_compileLLL":case"eth_compileSolidity":case"eth_compileSerpent":case"shh_version":return"perma";case"eth_getBlockByNumber":case"eth_getBlockTransactionCountByNumber":case"eth_getUncleCountByBlockNumber":case"eth_getTransactionByBlockNumberAndIndex":case"eth_getUncleByBlockNumberAndIndex":return"fork";case"eth_gasPrice":case"eth_blockNumber":case"eth_getBalance":case"eth_getStorageAt":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":case"eth_getFilterLogs":case"eth_getLogs":case"net_peerCount":return"block";case"net_version":case"net_peerCount":case"net_listening":case"eth_syncing":case"eth_sign":case"eth_coinbase":case"eth_mining":case"eth_hashrate":case"eth_accounts":case"eth_sendTransaction":case"eth_sendRawTransaction":case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_getFilterChanges":case"eth_getWork":case"eth_submitWork":case"eth_submitHashrate":case"db_putString":case"db_getString":case"db_putHex":case"db_getHex":case"shh_post":case"shh_newIdentity":case"shh_hasIdentity":case"shh_newGroup":case"shh_addToGroup":case"shh_newFilter":case"shh_uninstallFilter":case"shh_getFilterChanges":case"shh_getMessages":return"never"}}t.exports={cacheIdentifierForPayload:function(e,t={}){if(!i(e))return null;const{includeBlockRef:r}=t,a=r?e.params:o(e);return e.method+":"+n(a)},canCache:i,blockTagForPayload:function(e){var t=a(e);if(t>=e.params.length)return null;return e.params[t]},paramsWithoutBlockTag:o,blockTagParamIndex:a,cacheTypeForPayload:s}},{"json-stable-stringify":374}],395:[function(e,t,r){(function(r){const n=e("ethereumjs-util"),i=e("./assert.js");t.exports={intToQuantityHex:function(e){i("number"==typeof e&&e===Math.floor(e),"intToQuantityHex arg must be an integer");var t=n.toBuffer(e).toString("hex");"0"===t[0]&&(t=t.substring(1));return n.addHexPrefix(t)},quantityHexToInt:function(e){i("string"==typeof e,"arg to quantityHexToInt must be a string");var t=n.stripHexPrefix(e);t.length%2!=0&&(t="0"+t);var o=new r(t,"hex");return n.bufferToInt(o)}}}).call(this,e("buffer").Buffer)},{"./assert.js":390,buffer:84,"ethereumjs-util":141}],396:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits;function o(){n.call(this),this.isLocked=!0}t.exports=o,i(o,n),o.prototype.go=function(){this.isLocked=!1,this.emit("unlock")},o.prototype.stop=function(){this.isLocked=!0,this.emit("lock")},o.prototype.await=function(e){const t=this;t.isLocked?t.once("unlock",e):setTimeout(e)}},{events:157,util:333}],397:[function(e,t,r){const n=e("./index.js"),i=e("./subproviders/default-fixture.js"),o=e("./subproviders/nonce-tracker.js"),a=e("./subproviders/cache.js"),s=e("./subproviders/filters.js"),u=e("./subproviders/subscriptions"),c=e("./subproviders/inflight-cache"),f=e("./subproviders/hooked-wallet.js"),h=e("./subproviders/sanitizer.js"),l=e("./subproviders/infura.js"),d=e("./subproviders/fetch.js"),p=e("./subproviders/websocket.js");t.exports=function(e={}){const t=function({rpcUrl:e}){if(!e)return;switch(e.split(":")[0].toLowerCase()){case"http":case"https":return"http";case"ws":case"wss":return"ws";default:throw new Error(`ProviderEngine - unrecognized protocol in "${e}"`)}}(e),r=new n(e.engineParams),b=new i(e.static);r.addProvider(b),r.addProvider(new o);const y=new h;r.addProvider(y);const m=new a;if(r.addProvider(m),"ws"===t){const e=new s;r.addProvider(e)}else{const e=new u;e.on("data",(e,t)=>{r.emit("data",e,t)}),r.addProvider(e)}const v=new c;r.addProvider(v);const g=new f({getAccounts:e.getAccounts,processTransaction:e.processTransaction,approveTransaction:e.approveTransaction,signTransaction:e.signTransaction,publishTransaction:e.publishTransaction,processMessage:e.processMessage,approveMessage:e.approveMessage,signMessage:e.signMessage,processPersonalMessage:e.processPersonalMessage,processTypedMessage:e.processTypedMessage,approvePersonalMessage:e.approvePersonalMessage,approveTypedMessage:e.approveTypedMessage,signPersonalMessage:e.signPersonalMessage,signTypedMessage:e.signTypedMessage,personalRecoverSigner:e.personalRecoverSigner});r.addProvider(g);const w=e.dataSubprovider||function(e,t){const{rpcUrl:r,debug:n}=t;if(!e)return new l;if("http"===e)return new d({rpcUrl:r,debug:n});if("ws"===e)return new p({rpcUrl:r,debug:n});throw new Error(`ProviderEngine - unrecognized connectionType "${e}"`)}(t,e);"ws"===t&&w.on("data",(e,t)=>{r.emit("data",e,t)});r.addProvider(w),e.stopped||r.start();return r}},{"./index.js":373,"./subproviders/cache.js":376,"./subproviders/default-fixture.js":377,"./subproviders/fetch.js":378,"./subproviders/filters.js":379,"./subproviders/hooked-wallet.js":381,"./subproviders/inflight-cache":382,"./subproviders/infura.js":383,"./subproviders/nonce-tracker.js":384,"./subproviders/sanitizer.js":386,"./subproviders/subscriptions":388,"./subproviders/websocket.js":389}],398:[function(e,t,r){var n=e("web3-core-helpers").errors,i=e("xhr2-cookies").XMLHttpRequest,o=e("http"),a=e("https"),s=function(e,t){t=t||{},this.host=e||"http://localhost:8545","https"===this.host.substring(0,5)?this.httpsAgent=new a.Agent({keepAlive:!0}):this.httpAgent=new o.Agent({keepAlive:!0}),this.timeout=t.timeout||0,this.headers=t.headers,this.connected=!1};s.prototype._prepareRequest=function(){var e=new i;return e.nodejsSet({httpsAgent:this.httpsAgent,httpAgent:this.httpAgent}),e.open("POST",this.host,!0),e.setRequestHeader("Content-Type","application/json"),e.timeout=this.timeout&&1!==this.timeout?this.timeout:0,e.withCredentials=!0,this.headers&&this.headers.forEach(function(t){e.setRequestHeader(t.name,t.value)}),e},s.prototype.send=function(e,t){var r=this,i=this._prepareRequest();i.onreadystatechange=function(){if(4===i.readyState&&1!==i.timeout){var e=i.responseText,o=null;try{e=JSON.parse(e)}catch(e){o=n.InvalidResponse(i.responseText)}r.connected=!0,t(o,e)}},i.ontimeout=function(){r.connected=!1,t(n.ConnectionTimeout(this.timeout))};try{i.send(JSON.stringify(e))}catch(e){this.connected=!1,t(n.InvalidConnection(this.host))}},s.prototype.disconnect=function(){},t.exports=s},{http:312,https:175,"web3-core-helpers":338,"xhr2-cookies":418}],399:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("oboe"),a=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],this.path=e,this.connected=!1,this.connection=t.connect({path:this.path}),this.addDefaultEvents();var i=function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,t||-1===e.method.indexOf("_subscription")?r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t]):r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)})};"Socket"===t.constructor.name?o(this.connection).done(i):this.connection.on("data",function(e){r._parseResponse(e.toString()).forEach(i)})};a.prototype.addDefaultEvents=function(){var e=this;this.connection.on("connect",function(){e.connected=!0}),this.connection.on("close",function(){e.connected=!1}),this.connection.on("error",function(){e._timeout()}),this.connection.on("end",function(){e._timeout()}),this.connection.on("timeout",function(){e._timeout()})},a.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},a.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n},a.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on IPC")),delete this.responseCallbacks[e])},a.prototype.reconnect=function(){this.connection.connect({path:this.path})},a.prototype.send=function(e,t){this.connection.writable||this.connection.connect({path:this.path}),this.connection.write(JSON.stringify(e)),this._addResponseCallback(e,t)},a.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;default:this.connection.on(e,t)}},a.prototype.once=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");this.connection.once(e,t)},a.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)});break;default:this.connection.removeListener(e,t)}},a.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;default:this.connection.removeAllListeners(e)}},a.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.connection.removeAllListeners("error"),this.connection.removeAllListeners("end"),this.connection.removeAllListeners("timeout"),this.addDefaultEvents()},t.exports=a},{oboe:239,underscore:325,"web3-core-helpers":338}],400:[function(e,t,r){(function(r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=null,a=null,s=null;if("undefined"!=typeof window&&void 0!==window.WebSocket)o=function(e,t){return new window.WebSocket(e,t)},a=btoa,s=function(e){return new URL(e)};else{o=e("websocket").w3cwebsocket,a=function(e){return r(e).toString("base64")};var u=e("url");if(u.URL){var c=u.URL;s=function(e){return new c(e)}}else s=e("url").parse}var f=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],t=t||{},this._customTimeout=t.timeout;var i=s(e),u=t.headers||{},c=t.protocol||void 0;i.username&&i.password&&(u.authorization="Basic "+a(i.username+":"+i.password));var f=t.clientConfig||void 0;i.auth&&(u.authorization="Basic "+a(i.auth)),this.connection=new o(e,c,void 0,u,void 0,f),this.addDefaultEvents(),this.connection.onmessage=function(e){var t="string"==typeof e.data?e.data:"";r._parseResponse(t).forEach(function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,!t&&e&&e.method&&-1!==e.method.indexOf("_subscription")?r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)}):r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t])})},Object.defineProperty(this,"connected",{get:function(){return this.connection&&this.connection.readyState===this.connection.OPEN},enumerable:!0})};f.prototype.addDefaultEvents=function(){var e=this;this.connection.onerror=function(){e._timeout()},this.connection.onclose=function(){e._timeout(),e.reset()}},f.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},f.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n;var o=this;this._customTimeout&&setTimeout(function(){o.responseCallbacks[r]&&(o.responseCallbacks[r](i.ConnectionTimeout(o._customTimeout)),delete o.responseCallbacks[r])},this._customTimeout)},f.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on WS")),delete this.responseCallbacks[e])},f.prototype.send=function(e,t){var r=this;if(this.connection.readyState!==this.connection.CONNECTING){if(this.connection.readyState!==this.connection.OPEN)return console.error("connection not open on send()"),"function"==typeof this.connection.onerror?this.connection.onerror(new Error("connection not open")):console.error("no error callback"),void t(new Error("connection not open"));this.connection.send(JSON.stringify(e)),this._addResponseCallback(e,t)}else setTimeout(function(){r.send(e,t)},10)},f.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;case"connect":this.connection.onopen=t;break;case"end":this.connection.onclose=t;break;case"error":this.connection.onerror=t}},f.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)})}},f.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;case"connect":this.connection.onopen=null;break;case"end":this.connection.onclose=null;break;case"error":this.connection.onerror=null}},f.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.addDefaultEvents()},f.prototype.disconnect=function(){this.connection&&this.connection.close()},t.exports=f}).call(this,e("buffer").Buffer)},{buffer:84,underscore:325,url:327,"web3-core-helpers":338,websocket:408}],401:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-subscriptions").subscriptions,o=e("web3-core-method"),a=e("web3-net"),s=function(){var e=this;n.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments)},this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new a(this.currentProvider),[new i({name:"subscribe",type:"shh",subscriptions:{messages:{params:1}}}),new o({name:"getVersion",call:"shh_version",params:0}),new o({name:"getInfo",call:"shh_info",params:0}),new o({name:"setMaxMessageSize",call:"shh_setMaxMessageSize",params:1}),new o({name:"setMinPoW",call:"shh_setMinPoW",params:1}),new o({name:"markTrustedPeer",call:"shh_markTrustedPeer",params:1}),new o({name:"newKeyPair",call:"shh_newKeyPair",params:0}),new o({name:"addPrivateKey",call:"shh_addPrivateKey",params:1}),new o({name:"deleteKeyPair",call:"shh_deleteKeyPair",params:1}),new o({name:"hasKeyPair",call:"shh_hasKeyPair",params:1}),new o({name:"getPublicKey",call:"shh_getPublicKey",params:1}),new o({name:"getPrivateKey",call:"shh_getPrivateKey",params:1}),new o({name:"newSymKey",call:"shh_newSymKey",params:0}),new o({name:"addSymKey",call:"shh_addSymKey",params:1}),new o({name:"generateSymKeyFromPassword",call:"shh_generateSymKeyFromPassword",params:1}),new o({name:"hasSymKey",call:"shh_hasSymKey",params:1}),new o({name:"getSymKey",call:"shh_getSymKey",params:1}),new o({name:"deleteSymKey",call:"shh_deleteSymKey",params:1}),new o({name:"newMessageFilter",call:"shh_newMessageFilter",params:1}),new o({name:"getFilterMessages",call:"shh_getFilterMessages",params:1}),new o({name:"deleteMessageFilter",call:"shh_deleteMessageFilter",params:1}),new o({name:"post",call:"shh_post",params:1,inputFormatter:[null]}),new o({name:"unsubscribe",call:"shh_unsubscribe",params:1})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(s),t.exports=s},{"web3-core":348,"web3-core-method":339,"web3-core-subscriptions":345,"web3-net":372}],402:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],403:[function(e,t,r){var n=e("underscore"),i=e("ethjs-unit"),o=e("./utils.js"),a=e("./soliditySha3.js"),s=e("randomhex"),u=function(e,t){var r=[];return t.forEach(function(t){if("object"==typeof t.components){if("tuple"!==t.type.substring(0,5))throw new Error("components found but type is not tuple; report on GitHub");var i="",o=t.type.indexOf("[");o>=0&&(i=t.type.substring(o));var a=u(e,t.components);n.isArray(a)&&e?r.push("tuple("+a.join(",")+")"+i):e?r.push("("+a+")"):r.push("("+a.join(",")+")"+i)}else r.push(t.type)}),r},c=function(e){if(!o.isHexStrict(e))throw new Error("The parameter must be a valid HEX string.");var t="",r=0,n=e.length;for("0x"===e.substring(0,2)&&(r=2);r7?r+=e[n].toUpperCase():r+=e[n];return r},toHex:o.toHex,toBN:o.toBN,bytesToHex:o.bytesToHex,hexToBytes:o.hexToBytes,hexToNumberString:o.hexToNumberString,hexToNumber:o.hexToNumber,toDecimal:o.hexToNumber,numberToHex:o.numberToHex,fromDecimal:o.numberToHex,hexToUtf8:o.hexToUtf8,hexToString:o.hexToUtf8,toUtf8:o.hexToUtf8,utf8ToHex:o.utf8ToHex,stringToHex:o.utf8ToHex,fromUtf8:o.utf8ToHex,hexToAscii:c,toAscii:c,asciiToHex:f,fromAscii:f,unitMap:i.unitMap,toWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.toWei(e,t):i.toWei(e,t).toString(10)},fromWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.fromWei(e,t):i.fromWei(e,t).toString(10)},padLeft:o.leftPad,leftPad:o.leftPad,padRight:o.rightPad,rightPad:o.rightPad,toTwosComplement:o.toTwosComplement}},{"./soliditySha3.js":404,"./utils.js":405,"ethjs-unit":153,randomhex:274,underscore:325}],404:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("./utils.js"),a=function(e){var t=typeof e;if("string"===t)return o.isHexStrict(e)?new i(e.replace(/0x/i,""),16):new i(e,10);if("number"===t)return new i(e);if(o.isBigNumber(e))return new i(e.toString(10));if(o.isBN(e))return e;throw new Error(e+" is not a number")},s=function(e,t,r){var n,s,u;if("bytes"===(e=(u=e).startsWith("int[")?"int256"+u.slice(3):"int"===u?"int256":u.startsWith("uint[")?"uint256"+u.slice(4):"uint"===u?"uint256":u.startsWith("fixed[")?"fixed128x128"+u.slice(5):"fixed"===u?"fixed128x128":u.startsWith("ufixed[")?"ufixed128x128"+u.slice(6):"ufixed"===u?"ufixed128x128":u)){if(t.replace(/^0x/i,"").length%2!=0)throw new Error("Invalid bytes characters "+t.length);return t}if("string"===e)return o.utf8ToHex(t);if("bool"===e)return t?"01":"00";if(e.startsWith("address")){if(n=r?64:40,!o.isAddress(t))throw new Error(t+" is not a valid address, or the checksum is invalid.");return o.leftPad(t.toLowerCase(),n)}if(n=function(e){var t=/^\D+(\d+).*$/.exec(e);return t?parseInt(t[1],10):null}(e),e.startsWith("bytes")){if(!n)throw new Error("bytes[] not yet supported in solidity");if(r&&(n=32),n<1||n>32||n256)throw new Error("Invalid uint"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied uint exceeds width: "+n+" vs "+s.bitLength());if(s.lt(new i(0)))throw new Error("Supplied uint "+s.toString()+" is negative");return n?o.leftPad(s.toString("hex"),n/8*2):s}if(e.startsWith("int")){if(n%8||n<8||n>256)throw new Error("Invalid int"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied int exceeds width: "+n+" vs "+s.bitLength());return s.lt(new i(0))?s.toTwos(n).toString("hex"):n?o.leftPad(s.toString("hex"),n/8*2):s}throw new Error("Unsupported or invalid type: "+e)},u=function(e){if(n.isArray(e))throw new Error("Autodetection of array types is not supported.");var t,r,a="";if(n.isObject(e)&&(e.hasOwnProperty("v")||e.hasOwnProperty("t")||e.hasOwnProperty("value")||e.hasOwnProperty("type"))?(t=e.hasOwnProperty("t")?e.t:e.type,a=e.hasOwnProperty("v")?e.v:e.value):(t=o.toHex(e,!0),a=o.toHex(e),t.startsWith("int")||t.startsWith("uint")||(t="bytes")),!t.startsWith("int")&&!t.startsWith("uint")||"string"!=typeof a||/^(-)?0x/i.test(a)||(a=new i(a)),n.isArray(a)){if((r=function(e){var t=/^\D+\d*\[(\d+)\]$/.exec(e);return t?parseInt(t[1],10):null}(t))&&a.length!==r)throw new Error(t+" is not matching the given array "+JSON.stringify(a));r=a.length}return n.isArray(a)?a.map(function(e){return s(t,e,r).toString("hex").replace("0x","")}).join(""):s(t,a,r).toString("hex").replace("0x","")};t.exports=function(){var e=Array.prototype.slice.call(arguments),t=n.map(e,u);return o.sha3("0x"+t.join(""))}},{"./utils.js":405,"bn.js":402,underscore:325}],405:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("number-to-bn"),a=e("utf8"),s=e("eth-lib/lib/hash"),u=function(e){return e instanceof i||e&&e.constructor&&"BN"===e.constructor.name},c=function(e){return e&&e.constructor&&"BigNumber"===e.constructor.name},f=function(e){try{return o.apply(null,arguments)}catch(t){throw new Error(t+' Given value: "'+e+'"')}},h=function(e){return!!/^(0x)?[0-9a-f]{40}$/i.test(e)&&(!(!/^(0x|0X)?[0-9a-f]{40}$/.test(e)&&!/^(0x|0X)?[0-9A-F]{40}$/.test(e))||l(e))},l=function(e){e=e.replace(/^0x/i,"");for(var t=m(e.toLowerCase()).replace(/^0x/i,""),r=0;r<40;r++)if(parseInt(t[r],16)>7&&e[r].toUpperCase()!==e[r]||parseInt(t[r],16)<=7&&e[r].toLowerCase()!==e[r])return!1;return!0},d=function(e){var t="";e=(e=(e=(e=(e=a.encode(e)).replace(/^(?:\u0000)*/,"")).split("").reverse().join("")).replace(/^(?:\u0000)*/,"")).split("").reverse().join("");for(var r=0;r>>4).toString(16)),t.push((15&e[r]).toString(16));return"0x"+t.join("")},isHex:function(e){return(n.isString(e)||n.isNumber(e))&&/^(-0x|0x)?[0-9a-f]*$/i.test(e)},isHexStrict:y,leftPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+new Array(i).join(r||"0")+e},rightPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+e+new Array(i).join(r||"0")},toTwosComplement:function(e){return"0x"+f(e).toTwos(256).toString(16,64)},sha3:m}},{"bn.js":402,"eth-lib/lib/hash":134,"number-to-bn":237,underscore:325,utf8:329}],406:[function(e,t,r){t.exports={_from:"web3@1.0.0-beta.36",_id:"web3@1.0.0-beta.36",_inBundle:!1,_integrity:"sha512-fZDunw1V0AQS27r5pUN3eOVP7u8YAvyo6vOapdgVRolAu5LgaweP7jncYyLINqIX9ZgWdS5A090bt+ymgaYHsw==",_location:"/web3",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"web3@1.0.0-beta.36",name:"web3",escapedName:"web3",rawSpec:"1.0.0-beta.36",saveSpec:null,fetchSpec:"1.0.0-beta.36"},_requiredBy:["#USER","/"],_resolved:"https://registry.npmjs.org/web3/-/web3-1.0.0-beta.36.tgz",_shasum:"2954da9e431124c88396025510d840ba731c8373",_spec:"web3@1.0.0-beta.36",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy",author:{name:"ethereum.org"},authors:[{name:"Fabian Vogelsteller",email:"fabian@ethereum.org",homepage:"http://frozeman.de"},{name:"Marek Kotewicz",email:"marek@parity.io",url:"https://github.com/debris"},{name:"Marian Oancea",url:"https://github.com/cubedro"},{name:"Gav Wood",email:"g@parity.io",homepage:"http://gavwood.com"},{name:"Jeffery Wilcke",email:"jeffrey.wilcke@ethereum.org",url:"https://github.com/obscuren"}],bugs:{url:"https://github.com/ethereum/web3.js/issues"},bundleDependencies:!1,dependencies:{"web3-bzz":"1.0.0-beta.36","web3-core":"1.0.0-beta.36","web3-eth":"1.0.0-beta.36","web3-eth-personal":"1.0.0-beta.36","web3-net":"1.0.0-beta.36","web3-shh":"1.0.0-beta.36","web3-utils":"1.0.0-beta.36"},deprecated:!1,description:"Ethereum JavaScript API",keywords:["Ethereum","JavaScript","API"],license:"LGPL-3.0",main:"src/index.js",name:"web3",namespace:"ethereum",repository:{type:"git",url:"https://github.com/ethereum/web3.js/tree/master/packages/web3"},version:"1.0.0-beta.36"}},{}],407:[function(e,t,r){"use strict";var n=e("../package.json").version,i=e("web3-core"),o=e("web3-eth"),a=e("web3-net"),s=e("web3-eth-personal"),u=e("web3-shh"),c=e("web3-bzz"),f=e("web3-utils"),h=function(){var e=this;i.packageInit(this,arguments),this.version=n,this.utils=f,this.eth=new o(this),this.shh=new u(this),this.bzz=new c(this);var t=this.setProvider;this.setProvider=function(r,n){return t.apply(e,arguments),this.eth.setProvider(r,n),this.shh.setProvider(r,n),this.bzz.setProvider(r),!0}};h.version=n,h.utils=f,h.modules={Eth:o,Net:a,Personal:s,Shh:u,Bzz:c},i.addProviders(h),t.exports=h},{"../package.json":406,"web3-bzz":335,"web3-core":348,"web3-eth":371,"web3-eth-personal":369,"web3-net":372,"web3-shh":401,"web3-utils":403}],408:[function(e,t,r){var n=function(){return this||{}}(),i=n.WebSocket||n.MozWebSocket,o=e("./version");function a(e,t){return t?new i(e,t):new i(e)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(e){Object.defineProperty(a,e,{get:function(){return i[e]}})}),t.exports={w3cwebsocket:i?a:null,version:o}},{"./version":409}],409:[function(e,t,r){t.exports=e("../package.json").version},{"../package.json":410}],410:[function(e,t,r){t.exports={_from:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_id:"websocket@1.0.26",_inBundle:!1,_integrity:"",_location:"/websocket",_phantomChildren:{},_requested:{type:"git",raw:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",name:"websocket",escapedName:"websocket",rawSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",saveSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",fetchSpec:"git://github.com/frozeman/WebSocket-Node.git",gitCommittish:"browserifyCompatible"},_requiredBy:["/web3-providers-ws"],_resolved:"git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",_spec:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy/node_modules/web3-providers-ws",author:{name:"Brian McKelvey",email:"brian@worlize.com",url:"https://www.worlize.com/"},browser:"lib/browser.js",bugs:{url:"https://github.com/theturtle32/WebSocket-Node/issues"},bundleDependencies:!1,config:{verbose:!1},contributors:[{name:"Iñaki Baz Castillo",email:"ibc@aliax.net",url:"http://dev.sipdoc.net"}],dependencies:{debug:"^2.2.0",nan:"^2.3.3","typedarray-to-buffer":"^3.1.2",yaeti:"^0.0.6"},deprecated:!1,description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",devDependencies:{"buffer-equal":"^1.0.0",faucet:"^0.0.1",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-jshint":"^2.0.4",jshint:"^2.0.0","jshint-stylish":"^2.2.1",tape:"^4.0.1"},directories:{lib:"./lib"},engines:{node:">=0.10.0"},homepage:"https://github.com/theturtle32/WebSocket-Node",keywords:["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],license:"Apache-2.0",main:"index",name:"websocket",repository:{type:"git",url:"git+https://github.com/theturtle32/WebSocket-Node.git"},scripts:{gulp:"gulp",install:"(node-gyp rebuild 2> builderror.log) || (exit 0)",test:"faucet test/unit"},version:"1.0.26"}},{}],411:[function(e,t,r){var n=e("xhr-request");t.exports=function(e,t){return new Promise(function(r,i){n(e,t,function(e,t){e?i(e):r(t)})})}},{"xhr-request":412}],412:[function(e,t,r){var n=e("query-string"),i=e("url-set-query"),o=e("object-assign"),a=e("./lib/ensure-header.js"),s=e("./lib/request.js"),u="application/json",c=function(){};t.exports=function(e,t,r){if(!e||"string"!=typeof e)throw new TypeError("must specify a URL");"function"==typeof t&&(r=t,t={});if(r&&"function"!=typeof r)throw new TypeError("expected cb to be undefined or a function");r=r||c;var f=(t=t||{}).json?"json":"text",h=(t=o({responseType:f},t)).headers||{},l=(t.method||"GET").toUpperCase(),d=t.query;d&&("string"!=typeof d&&(d=n.stringify(d)),e=i(e,d));"json"===t.responseType&&a(h,"Accept",u);t.json&&"GET"!==l&&"HEAD"!==l&&(a(h,"Content-Type",u),t.body=JSON.stringify(t.body));return t.method=l,t.url=e,t.headers=h,delete t.query,delete t.json,s(t,r)}},{"./lib/ensure-header.js":413,"./lib/request.js":415,"object-assign":238,"query-string":266,"url-set-query":326}],413:[function(e,t,r){t.exports=function(e,t,r){var n=t.toLowerCase();e[t]||e[n]||(e[t]=r)}},{}],414:[function(e,t,r){t.exports=function(e,t){return t?{statusCode:t.statusCode,headers:t.headers,method:e.method,url:e.url,rawRequest:t.rawRequest?t.rawRequest:t}:null}},{}],415:[function(e,t,r){var n=e("xhr"),i=e("./normalize-response"),o=function(){};t.exports=function(e,t){delete e.uri;var r=!1;"json"===e.responseType&&(e.responseType="text",r=!0);var a=n(e,function(n,a,s){if(r&&!n)try{var u=a.rawRequest.responseText;s=JSON.parse(u)}catch(e){n=e}a=i(e,a),t(n,n?null:s,a),t=o}),s=a.onabort;return a.onabort=function(){var e=s.apply(a,Array.prototype.slice.call(arguments));return t(new Error("XHR Aborted")),t=o,e},a}},{"./normalize-response":414,xhr:416}],416:[function(e,t,r){"use strict";var n=e("global/window"),i=e("is-function"),o=e("parse-headers"),a=e("xtend");function s(e,t,r){var n=e;return i(t)?(r=t,"string"==typeof e&&(n={uri:e})):n=a(t,{uri:e}),n.callback=r,n}function u(e,t,r){return c(t=s(e,t,r))}function c(e){if(void 0===e.callback)throw new Error("callback argument missing");var t=!1,r=function(r,n,i){t||(t=!0,e.callback(r,n,i))};function n(e){return clearTimeout(f),e instanceof Error||(e=new Error(""+(e||"Unknown XMLHttpRequest Error"))),e.statusCode=0,r(e,m)}function i(){if(!s){var t;clearTimeout(f),t=e.useXDR&&void 0===c.status?200:1223===c.status?204:c.status;var n=m,i=null;return 0!==t?(n={body:function(){var e=void 0;if(e=c.response?c.response:c.responseText||function(e){try{if("document"===e.responseType)return e.responseXML;var t=e.responseXML&&"parsererror"===e.responseXML.documentElement.nodeName;if(""===e.responseType&&!t)return e.responseXML}catch(e){}return null}(c),y)try{e=JSON.parse(e)}catch(e){}return e}(),statusCode:t,method:l,headers:{},url:h,rawRequest:c},c.getAllResponseHeaders&&(n.headers=o(c.getAllResponseHeaders()))):i=new Error("Internal XMLHttpRequest Error"),r(i,n,n.body)}}var a,s,c=e.xhr||null;c||(c=e.cors||e.useXDR?new u.XDomainRequest:new u.XMLHttpRequest);var f,h=c.url=e.uri||e.url,l=c.method=e.method||"GET",d=e.body||e.data,p=c.headers=e.headers||{},b=!!e.sync,y=!1,m={body:void 0,headers:{},statusCode:0,method:l,url:h,rawRequest:c};if("json"in e&&!1!==e.json&&(y=!0,p.accept||p.Accept||(p.Accept="application/json"),"GET"!==l&&"HEAD"!==l&&(p["content-type"]||p["Content-Type"]||(p["Content-Type"]="application/json"),d=JSON.stringify(!0===e.json?d:e.json))),c.onreadystatechange=function(){4===c.readyState&&setTimeout(i,0)},c.onload=i,c.onerror=n,c.onprogress=function(){},c.onabort=function(){s=!0},c.ontimeout=n,c.open(l,h,!b,e.username,e.password),b||(c.withCredentials=!!e.withCredentials),!b&&e.timeout>0&&(f=setTimeout(function(){if(!s){s=!0,c.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT",n(e)}},e.timeout)),c.setRequestHeader)for(a in p)p.hasOwnProperty(a)&&c.setRequestHeader(a,p[a]);else if(e.headers&&!function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}(e.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in e&&(c.responseType=e.responseType),"beforeSend"in e&&"function"==typeof e.beforeSend&&e.beforeSend(c),c.send(d||null),c}t.exports=u,t.exports.default=u,u.XMLHttpRequest=n.XMLHttpRequest||function(){},u.XDomainRequest="withCredentials"in new u.XMLHttpRequest?u.XMLHttpRequest:n.XDomainRequest,function(e,t){for(var r=0;r=0)return this._url=this._parseUrl(t.headers.location),this._method="GET",this._loweredHeaders["content-type"]&&(delete this._headers[this._loweredHeaders["content-type"]],delete this._loweredHeaders["content-type"]),null!=this._headers["Content-Type"]&&delete this._headers["Content-Type"],delete this._headers["Content-Length"],this.upload._reset(),this._finalizeHeaders(),void this._sendHxxpRequest();this._response=t,this._response.on("data",function(e){return n._onHttpResponseData(t,e)}),this._response.on("end",function(){return n._onHttpResponseEnd(t)}),this._response.on("close",function(){return n._onHttpResponseClose(t)}),this.responseUrl=this._url.href.split("#")[0],this.status=t.statusCode,this.statusText=s.STATUS_CODES[this.status],this._parseResponseHeaders(t);var i=this._responseHeaders["content-length"]||"";this._totalBytes=+i,this._lengthComputable=!!i,this._setReadyState(r.HEADERS_RECEIVED)}},r.prototype._onHttpResponseData=function(e,t){this._response===e&&(this._responseParts.push(new n(t)),this._loadedBytes+=t.length,this.readyState!==r.LOADING&&this._setReadyState(r.LOADING),this._dispatchProgress("progress"))},r.prototype._onHttpResponseEnd=function(e){this._response===e&&(this._parseResponse(),this._request=null,this._response=null,this._setReadyState(r.DONE),this._dispatchProgress("load"),this._dispatchProgress("loadend"))},r.prototype._onHttpResponseClose=function(e){if(this._response===e){var t=this._request;this._setError(),t.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend")}},r.prototype._onHttpTimeout=function(e){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("timeout"),this._dispatchProgress("loadend"))},r.prototype._onHttpRequestError=function(e,t){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend"))},r.prototype._dispatchProgress=function(e){var t=new r.ProgressEvent(e);t.lengthComputable=this._lengthComputable,t.loaded=this._loadedBytes,t.total=this._totalBytes,this.dispatchEvent(t)},r.prototype._setError=function(){this._request=null,this._response=null,this._responseHeaders=null,this._responseParts=null},r.prototype._parseUrl=function(e,t,r){var n=null==this.nodejsBaseUrl?e:f.resolve(this.nodejsBaseUrl,e),i=f.parse(n,!1,!0);i.hash=null;var o=(i.auth||"").split(":"),a=o[0],s=o[1];return(a||s||t||r)&&(i.auth=(t||a||"")+":"+(r||s||"")),i},r.prototype._parseResponseHeaders=function(e){for(var t in this._responseHeaders={},e.headers){var r=t.toLowerCase();this._privateHeaders[r]||(this._responseHeaders[r]=e.headers[t])}null!=this._mimeOverride&&(this._responseHeaders["content-type"]=this._mimeOverride)},r.prototype._parseResponse=function(){var e=n.concat(this._responseParts);switch(this._responseParts=null,this.responseType){case"json":this.responseText=null;try{this.response=JSON.parse(e.toString("utf-8"))}catch(e){this.response=null}return;case"buffer":return this.responseText=null,void(this.response=e);case"arraybuffer":this.responseText=null;for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),i=0;i0&&(window.web3.eth.defaultAccount=t[0])})}window.ethereum=s}}},console.log("JS bridging rpc url access"),"undefined"!=typeof window&&window.bridge?window.bridge.post("getRPCurl",{},function(e,r){r&&t(r.description,null),t(null,e.rpcURL)}):(console.log("No bridge to native code is found"),t(!0,null))}()},{"./wk.bridge":424,web3:407,"web3-provider-engine/zero.js":397}],2:[function(e,t,r){t.exports=e("./register")().Promise},{"./register":4}],3:[function(e,t,r){"use strict";var n=null;t.exports=function(e,t){return function(r,i){r=r||null;var o=!1!==(i=i||{}).global;if(null===n&&o&&(n=e["@@any-promise/REGISTRATION"]||null),null!==n&&null!==r&&n.implementation!==r)throw new Error('any-promise already defined as "'+n.implementation+'". You can only register an implementation before the first call to require("any-promise") and an implementation cannot be changed');return null===n&&(n=null!==r&&void 0!==i.Promise?{Promise:i.Promise,implementation:r}:t(r),o&&(e["@@any-promise/REGISTRATION"]=n)),n}}},{}],4:[function(e,t,r){"use strict";t.exports=e("./loader")(window,function(){if(void 0===window.Promise)throw new Error("any-promise browser requires a polyfill or explicit registration e.g: require('any-promise/register/bluebird')");return{Promise:window.Promise,implementation:"window.Promise"}})},{"./loader":3}],5:[function(e,t,r){var n=r;n.bignum=e("bn.js"),n.define=e("./asn1/api").define,n.base=e("./asn1/base"),n.constants=e("./asn1/constants"),n.decoders=e("./asn1/decoders"),n.encoders=e("./asn1/encoders")},{"./asn1/api":6,"./asn1/base":8,"./asn1/constants":12,"./asn1/decoders":14,"./asn1/encoders":17,"bn.js":53}],6:[function(e,t,r){var n=e("../asn1"),i=e("inherits");function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}r.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(t){var r;try{r=e("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){r=function(e){this._initNamed(e)}}return i(r,t),r.prototype._initNamed=function(e){t.call(this,e)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(n.decoders[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(n.encoders[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},{"../asn1":5,inherits:180,vm:334}],7:[function(e,t,r){var n=e("inherits"),i=e("../base").Reporter,o=e("buffer").Buffer;function a(e,t){i.call(this,t),o.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function s(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return e instanceof s||(e=new s(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=o.byteLength(e);else{if(!o.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}n(a,i),r.DecoderBuffer=a,a.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},a.prototype.restore=function(e){var t=new a(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,i.prototype.restore.call(this,e.reporter),t},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},a.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new a(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},a.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},r.EncoderBuffer=s,s.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length?e:(Array.isArray(this.value)?this.value.forEach(function(r){r.join(e,t),t+=r.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):o.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},{"../base":8,buffer:84,inherits:180}],8:[function(e,t,r){var n=r;n.Reporter=e("./reporter").Reporter,n.DecoderBuffer=e("./buffer").DecoderBuffer,n.EncoderBuffer=e("./buffer").EncoderBuffer,n.Node=e("./node")},{"./buffer":7,"./node":9,"./reporter":10}],9:[function(e,t,r){var n=e("../base").Reporter,i=e("../base").EncoderBuffer,o=e("../base").DecoderBuffer,a=e("minimalistic-assert"),s=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],u=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function c(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}t.exports=c;var f=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){var e=this._baseState,t={};f.forEach(function(r){t[r]=e[r]});var r=new this.constructor(t.parent);return r._baseState=t,r},c.prototype._wrap=function(){var e=this._baseState;u.forEach(function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}},this)},c.prototype._init=function(e){var t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter(function(e){return e._baseState.parent===this},this),a.equal(t.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(e){var t=this._baseState,r=e.filter(function(e){return e instanceof this.constructor},this);e=e.filter(function(e){return!(e instanceof this.constructor)},this),0!==r.length&&(a(null===t.children),t.children=r,r.forEach(function(e){e._baseState.parent=this},this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map(function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach(function(r){r==(0|r)&&(r|=0);var n=e[r];t[n]=r}),t}))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(e){c.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}}),s.forEach(function(e){c.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(r),this}}),c.prototype.use=function(e){a(e);var t=this._baseState;return a(null===t.use),t.use=e,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(e){var t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},c.prototype.explicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},c.prototype.implicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},c.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},c.prototype.key=function(e){var t=this._baseState;return a(null===t.key),t.key=e,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(e){var t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map(function(t){return e[t]})),this},c.prototype.contains=function(e){var t=this._baseState;return a(null===t.use),t.contains=e,this},c.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var n,i=r.default,a=!0,s=null;if(null!==r.key&&(s=e.enterKey(r.key)),r.optional){var u=null;if(null!==r.explicit?u=r.explicit:null!==r.implicit?u=r.implicit:null!==r.tag&&(u=r.tag),null!==u||r.any){if(a=this._peekTag(e,u,r.any),e.isError(a))return a}else{var c=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(c)}}if(r.obj&&a&&(n=e.enterObject()),a){if(null!==r.explicit){var f=this._decodeTag(e,r.explicit);if(e.isError(f))return f;e=f}var h=e.offset;if(null===r.use&&null===r.choice){if(r.any)c=e.save();var l=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(l))return l;r.any?i=e.raw(c):e=l}if(t&&t.track&&null!==r.tag&&t.track(e.path(),h,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),i=r.any?i:null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),e.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach(function(r){r._decode(e,t)}),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var d=new o(i);i=this._getUse(r.contains,e._reporterState.obj)._decode(d,t)}}return r.obj&&a&&(i=e.leaveObject(n)),null===r.key||null===i&&!0!==a?null!==s&&e.exitKey(s):e.leaveKey(s,r.key,i),i},c.prototype._decodeGeneric=function(e,t,r){var n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},c.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},c.prototype._decodeChoice=function(e,t){var r=this._baseState,n=null,i=!1;return Object.keys(r.choice).some(function(o){var a=e.save(),s=r.choice[o];try{var u=s._decode(e,t);if(e.isError(u))return!1;n={type:o,value:u},i=!0}catch(t){return e.restore(a),!1}return!0},this),i?n:e.error("Choice not matched")},c.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},c.prototype._encode=function(e,t,r){var n=this._baseState;if(null===n.default||n.default!==e){var i=this._encodeValue(e,t,r);if(void 0!==i&&!this._skipDefault(i,t,r))return i}},c.prototype._encodeValue=function(e,t,r){var i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);var o=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}var a=null,s=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)a=this._getUse(i.contains,r)._encode(e,t),s=!0;else if(i.children)a=i.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i},this).filter(function(e){return e}),a=this._createEncoderBuffer(a);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var u=this.clone();u._baseState.implicit=null,a=this._createEncoderBuffer(e.map(function(r){var n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)},u))}else null!==i.use?o=this._getUse(i.use,r)._encode(e,t):(a=this._encodePrimitive(i.tag,e),s=!0);if(!i.any&&null===i.choice){var c=null!==i.implicit?i.implicit:i.tag,f=null===i.implicit?"universal":"context";null===c?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(c,s,f,a))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},c.prototype._encodeChoice=function(e,t){var r=this._baseState,n=r.choice[e.type];return n||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},c.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},c.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},c.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},{"../base":8,"minimalistic-assert":234}],10:[function(e,t,r){var n=e("inherits");function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}r.Reporter=i,i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,r){var n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){var t,r=this._reporterState,n=e instanceof o;if(t=n?e:new o(r.path.map(function(e){return"["+JSON.stringify(e)+"]"}).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},i.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},n(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{inherits:180}],11:[function(e,t,r){var n=e("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=n._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=n._reverse(r.tag)},{"../constants":12}],12:[function(e,t,r){var n=r;n._reverse=function(e){var t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r|=0);var n=e[r];t[n]=r}),t},n.der=e("./der")},{"./der":11}],13:[function(e,t,r){var n=e("inherits"),i=e("../../asn1"),o=i.base,a=i.bignum,s=i.constants.der;function u(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){o.Node.call(this,"der",e)}function f(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var n=s.tagClass[r>>6],i=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:s.tag[r]}}function h(e,t,r){var n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;var i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(var o=0;o=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=s.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(n.length<128)return(o=new i(2))[0]=a,o[1]=n.length,this._createEncoderBuffer([o,n]);for(var u=1,c=n.length;c>=256;c>>=8)u++;(o=new i(2+u))[0]=a,o[1]=128|u;c=1+u;for(var f=n.length;f>0;c--,f>>=8)o[c]=255&f;return this._createEncoderBuffer([o,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new i(2*e.length),n=0;n=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var o=0;for(n=0;n=128;a>>=7)o++}var s=new i(o),u=s.length-1;for(n=e.length-1;n>=0;n--){a=e[n];for(s[u--]=127&a;(a>>=7)>0;)s[u--]=128|127&a}return this._createEncoderBuffer(s)},c.prototype._encodeTime=function(e,t){var r,n=new Date(e);return"gentime"===t?r=[f(n.getFullYear()),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[f(n.getFullYear()%100),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!i.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new i(r)}if(i.isBuffer(e)){var n=e.length;0===e.length&&n++;var o=new i(n);return e.copy(o),0===e.length&&(o[0]=0),this._createEncoderBuffer(o)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);n=1;for(var a=e;a>=256;a>>=8)n++;for(a=(o=new Array(n)).length-1;a>=0;a--)o[a]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new i(o))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){var n,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,r).join()),o.length!==i.defaultBuffer.length)return!1;for(n=0;n=0;c--)if(f[c]!==h[c])return!1;for(c=f.length-1;c>=0;c--)if(u=f[c],!v(e[u],t[u],r,n))return!1;return!0}(e,t,r,a))}return r?e===t:e==t}function g(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function w(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function _(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&y(i,r,"Missing expected exception"+n);var a="string"==typeof n,s=!e&&i&&!r;if((!e&&o.isError(i)&&a&&w(i,r)||s)&&y(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(i,r)||!e&&i)throw i}h.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=p(b((t=this).actual),128)+" "+t.operator+" "+p(b(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=d(r),a=i.indexOf("\n"+o);if(a>=0){var s=i.indexOf("\n",a+1);i=i.substring(s+1)}this.stack=i}}},o.inherits(h.AssertionError,Error),h.fail=y,h.ok=m,h.equal=function(e,t,r){e!=t&&y(e,t,r,"==",h.equal)},h.notEqual=function(e,t,r){e==t&&y(e,t,r,"!=",h.notEqual)},h.deepEqual=function(e,t,r){v(e,t,!1)||y(e,t,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(e,t,r){v(e,t,!0)||y(e,t,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(e,t,r){v(e,t,!1)&&y(e,t,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function e(t,r,n){v(t,r,!0)&&y(t,r,n,"notDeepStrictEqual",e)},h.strictEqual=function(e,t,r){e!==t&&y(e,t,r,"===",h.strictEqual)},h.notStrictEqual=function(e,t,r){e===t&&y(e,t,r,"!==",h.notStrictEqual)},h.throws=function(e,t,r){_(!0,e,t,r)},h.doesNotThrow=function(e,t,r){_(!1,e,t,r)},h.ifError=function(e){if(e)throw e};var A=Object.keys||function(e){var t=[];for(var r in e)a.call(e,r)&&t.push(r);return t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":333}],20:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){return(0,i.default)(function(t,r){var i;try{i=e.apply(this,t)}catch(e){return r(e)}(0,n.default)(i)&&"function"==typeof i.then?i.then(function(e){s(r,null,e)},function(e){s(r,e.message?e:new Error(e))}):r(null,i)})};var n=a(e("lodash/isObject")),i=a(e("./internal/initialParams")),o=a(e("./internal/setImmediate"));function a(e){return e&&e.__esModule?e:{default:e}}function s(e,t,r){try{e(t,r)}catch(e){(0,o.default)(u,e)}}function u(e){throw e}t.exports=r.default},{"./internal/initialParams":31,"./internal/setImmediate":37,"lodash/isObject":225}],21:[function(e,t,r){(function(e,n){!function(e,n){"object"==typeof r&&void 0!==t?n(r):"function"==typeof define&&define.amd?define(["exports"],n):n(e.async=e.async||{})}(this,function(r){"use strict";function i(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i-1&&e%1==0&&e<=L}function D(e){return null!=e&&O(e.length)&&!function(e){if(!s(e))return!1;var t=B(e);return t==C||t==N||t==P||t==R}(e)}var F={};function q(){}function H(e){return function(){if(null!==e){var t=e;e=null,t.apply(this,arguments)}}}var z="function"==typeof Symbol&&Symbol.iterator,K=function(e){return z&&e[z]&&e[z]()};function V(e){return null!=e&&"object"==typeof e}var G="[object Arguments]";function W(e){return V(e)&&B(e)==G}var Y=Object.prototype,X=Y.hasOwnProperty,Z=Y.propertyIsEnumerable,J=W(function(){return arguments}())?W:function(e){return V(e)&&X.call(e,"callee")&&!Z.call(e,"callee")},$=Array.isArray;var Q="object"==typeof r&&r&&!r.nodeType&&r,ee=Q&&"object"==typeof t&&t&&!t.nodeType&&t,te=ee&&ee.exports===Q?A.Buffer:void 0,re=(te?te.isBuffer:void 0)||function(){return!1},ne=9007199254740991,ie=/^(?:0|[1-9]\d*)$/;function oe(e,t){return!!(t=null==t?ne:t)&&("number"==typeof e||ie.test(e))&&e>-1&&e%1==0&&e2&&(n=i(arguments,1)),t){var c={};Fe(o,function(e,t){c[t]=e}),c[e]=n,s=!0,u=Object.create(null),r(t,c)}else o[e]=n,Le(u[e]||[],function(e){e()}),d()});a++;var c=v(t[t.length-1]);t.length>1?c(o,n):c(n)}(e,t)})}function d(){if(0===c.length&&0===a)return r(null,o);for(;c.length&&a=0&&r.push(n)}),r}Fe(e,function(t,r){if(!$(t))return l(r,[t]),void f.push(r);var n=t.slice(0,t.length-1),i=n.length;if(0===i)return l(r,t),void f.push(r);h[r]=i,Le(n,function(o){if(!e[o])throw new Error("async.auto task `"+r+"` has a non-existent dependency `"+o+"` in "+n.join(", "));!function(e,t){var r=u[e];r||(r=u[e]=[]);r.push(t)}(o,function(){0===--i&&l(r,t)})})}),function(){var e,t=0;for(;f.length;)e=f.pop(),t++,Le(p(e),function(e){0==--h[e]&&f.push(e)});if(t!==n)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),d()};function Ke(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r=n?e:function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n-1;);return r}(i,o),function(e,t){for(var r=e.length;r--&&He(t,e[r],0)>-1;);return r}(i,o)+1).join("")}var ht=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,lt=/,/,dt=/(=.+)?(\s*)$/,pt=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;function bt(e,t){var r={};Fe(e,function(e,t){var n,i,o=m(e),a=!o&&1===e.length||o&&0===e.length;if($(e))n=e.slice(0,-1),e=e[e.length-1],r[t]=n.concat(n.length>0?s:e);else if(a)r[t]=e;else{if(n=i=(i=(i=(i=(i=e).toString().replace(pt,"")).match(ht)[2].replace(" ",""))?i.split(lt):[]).map(function(e){return ft(e.replace(dt,""))}),0===e.length&&!o&&0===n.length)throw new Error("autoInject task functions require explicit parameters.");o||n.pop(),r[t]=n.concat(s)}function s(t,r){var i=Ke(n,function(e){return t[e]});i.push(r),v(e).apply(null,i)}}),ze(r,t)}function yt(){this.head=this.tail=null,this.length=0}function mt(e,t){e.length=1,e.head=e.tail=t}function vt(e,t,r){if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var n=v(e),i=0,o=[],a=!1;function s(e,t,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(f.started=!0,$(e)||(e=[e]),0===e.length&&f.idle())return l(function(){f.drain()});for(var n=0,i=e.length;n0&&o.splice(s,1),a.callback.apply(a,arguments),null!=t&&f.error(t,a.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()}}var c=!1,f={_tasks:new yt,concurrency:t,payload:r,saturated:q,unsaturated:q,buffer:t/4,empty:q,drain:q,error:q,started:!1,paused:!1,push:function(e,t){s(e,!1,t)},kill:function(){f.drain=q,f._tasks.empty()},unshift:function(e,t){s(e,!0,t)},remove:function(e){f._tasks.remove(e)},process:function(){if(!c){for(c=!0;!f.paused&&i2&&(o=i(arguments,1)),n[t]=o,r(e)})},function(e){r(e,n)})}function br(e,t){pr(Ie,e,t)}function yr(e,t,r){pr(Ee(t),e,r)}var mr=function(e,t){var r=v(e);return vt(function(e,t){r(e[0],t)},t,1)},vr=function(e,t){var r=mr(e,t);return r.push=function(e,t,n){if(null==n&&(n=q),"function"!=typeof n)throw new Error("task callback must be a function");if(r.started=!0,$(e)||(e=[e]),0===e.length)return l(function(){r.drain()});t=t||0;for(var i=r._tasks.head;i&&t>=i.priority;)i=i.next;for(var o=0,a=e.length;on?1:0}je(e,function(e,t){n(e,function(r,n){if(r)return t(r);t(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);r(null,Ke(t.sort(i),Zt("value")))})}function Nr(e,t,r){var n=v(e);return a(function(i,o){var a,s=!1;i.push(function(){s||(o.apply(null,arguments),clearTimeout(a))}),a=setTimeout(function(){var t=e.name||"anonymous",n=new Error('Callback function "'+t+'" timed out.');n.code="ETIMEDOUT",r&&(n.info=r),s=!0,o(n)},t),n.apply(null,i)})}var Rr=Math.ceil,Lr=Math.max;function Or(e,t,r,n){var i=v(r);Ce(function(e,t,r,n){for(var i=-1,o=Lr(Rr((t-e)/(r||1)),0),a=Array(o);o--;)a[n?o:++i]=e,e+=r;return a}(0,e,1),t,i,n)}var Dr=ke(Or,1/0),Fr=ke(Or,1);function qr(e,t,r,n){arguments.length<=3&&(n=r,r=t,t=$(e)?[]:{}),n=H(n||q);var i=v(r);Ie(e,function(e,r,n){i(t,e,r,n)},function(e){n(e,t)})}function Hr(e,t){var r,n=null;t=t||q,Kt(e,function(e,t){v(e)(function(e,o){r=arguments.length>2?i(arguments,1):o,n=e,t(!e)})},function(){t(n,r)})}function zr(e){return function(){return(e.unmemoized||e).apply(null,arguments)}}function Kr(e,t,r){r=Ae(r||q);var n=v(t);if(!e())return r(null);var o=function(t){if(t)return r(t);if(e())return n(o);var a=i(arguments,1);r.apply(null,[null].concat(a))};n(o)}function Vr(e,t,r){Kr(function(){return!e.apply(this,arguments)},t,r)}var Gr=function(e,t){if(t=H(t||q),!$(e))return t(new Error("First argument to waterfall must be an array of functions"));if(!e.length)return t();var r=0;function n(t){var n=v(e[r++]);t.push(Ae(o)),n.apply(null,t)}function o(o){if(o||r===e.length)return t.apply(null,arguments);n(i(arguments,1))}n([])},Wr={apply:o,applyEach:Be,applyEachSeries:Re,asyncify:d,auto:ze,autoInject:bt,cargo:gt,compose:Et,concat:St,concatLimit:kt,concatSeries:Mt,constant:It,detect:Bt,detectLimit:Pt,detectSeries:Ct,dir:Rt,doDuring:Lt,doUntil:Dt,doWhilst:Ot,during:Ft,each:Ht,eachLimit:zt,eachOf:Ie,eachOfLimit:xe,eachOfSeries:wt,eachSeries:Kt,ensureAsync:Vt,every:Wt,everyLimit:Yt,everySeries:Xt,filter:er,filterLimit:tr,filterSeries:rr,forever:nr,groupBy:or,groupByLimit:ir,groupBySeries:ar,log:sr,map:je,mapLimit:Ce,mapSeries:Ne,mapValues:cr,mapValuesLimit:ur,mapValuesSeries:fr,memoize:lr,nextTick:dr,parallel:br,parallelLimit:yr,priorityQueue:vr,queue:mr,race:gr,reduce:_t,reduceRight:wr,reflect:_r,reflectAll:Ar,reject:xr,rejectLimit:kr,rejectSeries:Sr,retry:Ir,retryable:Tr,seq:At,series:Ur,setImmediate:l,some:jr,someLimit:Br,someSeries:Pr,sortBy:Cr,timeout:Nr,times:Dr,timesLimit:Or,timesSeries:Fr,transform:qr,tryEach:Hr,unmemoize:zr,until:Vr,waterfall:Gr,whilst:Kr,all:Wt,allLimit:Yt,allSeries:Xt,any:jr,anyLimit:Br,anySeries:Pr,find:Bt,findLimit:Pt,findSeries:Ct,forEach:Ht,forEachSeries:Kt,forEachLimit:zt,forEachOf:Ie,forEachOfSeries:wt,forEachOfLimit:xe,inject:_t,foldl:_t,foldr:wr,select:er,selectLimit:tr,selectSeries:rr,wrapSync:d};r.default=Wr,r.apply=o,r.applyEach=Be,r.applyEachSeries=Re,r.asyncify=d,r.auto=ze,r.autoInject=bt,r.cargo=gt,r.compose=Et,r.concat=St,r.concatLimit=kt,r.concatSeries=Mt,r.constant=It,r.detect=Bt,r.detectLimit=Pt,r.detectSeries=Ct,r.dir=Rt,r.doDuring=Lt,r.doUntil=Dt,r.doWhilst=Ot,r.during=Ft,r.each=Ht,r.eachLimit=zt,r.eachOf=Ie,r.eachOfLimit=xe,r.eachOfSeries=wt,r.eachSeries=Kt,r.ensureAsync=Vt,r.every=Wt,r.everyLimit=Yt,r.everySeries=Xt,r.filter=er,r.filterLimit=tr,r.filterSeries=rr,r.forever=nr,r.groupBy=or,r.groupByLimit=ir,r.groupBySeries=ar,r.log=sr,r.map=je,r.mapLimit=Ce,r.mapSeries=Ne,r.mapValues=cr,r.mapValuesLimit=ur,r.mapValuesSeries=fr,r.memoize=lr,r.nextTick=dr,r.parallel=br,r.parallelLimit=yr,r.priorityQueue=vr,r.queue=mr,r.race=gr,r.reduce=_t,r.reduceRight=wr,r.reflect=_r,r.reflectAll=Ar,r.reject=xr,r.rejectLimit=kr,r.rejectSeries=Sr,r.retry=Ir,r.retryable=Tr,r.seq=At,r.series=Ur,r.setImmediate=l,r.some=jr,r.someLimit=Br,r.someSeries=Pr,r.sortBy=Cr,r.timeout=Nr,r.times=Dr,r.timesLimit=Or,r.timesSeries=Fr,r.transform=qr,r.tryEach=Hr,r.unmemoize=zr,r.until=Vr,r.waterfall=Gr,r.whilst=Kr,r.all=Wt,r.allLimit=Yt,r.allSeries=Xt,r.any=jr,r.anyLimit=Br,r.anySeries=Pr,r.find=Bt,r.findLimit=Pt,r.findSeries=Ct,r.forEach=Ht,r.forEachSeries=Kt,r.forEachLimit=zt,r.forEachOf=Ie,r.forEachOfSeries=wt,r.forEachOfLimit=xe,r.inject=_t,r.foldl=_t,r.foldr=wr,r.select=er,r.selectLimit=tr,r.selectSeries=rr,r.wrapSync=d,Object.defineProperty(r,"__esModule",{value:!0})})}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257}],22:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r,a){(0,n.default)(t)(e,(0,i.default)((0,o.default)(r)),a)};var n=a(e("./internal/eachOfLimit")),i=a(e("./internal/withoutIndex")),o=a(e("./internal/wrapAsync"));function a(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./internal/eachOfLimit":29,"./internal/withoutIndex":39,"./internal/wrapAsync":40}],23:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r){((0,n.default)(e)?l:d)(e,(0,f.default)(t),r)};var n=h(e("lodash/isArrayLike")),i=h(e("./internal/breakLoop")),o=h(e("./eachOfLimit")),a=h(e("./internal/doLimit")),s=h(e("lodash/noop")),u=h(e("./internal/once")),c=h(e("./internal/onlyOnce")),f=h(e("./internal/wrapAsync"));function h(e){return e&&e.__esModule?e:{default:e}}function l(e,t,r){r=(0,u.default)(r||s.default);var n=0,o=0,a=e.length;function f(e,t){e?r(e):++o!==a&&t!==i.default||r(null)}for(0===a&&r(null);n2&&(n=(0,o.default)(arguments,1)),s[t]=n,r(e)})},function(e){r(e,s)})};var n=s(e("lodash/noop")),i=s(e("lodash/isArrayLike")),o=s(e("./slice")),a=s(e("./wrapAsync"));function s(e){return e&&e.__esModule?e:{default:e}}t.exports=r.default},{"./slice":38,"./wrapAsync":40,"lodash/isArrayLike":221,"lodash/noop":229}],37:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.hasNextTick=r.hasSetImmediate=void 0,r.fallback=c,r.wrap=f;var n,i=e("./slice"),o=(n=i)&&n.__esModule?n:{default:n};var a,s=r.hasSetImmediate="function"==typeof setImmediate&&setImmediate,u=r.hasNextTick="object"==typeof t&&"function"==typeof t.nextTick;function c(e){setTimeout(e,0)}function f(e){return function(t){var r=(0,o.default)(arguments,1);e(function(){t.apply(null,r)})}}a=s?setImmediate:u?t.nextTick:c,r.default=f(a)}).call(this,e("_process"))},{"./slice":38,_process:257}],38:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i0,"Expected a maximum number of retry greater than 0 but got %s.",e),this.maxNumberOfRetry_=e},o.prototype.backoff=function(e){i.checkState(-1===this.timeoutID_,"Backoff in progress."),this.backoffNumber_===this.maxNumberOfRetry_?(this.emit("fail",e),this.reset()):(this.backoffDelay_=this.backoffStrategy_.next(),this.timeoutID_=setTimeout(this.handlers.backoff,this.backoffDelay_),this.emit("backoff",this.backoffNumber_,this.backoffDelay_,e))},o.prototype.onBackoff_=function(){this.timeoutID_=-1,this.emit("ready",this.backoffNumber_,this.backoffDelay_),this.backoffNumber_++},o.prototype.reset=function(){this.backoffNumber_=0,this.backoffStrategy_.reset(),clearTimeout(this.timeoutID_),this.timeoutID_=-1},t.exports=o},{events:157,precond:253,util:333}],47:[function(e,t,r){var n=e("events"),i=e("precond"),o=e("util"),a=e("./backoff"),s=e("./strategy/fibonacci");function u(e,t,r){n.EventEmitter.call(this),i.checkIsFunction(e,"Expected fn to be a function."),i.checkIsArray(t,"Expected args to be an array."),i.checkIsFunction(r,"Expected callback to be a function."),this.function_=e,this.arguments_=t,this.callback_=r,this.lastResult_=[],this.numRetries_=0,this.backoff_=null,this.strategy_=null,this.failAfter_=-1,this.retryPredicate_=u.DEFAULT_RETRY_PREDICATE_,this.state_=u.State_.PENDING}o.inherits(u,n.EventEmitter),u.State_={PENDING:0,RUNNING:1,COMPLETED:2,ABORTED:3},u.DEFAULT_RETRY_PREDICATE_=function(e){return!0},u.prototype.isPending=function(){return this.state_==u.State_.PENDING},u.prototype.isRunning=function(){return this.state_==u.State_.RUNNING},u.prototype.isCompleted=function(){return this.state_==u.State_.COMPLETED},u.prototype.isAborted=function(){return this.state_==u.State_.ABORTED},u.prototype.setStrategy=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.strategy_=e,this},u.prototype.retryIf=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.retryPredicate_=e,this},u.prototype.getLastResult=function(){return this.lastResult_.concat()},u.prototype.getNumRetries=function(){return this.numRetries_},u.prototype.failAfter=function(e){return i.checkState(this.isPending(),"FunctionCall in progress."),this.failAfter_=e,this},u.prototype.abort=function(){this.isCompleted()||this.isAborted()||(this.isRunning()&&this.backoff_.reset(),this.state_=u.State_.ABORTED,this.lastResult_=[new Error("Backoff aborted.")],this.emit("abort"),this.doCallback_())},u.prototype.start=function(e){i.checkState(!this.isAborted(),"FunctionCall is aborted."),i.checkState(this.isPending(),"FunctionCall already started.");var t=this.strategy_||new s;this.backoff_=e?e(t):new a(t),this.backoff_.on("ready",this.doCall_.bind(this,!0)),this.backoff_.on("fail",this.doCallback_.bind(this)),this.backoff_.on("backoff",this.handleBackoff_.bind(this)),this.failAfter_>0&&this.backoff_.failAfter(this.failAfter_),this.state_=u.State_.RUNNING,this.doCall_(!1)},u.prototype.doCall_=function(e){e&&this.numRetries_++;var t=["call"].concat(this.arguments_);n.EventEmitter.prototype.emit.apply(this,t);var r=this.handleFunctionCallback_.bind(this);this.function_.apply(null,this.arguments_.concat(r))},u.prototype.doCallback_=function(){this.callback_.apply(null,this.lastResult_)},u.prototype.handleFunctionCallback_=function(){if(!this.isAborted()){var e=Array.prototype.slice.call(arguments);this.lastResult_=e,n.EventEmitter.prototype.emit.apply(this,["callback"].concat(e));var t=e[0];t&&this.retryPredicate_(t)?this.backoff_.backoff(t):(this.state_=u.State_.COMPLETED,this.doCallback_())}},u.prototype.handleBackoff_=function(e,t,r){this.emit("backoff",e,t,r)},t.exports=u},{"./backoff":46,"./strategy/fibonacci":49,events:157,precond:253,util:333}],48:[function(e,t,r){var n=e("util"),i=e("precond"),o=e("./strategy");function a(e){o.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay(),this.factor_=a.DEFAULT_FACTOR,e&&void 0!==e.factor&&(i.checkArgument(e.factor>1,"Exponential factor should be greater than 1 but got %s.",e.factor),this.factor_=e.factor)}n.inherits(a,o),a.DEFAULT_FACTOR=2,a.prototype.next_=function(){return this.backoffDelay_=Math.min(this.nextBackoffDelay_,this.getMaxDelay()),this.nextBackoffDelay_=this.backoffDelay_*this.factor_,this.backoffDelay_},a.prototype.reset_=function(){this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()},t.exports=a},{"./strategy":50,precond:253,util:333}],49:[function(e,t,r){var n=e("util"),i=e("./strategy");function o(e){i.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}n.inherits(o,i),o.prototype.next_=function(){var e=Math.min(this.nextBackoffDelay_,this.getMaxDelay());return this.nextBackoffDelay_+=this.backoffDelay_,this.backoffDelay_=e,e},o.prototype.reset_=function(){this.nextBackoffDelay_=this.getInitialDelay(),this.backoffDelay_=0},t.exports=o},{"./strategy":50,util:333}],50:[function(e,t,r){e("events"),e("util");function n(e){return null!=e}function i(e){if(n((e=e||{}).initialDelay)&&e.initialDelay<1)throw new Error("The initial timeout must be greater than 0.");if(n(e.maxDelay)&&e.maxDelay<1)throw new Error("The maximal timeout must be greater than 0.");if(this.initialDelay_=e.initialDelay||100,this.maxDelay_=e.maxDelay||1e4,this.maxDelay_<=this.initialDelay_)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");if(n(e.randomisationFactor)&&(e.randomisationFactor<0||e.randomisationFactor>1))throw new Error("The randomisation factor must be between 0 and 1.");this.randomisationFactor_=e.randomisationFactor||0}i.prototype.getMaxDelay=function(){return this.maxDelay_},i.prototype.getInitialDelay=function(){return this.initialDelay_},i.prototype.next=function(){var e=this.next_(),t=1+Math.random()*this.randomisationFactor_;return Math.round(e*t)},i.prototype.next_=function(){throw new Error("BackoffStrategy.next_() unimplemented.")},i.prototype.reset=function(){this.reset_()},i.prototype.reset_=function(){throw new Error("BackoffStrategy.reset_() unimplemented.")},t.exports=i},{events:157,util:333}],51:[function(e,t,r){"use strict";r.byteLength=function(e){return 3*e.length/4-c(e)},r.toByteArray=function(e){var t,r,n,a,s,u=e.length;a=c(e),s=new o(3*u/4-a),r=a>0?u-4:u;var f=0;for(t=0;t>16&255,s[f++]=n>>8&255,s[f++]=255&n;2===a?(n=i[e.charCodeAt(t)]<<2|i[e.charCodeAt(t+1)]>>4,s[f++]=255&n):1===a&&(n=i[e.charCodeAt(t)]<<10|i[e.charCodeAt(t+1)]<<4|i[e.charCodeAt(t+2)]>>2,s[f++]=n>>8&255,s[f++]=255&n);return s},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o="",a=[],s=0,u=r-i;su?u:s+16383));1===i?(t=e[r-1],o+=n[t>>2],o+=n[t<<4&63],o+="=="):2===i&&(t=(e[r-2]<<8)+e[r-1],o+=n[t>>10],o+=n[t>>4&63],o+=n[t<<2&63],o+="=");return a.push(o),a.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function f(e,t,r){for(var i,o,a=[],s=t;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],52:[function(e,t,r){var n=e("safe-buffer").Buffer;t.exports={check:function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))},decode:function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");var r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},encode:function(e,t){var r=e.length,i=t.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(i>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+r]=2,o[5+r]=t.length,t.copy(o,6+r),o}}},{"safe-buffer":290}],53:[function(e,t,r){!function(t,r){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var a;"object"==typeof t?t.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{a=e("buffer").Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:55}],54:[function(e,t,r){var n;function i(e){this.rand=e}if(t.exports=function(e){return n||(n=new i(null)),n.generate(e)},t.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^t[m++],a=c[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^t[m++],s=c[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^t[m++],u=c[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^t[m++],d=o,p=a,b=s,y=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^t[m++],a=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^t[m++],s=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[m++],u=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^t[m++],[o>>>=0,a>>>=0,s>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],u=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,u=0;u<256;++u){var c=s^s<<1^s<<2^s<<3^s<<4;c=c>>>8^255&c^99,r[a]=c,n[c]=a;var f=e[a],h=e[f],l=e[h],d=257*e[c]^16843008*c;i[0][a]=d<<24|d>>>8,i[1][a]=d<<16|d>>>16,i[2][a]=d<<8|d>>>24,i[3][a]=d,d=16843009*l^65537*h^257*f^16843008*a,o[0][c]=d<<24|d>>>8,o[1][c]=d<<16|d>>>16,o[2][c]=d<<8|d>>>24,o[3][c]=d,0===a?a=s=1:(a=f^e[e[e[l^f]]],s^=e[e[s]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(e){this._key=i(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a],a^=s[o/t|0]<<24):t>6&&o%t==4&&(a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a]),i[o]=i[o-t]^a}for(var c=[],f=0;f>>24]]^u.INV_SUB_MIX[1][u.SBOX[l>>>16&255]]^u.INV_SUB_MIX[2][u.SBOX[l>>>8&255]]^u.INV_SUB_MIX[3][u.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},c.prototype.encryptBlockRaw=function(e){return a(e=i(e),this._keySchedule,u.SUB_MIX,u.SBOX,this._nRounds)},c.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=n.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},c.prototype.decryptBlock=function(e){var t=(e=i(e))[1];e[1]=e[3],e[3]=t;var r=a(e,this._invKeySchedule,u.INV_SUB_MIX,u.INV_SBOX,this._nRounds),o=n.allocUnsafe(16);return o.writeUInt32BE(r[0],0),o.writeUInt32BE(r[3],4),o.writeUInt32BE(r[2],8),o.writeUInt32BE(r[1],12),o},c.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},t.exports.AES=c},{"safe-buffer":290}],57:[function(e,t,r){var n=e("./aes"),i=e("safe-buffer").Buffer,o=e("cipher-base"),a=e("inherits"),s=e("./ghash"),u=e("buffer-xor"),c=e("./incr32");function f(e,t,r,a){o.call(this);var u=i.alloc(4,0);this._cipher=new n.AES(t);var f=this._cipher.encryptBlock(u);this._ghash=new s(f),r=function(e,t,r){if(12===t.length)return e._finID=i.concat([t,i.from([0,0,0,1])]),i.concat([t,i.from([0,0,0,2])]);var n=new s(r),o=t.length,a=o%16;n.update(t),a&&(a=16-a,n.update(i.alloc(a,0))),n.update(i.alloc(8,0));var u=8*o,f=i.alloc(8);f.writeUIntBE(u,0,8),n.update(f),e._finID=n.state;var h=i.from(e._finID);return c(h),h}(this,r,f),this._prev=i.from(r),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=a,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}a(f,o),f.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=i.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},f.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=u(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var n=Math.min(e.length,t.length),i=0;i16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},h.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(e,t){var r=o[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(t,!1,r.key,r.iv);return l(e,n.key,n.iv)},r.createDecipheriv=l},{"./aes":56,"./authCipher":57,"./modes":69,"./streamCipher":72,"cipher-base":86,evp_bytestokey:158,inherits:180,"safe-buffer":290}],60:[function(e,t,r){var n=e("./modes"),i=e("./authCipher"),o=e("safe-buffer").Buffer,a=e("./streamCipher"),s=e("cipher-base"),u=e("./aes"),c=e("evp_bytestokey");function f(e,t,r){s.call(this),this._cache=new l,this._cipher=new u.AES(t),this._prev=o.from(r),this._mode=e,this._autopadding=!0}e("inherits")(f,s),f.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get();)r=this._mode.encrypt(this,t),n.push(r);return o.concat(n)};var h=o.alloc(16,16);function l(){this.cache=o.allocUnsafe(0)}function d(e,t,r){var s=n[e.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=o.from(t)),t.length!==s.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=o.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new a(s.module,t,r):"auth"===s.type?new i(s.module,t,r):new f(s.module,t,r)}f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(h))throw this._cipher.scrub(),new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},l.prototype.add=function(e){this.cache=o.concat([this.cache,e])},l.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},l.prototype.flush=function(){for(var e=16-this.cache.length,t=o.allocUnsafe(e),r=-1;++r>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function a(e){this.h=e,this.state=n.alloc(16,0),this.cache=n.allocUnsafe(0)}a.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=o(i)},a.prototype.update=function(e){var t;for(this.cache=n.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},a.prototype.final=function(e,t){return this.cache.length&&this.ghash(n.concat([this.cache,i],16)),this.ghash(o([0,e,0,t])),this.state},t.exports=a},{"safe-buffer":290}],62:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],63:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":83}],64:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("buffer-xor");function o(e,t,r){var o=t.length,a=i(t,e._cache);return e._cache=e._cache.slice(o),e._prev=n.concat([e._prev,r?t:a]),a}r.encrypt=function(e,t,r){for(var i,a=n.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=n.allocUnsafe(0)),!(e._cache.length<=t.length)){a=n.concat([a,o(e,t,r)]);break}i=e._cache.length,a=n.concat([a,o(e,t.slice(0,i),r)]),t=t.slice(i)}return a}},{"buffer-xor":83,"safe-buffer":290}],65:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t,r){for(var n,i,a=-1,s=0;++a<8;)n=t&1<<7-a?128:0,s+=(128&(i=e._cipher.encryptBlock(e._prev)[0]^n))>>a%8,e._prev=o(e._prev,r?n:i);return s}function o(e,t){var r=e.length,i=-1,o=n.allocUnsafe(e.length);for(e=n.concat([e,n.from([t])]);++i>7;return o}r.encrypt=function(e,t,r){for(var o=t.length,a=n.allocUnsafe(o),s=-1;++s=0||!r.umod(e.prime1)||!r.umod(e.prime2);)r=new n(i(t));return r}t.exports=o,o.getr=a}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84,randombytes:270}],77:[function(e,t,r){t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":78}],78:[function(e,t,r){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],79:[function(e,t,r){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],80:[function(e,t,r){(function(r){var n=e("create-hash"),i=e("stream"),o=e("inherits"),a=e("./sign"),s=e("./verify"),u=e("./algorithms.json");function c(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function f(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function h(e){return new c(e)}function l(e){return new f(e)}Object.keys(u).forEach(function(e){u[e].id=new r(u[e].id,"hex"),u[e.toLowerCase()]=u[e]}),o(c,i.Writable),c.prototype._write=function(e,t,r){this._hash.update(e),r()},c.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},c.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),n=a(r,e,this._hashType,this._signType,this._tag);return t?n.toString(t):n},o(f,i.Writable),f.prototype._write=function(e,t,r){this._hash.update(e),r()},f.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},f.prototype.verify=function(e,t,n){"string"==typeof t&&(t=new r(t,n)),this.end();var i=this._hash.digest();return s(t,i,e,this._signType,this._tag)},t.exports={Sign:h,Verify:l,createSign:h,createVerify:l}}).call(this,e("buffer").Buffer)},{"./algorithms.json":78,"./sign":81,"./verify":82,buffer:84,"create-hash":91,inherits:180,stream:311}],81:[function(e,t,r){(function(r){var n=e("create-hmac"),i=e("browserify-rsa"),o=e("elliptic").ec,a=e("bn.js"),s=e("parse-asn1"),u=e("./curves.json");function c(e,t,i,o){if((e=new r(e.toArray())).length0&&r.ishrn(n),r}function h(e,t,i){var o,a;do{for(o=new r(0);8*o.length=t)throw new Error("invalid sig")}t.exports=function(e,t,u,c,f){var h=o(u);if("ec"===h.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var n=a[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),s=r.data.subjectPrivateKey.data;return o.verify(t,e,s)}(e,t,h)}if("dsa"===h.type){if("dsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var i=r.data.p,a=r.data.q,u=r.data.g,c=r.data.pub_key,f=o.signature.decode(e,"der"),h=f.s,l=f.r;s(h,a),s(l,a);var d=n.mont(i),p=h.invm(a);return 0===u.toRed(d).redPow(new n(t).mul(p).mod(a)).fromRed().mul(c.toRed(d).redPow(l.mul(p).mod(a)).fromRed()).mod(i).mod(a).cmp(l)}(e,t,h)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");t=r.concat([f,t]);for(var l=h.modulus.byteLength(),d=[1],p=0;t.length+d.length+2o)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=s.prototype,t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(e)}return u(e,t,r)}function u(e,t,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return F(e)?function(e,t,r){if(t<0||e.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function d(e,t){if(s.isBuffer(e))return e.length;if(q(e)||F(e))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return O(e).length;default:if(n)return L(e).length;t=(""+t).toLowerCase(),n=!0}}function p(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var o,a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var f=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function x(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return x(this,t,r);case"ascii":return S(this,t,r);case"latin1":case"binary":return M(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},s.prototype.compare=function(e,t,r,n,i){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),u=Math.min(o,a),c=this.slice(n,i),f=e.slice(t,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return m(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return g(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function S(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,r,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function B(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function C(e,t,r,n,o){return t=+t,r>>>=0,o||B(e,0,r,8),i.write(e,t,r,n,52,8),r+8}s.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},s.prototype.readUInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||U(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||U(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||U(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||U(e,8,this.length),i.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n)||j(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);j(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||j(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeFloatLE=function(e,t,r){return P(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return P(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return C(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return C(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(e){return n.toByteArray(function(e){if((e=e.trim().replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function F(e){return e instanceof ArrayBuffer||null!=e&&null!=e.constructor&&"ArrayBuffer"===e.constructor.name&&"number"==typeof e.byteLength}function q(e){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(e)}function H(e){return e!=e}},{"base64-js":51,ieee754:178}],85:[function(e,t,r){t.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],86:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("stream").Transform,o=e("string_decoder").StringDecoder;function a(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(a,i),a.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},a.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},a.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},a.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},t.exports=a},{inherits:180,"safe-buffer":290,stream:311,string_decoder:317}],87:[function(e,t,r){(function(e){var r=function(){"use strict";function t(e,t){return null!=t&&e instanceof t}var r,n,i;try{r=Map}catch(e){r=function(){}}try{n=Set}catch(e){n=function(){}}try{i=Promise}catch(e){i=function(){}}function o(a,u,c,f,h){"object"==typeof u&&(c=u.depth,f=u.prototype,h=u.includeNonEnumerable,u=u.circular);var l=[],d=[],p=void 0!==e;return void 0===u&&(u=!0),void 0===c&&(c=1/0),function a(c,b){if(null===c)return null;if(0===b)return c;var y,m;if("object"!=typeof c)return c;if(t(c,r))y=new r;else if(t(c,n))y=new n;else if(t(c,i))y=new i(function(e,t){c.then(function(t){e(a(t,b-1))},function(e){t(a(e,b-1))})});else if(o.__isArray(c))y=[];else if(o.__isRegExp(c))y=new RegExp(c.source,s(c)),c.lastIndex&&(y.lastIndex=c.lastIndex);else if(o.__isDate(c))y=new Date(c.getTime());else{if(p&&e.isBuffer(c))return y=e.allocUnsafe?e.allocUnsafe(c.length):new e(c.length),c.copy(y),y;t(c,Error)?y=Object.create(c):void 0===f?(m=Object.getPrototypeOf(c),y=Object.create(m)):(y=Object.create(f),m=f)}if(u){var v=l.indexOf(c);if(-1!=v)return d[v];l.push(c),d.push(y)}for(var g in t(c,r)&&c.forEach(function(e,t){var r=a(t,b-1),n=a(e,b-1);y.set(r,n)}),t(c,n)&&c.forEach(function(e){var t=a(e,b-1);y.add(t)}),c){var w;m&&(w=Object.getOwnPropertyDescriptor(m,g)),w&&null==w.set||(y[g]=a(c[g],b-1))}if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(c);for(g=0;g<_.length;g++){var A=_[g];(!(x=Object.getOwnPropertyDescriptor(c,A))||x.enumerable||h)&&(y[A]=a(c[A],b-1),x.enumerable||Object.defineProperty(y,A,{enumerable:!1}))}}if(h){var E=Object.getOwnPropertyNames(c);for(g=0;g>>2),a=0,s=0;a>5]|=128<>>9<<4)]=t;for(var r=1732584193,n=-271733879,i=-1732584194,o=271733878,h=0;h>>32-s,r);var a,s}function a(e,t,r,n,i,a,s){return o(t&r|~t&n,e,t,i,a,s)}function s(e,t,r,n,i,a,s){return o(t&n|r&~n,e,t,i,a,s)}function u(e,t,r,n,i,a,s){return o(t^r^n,e,t,i,a,s)}function c(e,t,r,n,i,a,s){return o(r^(t|~n),e,t,i,a,s)}function f(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}t.exports=function(e){return n(e,i)}},{"./make-hash":92}],94:[function(e,t,r){"use strict";var n=e("inherits"),i=e("./legacy"),o=e("cipher-base"),a=e("safe-buffer").Buffer,s=e("create-hash/md5"),u=e("ripemd160"),c=e("sha.js"),f=a.alloc(128);function h(e,t){o.call(this,"digest"),"string"==typeof t&&(t=a.from(t));var r="sha512"===e||"sha384"===e?128:64;(this._alg=e,this._key=t,t.length>r)?t=("rmd160"===e?new u:c(e)).update(t).digest():t.lengths?t=e(t):t.length-1};f.prototype.append=function(e,t){e=s(e),t=u(t);var r=this.map[e];this.map[e]=r?r+","+t:t},f.prototype.delete=function(e){delete this.map[s(e)]},f.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},f.prototype.set=function(e,t){this.map[s(e)]=u(t)},f.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},f.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),c(e)},f.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),c(e)},f.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),c(e)},t.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);var o=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},b.call(y.prototype),b.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:0,statusText:""});return e.type="error",e};var a=[301,302,303,307,308];v.redirect=function(e,t){if(-1===a.indexOf(t))throw new RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},e.Headers=f,e.Request=y,e.Response=v,e.fetch=function(e,r){return new Promise(function(n,i){var o=new y(e,r),a=new XMLHttpRequest;a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new v(i,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&t.blob&&(a.responseType="blob"),o.headers.forEach(function(e,t){a.setRequestHeader(t,e)}),a.send(void 0===o._bodyInit?null:o._bodyInit)})},e.fetch.polyfill=!0}function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function u(e){return"string"!=typeof e&&(e=String(e)),e}function c(e){var r={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t.iterable&&(r[Symbol.iterator]=function(){return r}),r}function f(e){this.map={},e instanceof f?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function h(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function l(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function d(e){var t=new FileReader,r=l(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(t.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(t.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(t.arrayBuffer&&t.blob&&n(e))this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!t.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(e)&&!i(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=p(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},t.blob&&(this.blob=function(){var e=h(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var e,t,r,n=h(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=l(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function v(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}}(void 0!==e?e:this)}).call(n,void 0);var i=n.fetch;i.Response=n.Response,i.Request=n.Request,i.Headers=n.Headers;"object"==typeof t&&t.exports&&(t.exports=i,t.exports.default=i)},{}],97:[function(e,t,r){"use strict";r.randomBytes=r.rng=r.pseudoRandomBytes=r.prng=e("randombytes"),r.createHash=r.Hash=e("create-hash"),r.createHmac=r.Hmac=e("create-hmac");var n=e("browserify-sign/algos"),i=Object.keys(n),o=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(i);r.getHashes=function(){return o};var a=e("pbkdf2");r.pbkdf2=a.pbkdf2,r.pbkdf2Sync=a.pbkdf2Sync;var s=e("browserify-cipher");r.Cipher=s.Cipher,r.createCipher=s.createCipher,r.Cipheriv=s.Cipheriv,r.createCipheriv=s.createCipheriv,r.Decipher=s.Decipher,r.createDecipher=s.createDecipher,r.Decipheriv=s.Decipheriv,r.createDecipheriv=s.createDecipheriv,r.getCiphers=s.getCiphers,r.listCiphers=s.listCiphers;var u=e("diffie-hellman");r.DiffieHellmanGroup=u.DiffieHellmanGroup,r.createDiffieHellmanGroup=u.createDiffieHellmanGroup,r.getDiffieHellman=u.getDiffieHellman,r.createDiffieHellman=u.createDiffieHellman,r.DiffieHellman=u.DiffieHellman;var c=e("browserify-sign");r.createSign=c.createSign,r.Sign=c.Sign,r.createVerify=c.createVerify,r.Verify=c.Verify,r.createECDH=e("create-ecdh");var f=e("public-encrypt");r.publicEncrypt=f.publicEncrypt,r.privateEncrypt=f.privateEncrypt,r.publicDecrypt=f.publicDecrypt,r.privateDecrypt=f.privateDecrypt;var h=e("randomfill");r.randomFill=h.randomFill,r.randomFillSync=h.randomFillSync,r.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))},r.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},{"browserify-cipher":73,"browserify-sign":80,"browserify-sign/algos":77,"create-ecdh":90,"create-hash":91,"create-hmac":94,"diffie-hellman":105,pbkdf2:247,"public-encrypt":259,randombytes:270,randomfill:271}],98:[function(e,t,r){"use strict";var n=new RegExp("%[a-f0-9]{2}","gi"),i=new RegExp("(%[a-f0-9]{2})+","gi");function o(e,t){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],o(r),o(n))}function a(e){try{return decodeURIComponent(e)}catch(i){for(var t=e.match(n),r=1;r0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];r=a.r28shl(r,s),i=a.r28shl(i,s),a.pc2(r,i,e.keys,o)}},u.prototype._update=function(e,t,r,n){var i=this._desState,o=a.readUInt32BE(e,t),s=a.readUInt32BE(e,t+4);a.ip(o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,s,i.tmp,0):this._decrypt(i,o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],a.writeUInt32BE(r,o,n),a.writeUInt32BE(r,s,n+4)},u.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,o=l}a.rip(s,o,n,i)},u.prototype._decrypt=function(e,t,r,n,i){for(var o=r,s=t,u=e.keys.length-2;u>=0;u-=2){var c=e.keys[u],f=e.keys[u+1];a.expand(o,e.tmp,0),c^=e.tmp[0],f^=e.tmp[1];var h=a.substitute(c,f),l=o;o=(s^a.permute(h))>>>0,s=l}a.rip(o,s,n,i)}},{"../des":99,inherits:180,"minimalistic-assert":234}],103:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits"),o=e("../des"),a=o.Cipher,s=o.DES;function u(e){a.call(this,e);var t=new function(e,t){n.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),i=t.slice(8,16),o=t.slice(16,24);this.ciphers="encrypt"===e?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=t}i(u,a),t.exports=u,u.create=function(e){return new u(e)},u.prototype._update=function(e,t,r,n){var i=this._edeState;i.ciphers[0]._update(e,t,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},u.prototype._pad=s.prototype._pad,u.prototype._unpad=s.prototype._unpad},{"../des":99,inherits:180,"minimalistic-assert":234}],104:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,n){for(var i=0,o=0,a=6;a>=0;a-=2){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>>s+a&1}for(a=6;a>=0;a-=2){for(s=1;s<=25;s+=8)o<<=1,o|=t>>>s+a&1;for(s=1;s<=25;s+=8)o<<=1,o|=e>>>s+a&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(e,t,r,n){for(var i=0,o=0,a=0;a<4;a++)for(var s=24;s>=0;s-=8)i<<=1,i|=t>>>s+a&1,i<<=1,i|=e>>>s+a&1;for(a=4;a<8;a++)for(s=24;s>=0;s-=8)o<<=1,o|=t>>>s+a&1,o<<=1,o|=e>>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(e,t,r,n){for(var i=0,o=0,a=7;a>=5;a--){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+a&1}for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(a=1;a<=3;a++){for(s=0;s<=24;s+=8)o<<=1,o|=t>>s+a&1;for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1}for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,i){for(var o=0,a=0,s=n.length>>>1,u=0;u>>n[u]&1;for(u=s;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=a>>>0},r.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var n=e.toString(2);n.lengthe;)r.ishrn(1);if(r.isEven()&&r.iadd(s),r.testn(1)||r.iadd(u),t.cmp(u)){if(!t.cmp(c))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&m(p)&&m(r)&&a.test(p)&&a.test(r))return r}}},{"bn.js":53,"miller-rabin":233,randombytes:270}],108:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],109:[function(e,t,r){"use strict";var n=r;n.version=e("../package.json").version,n.utils=e("./elliptic/utils"),n.rand=e("brorand"),n.curve=e("./elliptic/curve"),n.curves=e("./elliptic/curves"),n.ec=e("./elliptic/ec"),n.eddsa=e("./elliptic/eddsa")},{"../package.json":124,"./elliptic/curve":112,"./elliptic/curves":115,"./elliptic/ec":116,"./elliptic/eddsa":119,"./elliptic/utils":123,brorand:54}],110:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.getNAF,a=i.getJSF,s=i.assert;function u(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){s(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=u;t--)c=(c<<1)+n[t];a.push(c)}for(var f=this.jpoint(null,null,null),h=this.jpoint(null,null,null),l=i;l>0;l--){for(u=0;u=0;c--){for(t=0;c>=0&&0===a[c];c--)t++;if(c>=0&&t++,u=u.dblp(t),c<0)break;var f=a[c];s(0!==f),u="affine"===e.type?f>0?u.mixedAdd(i[f-1>>1]):u.mixedAdd(i[-f-1>>1].neg()):f>0?u.add(i[f-1>>1]):u.add(i[-f-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){for(var s=this._wnafT1,u=this._wnafT2,c=this._wnafT3,f=0,h=0;h=1;h-=2){var d=h-1,p=h;if(1===s[d]&&1===s[p]){var b=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(b[1]=t[d].add(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].add(t[p].neg())):(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],m=a(r[d],r[p]);f=Math.max(m[0].length,f),c[d]=new Array(f),c[p]=new Array(f);for(var v=0;v=0;h--){for(var E=0;h>=0;){var x=!0;for(v=0;v=0&&E++,_=_.dblp(E),h<0)break;for(v=0;v0?k=u[v][S-1>>1]:S<0&&(k=u[v][-S-1>>1].neg()),_="affine"===k.type?_.mixedAdd(k):_.add(k))}}for(h=0;h=Math.ceil((e.bitLength()+1)/t.step)},c.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},f.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},f.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(r),s=n.redSub(t),u=i.redMul(a),c=o.redMul(s),f=i.redMul(s),h=a.redMul(o);return this.curve.point(u,c,h,f)},f.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var a=(c=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(a.redSub(this.curve.two)),t=a.redMul(c.redSub(o)),r=a.redSqr().redSub(a).redSub(a);else{var s=this.z.redSqr(),u=a.redSub(s).redISub(s);e=n.redSub(i).redISub(o).redMul(u),t=a.redMul(c.redSub(o)),r=a.redMul(u)}}else{var c=i.redAdd(o);s=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=c.redSub(s).redSub(s);e=this.curve._mulC(n.redISub(c)).redMul(u),t=this.curve._mulC(c).redMul(i.redISub(o)),r=c.redMul(u)}return this.curve.point(e,t,r)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},f.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=i.redSub(n),s=i.redAdd(n),u=r.redAdd(t),c=o.redMul(a),f=s.redMul(u),h=o.redMul(u),l=a.redMul(s);return this.curve.point(c,f,l,h)},f.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),c=i.redAdd(s),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),h=n.redMul(u).redMul(f);return this.curve.twisted?(t=n.redMul(c).redMul(a.redSub(this.curve._mulA(o))),r=u.redMul(c)):(t=n.redMul(c).redMul(a.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(h,t,r)},f.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},f.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},f.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},f.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},f.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()},f.prototype.getY=function(){return this.normalize(),this.y.fromRed()},f.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},f.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}return!1},f.prototype.toP=f.prototype.normalize,f.prototype.mixedAdd=f.prototype.add},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],112:[function(e,t,r){"use strict";var n=r;n.base=e("./base"),n.short=e("./short"),n.mont=e("./mont"),n.edwards=e("./edwards")},{"./base":110,"./edwards":111,"./mont":113,"./short":114}],113:[function(e,t,r){"use strict";var n=e("../curve"),i=e("bn.js"),o=e("inherits"),a=n.base,s=e("../../elliptic").utils;function u(e){a.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,r){a.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(u,a),t.exports=u,u.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},o(c,a.BasePoint),u.prototype.decodePoint=function(e,t){return this.point(s.toArray(e,t),1)},u.prototype.point=function(e,t){return new c(this,e,t)},u.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=i.redMul(n),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},c.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],114:[function(e,t,r){"use strict";var n=e("../curve"),i=e("../../elliptic"),o=e("bn.js"),a=e("inherits"),s=n.base,u=i.utils.assert;function c(e){s.call(this,"short",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function f(e,t,r,n){s.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new o(t,16),this.y=new o(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function h(e,t,r,n){s.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new o(0)):(this.x=new o(t,16),this.y=new o(r,16),this.z=new o(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}a(c,s),t.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new o(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new o(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?r=i[0]:(r=i[1],u(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new o(e.a,16),b:new o(e.b,16)}}):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:o.mont(e),r=new o(2).toRed(t).redInvm(),n=r.redNeg(),i=new o(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,r,n,i,a,s,u,c,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=e,d=this.n.clone(),p=new o(1),b=new o(0),y=new o(0),m=new o(1),v=0;0!==l.cmpn(0);){var g=d.div(l);c=d.sub(g.mul(l)),f=y.sub(g.mul(p));var w=m.sub(g.mul(b));if(!n&&c.cmp(h)<0)t=u.neg(),r=p,n=c.neg(),i=f;else if(n&&2==++v)break;u=c,d=l,l=c,y=p,p=f,m=b,b=w}a=c.neg(),s=f;var _=n.sqr().add(i.sqr());return a.sqr().add(s.sqr()).cmp(_)>=0&&(a=t,s=r),n.negative&&(n=n.neg(),i=i.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:n,b:i},{a:a,b:s}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(c).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},f.prototype.isInfinity=function(){return this.inf},f.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},f.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},f.prototype.getX=function(){return this.x.fromRed()},f.prototype.getY=function(){return this.y.fromRed()},f.prototype.mul=function(e){return e=new o(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},f.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},f.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},f.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},f.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},a(h,s.BasePoint),c.prototype.jpoint=function(e,t,r){return new h(this,e,t,r)},h.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},h.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},h.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),f=c.redMul(s),h=n.redMul(c),l=u.redSqr().redIAdd(f).redISub(h).redISub(h),d=u.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(l,d,p)},h.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),f=r.redMul(u),h=s.redSqr().redIAdd(c).redISub(f).redISub(f),l=s.redMul(f.redISub(h)).redISub(i.redMul(c)),d=this.z.redMul(a);return this.curve.jpoint(h,l,d)},h.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}return!1},h.prototype.inspect=function(){return this.isInfinity()?"":""},h.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":109,"../curve":112,"bn.js":53,inherits:180}],115:[function(e,t,r){"use strict";var n,i=r,o=e("hash.js"),a=e("../elliptic"),s=a.utils.assert;function u(e){"short"===e.type?this.curve=new a.curve.short(e):"edwards"===e.type?this.curve=new a.curve.edwards(e):this.curve=new a.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=e("./precomputed/secp256k1")}catch(e){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"../elliptic":109,"./precomputed/secp256k1":122,"hash.js":162}],116:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("hmac-drbg"),o=e("../../elliptic"),a=o.utils.assert,s=e("./key"),u=e("./signature");function c(e){if(!(this instanceof c))return new c(e);"string"==typeof e&&(a(o.curves.hasOwnProperty(e),"Unknown curve "+e),e=o.curves[e]),e instanceof o.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=c,c.prototype.keyPair=function(e){return new s(this,e)},c.prototype.keyFromPrivate=function(e,t){return s.fromPrivate(this,e,t)},c.prototype.keyFromPublic=function(e,t){return s.fromPublic(this,e,t)},c.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||o.rand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),a=this.n.sub(new n(2));;){var s=new n(t.generate(r));if(!(s.cmp(a)>0))return s.iaddn(1),this.keyFromPrivate(s)}},c.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},c.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),c=e.toArray("be",a),f=new i({hash:this.hash,entropy:s,nonce:c,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(f.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var m=d.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),v^=1),new u({r:y,s:m,recoveryParam:v})}}}}}},c.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new u(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,c=a.invm(this.n),f=c.mul(e).umod(this.n),h=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(f,r.getPublic(),h)).isInfinity()&&s.eqXToP(o):!(s=this.g.mulAdd(f,r.getPublic(),h)).isInfinity()&&0===s.getX().umod(this.n).cmp(o)},c.prototype.recoverPubKey=function(e,t,r,i){a((3&r)===r,"The recovery param is more than two bits"),t=new u(t,i);var o=this.n,s=new n(e),c=t.r,f=t.s,h=1&r,l=r>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");c=l?this.curve.pointFromX(c.add(this.curve.n),h):this.curve.pointFromX(c,h);var d=t.r.invm(o),p=o.sub(s).mul(d).umod(o),b=f.mul(d).umod(o);return this.g.mulAdd(p,c,b)},c.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new u(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":109,"./key":117,"./signature":118,"bn.js":53,"hmac-drbg":174}],117:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils.assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../../elliptic":109,"bn.js":53}],118:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new function(){this.place=0};if(48!==e[r.place++])return!1;if(s(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=s(e,r),a=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var u=s(e,r);if(e.length!==u+r.place)return!1;var c=e.slice(r.place,u+r.place);return 0===a[0]&&128&a[1]&&(a=a.slice(1)),0===c[0]&&128&c[1]&&(c=c.slice(1)),this.r=new n(a),this.s=new n(c),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=u(t),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),a=[48];return c(a,o.length),a=a.concat(o),i.encode(a,e)}},{"../../elliptic":109,"bn.js":53}],119:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("../../elliptic"),o=i.utils,a=o.assert,s=o.parseBytes,u=e("./key"),c=e("./signature");function f(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}t.exports=f,f.prototype.sign=function(e,t){e=s(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),u=n.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(e,t,r){e=s(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var s=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,c=t.andln(3)+i&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!=(s=e.andln(7)+n&7)&&5!==s||2!==c?u:-u,r[0].push(o),a=0==(1&c)?0:3!=(s=t.andln(7)+i&7)&&5!==s||2!==u?c:-c,r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},{"bn.js":53,"minimalistic-assert":234,"minimalistic-crypto-utils":235}],124:[function(e,t,r){t.exports={_from:"elliptic@^6.0.0",_id:"elliptic@6.4.0",_inBundle:!1,_integrity:"sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=",_location:"/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.0.0",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.0.0",saveSpec:null,fetchSpec:"^6.0.0"},_requiredBy:["/browserify-sign","/create-ecdh"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",_shasum:"cac9af8762c85836187003c8dfe193e5e2eae5df",_spec:"elliptic@^6.0.0",_where:"/Users/alexvlasov/Blockchain/web3swift_jsproxy/node_modules/browserify-sign",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.4.0"}},{}],125:[function(e,t,r){"use strict";const n=e("ethjs-util");function i(e){let t=n.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}t.exports={incrementHexNumber:function(e){return i(n.intToHex(parseInt(e,16)+1))},formatHex:i}},{"ethjs-util":155}],126:[function(e,t,r){const n=e("eth-query"),i=e("events"),o=e("pify"),a=e("./hexUtils"),s=a.incrementHexNumber,u=1e3,c=60*u;t.exports=class extends i{constructor(e={}){if(super(),!e.provider)throw new Error("RpcBlockTracker - no provider specified.");this._provider=e.provider,this._query=new n(e.provider),this._pollingInterval=e.pollingInterval||4*u,this._syncingTimeout=e.syncingTimeout||1*c,this._trackingBlock=null,this._trackingBlockTimestamp=null,this._currentBlock=null,this._isRunning=!1,this._performSync=this._performSync.bind(this),this._handleNewBlockNotification=this._handleNewBlockNotification.bind(this)}getTrackingBlock(){return this._trackingBlock}getCurrentBlock(){return this._currentBlock}async awaitCurrentBlock(){return this._currentBlock?this._currentBlock:(await new Promise(e=>this.once("latest",e)),this._currentBlock)}async start(e={}){this._isRunning||(this._isRunning=!0,e.fromBlock?await this._setTrackingBlock(await this._fetchBlockByNumber(e.fromBlock)):await this._setTrackingBlock(await this._fetchLatestBlock()),this._provider.on?await this._initSubscription():this._performSync().catch(e=>{e&&console.error(e)}))}async stop(){this._isRunning=!1,this._provider.on&&await this._removeSubscription()}async _setTrackingBlock(e){if(this._trackingBlock&&this._trackingBlock.hash===e.hash)return;const t=this._trackingBlockTimestamp,r=Date.now();t&&r-t>this._syncingTimeout?(this._trackingBlockTimestamp=null,await this._warpToLatest()):(this._trackingBlock=e,this._trackingBlockTimestamp=r,this.emit("block",e))}async _setCurrentBlock(e){if(this._currentBlock&&this._currentBlock.hash===e.hash)return;const t=this._currentBlock;this._currentBlock=e,this.emit("latest",e),this.emit("sync",{newBlock:e,oldBlock:t})}async _warpToLatest(){await this._setTrackingBlock(await this._fetchLatestBlock())}async _pollForNextBlock(){setTimeout(()=>this._performSync(),this._pollingInterval)}async _performSync(){if(!this._isRunning)return;const e=this.getTrackingBlock();if(!e)throw new Error("RpcBlockTracker - tracking block is missing");const t=s(e.number);try{const r=await this._fetchBlockByNumber(t);r?(await this._setTrackingBlock(r),this._performSync()):(await this._setCurrentBlock(e),this._pollForNextBlock())}catch(t){t.message.includes("index out of range")||t.message.includes("Couldn't find block by reference")?(await this._setCurrentBlock(e),this._pollForNextBlock()):(console.error(t),this._pollForNextBlock())}}async _handleNewBlockNotification(e,t){t.id==this._subscriptionId&&(e&&(this.emit("error",e),await this._removeSubscription()),await this._setTrackingBlock(await this._fetchBlockByNumber(t.result.number)))}async _initSubscription(){this._provider.on("data",this._handleNewBlockNotification);let e=await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_subscribe",params:["newHeads"]});this._subscriptionId=e.result}async _removeSubscription(){if(!this._subscriptionId)throw new Error("Not subscribed.");this._provider.removeListener("data",this._handleNewBlockNotification),await o(this._provider.sendAsync||this._provider.send)({jsonrpc:"2.0",id:(new Date).getTime(),method:"eth_unsubscribe",params:[this._subscriptionId]}),delete this._subscriptionId}_fetchLatestBlock(){return o(this._query.getBlockByNumber).call(this._query,"latest",!0)}_fetchBlockByNumber(e){const t=a.formatHex(e);return o(this._query.getBlockByNumber).call(this._query,t,!0)}}},{"./hexUtils":125,"eth-query":135,events:157,pify:252}],127:[function(e,t,r){(function(t){var n=e("js-sha3").keccak_256,i=e("idna-uts46-hx");function o(e){return e?i.toUnicode(e,{useStd3ASCII:!0,transitional:!1}):e}r.hash=function(e){for(var r="",i=0;i<32;i++)r+="00";if(name=o(e),name){var a=name.split(".");for(i=a.length-1;i>=0;i--){var s=n(a[i]);r=n(new t(r+s,"hex"))}}return"0x"+r},r.normalize=o}).call(this,e("buffer").Buffer)},{buffer:84,"idna-uts46-hx":177,"js-sha3":128}],128:[function(e,t,r){(function(e,r){!function(){"use strict";var n="object"==typeof window?window:{};!n.JS_SHA3_NO_NODE_JS&&"object"==typeof e&&e.versions&&e.versions.node&&(n=r);for(var i=!n.JS_SHA3_NO_COMMON_JS&&"object"==typeof t&&t.exports,o="0123456789abcdef".split(""),a=[0,8,16,24],s=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],u=[224,256,384,512],c=["hex","buffer","arrayBuffer","array"],f=function(e,t,r){return function(n){return new _(e,t,e).update(n)[r]()}},h=function(e,t,r){return function(n,i){return new _(e,t,i).update(n)[r]()}},l=function(e,t){var r=f(e,t,"hex");r.create=function(){return new _(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}_.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,o=this.blocks,s=this.byteCount,u=this.blockCount,c=0,f=this.s;c>2]|=e[c]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(o[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=s){for(this.start=r-s,this.block=o[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+o[15&e]+o[e>>12&15]+o[e>>8&15]+o[e>>20&15]+o[e>>16&15]+o[e>>28&15]+o[e>>24&15];s%t==0&&(A(r),a=0)}return i&&(e=r[a],i>0&&(u+=o[e>>4&15]+o[15&e]),i>1&&(u+=o[e>>12&15]+o[e>>8&15]),i>2&&(u+=o[e>>20&15]+o[e>>16&15])),u},_.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&A(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var A=function(e){var t,r,n,i,o,a,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],a=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(a<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|a>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=a^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=s[n],e[1]^=s[n+1]};if(i)t.exports=p;else for(y=0;y{setTimeout(t,e)})}function c(e){const t=e.toString();return s.some(e=>t.includes(e))}async function f(e,t,r){const{fetchUrl:n,fetchParams:a}=h({network:e,req:t}),s=await o(n,a),u=await s.text();if(!s.ok)switch(s.status){case 405:throw new i.MethodNotFound;case 418:throw l("Request is being rate limited.");case 503:case 504:throw function(){let e="Gateway timeout. The request took too long to process. ";return e+="This can happen when querying logs over too wide a block range.",l("Gateway timeout. The request took too long to process. This can happen when querying logs over too wide a block range.")}();default:throw l(u)}if("eth_getBlockByNumber"===t.method&&"Not Found"===u)return void(r.result=null);const c=JSON.parse(u);r.result=c.result,r.error=c.error}function h({network:e,req:t}){const r=function(e){return{id:e.id,jsonrpc:e.jsonrpc,method:e.method,params:e.params}}(t),{method:n,params:i}=r,o={};let s=`https://api.infura.io/v1/jsonrpc/${e}`;if(a.includes(n))o.method="POST",o.headers={Accept:"application/json","Content-Type":"application/json"},o.body=JSON.stringify(r);else{o.method="GET",s+=`/${n}?params=${encodeURIComponent(JSON.stringify(i))}`}return{fetchUrl:s,fetchParams:o}}function l(e){const t=new Error(e);return new i.InternalError(t)}t.exports=function(e={}){const t=e.network||"mainnet",r=e.maxAttempts||5;if(!r)throw new Error(`Invalid value for 'maxAttempts': "${r}" (${typeof r})`);return n(async(e,n,i)=>{for(let i=1;i<=r;i++)try{await f(t,e,n);break}catch(e){if(!c(e))throw e;const t=r-i;if(!t){const t=`InfuraProvider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,r=new Error(t);throw r}await u(1e3)}})},t.exports.fetchConfigFromReq=h},{"cross-fetch":96,"json-rpc-engine/src/createAsyncMiddleware":187,"json-rpc-error":189}],131:[function(e,t,r){t.exports=function(e){return{sendAsync:e.handle.bind(e)}}},{}],132:[function(e,t,r){var n=function(e,t){for(var r=[],n=0;n>6|192);else{if(i>55295&&i<56320){if(++n==e.length)return null;var o=e.charCodeAt(n);if(o<56320||o>57343)return null;r+=t((i=65536+((1023&i)<<10)+(1023&o))>>18|240),r+=t(i>>12&63|128)}else r+=t(i>>12|224);r+=t(i>>6&63|128)}r+=t(63&i|128)}}return r},toString:function(e){for(var t="",r=0,o=i(e);r127){if(a>191&&a<224){if(r>=o)return null;a=(31&a)<<6|63&n(e,r)}else if(a>223&&a<240){if(r+1>=o)return null;a=(15&a)<<12|(63&n(e,r))<<6|63&n(e,++r)}else{if(!(a>239&&a<248))return null;if(r+2>=o)return null;a=(7&a)<<18|(63&n(e,r))<<12|(63&n(e,++r))<<6|63&n(e,++r)}++r}if(a<=65535)t+=String.fromCharCode(a);else{if(!(a<=1114111))return null;a-=65536,t+=String.fromCharCode(a>>10|55296),t+=String.fromCharCode(1023&a|56320)}}return t},fromNumber:function(e){var t=e.toString(16);return t.length%2==0?"0x"+t:"0x0"+t},toNumber:function(e){return parseInt(e.slice(2),16)},fromNat:function(e){return"0x0"===e?"0x":e.length%2==0?e:"0x0"+e.slice(2)},toNat:function(e){return"0"===e[2]?"0x"+e.slice(3):e},fromArray:a,toArray:o,fromUint8Array:function(e){return a([].slice.call(e,0))},toUint8Array:function(e){return new Uint8Array(o(e))}}},{"./array.js":132}],134:[function(e,t,r){var n="0123456789abcdef".split(""),i=[1,256,65536,16777216],o=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],s=function(e){var t,r,n,i,o,s,u,c,f,h,l,d,p,b,y,m,v,g,w,_,A,E,x,k,S,M,I,T,U,j,B,P,C,N,R,L,O,D,F,q,H,z,K,V,G,W,Y,X,Z,J,$,Q,ee,te,re,ne,ie,oe,ae,se,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],f=e[5]^e[15]^e[25]^e[35]^e[45],h=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|f>>>31),r=o^(f<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(h<<1|l>>>31),r=u^(l<<1|h>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=f^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=h^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,b=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,U=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,N=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,X=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,j=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,g=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,P=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,A=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,I=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,q=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,x=e[49]<<14|e[48]>>>18,e[0]=b^~m&g,e[1]=y^~v&w,e[10]=k^~M&T,e[11]=S^~I&U,e[20]=N^~L&D,e[21]=R^~O&F,e[30]=V^~W&X,e[31]=G^~Y&Z,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=m^~g&_,e[3]=v^~w&A,e[12]=M^~T&j,e[13]=I^~U&B,e[22]=L^~D&q,e[23]=O^~F&H,e[32]=W^~X&J,e[33]=Y^~Z&$,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=g^~_&E,e[5]=w^~A&x,e[14]=T^~j&P,e[15]=U^~B&C,e[24]=D^~q&z,e[25]=F^~H&K,e[34]=X^~J&Q,e[35]=Z^~$&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&fe,e[6]=_^~E&b,e[7]=A^~x&y,e[16]=j^~P&k,e[17]=B^~C&S,e[26]=q^~z&N,e[27]=H^~K&R,e[36]=J^~Q&V,e[37]=$^~ee&G,e[46]=se^~ce&te,e[47]=ue^~fe&re,e[8]=E^~b&m,e[9]=x^~y&v,e[18]=P^~k&M,e[19]=C^~S&I,e[28]=z^~N&L,e[29]=K^~R&O,e[38]=Q^~V&W,e[39]=ee^~G&Y,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=a[n],e[1]^=a[n+1]},u=function(e){return function(t){var r;if("0x"===t.slice(0,2)){r=[];for(var a=2,u=t.length;a>2]|=t[d]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|63&r)<=57344?(u[y>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<=c){for(e.start=y-c,e.block=u[f],y=0;y>2]|=i[3&y],e.lastByteIndex===c)for(u[0]=u[f],y=1;y>4&15]+n[15&p]+n[p>>12&15]+n[p>>8&15]+n[p>>20&15]+n[p>>16&15]+n[p>>28&15]+n[p>>24&15];m%f==0&&(s(l),y=0)}return"0x"+b}(function(e){return{blocks:[],reset:!0,block:0,start:0,blockCount:1600-(e<<1)>>5,outputBlocks:e>>5,s:(t=[0,0,0,0,0,0,0,0,0,0],[].concat(t,t,t,t,t))};var t}(e),r)}};t.exports={keccak256:u(256),keccak512:u(512),keccak256s:u(256),keccak512s:u(512)}},{}],135:[function(e,t,r){const n=e("xtend"),i=e("json-rpc-random-id")();function o(e){this.currentProvider=e}function a(e){return function(){var t=[].slice.call(arguments),r=t.pop();this.sendAsync({method:e,params:t},r)}}function s(e,t){return function(){var r=[].slice.call(arguments),n=r.pop();r.lengtho)throw new Error("Elements exceed array size: "+o);for(d in h=[],e=e.slice(0,e.lastIndexOf("[")),"string"==typeof t&&(t=JSON.parse(t)),t)h.push(l(e,t[d]));if("dynamic"===o){var p=l("uint256",t.length);h.unshift(p)}return r.concat(h)}if("bytes"===e)return t=new r(t),h=r.concat([l("uint256",t.length),t]),t.length%32!=0&&(h=r.concat([h,n.zeros(32-t.length%32)])),h;if(e.startsWith("bytes")){if((o=s(e))<1||o>32)throw new Error("Invalid bytes width: "+o);return n.setLengthRight(t,32)}if(e.startsWith("uint")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid uint width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied uint exceeds width: "+o+" vs "+a.bitLength());if(a<0)throw new Error("Supplied uint is negative");return a.toArrayLike(r,"be",32)}if(e.startsWith("int")){if((o=s(e))%8||o<8||o>256)throw new Error("Invalid int width: "+o);if((a=f(t)).bitLength()>o)throw new Error("Supplied int exceeds width: "+o+" vs "+a.bitLength());return a.toTwos(256).toArrayLike(r,"be",32)}if(e.startsWith("ufixed")){if(o=u(e),(a=f(t))<0)throw new Error("Supplied ufixed is negative");return l("uint256",a.mul(new i(2).pow(new i(o[1]))))}if(e.startsWith("fixed"))return o=u(e),l("int256",f(t).mul(new i(2).pow(new i(o[1]))));throw new Error("Unsupported or invalid type: "+e)}function d(e,t,n){var o,a,s,u;if("string"==typeof e&&(e=p(e)),"address"===e.name)return d(e.rawType,t,n).toArrayLike(r,"be",20).toString("hex");if("bool"===e.name)return d(e.rawType,t,n).toString()===new i(1).toString();if("string"===e.name){var c=d(e.rawType,t,n);return new r(c,"utf8").toString()}if(e.isArray){for(s=[],o=e.size,"dynamic"===e.size&&(o=d("uint256",t,n=d("uint256",t,n).toNumber()).toNumber(),n+=32),u=0;ue.size)throw new Error("Decoded int exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("int")){if((a=new i(t.slice(n,n+32),16,"be").fromTwos(256)).bitLength()>e.size)throw new Error("Decoded uint exceeds width: "+e.size+" vs "+a.bitLength());return a}if(e.name.startsWith("ufixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("uint256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}if(e.name.startsWith("fixed")){if(o=new i(2).pow(new i(e.size[1])),!(a=d("int256",t,n)).mod(o).isZero())throw new Error("Decimals not supported yet");return a.div(o)}throw new Error("Unsupported or invalid type: "+e.name)}function p(e){var t,r,n;if(y(e)){t=c(e);var i=e.slice(0,e.lastIndexOf("["));return i=p(i),r={isArray:!0,name:e,size:t,memoryUsage:"dynamic"===t?32:i.memoryUsage*t,subArray:i}}switch(e){case"address":n="uint160";break;case"bool":n="uint8";break;case"string":n="bytes"}if(r={rawType:n,name:e,memoryUsage:32},e.startsWith("bytes")&&"bytes"!==e||e.startsWith("uint")||e.startsWith("int")?r.size=s(e):(e.startsWith("ufixed")||e.startsWith("fixed"))&&(r.size=u(e)),e.startsWith("bytes")&&"bytes"!==e&&(r.size<1||r.size>32))throw new Error("Invalid bytes width: "+r.size);if((e.startsWith("uint")||e.startsWith("int"))&&(r.size%8||r.size<8||r.size>256))throw new Error("Invalid int/uint width: "+r.size);return r}function b(e){return"string"===e||"bytes"===e||"dynamic"===c(e)}function y(e){return e.lastIndexOf("]")===e.length-1}function m(e,t){return e.startsWith("address")||e.startsWith("bytes")?"0x"+t.toString("hex"):t.toString()}o.eventID=function(e,t){var i=e+"("+t.map(a).join(",")+")";return n.sha3(new r(i))},o.methodID=function(e,t){return o.eventID(e,t).slice(0,4)},o.rawEncode=function(e,t){var n=[],i=[],o=0;e.forEach(function(e){if(y(e)){var t=c(e);o+="dynamic"!==t?32*t:32}else o+=32});for(var s=0;s32)throw new Error("Invalid bytes width: "+i);u.push(n.setLengthRight(l,i))}else if(h.startsWith("uint")){if((i=s(h))%8||i<8||i>256)throw new Error("Invalid uint width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied uint exceeds width: "+i+" vs "+o.bitLength());u.push(o.toArrayLike(r,"be",i/8))}else{if(!h.startsWith("int"))throw new Error("Unsupported or invalid type: "+h);if((i=s(h))%8||i<8||i>256)throw new Error("Invalid int width: "+i);if((o=f(l)).bitLength()>i)throw new Error("Supplied int exceeds width: "+i+" vs "+o.bitLength());u.push(o.toTwos(i).toArrayLike(r,"be",i/8))}}return r.concat(u)},o.soliditySHA3=function(e,t){return n.sha3(o.solidityPack(e,t))},o.soliditySHA256=function(e,t){return n.sha256(o.solidityPack(e,t))},o.solidityRIPEMD160=function(e,t){return n.ripemd160(o.solidityPack(e,t),!0)},o.fromSerpent=function(e){for(var t,r=[],n=0;n="0"&&t<="9");)o+=e[a]-"0",a++;n=a-1,r.push(o)}else if("i"===i)r.push("int256");else{if("a"!==i)throw new Error("Unsupported or invalid type: "+i);r.push("int256[]")}}return r},o.toSerpent=function(e){for(var t=[],r=0;r0){var r=this.raw.slice();this.v=this._chainId,this.r=0,this.s=0,t=this.raw,this.raw=r}else t=this.raw.slice(0,6);return n.rlphash(t)},e.prototype.getChainId=function(){return this._chainId},e.prototype.getSenderAddress=function(){if(this._from)return this._from;var e=this.getSenderPublicKey();return this._from=n.publicToAddress(e),this._from},e.prototype.getSenderPublicKey=function(){if(!(this._senderPubKey&&this._senderPubKey.length||this.verifySignature()))throw new Error("Invalid Signature");return this._senderPubKey},e.prototype.verifySignature=function(){var e=this.hash(!1);if(this._homestead&&1===new o(this.s).cmp(a))return!1;try{var t=n.bufferToInt(this.v);this._chainId>0&&(t-=2*this._chainId+8),this._senderPubKey=n.ecrecover(e,t,this.r,this.s)}catch(e){return!1}return!!this._senderPubKey},e.prototype.sign=function(e){var t=this.hash(!1),r=n.ecsign(t,e);this._chainId>0&&(r.v+=2*this._chainId+8),Object.assign(this,r)},e.prototype.getDataFee=function(){for(var e=this.raw[5],t=new o(0),r=0;r0&&t.push(["gas limit is too low. Need at least "+this.getBaseFee()]),void 0===e||!1===e?0===t.length:t.join(" ")},e}();t.exports=s}).call(this,e("buffer").Buffer)},{buffer:84,"ethereum-common/params.json":137,"ethereumjs-util":141}],141:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("keccak"),o=e("secp256k1"),a=e("assert"),s=e("rlp"),u=e("bn.js"),c=e("create-hash"),f=e("safe-buffer").Buffer;Object.assign(r,e("ethjs-util")),r.MAX_INTEGER=new u("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16),r.TWO_POW256=new u("10000000000000000000000000000000000000000000000000000000000000000",16),r.KECCAK256_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",r.SHA3_NULL_S=r.KECCAK256_NULL_S,r.KECCAK256_NULL=f.from(r.KECCAK256_NULL_S,"hex"),r.SHA3_NULL=r.KECCAK256_NULL,r.KECCAK256_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",r.SHA3_RLP_ARRAY_S=r.KECCAK256_RLP_ARRAY_S,r.KECCAK256_RLP_ARRAY=f.from(r.KECCAK256_RLP_ARRAY_S,"hex"),r.SHA3_RLP_ARRAY=r.KECCAK256_RLP_ARRAY,r.KECCAK256_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",r.SHA3_RLP_S=r.KECCAK256_RLP_S,r.KECCAK256_RLP=f.from(r.KECCAK256_RLP_S,"hex"),r.SHA3_RLP=r.KECCAK256_RLP,r.BN=u,r.rlp=s,r.secp256k1=o,r.zeros=function(e){return f.allocUnsafe(e).fill(0)},r.zeroAddress=function(){var e=r.zeros(20);return r.bufferToHex(e)},r.setLengthLeft=r.setLength=function(e,t,n){var i=r.zeros(t);return e=r.toBuffer(e),n?e.length0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e},r.toBuffer=function(e){if(!f.isBuffer(e))if(Array.isArray(e))e=f.from(e);else if("string"==typeof e)e=r.isHexString(e)?f.from(r.padToEven(r.stripHexPrefix(e)),"hex"):f.from(e);else if("number"==typeof e)e=r.intToBuffer(e);else if(null==e)e=f.allocUnsafe(0);else if(u.isBN(e))e=e.toArrayLike(f);else{if(!e.toArray)throw new Error("invalid type");e=f.from(e.toArray())}return e},r.bufferToInt=function(e){return new u(r.toBuffer(e)).toNumber()},r.bufferToHex=function(e){return"0x"+(e=r.toBuffer(e)).toString("hex")},r.fromSigned=function(e){return new u(e).fromTwos(256)},r.toUnsigned=function(e){return f.from(e.toTwos(256).toArray())},r.keccak=function(e,t){return e=r.toBuffer(e),t||(t=256),i("keccak"+t).update(e).digest()},r.keccak256=function(e){return r.keccak(e)},r.sha3=r.keccak,r.sha256=function(e){return e=r.toBuffer(e),c("sha256").update(e).digest()},r.ripemd160=function(e,t){e=r.toBuffer(e);var n=c("rmd160").update(e).digest();return!0===t?r.setLength(n,32):n},r.rlphash=function(e){return r.keccak(s.encode(e))},r.isValidPrivate=function(e){return o.privateKeyVerify(e)},r.isValidPublic=function(e,t){return 64===e.length?o.publicKeyVerify(f.concat([f.from([4]),e])):!!t&&o.publicKeyVerify(e)},r.pubToAddress=r.publicToAddress=function(e,t){return e=r.toBuffer(e),t&&64!==e.length&&(e=o.publicKeyConvert(e,!1).slice(1)),a(64===e.length),r.keccak(e).slice(-20)};var h=r.privateToPublic=function(e){return e=r.toBuffer(e),o.publicKeyCreate(e,!1).slice(1)};r.importPublic=function(e){return 64!==(e=r.toBuffer(e)).length&&(e=o.publicKeyConvert(e,!1).slice(1)),e},r.ecsign=function(e,t){var r=o.sign(e,t),n={};return n.r=r.signature.slice(0,32),n.s=r.signature.slice(32,64),n.v=r.recovery+27,n},r.hashPersonalMessage=function(e){var t=r.toBuffer("Ethereum Signed Message:\n"+e.length.toString());return r.keccak(f.concat([t,e]))},r.ecrecover=function(e,t,n,i){var a=f.concat([r.setLength(n,32),r.setLength(i,32)],64),s=t-27;if(0!==s&&1!==s)throw new Error("Invalid signature v value");var u=o.recover(e,a,s);return o.publicKeyConvert(u,!1).slice(1)},r.toRpcSig=function(e,t,n){if(27!==e&&28!==e)throw new Error("Invalid recovery id");return r.bufferToHex(f.concat([r.setLengthLeft(t,32),r.setLengthLeft(n,32),r.toBuffer(e-27)]))},r.fromRpcSig=function(e){if(65!==(e=r.toBuffer(e)).length)throw new Error("Invalid signature length");var t=e[64];return t<27&&(t+=27),{v:t,r:e.slice(0,32),s:e.slice(32,64)}},r.privateToAddress=function(e){return r.publicToAddress(h(e))},r.isValidAddress=function(e){return/^0x[0-9a-fA-F]{40}$/.test(e)},r.isZeroAddress=function(e){return r.zeroAddress()===r.addHexPrefix(e)},r.toChecksumAddress=function(e){e=r.stripHexPrefix(e).toLowerCase();for(var t=r.keccak(e).toString("hex"),n="0x",i=0;i=8?n+=e[i].toUpperCase():n+=e[i];return n},r.isValidChecksumAddress=function(e){return r.isValidAddress(e)&&r.toChecksumAddress(e)===e},r.generateAddress=function(e,t){return e=r.toBuffer(e),t=(t=new u(t)).isZero()?null:f.from(t.toArray()),r.rlphash([e,t]).slice(-20)},r.isPrecompiled=function(e){var t=r.unpad(e);return 1===t.length&&t[0]>=1&&t[0]<=8},r.addHexPrefix=function(e){return"string"!=typeof e?e:r.isHexPrefixed(e)?e:"0x"+e},r.isValidSignature=function(e,t,r,n){var i=new u("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16),o=new u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16);return 32===t.length&&32===r.length&&((27===e||28===e)&&(t=new u(t),r=new u(r),!(t.isZero()||t.gt(o)||r.isZero()||r.gt(o))&&(!1!==n||1!==new u(r).cmp(i))))},r.baToJSON=function(e){if(f.isBuffer(e))return"0x"+e.toString("hex");if(e instanceof Array){for(var t=[],n=0;n=i.length,"The field "+t.name+" must not have more "+t.length+" bytes")):t.allowZero&&0===i.length||!t.length||a(t.length===i.length,"The field "+t.name+" must have byte length of "+t.length),e.raw[n]=i}e._fields.push(t.name),Object.defineProperty(e,t.name,{enumerable:!0,configurable:!0,get:i,set:o}),t.default&&(e[t.name]=t.default),t.alias&&Object.defineProperty(e,t.alias,{enumerable:!1,configurable:!0,set:o,get:i})}),i)if("string"==typeof i&&(i=f.from(r.stripHexPrefix(i),"hex")),f.isBuffer(i)&&(i=s.decode(i)),Array.isArray(i)){if(i.length>e._fields.length)throw new Error("wrong number of fields in data");i.forEach(function(t,n){e[e._fields[n]]=r.toBuffer(t)})}else{if("object"!==(void 0===i?"undefined":n(i)))throw new Error("invalid data");var o=Object.keys(i);t.forEach(function(t){-1!==o.indexOf(t.name)&&(e[t.name]=i[t.name]),-1!==o.indexOf(t.alias)&&(e[t.alias]=i[t.alias])})}}},{assert:19,"bn.js":53,"create-hash":91,"ethjs-util":155,keccak:195,rlp:289,"safe-buffer":290,secp256k1:295}],142:[function(e,t,r){arguments[4][128][0].apply(r,arguments)},{_process:257,dup:128}],143:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var a=e("./address"),s=e("./bignumber"),u=e("./bytes"),c=e("./utf8"),f=e("./properties"),h=o(e("./errors")),l=new RegExp(/^bytes([0-9]*)$/),d=new RegExp(/^(u?int)([0-9]*)$/),p=new RegExp(/^(.*)\[([0-9]*)\]$/);r.defaultCoerceFunc=function(e,t){var r=e.match(d);return r&&parseInt(r[2])<=48?t.toNumber():t};var b=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"),y=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function m(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}function v(e,t){function r(t){throw new Error('unexpected character "'+e[t]+'" at position '+t+' in "'+e+'"')}for(var n={type:"",name:"",state:{allowType:!0}},i=n,o=0;o1){var i=r[1].match(b);if(""!=i[1].trim()||""!=i[3].trim())throw new Error("unexpected tokens");L(i[2]).forEach(function(e){t.outputs.push(v(e))})}return t}(e.trim()));throw new Error("unknown signature")};var w=function(){return function(e,t,r,n,i){this.coerceFunc=e,this.name=t,this.type=r,this.localName=n,this.dynamic=i}}(),_=function(e){function t(t){var r=e.call(this,t.coerceFunc,t.name,t.type,void 0,t.dynamic)||this;return f.defineReadOnly(r,"coder",t),r}return i(t,e),t.prototype.encode=function(e){return this.coder.encode(e)},t.prototype.decode=function(e,t){return this.coder.decode(e,t)},t}(w),A=function(e){function t(t,r){return e.call(this,t,"null","",r,!1)||this}return i(t,e),t.prototype.encode=function(e){return u.arrayify([])},t.prototype.decode=function(e,t){if(t>e.length)throw new Error("invalid null");return{consumed:0,value:this.coerceFunc("null",void 0)}},t}(w),E=function(e){function t(t,r,n,i){var o=this,a=(n?"int":"uint")+8*r;return(o=e.call(this,t,a,a,i,!1)||this).size=r,o.signed=n,o}return i(t,e),t.prototype.encode=function(e){try{var t=s.bigNumberify(e);return t=t.toTwos(8*this.size).maskn(8*this.size),this.signed&&(t=t.fromTwos(8*this.size).toTwos(256)),u.padZeros(u.arrayify(t),32)}catch(t){h.throwError("invalid number value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:e})}return null},t.prototype.decode=function(e,t){e.length32)throw new Error;t.set(r)}catch(t){h.throwError("invalid "+this.name+" value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:this.name,value:t.value||e})}return t},t.prototype.decode=function(e,t){return e.length=0?n:"")+"]",s=-1===n||r.dynamic;return(o=e.call(this,t,"array",a,i,s)||this).coder=r,o.length=n,o}return i(t,e),t.prototype.encode=function(e){Array.isArray(e)||h.throwError("expected array value",h.INVALID_ARGUMENT,{arg:this.localName,coderType:"array",value:e});var t=this.length,r=new Uint8Array(0);-1===t&&(t=e.length,r=x.encode(t)),h.checkArgumentCount(t,e.length,"in coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i256||i%8!=0)&&h.throwError("invalid "+r[1]+" bit length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new E(e,i/8,"int"===r[1],t.name);if(r=t.type.match(l))return(0===(i=parseInt(r[1]))||i>32)&&h.throwError("invalid bytes length",h.INVALID_ARGUMENT,{arg:"param",value:t}),new S(e,i,t.name);if(r=t.type.match(p)){var i=parseInt(r[2]||"-1");return(t=f.jsonCopy(t)).type=r[1],new N(e,D(e,t),i,t.name)}return"tuple"===t.type.substring(0,5)?function(e,t,r){t||(t=[]);var n=[];return t.forEach(function(t){n.push(D(e,t))}),new R(e,n,r)}(e,t.components,t.name):""===t.type?new A(e,t.name):(h.throwError("invalid type",h.INVALID_ARGUMENT,{arg:"type",value:t.type}),null)}var F=function(){function e(t){h.checkNew(this,e),t||(t=r.defaultCoerceFunc),f.defineReadOnly(this,"coerceFunc",t)}return e.prototype.encode=function(e,t){e.length!==t.length&&h.throwError("types/values length mismatch",h.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):e,r.push(D(this.coerceFunc,t))},this),u.hexlify(new R(this.coerceFunc,r,"_").encode(t))},e.prototype.decode=function(e,t){var r=[];return e.forEach(function(e){var t=null;t="string"==typeof e?v(e):f.jsonCopy(e),r.push(D(this.coerceFunc,t))},this),new R(this.coerceFunc,r,"_").decode(u.arrayify(t),0).value},e}();r.AbiCoder=F,r.defaultAbiCoder=new F},{"./address":144,"./bignumber":145,"./bytes":146,"./errors":147,"./properties":149,"./utf8":152}],144:[function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var i=n(e("bn.js")),o=e("./bytes"),a=e("./keccak256"),s=e("./rlp"),u=e("./errors");function c(e){"string"==typeof e&&e.match(/^0x[0-9A-Fa-f]{40}$/)||u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=o.arrayify(a.keccak256(r));for(var i=0;i<40;i+=2)r[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(15&r[i>>1])>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}for(var f={},h=0;h<10;h++)f[String(h)]=String(h);for(h=0;h<26;h++)f[String.fromCharCode(65+h)]=String(10+h);var l,d=Math.floor((l=9007199254740991,Math.log10?Math.log10(l):Math.log(l)/Math.LN10));function p(e){e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00";var t="";for(e.split("").forEach(function(e){t+=f[e]});t.length>=d;){var r=t.substring(0,d);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function b(e){var t=null;if("string"!=typeof e&&u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e}),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=c(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&u.throwError("bad address checksum",u.INVALID_ARGUMENT,{arg:"address",value:e});else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==p(e)&&u.throwError("bad icap checksum",u.INVALID_ARGUMENT,{arg:"address",value:e}),t=new i.default.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=c("0x"+t)}else u.throwError("invalid address",u.INVALID_ARGUMENT,{arg:"address",value:e});return t}r.getAddress=b,r.getIcapAddress=function(e){for(var t=new i.default.BN(b(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+p("XE00"+t)+t},r.getContractAddress=function(e){if(!e.from)throw new Error("missing from address");var t=e.nonce;return b("0x"+a.keccak256(s.encode([b(e.from),o.stripZeros(o.hexlify(t))])).substring(26))}},{"./bytes":146,"./errors":147,"./keccak256":148,"./rlp":150,"bn.js":53}],145:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var s=o(e("bn.js")),u=e("./bytes"),c=e("./properties"),f=e("./types"),h=a(e("./errors")),l=new s.default.BN(-1);function d(e){var t=e.toString(16);return"-"===t[0]?t.length%2==0?"-0x0"+t.substring(1):"-0x"+t.substring(1):t.length%2==1?"0x0"+t:"0x"+t}function p(e){return m(e)._bn}function b(e){return new y(d(e))}var y=function(e){function t(r){var n=e.call(this)||this;if(h.checkNew(n,t),"string"==typeof r)u.isHexString(r)?("0x"==r&&(r="0x0"),c.defineReadOnly(n,"_hex",r)):"-"===r[0]&&u.isHexString(r.substring(1))?c.defineReadOnly(n,"_hex",r):r.match(/^-?[0-9]*$/)?(""==r&&(r="0"),c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))):h.throwError("invalid BigNumber string value",h.INVALID_ARGUMENT,{arg:"value",value:r});else if("number"==typeof r){parseInt(String(r))!==r&&h.throwError("underflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"underflow",value:r,outputValue:parseInt(String(r))});try{c.defineReadOnly(n,"_hex",d(new s.default.BN(r)))}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}}else r instanceof t?c.defineReadOnly(n,"_hex",r._hex):r.toHexString?c.defineReadOnly(n,"_hex",d(p(r.toHexString()))):u.isArrayish(r)?c.defineReadOnly(n,"_hex",d(new s.default.BN(u.hexlify(r).substring(2),16))):h.throwError("invalid BigNumber value",h.INVALID_ARGUMENT,{arg:"value",value:r});return n}return i(t,e),Object.defineProperty(t.prototype,"_bn",{get:function(){return"-"===this._hex[0]?new s.default.BN(this._hex.substring(3),16).mul(l):new s.default.BN(this._hex.substring(2),16)},enumerable:!0,configurable:!0}),t.prototype.fromTwos=function(e){return b(this._bn.fromTwos(e))},t.prototype.toTwos=function(e){return b(this._bn.toTwos(e))},t.prototype.add=function(e){return b(this._bn.add(p(e)))},t.prototype.sub=function(e){return b(this._bn.sub(p(e)))},t.prototype.div=function(e){return m(e).isZero()&&h.throwError("division by zero",h.NUMERIC_FAULT,{operation:"divide",fault:"division by zero"}),b(this._bn.div(p(e)))},t.prototype.mul=function(e){return b(this._bn.mul(p(e)))},t.prototype.mod=function(e){return b(this._bn.mod(p(e)))},t.prototype.pow=function(e){return b(this._bn.pow(p(e)))},t.prototype.maskn=function(e){return b(this._bn.maskn(e))},t.prototype.eq=function(e){return this._bn.eq(p(e))},t.prototype.lt=function(e){return this._bn.lt(p(e))},t.prototype.lte=function(e){return this._bn.lte(p(e))},t.prototype.gt=function(e){return this._bn.gt(p(e))},t.prototype.gte=function(e){return this._bn.gte(p(e))},t.prototype.isZero=function(){return this._bn.isZero()},t.prototype.toNumber=function(){try{return this._bn.toNumber()}catch(e){h.throwError("overflow",h.NUMERIC_FAULT,{operation:"setValue",fault:"overflow",details:e.message})}return null},t.prototype.toString=function(){return this._bn.toString(10)},t.prototype.toHexString=function(){return this._hex},t}(f.BigNumber);function m(e){return e instanceof y?e:new y(e)}r.bigNumberify=m,r.ConstantNegativeOne=m(-1),r.ConstantZero=m(0),r.ConstantOne=m(1),r.ConstantTwo=m(2),r.ConstantWeiPerEther=m("1000000000000000000")},{"./bytes":146,"./errors":147,"./properties":149,"./types":151,"bn.js":53}],146:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./errors");function i(e){return!!e._bn}function o(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return new Uint8Array(Array.prototype.slice.apply(e,t))},e)}function a(e){if(!e||parseInt(String(e.length))!=e.length||"string"==typeof e)return!1;for(var t=0;t=256||parseInt(String(r))!=r)return!1}return!0}function s(e){if(null==e&&n.throwError("cannot convert null value to array",n.INVALID_ARGUMENT,{arg:"value",value:e}),i(e)&&(e=e.toHexString()),"string"==typeof e){var t=e.match(/^(0x)?[0-9a-fA-F]*$/);t||n.throwError("invalid hexidecimal string",n.INVALID_ARGUMENT,{arg:"value",value:e}),"0x"!==t[1]&&n.throwError("hex string must have 0x prefix",n.INVALID_ARGUMENT,{arg:"value",value:e}),(e=e.substring(2)).length%2&&(e="0"+e);for(var r=[],s=0;s>4]+f[15&u])}return"0x"+o.join("")}return n.throwError("invalid hexlify value",null,{arg:"value",value:e}),"never"}function l(e,t){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length<2*t+2;)e="0x0"+e.substring(2);return e}function d(e){var t,r=0,i="0x",o="0x";if((t=e)&&null!=t.r&&null!=t.s){null==e.v&&null==e.recoveryParam&&n.throwError("at least on of recoveryParam or v must be specified",n.INVALID_ARGUMENT,{argument:"signature",value:e}),i=l(e.r,32),o=l(e.s,32),"string"==typeof(r=e.v)&&(r=parseInt(r,16));var a=e.recoveryParam;null==a&&null!=e.v&&(a=1-r%2),r=27+a}else{var u=s(e);if(65!==u.length)throw new Error("invalid signature");i=h(u.slice(0,32)),o=h(u.slice(32,64)),27!==(r=u[64])&&28!==r&&(r=27+r%2)}return{r:i,s:o,recoveryParam:r-27,v:r}}r.hexlify=h,r.hexDataLength=function(e){return c(e)&&e.length%2==0?(e.length-2)/2:null},r.hexDataSlice=function(e,t,r){return c(e)||n.throwError("invalid hex data",n.INVALID_ARGUMENT,{arg:"value",value:e}),e.length%2!=0&&n.throwError("hex data length must be even",n.INVALID_ARGUMENT,{arg:"value",value:e}),t=2+2*t,null!=r?"0x"+e.substring(t,t+2*r):"0x"+e.substring(t)},r.hexStripZeros=function(e){for(c(e)||n.throwError("invalid hex string",n.INVALID_ARGUMENT,{arg:"value",value:e});e.length>3&&"0x0"===e.substring(0,3);)e="0x"+e.substring(3);return e},r.hexZeroPad=l,r.splitSignature=d,r.joinSignature=function(e){return h(u([(e=d(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}},{"./errors":147}],147:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.MISSING_NEW="MISSING_NEW",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.NUMERIC_FAULT="NUMERIC_FAULT",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION";var n=!1,i=!1;function o(e,t,n){if(i)throw new Error("unknown error");t||(t=r.UNKNOWN_ERROR),n||(n={});var o=[];Object.keys(n).forEach(function(e){try{o.push(e+"="+JSON.stringify(n[e]))}catch(t){o.push(e+"="+JSON.stringify(n[e].toString()))}});var a=e;o.length&&(e+=" ("+o.join(", ")+")");var s=new Error(e);throw s.reason=a,s.code=t,Object.keys(n).forEach(function(e){s[e]=n[e]}),s}r.throwError=o,r.checkNew=function(e,t){e instanceof t||o("missing new",r.MISSING_NEW,{name:t.name})},r.checkArgumentCount=function(e,t,n){n||(n=""),et&&o("too many arguments"+n,r.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})},r.setCensorship=function(e,t){n&&o("error censorship permanent",r.UNSUPPORTED_OPERATION,{operation:"setCersorship"}),i=!!e,n=!!t}},{}],148:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("js-sha3"),i=e("./bytes");r.keccak256=function(e){return"0x"+n.keccak_256(i.arrayify(e))}},{"./bytes":146,"js-sha3":142}],149:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defineReadOnly=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})},r.defineFrozen=function(e,t,r){var n=JSON.stringify(r);Object.defineProperty(e,t,{enumerable:!0,get:function(){return JSON.parse(n)}})},r.resolveProperties=function(e){var t={},r=[];return Object.keys(e).forEach(function(n){var i=e[n];i instanceof Promise?r.push(i.then(function(e){return t[n]=e,null})):t[n]=i}),Promise.all(r).then(function(){return t})},r.shallowCopy=function(e){var t={};for(var r in e)t[r]=e[r];return t},r.jsonCopy=function(e){return JSON.parse(JSON.stringify(e))}},{}],150:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./bytes");function i(e){for(var t=[];e;)t.unshift(255&e),e>>=8;return t}function o(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function s(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(r=e[t]-247)>e.length)throw new Error("too short");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("to short");return a(e,t,t+1+r,r+i)}if(e[t]>=192){if(t+1+(i=e[t]-192)>e.length)throw new Error("invalid rlp data");return a(e,t,t+1,i)}if(e[t]>=184){var r;if(t+1+(r=e[t]-183)>e.length)throw new Error("invalid rlp data");if(t+1+r+(i=o(e,t+1,r))>e.length)throw new Error("invalid rlp data");return{consumed:1+r+i,result:n.hexlify(e.slice(t+1+r,t+1+r+i))}}if(e[t]>=128){var i;if(t+1+(i=e[t]-128)>e.length)throw new Error("invlaid rlp data");return{consumed:1+i,result:n.hexlify(e.slice(t+1,t+1+i))}}return{consumed:1,result:n.hexlify(e[t])}}r.encode=function(e){return n.hexlify(function e(t){if(Array.isArray(t)){var r=[];return t.forEach(function(t){r=r.concat(e(t))}),r.length<=55?(r.unshift(192+r.length),r):((o=i(r.length)).unshift(247+o.length),o.concat(r))}var o,a=Array.prototype.slice.call(n.arrayify(t));return 1===a.length&&a[0]<=127?a:a.length<=55?(a.unshift(128+a.length),a):((o=i(a.length)).unshift(183+o.length),o.concat(a))}(e))},r.decode=function(e){var t=n.arrayify(e),r=s(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}},{"./bytes":146}],151:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=function(){return function(){}}();r.BigNumber=n;var i=function(){return function(){}}();r.Indexed=i;var o=function(){return function(){}}();r.MinimalProvider=o;var a=function(){return function(){}}();r.Signer=a;var s=function(){return function(){}}();r.HDNode=s},{}],152:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,i=e("./bytes");!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(n=r.UnicodeNormalizationForm||(r.UnicodeNormalizationForm={})),r.toUtf8Bytes=function(e,t){void 0===t&&(t=n.current),t!=n.current&&(e=e.normalize(t));for(var r=[],o=0,a=0;a>6|192,r[o++]=63&s|128):55296==(64512&s)&&a+1>18|240,r[o++]=s>>12&63|128,r[o++]=s>>6&63|128,r[o++]=63&s|128):(r[o++]=s>>12|224,r[o++]=s>>6&63|128,r[o++]=63&s|128)}return i.arrayify(r)},r.toUtf8String=function(e){e=i.arrayify(e);for(var t="",r=0;r>7!=0){if(n>>6!=2){var o=null;if(n>>5==6)o=1;else if(n>>4==14)o=2;else if(n>>3==30)o=3;else if(n>>2==62)o=4;else{if(n>>1!=126)continue;o=5}if(r+o>e.length){for(;r>6==2;r++);if(r!=e.length)continue;return t}var a,s=n&(1<<8-o-1)-1;for(a=0;a>6!=2)break;s=s<<6|63&u}a==o?s<=65535?t+=String.fromCharCode(s):(s-=65536,t+=String.fromCharCode(55296+(s>>10&1023),56320+(1023&s))):r--}}else t+=String.fromCharCode(n)}return t}},{"./bytes":146}],153:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("number-to-bn"),o=new n(0),a=new n(-1),s={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",Gwei:"1000000000",shannon:"1000000000",nanoether:"1000000000",nano:"1000000000",szabo:"1000000000000",microether:"1000000000000",micro:"1000000000000",finney:"1000000000000000",milliether:"1000000000000000",milli:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"};function u(e){var t=e?e.toLowerCase():"ether",r=s[t];if("string"!=typeof r)throw new Error("[ethjs-unit] the unit provided "+e+" doesn't exists, please use the one of the following units "+JSON.stringify(s,null,2));return new n(r,10)}function c(e){if("string"==typeof e){if(!e.match(/^-?[0-9.]+$/))throw new Error("while converting number to string, invalid number value '"+e+"', should be a number matching (^-?[0-9.]+).");return e}if("number"==typeof e)return String(e);if("object"==typeof e&&e.toString&&(e.toTwos||e.dividedToIntegerBy))return e.toPrecision?String(e.toPrecision()):e.toString(10);throw new Error("while converting number to string, invalid number value '"+e+"' type "+typeof e+".")}t.exports={unitMap:s,numberToString:c,getValueOfUnit:u,fromWei:function(e,t,r){var n=i(e),c=n.lt(o),f=u(t),h=s[t].length-1||1,l=r||{};c&&(n=n.mul(a));for(var d=n.mod(f).toString(10);d.length2)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal points");var l=h[0],d=h[1];if(l||(l="0"),d||(d="0"),d.length>o)throw new Error("[ethjs-unit] while converting number "+e+" to wei, too many decimal places");for(;d.length=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&a}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),f=this.clone();if(u){for(s=0;!f.isZero();s++)a=f.andln(255),f.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,b=d>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,A=0|a[4],E=8191&A,x=A>>>13,k=0|a[5],S=8191&k,M=k>>>13,I=0|a[6],T=8191&I,U=I>>>13,j=0|a[7],B=8191&j,P=j>>>13,C=0|a[8],N=8191&C,R=C>>>13,L=0|a[9],O=8191&L,D=L>>>13,F=0|s[0],q=8191&F,H=F>>>13,z=0|s[1],K=8191&z,V=z>>>13,G=0|s[2],W=8191&G,Y=G>>>13,X=0|s[3],Z=8191&X,J=X>>>13,$=0|s[4],Q=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],he=8191&fe,le=fe>>>13,de=0|s[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(l,q)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,H))+Math.imul(b,q)|0,o=Math.imul(b,H);var me=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,H))+Math.imul(v,q)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,V)|0;var ve=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,W)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,H))+Math.imul(_,q)|0,o=Math.imul(_,H),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,Y)|0;var ge=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,H))+Math.imul(x,q)|0,o=Math.imul(x,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var we=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,q),i=(i=Math.imul(S,H))+Math.imul(M,q)|0,o=Math.imul(M,H),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,H))+Math.imul(U,q)|0,o=Math.imul(U,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ae=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ae)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,ae)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,H))+Math.imul(P,q)|0,o=Math.imul(P,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ee=(c+(n=n+Math.imul(h,ue)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,H))+Math.imul(R,q)|0,o=Math.imul(R,H),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(U,W)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0;var xe=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,H))+Math.imul(D,q)|0,o=Math.imul(D,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var ke=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,V))+Math.imul(D,K)|0,o=Math.imul(D,V),n=n+Math.imul(N,W)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,Y))+Math.imul(D,W)|0,o=Math.imul(D,Y),n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,J))+Math.imul(D,Z)|0,o=Math.imul(D,J),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(U,ue)|0,o=o+Math.imul(U,ce)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Te=(c+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(O,re),i=(i=Math.imul(O,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,le)|0;var Ue=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,n=Math.imul(O,oe),i=(i=Math.imul(O,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var je=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(U,pe)|0))<<13)|0;c=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(O,ue),i=(i=Math.imul(O,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(O,he),i=(i=Math.imul(O,le))+Math.imul(D,he)|0,o=Math.imul(D,le);var Pe=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863;var Ce=(c+(n=Math.imul(O,pe))|0)+((8191&(i=(i=Math.imul(O,be))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,be))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=ye,u[1]=me,u[2]=ve,u[3]=ge,u[4]=we,u[5]=_e,u[6]=Ae,u[7]=Ee,u[8]=xe,u[9]=ke,u[10]=Se,u[11]=Me,u[12]=Ie,u[13]=Te,u[14]=Ue,u[15]=je,u[16]=Be,u[17]=Pe,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/a|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(h)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var b=d,y=0;0!==b.cmp(s);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===f)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,A),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{}],155:[function(e,t,r){(function(r){"use strict";var n=e("is-hex-prefixed"),i=e("strip-hex-prefix");function o(e){var t=e;if("string"!=typeof t)throw new Error("[ethjs-util] while padding to even, value must be string, is currently "+typeof t+", while padToEven.");return t.length%2&&(t="0"+t),t}function a(e){return"0x"+e.toString(16)}t.exports={arrayContainsArray:function(e,t,r){if(!0!==Array.isArray(e))throw new Error("[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '"+typeof e+"'");if(!0!==Array.isArray(t))throw new Error("[ethjs-util] method arrayContainsArray requires input 'subset' to be an array got type '"+typeof t+"'");return t[Boolean(r)?"some":"every"](function(t){return e.indexOf(t)>=0})},intToBuffer:function(e){var t=a(e);return new r(o(t.slice(2)),"hex")},getBinarySize:function(e){if("string"!=typeof e)throw new Error("[ethjs-util] while getting binary size, method getBinarySize requires input 'str' to be type String, got '"+typeof e+"'.");return r.byteLength(e,"utf8")},isHexPrefixed:n,stripHexPrefix:i,padToEven:o,intToHex:a,fromAscii:function(e){for(var t="",r=0;r0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var r,n,a,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(r=this._events[e]).length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=a;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){n=s;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],158:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("md5.js");t.exports=function(e,t,r,o){if(n.isBuffer(e)||(e=n.from(e,"binary")),t&&(n.isBuffer(t)||(t=n.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var a=r/8,s=n.alloc(a),u=n.alloc(o||0),c=n.alloc(0);a>0||o>0;){var f=new i;f.update(c),f.update(e),t&&f.update(t),c=f.digest();var h=0;if(a>0){var l=s.length-a;h=Math.min(a,c.length),c.copy(s,l,0,h),a-=h}if(h0){var d=u.length-o,p=Math.min(o,c.length-h);c.copy(u,d,h,h+p),o-=p}}return c.fill(0),{key:s,iv:u}}},{"md5.js":231,"safe-buffer":290}],159:[function(e,t,r){"use strict";var n=e("is-callable"),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.exports=function(e,t,r){if(!n(t))throw new TypeError("iterator must be a function");var a;arguments.length>=3&&(a=r),"[object Array]"===i.call(e)?function(e,t,r){for(var n=0,i=e.length;n=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},i.prototype._update=function(e){throw new Error("_update is not implemented")},i.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();return void 0!==e&&(t=t.toString(e)),t},i.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=i}).call(this,e("buffer").Buffer)},{buffer:84,inherits:180,stream:311}],162:[function(e,t,r){var n=r;n.utils=e("./hash/utils"),n.common=e("./hash/common"),n.sha=e("./hash/sha"),n.ripemd=e("./hash/ripemd"),n.hmac=e("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":163,"./hash/hmac":164,"./hash/ripemd":165,"./hash/sha":166,"./hash/utils":173}],163:[function(e,t,r){"use strict";var n=e("./utils"),i=e("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},{"../utils":173}],173:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits");function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function s(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=i,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,a=255&i;o?r.push(o,a):r.push(a)}else for(n=0;n>>0}return a},r.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},r.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},r.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},r.sum64_lo=function(e,t,r,n){return t+n>>>0},r.sum64_4_hi=function(e,t,r,n,i,o,a,s){var u=0,c=t;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},r.sum64_5_hi=function(e,t,r,n,i,o,a,s,u,c){var f=0,h=t;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,n,i,o,a,s,u,c){return t+n+o+s+c>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:180,"minimalistic-assert":234}],174:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("minimalistic-crypto-utils"),o=e("minimalistic-assert");function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}t.exports=a,a.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},a.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length\\$%@ءؤة\"'^|~⦅⦆・ゥャ¢£¬¦¥₩│←↑→↓■○𐐨𐐩𐐪𐐫𐐬𐐭𐐮𐐯𐐰𐐱𐐲𐐳𐐴𐐵𐐶𐐷𐐸𐐹𐐺𐐻𐐼𐐽𐐾𐐿𐑀𐑁𐑂𐑃𐑄𐑅𐑆𐑇𐑈𐑉𐑊𐑋𐑌𐑍𐑎𐑏𐓘𐓙𐓚𐓛𐓜𐓝𐓞𐓟𐓠𐓡𐓢𐓣𐓤𐓥𐓦𐓧𐓨𐓩𐓪𐓫𐓬𐓭𐓮𐓯𐓰𐓱𐓲𐓳𐓴𐓵𐓶𐓷𐓸𐓹𐓺𐓻𐳀𐳁𐳂𐳃𐳄𐳅𐳆𐳇𐳈𐳉𐳊𐳋𐳌𐳍𐳎𐳏𐳐𐳑𐳒𐳓𐳔𐳕𐳖𐳗𐳘𐳙𐳚𐳛𐳜𐳝𐳞𐳟𐳠𐳡𐳢𐳣𐳤𐳥𐳦𐳧𐳨𐳩𐳪𐳫𐳬𐳭𐳮𐳯𐳰𐳱𐳲𑣀𑣁𑣂𑣃𑣄𑣅𑣆𑣇𑣈𑣉𑣊𑣋𑣌𑣍𑣎𑣏𑣐𑣑𑣒𑣓𑣔𑣕𑣖𑣗𑣘𑣙𑣚𑣛𑣜𑣝𑣞𑣟ıȷ∇∂𞤢𞤣𞤤𞤥𞤦𞤧𞤨𞤩𞤪𞤫𞤬𞤭𞤮𞤯𞤰𞤱𞤲𞤳𞤴𞤵𞤶𞤷𞤸𞤹𞤺𞤻𞤼𞤽𞤾𞤿𞥀𞥁𞥂𞥃ٮڡٯ字双多解交映無前後再新初終販声吹演投捕遊指禁空合満申割営配得可丽丸乁𠄢你侻倂偺備像㒞𠘺兔兤具𠔜㒹內𠕋冗冤仌冬𩇟刃㓟刻剆剷㔕包匆卉博即卽卿𠨬灰及叟𠭣叫叱吆咞吸呈周咢哶唐啓啣善喫喳嗂圖圗噑噴壮城埴堍型堲報墬𡓤売壷夆夢奢𡚨𡛪姬娛娧姘婦㛮嬈嬾𡧈寃寘寳𡬘寿将㞁屠峀岍𡷤嵃𡷦嵮嵫嵼巡巢㠯巽帨帽幩㡢𢆃㡼庰庳庶𪎒𢌱舁弢㣇𣊸𦇚形彫㣣徚忍志忹悁㤺㤜𢛔惇慈慌慺憲憤憯懞戛扝抱拔捐𢬌挽拼捨掃揤𢯱搢揅掩㨮摩摾撝摷㩬敬𣀊旣書晉㬙㬈㫤冒冕最暜肭䏙朡杞杓𣏃㭉柺枅桒𣑭梎栟椔楂榣槪檨𣚣櫛㰘次𣢧歔㱎歲殟殻𣪍𡴋𣫺汎𣲼沿泍汧洖派浩浸涅𣴞洴港湮㴳滇𣻑淹潮𣽞𣾎濆瀹瀛㶖灊災灷炭𠔥煅𤉣熜爨牐𤘈犀犕𤜵𤠔獺王㺬玥㺸瑇瑜璅瓊㼛甤𤰶甾𤲒𢆟瘐𤾡𤾸𥁄㿼䀈𥃳𥃲𥄙𥄳眞真瞋䁆䂖𥐝硎䃣𥘦𥚚𥛅秫䄯穊穏𥥼𥪧䈂𥮫篆築䈧𥲀糒䊠糨糣紀𥾆絣䌁緇縂繅䌴𦈨𦉇䍙𦋙罺𦌾羕翺𦓚𦔣聠𦖨聰𣍟䏕育脃䐋脾媵𦞧𦞵𣎓𣎜舄辞䑫芑芋芝劳花芳芽苦𦬼茝荣莭茣莽菧荓菊菌菜𦰶𦵫𦳕䔫蓱蓳蔖𧏊蕤𦼬䕝䕡𦾱𧃒䕫虐虧虩蚩蚈蜎蛢蜨蝫螆蟡蠁䗹衠𧙧裗裞䘵裺㒻𧢮𧥦䚾䛇誠𧲨貫賁贛起𧼯𠠄跋趼跰𠣞軔𨗒𨗭邔郱鄑𨜮鄛鈸鋗鋘鉼鏹鐕𨯺開䦕閷𨵷䧦雃嶲霣𩅅𩈚䩮䩶韠𩐊䪲𩒖頩𩖶飢䬳餩馧駂駾䯎𩬰鱀鳽䳎䳭鵧𪃎䳸𪄅𪈎𪊑䵖黾鼅鼏鼖𪘀",mapChar:function(r){return r>=196608?r>=917760&&r<=917999?18874368:0:e[t[r>>4]][15&r]}}},"function"==typeof define&&define.amd?define([],function(){return i()}):"object"==typeof r?t.exports=i():n.uts46_map=i()},{}],177:[function(e,t,r){var n,i;n=this,i=function(e,t){function r(r,n,i){for(var o=[],a=e.ucs2.decode(r),s=0;s>23,l=f>>21&3,d=f>>5&65535,p=31&f,b=t.mapStr.substr(d,p);if(0===l||n&&1&h)throw new Error("Illegal char "+c);1===l?o.push(b):2===l?o.push(i?b:c):3===l&&o.push(c)}return o.join("").normalize("NFC")}function n(t,n,o){void 0===o&&(o=!1);var a=r(t,o,n).split(".");return(a=a.map(function(t){return t.startsWith("xn--")?i(t=e.decode(t.substring(4)),o,!1):i(t,o,n),t})).join(".")}function i(e,n,i){if("-"===e[2]&&"-"===e[3])throw new Error("Failed to validate "+e);if(e.startsWith("-")||e.endsWith("-"))throw new Error("Failed to validate "+e);if(e.includes("."))throw new Error("Failed to validate "+e);if(r(e,n,i)!==e)throw new Error("Failed to validate "+e);var o=e.codePointAt(0);if(t.mapChar(o)&2<<23)throw new Error("Label contains illegal character: "+o)}return{toUnicode:function(e,t){return void 0===t&&(t={}),n(e,!1,"useStd3ASCII"in t&&t.useStd3ASCII)},toAscii:function(t,r){void 0===r&&(r={});var i,o=!("transitional"in r)||r.transitional,a="useStd3ASCII"in r&&r.useStd3ASCII,s="verifyDnsLength"in r&&r.verifyDnsLength,u=n(t,o,a).split(".").map(e.toASCII),c=u.join(".");if(s){if(c.length<1||c.length>253)throw new Error("DNS name has wrong length: "+c);for(i=0;i63)throw new Error("DNS label has wrong length: "+f)}}return c}}},"function"==typeof define&&define.amd?define(["punycode","./idna-map"],function(e,t){return i(e,t)}):"object"==typeof r?t.exports=i(e("punycode"),e("./idna-map")):n.uts46=i(n.punycode,n.idna_map)},{"./idna-map":176,punycode:265}],178:[function(e,t,r){r.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,f=-7,h=r?i-1:0,l=r?-1:1,d=e[t+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=s;f>0;o=256*o+e[t+h],h+=l,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+e[t+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=c}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var a,s,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(a++,u/=2),a+h>=f?(s=0,a=f):a+h>=1?(s=(t*u-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;e[r+d]=255&a,d+=p,a/=256,c-=8);e[r+d-p]|=128*b}},{}],179:[function(e,t,r){var n=[].indexOf;t.exports=function(e,t){if(n)return e.indexOf(t);for(var r=0;r-32e3)throw new Error("Invalid error code");if(!(this instanceof f))return new f(e);i.call(this,"Server error",e)};n(f,i),i.ParseError=o,i.InvalidRequest=a,i.MethodNotFound=s,i.InvalidParams=u,i.InternalError=c,i.ServerError=f,t.exports=i},{inherits:180}],191:[function(e,t,r){t.exports=function(e){var t=(e=e||{}).max||Number.MAX_SAFE_INTEGER,r=void 0!==e.start?e.start:Math.floor(Math.random()*t);return function(){return r%=t,r++}}},{}],192:[function(e,t,r){r.parse=e("./lib/parse"),r.stringify=e("./lib/stringify")},{"./lib/parse":193,"./lib/stringify":194}],193:[function(e,t,r){var n,i,o,a,s={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},u=function(e){throw{name:"SyntaxError",message:e,at:n,text:o}},c=function(e){return e&&e!==i&&u("Expected '"+e+"' instead of '"+i+"'"),i=o.charAt(n),n+=1,i},f=function(){var e,t="";for("-"===i&&(t="-",c("-"));i>="0"&&i<="9";)t+=i,c();if("."===i)for(t+=".";c()&&i>="0"&&i<="9";)t+=i;if("e"===i||"E"===i)for(t+=i,c(),"-"!==i&&"+"!==i||(t+=i,c());i>="0"&&i<="9";)t+=i,c();if(e=+t,isFinite(e))return e;u("Bad number")},h=function(){var e,t,r,n="";if('"'===i)for(;c();){if('"'===i)return c(),n;if("\\"===i)if(c(),"u"===i){for(r=0,t=0;t<4&&(e=parseInt(c(),16),isFinite(e));t+=1)r=16*r+e;n+=String.fromCharCode(r)}else{if("string"!=typeof s[i])break;n+=s[i]}else n+=i}u("Bad string")},l=function(){for(;i&&i<=" ";)c()};a=function(){switch(l(),i){case"{":return function(){var e,t={};if("{"===i){if(c("{"),l(),"}"===i)return c("}"),t;for(;i;){if(e=h(),l(),c(":"),Object.hasOwnProperty.call(t,e)&&u('Duplicate key "'+e+'"'),t[e]=a(),l(),"}"===i)return c("}"),t;c(","),l()}}u("Bad object")}();case"[":return function(){var e=[];if("["===i){if(c("["),l(),"]"===i)return c("]"),e;for(;i;){if(e.push(a()),l(),"]"===i)return c("]"),e;c(","),l()}}u("Bad array")}();case'"':return h();case"-":return f();default:return i>="0"&&i<="9"?f():function(){switch(i){case"t":return c("t"),c("r"),c("u"),c("e"),!0;case"f":return c("f"),c("a"),c("l"),c("s"),c("e"),!1;case"n":return c("n"),c("u"),c("l"),c("l"),null}u("Unexpected '"+i+"'")}()}},t.exports=function(e,t){var r;return o=e,n=0,i=" ",r=a(),l(),i&&u("Syntax error"),"function"==typeof t?function e(r,n){var i,o,a=r[n];if(a&&"object"==typeof a)for(i in a)Object.prototype.hasOwnProperty.call(a,i)&&(void 0!==(o=e(a,i))?a[i]=o:delete a[i]);return t.call(r,n,a)}({"":r},""):r}},{}],194:[function(e,t,r){var n,i,o,a=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,s={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function u(e){return a.lastIndex=0,a.test(e)?'"'+e.replace(a,function(e){var t=s[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}t.exports=function(e,t,r){var a;if(n="",i="","number"==typeof r)for(a=0;a>>31),p=l^(a<<1|o>>>31),b=e[0]^d,y=e[1]^p,m=e[10]^d,v=e[11]^p,g=e[20]^d,w=e[21]^p,_=e[30]^d,A=e[31]^p,E=e[40]^d,x=e[41]^p;d=r^(s<<1|u>>>31),p=i^(u<<1|s>>>31);var k=e[2]^d,S=e[3]^p,M=e[12]^d,I=e[13]^p,T=e[22]^d,U=e[23]^p,j=e[32]^d,B=e[33]^p,P=e[42]^d,C=e[43]^p;d=o^(c<<1|f>>>31),p=a^(f<<1|c>>>31);var N=e[4]^d,R=e[5]^p,L=e[14]^d,O=e[15]^p,D=e[24]^d,F=e[25]^p,q=e[34]^d,H=e[35]^p,z=e[44]^d,K=e[45]^p;d=s^(h<<1|l>>>31),p=u^(l<<1|h>>>31);var V=e[6]^d,G=e[7]^p,W=e[16]^d,Y=e[17]^p,X=e[26]^d,Z=e[27]^p,J=e[36]^d,$=e[37]^p,Q=e[46]^d,ee=e[47]^p;d=c^(r<<1|i>>>31),p=f^(i<<1|r>>>31);var te=e[8]^d,re=e[9]^p,ne=e[18]^d,ie=e[19]^p,oe=e[28]^d,ae=e[29]^p,se=e[38]^d,ue=e[39]^p,ce=e[48]^d,fe=e[49]^p,he=b,le=y,de=v<<4|m>>>28,pe=m<<4|v>>>28,be=g<<3|w>>>29,ye=w<<3|g>>>29,me=A<<9|_>>>23,ve=_<<9|A>>>23,ge=E<<18|x>>>14,we=x<<18|E>>>14,_e=k<<1|S>>>31,Ae=S<<1|k>>>31,Ee=I<<12|M>>>20,xe=M<<12|I>>>20,ke=T<<10|U>>>22,Se=U<<10|T>>>22,Me=B<<13|j>>>19,Ie=j<<13|B>>>19,Te=P<<2|C>>>30,Ue=C<<2|P>>>30,je=R<<30|N>>>2,Be=N<<30|R>>>2,Pe=L<<6|O>>>26,Ce=O<<6|L>>>26,Ne=F<<11|D>>>21,Re=D<<11|F>>>21,Le=q<<15|H>>>17,Oe=H<<15|q>>>17,De=K<<29|z>>>3,Fe=z<<29|K>>>3,qe=V<<28|G>>>4,He=G<<28|V>>>4,ze=Y<<23|W>>>9,Ke=W<<23|Y>>>9,Ve=X<<25|Z>>>7,Ge=Z<<25|X>>>7,We=J<<21|$>>>11,Ye=$<<21|J>>>11,Xe=ee<<24|Q>>>8,Ze=Q<<24|ee>>>8,Je=te<<27|re>>>5,$e=re<<27|te>>>5,Qe=ne<<20|ie>>>12,et=ie<<20|ne>>>12,tt=ae<<7|oe>>>25,rt=oe<<7|ae>>>25,nt=se<<8|ue>>>24,it=ue<<8|se>>>24,ot=ce<<14|fe>>>18,at=fe<<14|ce>>>18;e[0]=he^~Ee&Ne,e[1]=le^~xe&Re,e[10]=qe^~Qe&be,e[11]=He^~et&ye,e[20]=_e^~Pe&Ve,e[21]=Ae^~Ce&Ge,e[30]=Je^~de&ke,e[31]=$e^~pe&Se,e[40]=je^~ze&tt,e[41]=Be^~Ke&rt,e[2]=Ee^~Ne&We,e[3]=xe^~Re&Ye,e[12]=Qe^~be&Me,e[13]=et^~ye&Ie,e[22]=Pe^~Ve&nt,e[23]=Ce^~Ge&it,e[32]=de^~ke&Le,e[33]=pe^~Se&Oe,e[42]=ze^~tt&me,e[43]=Ke^~rt&ve,e[4]=Ne^~We&ot,e[5]=Re^~Ye&at,e[14]=be^~Me&De,e[15]=ye^~Ie&Fe,e[24]=Ve^~nt&ge,e[25]=Ge^~it&we,e[34]=ke^~Le&Xe,e[35]=Se^~Oe&Ze,e[44]=tt^~me&Te,e[45]=rt^~ve&Ue,e[6]=We^~ot&he,e[7]=Ye^~at&le,e[16]=Me^~De&qe,e[17]=Ie^~Fe&He,e[26]=nt^~ge&_e,e[27]=it^~we&Ae,e[36]=Le^~Xe&Je,e[37]=Oe^~Ze&$e,e[46]=me^~Te&je,e[47]=ve^~Ue&Be,e[8]=ot^~he&Ee,e[9]=at^~le&xe,e[18]=De^~qe&Qe,e[19]=Fe^~He&et,e[28]=ge^~_e&Pe,e[29]=we^~Ae&Ce,e[38]=Xe^~Je&de,e[39]=Ze^~$e&pe,e[48]=Te^~je&ze,e[49]=Ue^~Be&Ke,e[0]^=n[2*t],e[1]^=n[2*t+1]}}},{}],200:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("./keccak-state-unroll");function o(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}o.prototype.initialize=function(e,t){for(var r=0;r<50;++r)this.state[r]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},o.prototype.absorb=function(e){for(var t=0;t>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(i.p1600(this.state),this.count=0);return t},o.prototype.copy=function(e){for(var t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},t.exports=o},{"./keccak-state-unroll":199,"safe-buffer":290}],201:[function(e,t,r){var n=e("./_root").Symbol;t.exports=n},{"./_root":217}],202:[function(e,t,r){var n=e("./_baseTimes"),i=e("./isArguments"),o=e("./isArray"),a=e("./isBuffer"),s=e("./_isIndex"),u=e("./isTypedArray"),c=Object.prototype.hasOwnProperty;t.exports=function(e,t){var r=o(e),f=!r&&i(e),h=!r&&!f&&a(e),l=!r&&!f&&!h&&u(e),d=r||f||h||l,p=d?n(e.length,String):[],b=p.length;for(var y in e)!t&&!c.call(e,y)||d&&("length"==y||h&&("offset"==y||"parent"==y)||l&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||s(y,b))||p.push(y);return p}},{"./_baseTimes":207,"./_isIndex":211,"./isArguments":219,"./isArray":220,"./isBuffer":222,"./isTypedArray":227}],203:[function(e,t,r){var n=e("./_Symbol"),i=e("./_getRawTag"),o=e("./_objectToString"),a="[object Null]",s="[object Undefined]",u=n?n.toStringTag:void 0;t.exports=function(e){return null==e?void 0===e?s:a:u&&u in Object(e)?i(e):o(e)}},{"./_Symbol":201,"./_getRawTag":210,"./_objectToString":215}],204:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isObjectLike"),o="[object Arguments]";t.exports=function(e){return i(e)&&n(e)==o}},{"./_baseGetTag":203,"./isObjectLike":226}],205:[function(e,t,r){var n=e("./_baseGetTag"),i=e("./isLength"),o=e("./isObjectLike"),a={};a["[object Float32Array]"]=a["[object Float64Array]"]=a["[object Int8Array]"]=a["[object Int16Array]"]=a["[object Int32Array]"]=a["[object Uint8Array]"]=a["[object Uint8ClampedArray]"]=a["[object Uint16Array]"]=a["[object Uint32Array]"]=!0,a["[object Arguments]"]=a["[object Array]"]=a["[object ArrayBuffer]"]=a["[object Boolean]"]=a["[object DataView]"]=a["[object Date]"]=a["[object Error]"]=a["[object Function]"]=a["[object Map]"]=a["[object Number]"]=a["[object Object]"]=a["[object RegExp]"]=a["[object Set]"]=a["[object String]"]=a["[object WeakMap]"]=!1,t.exports=function(e){return o(e)&&i(e.length)&&!!a[n(e)]}},{"./_baseGetTag":203,"./isLength":224,"./isObjectLike":226}],206:[function(e,t,r){var n=e("./_isPrototype"),i=e("./_nativeKeys"),o=Object.prototype.hasOwnProperty;t.exports=function(e){if(!n(e))return i(e);var t=[];for(var r in Object(e))o.call(e,r)&&"constructor"!=r&&t.push(r);return t}},{"./_isPrototype":212,"./_nativeKeys":213}],207:[function(e,t,r){t.exports=function(e,t){for(var r=-1,n=Array(e);++r-1&&e%1==0&&e-1&&e%1==0&&e<=n}},{}],225:[function(e,t,r){t.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},{}],226:[function(e,t,r){t.exports=function(e){return null!=e&&"object"==typeof e}},{}],227:[function(e,t,r){var n=e("./_baseIsTypedArray"),i=e("./_baseUnary"),o=e("./_nodeUtil"),a=o&&o.isTypedArray,s=a?i(a):n;t.exports=s},{"./_baseIsTypedArray":205,"./_baseUnary":208,"./_nodeUtil":214}],228:[function(e,t,r){var n=e("./_arrayLikeKeys"),i=e("./_baseKeys"),o=e("./isArrayLike");t.exports=function(e){return o(e)?n(e):i(e)}},{"./_arrayLikeKeys":202,"./_baseKeys":206,"./isArrayLike":221}],229:[function(e,t,r){t.exports=function(){}},{}],230:[function(e,t,r){t.exports=function(){return!1}},{}],231:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base"),o=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function s(e,t){return e<>>32-t}function u(e,t,r,n,i,o,a){return s(e+(t&r|~t&n)+i+o|0,a)+t|0}function c(e,t,r,n,i,o,a){return s(e+(t&n|r&~n)+i+o|0,a)+t|0}function f(e,t,r,n,i,o,a){return s(e+(t^r^n)+i+o|0,a)+t|0}function h(e,t,r,n,i,o,a){return s(e+(r^(t|~n))+i+o|0,a)+t|0}n(a,i),a.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,a=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,a=u(a,r=u(r,n,i,a,e[0],3614090360,7),n,i,e[1],3905402710,12),r,n,e[2],606105819,17),a,r,e[3],3250441966,22),i=u(i,a=u(a,r=u(r,n,i,a,e[4],4118548399,7),n,i,e[5],1200080426,12),r,n,e[6],2821735955,17),a,r,e[7],4249261313,22),i=u(i,a=u(a,r=u(r,n,i,a,e[8],1770035416,7),n,i,e[9],2336552879,12),r,n,e[10],4294925233,17),a,r,e[11],2304563134,22),i=u(i,a=u(a,r=u(r,n,i,a,e[12],1804603682,7),n,i,e[13],4254626195,12),r,n,e[14],2792965006,17),a,r,e[15],1236535329,22),i=c(i,a=c(a,r=c(r,n,i,a,e[1],4129170786,5),n,i,e[6],3225465664,9),r,n,e[11],643717713,14),a,r,e[0],3921069994,20),i=c(i,a=c(a,r=c(r,n,i,a,e[5],3593408605,5),n,i,e[10],38016083,9),r,n,e[15],3634488961,14),a,r,e[4],3889429448,20),i=c(i,a=c(a,r=c(r,n,i,a,e[9],568446438,5),n,i,e[14],3275163606,9),r,n,e[3],4107603335,14),a,r,e[8],1163531501,20),i=c(i,a=c(a,r=c(r,n,i,a,e[13],2850285829,5),n,i,e[2],4243563512,9),r,n,e[7],1735328473,14),a,r,e[12],2368359562,20),i=f(i,a=f(a,r=f(r,n,i,a,e[5],4294588738,4),n,i,e[8],2272392833,11),r,n,e[11],1839030562,16),a,r,e[14],4259657740,23),i=f(i,a=f(a,r=f(r,n,i,a,e[1],2763975236,4),n,i,e[4],1272893353,11),r,n,e[7],4139469664,16),a,r,e[10],3200236656,23),i=f(i,a=f(a,r=f(r,n,i,a,e[13],681279174,4),n,i,e[0],3936430074,11),r,n,e[3],3572445317,16),a,r,e[6],76029189,23),i=f(i,a=f(a,r=f(r,n,i,a,e[9],3654602809,4),n,i,e[12],3873151461,11),r,n,e[15],530742520,16),a,r,e[2],3299628645,23),i=h(i,a=h(a,r=h(r,n,i,a,e[0],4096336452,6),n,i,e[7],1126891415,10),r,n,e[14],2878612391,15),a,r,e[5],4237533241,21),i=h(i,a=h(a,r=h(r,n,i,a,e[12],1700485571,6),n,i,e[3],2399980690,10),r,n,e[10],4293915773,15),a,r,e[1],2240044497,21),i=h(i,a=h(a,r=h(r,n,i,a,e[8],1873313359,6),n,i,e[15],4264355552,10),r,n,e[6],2734768916,15),a,r,e[13],1309151649,21),i=h(i,a=h(a,r=h(r,n,i,a,e[4],4149444226,6),n,i,e[11],3174756917,10),r,n,e[2],718787259,15),a,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+a|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=a}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":232,inherits:180}],232:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("stream").Transform;function o(e){i.call(this),this._block=n.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}e("inherits")(o,i),o.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},o.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},o.prototype.update=function(e,t){if(function(e,t){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");n.isBuffer(e)||(e=n.from(e,t));for(var r=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},{inherits:180,"safe-buffer":290,stream:311}],233:[function(e,t,r){var n=e("bn.js"),i=e("brorand");function o(e){this.rand=e||new i.Rand}t.exports=o,o.create=function(e){return new o(e)},o.prototype._randbelow=function(e){var t=e.bitLength(),r=Math.ceil(t/8);do{var i=new n(this.rand.generate(r))}while(i.cmp(e)>=0);return i},o.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},o.prototype.test=function(e,t,r){var i=e.bitLength(),o=n.mont(e),a=new n(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var s=e.subn(1),u=0;!s.testn(u);u++);for(var c=e.shrn(u),f=s.toRed(o);t>0;t--){var h=this._randrange(new n(2),s);r&&r(h);var l=h.toRed(o).redPow(c);if(0!==l.cmp(a)&&0!==l.cmp(f)){for(var d=1;d0;t--){var f=this._randrange(new n(2),a),h=e.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(u);if(0!==l.cmp(o)&&0!==l.cmp(c)){for(var d=1;d>8,a=255&i;o?r.push(o,a):r.push(a)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},{}],236:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],237:[function(e,t,r){var n=e("bn.js"),i=e("strip-hex-prefix");t.exports=function(e){if("string"==typeof e||"number"==typeof e){var t=new n(1),r=String(e).toLowerCase().trim(),o="0x"===r.substr(0,2)||"-0x"===r.substr(0,3),a=i(r);if("-"===a.substr(0,1)&&(a=i(a.slice(1)),t=new n(-1,10)),!(a=""===a?"0":a).match(/^-?[0-9]+$/)&&a.match(/^[0-9A-Fa-f]+$/)||a.match(/^[a-fA-F]+$/)||!0===o&&a.match(/^[0-9A-Fa-f]+$/))return new n(a,16).mul(t);if((a.match(/^-?[0-9]+$/)||""===a)&&!1===o)return new n(a,10).mul(t)}else if("object"==typeof e&&e.toString&&!e.pop&&!e.push&&e.toString(10).match(/^-?[0-9]+$/)&&(e.mul||e.dividedToIntegerBy))return new n(e.toString(10),10);throw new Error("[number-to-bn] while converting number "+JSON.stringify(e)+" to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.")}},{"bn.js":236,"strip-hex-prefix":318}],238:[function(e,t,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,a,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),u=1;u0;)if(q+=r,r=e.charAt(o++),4===H?(N+=String.fromCharCode(parseInt(q,16)),H=0,c=o-1):H++,!r)break e;if('"'===r&&!L){D=F.pop()||p,N+=e.substring(c,o-1);break}if(!("\\"!==r||L||(L=!0,N+=e.substring(c,o-1),r=e.charAt(o++))))break;if(L){if(L=!1,"n"===r?N+="\n":"r"===r?N+="\r":"t"===r?N+="\t":"f"===r?N+="\f":"b"===r?N+="\b":"u"===r?(H=1,q=""):N+=r,r=e.charAt(o++),c=o-1,r)continue;break}h.lastIndex=o;var l=h.exec(e);if(!l){o=e.length+1,N+=e.substring(c,o-1);break}if(o=l.index+1,!(r=e.charAt(l.index))){N+=e.substring(c,o-1);break}}continue;case A:if(!r)continue;if("r"!==r)return W("Invalid true started with t"+r);D=E;continue;case E:if(!r)continue;if("u"!==r)return W("Invalid true started with tr"+r);D=x;continue;case x:if(!r)continue;if("e"!==r)return W("Invalid true started with tru"+r);a(!0),u(),D=F.pop()||p;continue;case k:if(!r)continue;if("a"!==r)return W("Invalid false started with f"+r);D=S;continue;case S:if(!r)continue;if("l"!==r)return W("Invalid false started with fa"+r);D=M;continue;case M:if(!r)continue;if("s"!==r)return W("Invalid false started with fal"+r);D=I;continue;case I:if(!r)continue;if("e"!==r)return W("Invalid false started with fals"+r);a(!1),u(),D=F.pop()||p;continue;case T:if(!r)continue;if("u"!==r)return W("Invalid null started with n"+r);D=U;continue;case U:if(!r)continue;if("l"!==r)return W("Invalid null started with nu"+r);D=j;continue;case j:if(!r)continue;if("l"!==r)return W("Invalid null started with nul"+r);a(null),u(),D=F.pop()||p;continue;case B:if("."!==r)return W("Leading zero not followed by .");R+=r,D=P;continue;case P:if(-1!=="0123456789".indexOf(r))R+=r;else if("."===r){if(-1!==R.indexOf("."))return W("Invalid number has two dots");R+=r}else if("e"===r||"E"===r){if(-1!==R.indexOf("e")||-1!==R.indexOf("E"))return W("Invalid number has two exponential");R+=r}else if("+"===r||"-"===r){if("e"!==n&&"E"!==n)return W("Invalid symbol in number");R+=r}else R&&(a(parseFloat(R)),u(),R=""),o--,D=F.pop()||p;continue;default:return W("Unknown state: "+D)}K>=C&&(X=0,N!==s&&N.length>f&&(W("Max buffer length exceeded: textNode"),X=Math.max(X,N.length)),R.length>f&&(W("Max buffer length exceeded: numberNode"),X=Math.max(X,R.length)),C=f-X+K);var X}),e(ce).on(function(){if(D==d)return a({}),u(),void(O=!0);D===p&&0===z||W("Unexpected end");N!==s&&(a(N),u(),N=s);O=!0})}var C,N,R,L,O,D,F,q,H,z,K,V=(C=d(function(e){return e.unshift(/^/),(t=RegExp(e.map(f("source")).join(""))).exec.bind(t);var t}),L=C(N=/(\$?)/,/([\w-_]+|\*)/,R=/(?:{([\w ]*?)})?/),O=C(N,/\["([^"]+)"\]/,R),D=C(N,/\[(\d+|\*)\]/,R),F=C(N,/()/,/{([\w ]*?)}/),q=C(/\.\./),H=C(/\./),z=C(N,/!/),K=C(/$/),function(e){return e(h(L,O,D,F),q,H,z,K)});function G(e,t){return{key:e,node:t}}var W=f("key"),Y=f("node"),X={};function Z(e){var t=e(ee).emit,r=e(te).emit,n=e(ae).emit,o=e(oe).emit;function a(e,t,r){Y(x(e))[t]=r}function s(e,r,n){e&&a(e,r,n);var i=A(G(r,n),e);return t(i),i}var u={};return u[le]=function(e,t){if(!e)return n(t),s(e,X,t);var r=function(e,t){var r=Y(x(e));return m(i,r)?s(e,v(r),t):e}(e,t),o=k(r),u=W(x(r));return a(o,u,t),A(G(u,t),o)},u[de]=function(e){return r(e),k(e)||o(Y(x(e)))},u[he]=s,u}var J=V(function(e,t,r,n,i){var a=1,s=2,f=3,l=c(W,x),d=c(Y,x);function b(e,t){return!!t[a]?p(e,x):e}function m(e){if(e==y)return y;return p(function(e){return l(e)!=X},c(e,k))}function g(){return function(e){return l(e)==X}}function w(e,t,r,n,i){var o=e(r);if(o){var a=function(e,t,r){return U(function(e,t){return t(e,r)},t,e)}(t,n,o);return i(r.substr(v(o[0])),a)}}function A(e,t){return u(w,e,t)}var E=h(A(e,M(b,function(e,t){var r=t[f];return r?p(c(u(_,S(r.split(/\W+/))),d),e):e},function(e,t){var r=t[s];return p(r&&"*"!=r?function(e){return l(e)==r}:y,e)},m)),A(t,M(function(e){if(e==y)return y;var t=g(),r=e,n=m(function(e){return i(e)}),i=h(t,r,n);return i})),A(r,M()),A(n,M(b,g)),A(i,M(function(e){return function(t){var r=e(t);return!0===r?x(t):r}})),function(e){throw o('"'+e+'" could not be tokenised')});function I(e,t){return t}function T(e,t){return E(e,t,e?T:I)}return function(e){try{return T(e,y)}catch(t){throw o('Could not compile "'+e+'" because '+t.message)}}});function $(e,t,r){var n,i;function o(e){return function(t){return t.id==e}}return{on:function(r,o){var a={listener:r,id:o||r};return t&&t.emit(e,r,a.id),n=A(a,n),i=A(r,i),this},emit:function(){!function e(t,r){t&&(x(t).apply(null,r),e(k(t),r))}(i,arguments)},un:function(t){var a;n=j(n,o(t),function(e){a=e}),a&&(i=j(i,function(e){return e==a.listener}),r&&r.emit(e,a.listener,a.id))},listeners:function(){return i},hasListener:function(e){return w(function e(t,r){return r&&(t(x(r))?x(r):e(t,k(r)))}(e?o(e):y,n))}}}var Q=1,ee=Q++,te=Q++,re=Q++,ne=Q++,ie="fail",oe=Q++,ae=Q++,se="start",ue="data",ce="end",fe=Q++,he=Q++,le=Q++,de=Q++;function pe(e,t,r){try{var n=a.parse(t)}catch(e){}return{statusCode:e,body:t,jsonBody:n,thrown:r}}function be(e,t){var r={node:e(te),path:e(ee)};function n(t,r,n){var i=e(t).emit;r.on(function(e){var t=n(e);!1!==t&&function(e,t,r){var n=B(r);e(t,I(k(T(W,n))),I(T(Y,n)))}(i,Y(t),e)},t),e("removeListener").on(function(n){n==t&&(e(n).listeners()||r.un(t))})}e("newListener").on(function(e){var i=/(node|path):(.*)/.exec(e);if(i){var o=r[i[1]];o.hasListener(e)||n(e,o,t(i[2]))}})}function ye(e,t){var r,n=/^(node|path):./,i=e(oe),o=e(ne).emit,a=e(re).emit,s=d(function(t,i){if(r[t])l(i,r[t]);else{var o=e(t),a=i[0];n.test(t)?c(o,a):o.on(a)}return r});function c(e,t,n){n=n||t;var i=f(t);return e.on(function(){var t=!1;r.forget=function(){t=!0},l(arguments,i),delete r.forget,t&&e.un(n)},n),r}function f(e){return function(){try{return e.apply(r,arguments)}catch(e){setTimeout(function(){throw e})}}}function h(t,r,n){var i;i="node"==t?function(e){return function(){var t=e.apply(this,arguments);w(t)&&(t==ge.drop?o():a(t))}}(n):n,c(function(t,r){return e(t+":"+r)}(t,r),i,n)}function p(e,t,n){return g(t)?h(e,t,n):function(e,t){for(var r in t)h(e,r,t[r])}(e,t),r}return e(ae).on(function(e){var t;r.root=(t=e,function(){return t})}),e(se).on(function(e,t){r.header=function(e){return e?t[e]:t}}),r={on:s,addListener:s,removeListener:function(t,n,o){if("done"==t)i.un(n);else if("node"==t||"path"==t)e.un(t+":"+n,o);else{var a=n;e(t).un(a)}return r},emit:e.emit,node:u(p,"node"),path:u(p,"path"),done:u(c,i),start:u(function(t,n){return e(t).on(f(n),n),r},se),fail:e(ie).on,abort:e(fe).emit,header:b,root:b,source:t}}function me(t,r,n,i,o){var a=function(){var e={},t=n("newListener"),r=n("removeListener");function n(n){return e[n]=$(n,t,r)}function i(t){return e[t]||n(t)}return["emit","on","un"].forEach(function(e){i[e]=d(function(t,r){l(r,i(t)[e])})}),i}();return r&&function(t,r,n,i,o,a,c){"use strict";var f=t(ue).emit,h=t(ie).emit,l=0,d=!0;function p(){var e=r.responseText,t=e.substr(l);t&&f(t),l=v(e)}t(fe).on(function(){r.onreadystatechange=null,r.abort()}),"onprogress"in r&&(r.onprogress=p),r.onreadystatechange=function(){function e(){try{d&&t(se).emit(r.status,(e=r.getAllResponseHeaders(),n={},e&&e.split("\r\n").forEach(function(e){var t=e.indexOf(": ");n[e.substring(0,t)]=e.substring(t+2)}),n)),d=!1}catch(e){}var e,n}switch(r.readyState){case 2:case 3:return e();case 4:e(),2==String(r.status)[0]?(p(),t(ce).emit()):h(pe(r.status,r.responseText))}};try{for(var b in r.open(n,i,!0),a)r.setRequestHeader(b,a[b]);(function(e,t){function r(t){return t.port||{"http:":80,"https:":443}[t.protocol||e.protocol]}return!!(t.protocol&&t.protocol!=e.protocol||t.host&&t.host!=e.host||t.host&&r(t)!=r(e))})(e.location,function(e){var t=/(\w+:)?(?:\/\/)([\w.-]+)?(?::(\d+))?\/?/.exec(e)||[];return{protocol:t[1]||"",host:t[2]||"",port:t[3]||""}}(i))||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.withCredentials=c,r.send(o)}catch(t){e.setTimeout(u(h,pe(s,s,t)),0)}}(a,new XMLHttpRequest,t,r,n,i,o),P(a),function(e,t){"use strict";var r,n={};function i(e){return function(t){r=e(r,t)}}for(var o in t)e(o).on(i(t[o]),n);e(re).on(function(e){var t=x(r),n=W(t),i=k(r);i&&(Y(x(i))[n]=e)}),e(ne).on(function(){var e=x(r),t=W(e),n=k(r);n&&delete Y(x(n))[t]}),e(fe).on(function(){for(var r in t)e(r).un(n)})}(a,Z(a)),be(a,J),ye(a,r)}function ve(e,t,r,n,i,o,s){return i=i?a.parse(a.stringify(i)):{},n?g(n)||(n=a.stringify(n),i["Content-Type"]=i["Content-Type"]||"application/json"):n=null,e(r||"GET",function(e,t){return!1===t&&(-1==e.indexOf("?")?e+="?":e+="&",e+="_="+(new Date).getTime()),e}(t,s),n,i,o||!1)}function ge(e){var t=M("resume","pause","pipe"),r=u(_,t);return e?r(e)||g(e)?ve(me,e):ve(me,e.url,e.method,e.body,e.headers,e.withCredentials,e.cached):me()}ge.drop=function(){return ge.drop},"function"==typeof define&&define.amd?define("oboe",[],function(){return ge}):"object"==typeof r?t.exports=ge:e.oboe=ge}(function(){try{return window}catch(e){return self}}(),Object,Array,Error,JSON)},{}],240:[function(e,t,r){r.endianness=function(){return"LE"},r.hostname=function(){return"undefined"!=typeof location?location.hostname:""},r.loadavg=function(){return[]},r.uptime=function(){return 0},r.freemem=function(){return Number.MAX_VALUE},r.totalmem=function(){return Number.MAX_VALUE},r.cpus=function(){return[]},r.type=function(){return"Browser"},r.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},r.networkInterfaces=r.getNetworkInterfaces=function(){return{}},r.arch=function(){return"javascript"},r.platform=function(){return"browser"},r.tmpdir=r.tmpDir=function(){return"/tmp"},r.EOL="\n",r.homedir=function(){return"/"}},{}],241:[function(e,t,r){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],242:[function(e,t,r){"use strict";var n=e("asn1.js");r.certificate=e("./certificate");var i=n.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});r.RSAPrivateKey=i;var o=n.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});r.RSAPublicKey=o;var a=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())});r.PublicKey=a;var s=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),u=n.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(s),this.key("subjectPrivateKey").octstr())});r.PrivateKey=u;var c=n.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});r.EncryptedPrivateKey=c;var f=n.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});r.DSAPrivateKey=f,r.DSAparam=n.define("DSAparam",function(){this.int()});var h=n.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(l),this.key("publicKey").optional().explicit(1).bitstr())});r.ECPrivateKey=h;var l=n.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});r.signature=n.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},{"./certificate":243,"asn1.js":5}],243:[function(e,t,r){"use strict";var n=e("asn1.js"),i=n.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),o=n.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),a=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional())}),s=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())}),u=n.define("RelativeDistinguishedName",function(){this.setof(o)}),c=n.define("RDNSequence",function(){this.seqof(u)}),f=n.define("Name",function(){this.choice({rdnSequence:this.use(c)})}),h=n.define("Validity",function(){this.seq().obj(this.key("notBefore").use(i),this.key("notAfter").use(i))}),l=n.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),d=n.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int(),this.key("serialNumber").int(),this.key("signature").use(a),this.key("issuer").use(f),this.key("validity").use(h),this.key("subject").use(f),this.key("subjectPublicKeyInfo").use(s),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(l).optional())}),p=n.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(a),this.key("signatureValue").bitstr())});t.exports=p},{"asn1.js":5}],244:[function(e,t,r){(function(r){var n=/Proc-Type: 4,ENCRYPTED\n\r?DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\n\r?\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?/m,i=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n/m,o=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?-----END \1-----$/m,a=e("evp_bytestokey"),s=e("browserify-aes");t.exports=function(e,t){var u,c=e.toString(),f=c.match(n);if(f){var h="aes"+f[1],l=new r(f[2],"hex"),d=new r(f[3].replace(/\r?\n/g,""),"base64"),p=a(t,l.slice(0,8),parseInt(f[1],10)).key,b=[],y=s.createDecipheriv(h,p,l);b.push(y.update(d)),b.push(y.final()),u=r.concat(b)}else{var m=c.match(o);u=new r(m[2].replace(/\r?\n/g,""),"base64")}return{tag:c.match(i)[1],data:u}}}).call(this,e("buffer").Buffer)},{"browserify-aes":58,buffer:84,evp_bytestokey:158}],245:[function(e,t,r){(function(r){var n=e("./asn1"),i=e("./aesid.json"),o=e("./fixProc"),a=e("browserify-aes"),s=e("pbkdf2");function u(e){var t;"object"!=typeof e||r.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=new r(e));var u,c,f=o(e,t),h=f.tag,l=f.data;switch(h){case"CERTIFICATE":c=n.certificate.decode(l,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(c||(c=n.PublicKey.decode(l,"der")),u=c.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPublicKey.decode(c.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return c.subjectPrivateKey=c.subjectPublicKey,{type:"ec",data:c};case"1.2.840.10040.4.1":return c.algorithm.params.pub_key=n.DSAparam.decode(c.subjectPublicKey.data,"der"),{type:"dsa",data:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"ENCRYPTED PRIVATE KEY":l=function(e,t){var n=e.algorithm.decrypt.kde.kdeparams.salt,o=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),u=i[e.algorithm.decrypt.cipher.algo.join(".")],c=e.algorithm.decrypt.cipher.iv,f=e.subjectPrivateKey,h=parseInt(u.split("-")[1],10)/8,l=s.pbkdf2Sync(t,n,o,h),d=a.createDecipheriv(u,l,c),p=[];return p.push(d.update(f)),p.push(d.final()),r.concat(p)}(l=n.EncryptedPrivateKey.decode(l,"der"),t);case"PRIVATE KEY":switch(u=(c=n.PrivateKey.decode(l,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return n.RSAPrivateKey.decode(c.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:c.algorithm.curve,privateKey:n.ECPrivateKey.decode(c.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return c.algorithm.params.priv_key=n.DSAparam.decode(c.subjectPrivateKey,"der"),{type:"dsa",params:c.algorithm.params};default:throw new Error("unknown key id "+u)}throw new Error("unknown key type "+h);case"RSA PUBLIC KEY":return n.RSAPublicKey.decode(l,"der");case"RSA PRIVATE KEY":return n.RSAPrivateKey.decode(l,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:n.DSAPrivateKey.decode(l,"der")};case"EC PRIVATE KEY":return{curve:(l=n.ECPrivateKey.decode(l,"der")).parameters.value,privateKey:l.privateKey};default:throw new Error("unknown key type "+h)}}t.exports=u,u.signature=n.signature}).call(this,e("buffer").Buffer)},{"./aesid.json":241,"./asn1":242,"./fixProc":244,"browserify-aes":58,buffer:84,pbkdf2:247}],246:[function(e,t,r){var n=e("trim"),i=e("for-each");t.exports=function(e){if(!e)return{};var t={};return i(n(e).split("\n"),function(e){var r,i=e.indexOf(":"),o=n(e.slice(0,i)).toLowerCase(),a=n(e.slice(i+1));void 0===t[o]?t[o]=a:(r=t[o],"[object Array]"===Object.prototype.toString.call(r)?t[o].push(a):t[o]=[t[o],a])}),t}},{"for-each":159,trim:324}],247:[function(e,t,r){r.pbkdf2=e("./lib/async"),r.pbkdf2Sync=e("./lib/sync")},{"./lib/async":248,"./lib/sync":251}],248:[function(e,t,r){(function(r,n){var i,o=e("./precondition"),a=e("./default-encoding"),s=e("./sync"),u=e("safe-buffer").Buffer,c=n.crypto&&n.crypto.subtle,f={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},h=[];function l(e,t,r,n,i){return c.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then(function(e){return c.deriveBits({name:"PBKDF2",salt:t,iterations:r,hash:{name:i}},e,n<<3)}).then(function(e){return u.from(e)})}t.exports=function(e,t,d,p,b,y){if(u.isBuffer(e)||(e=u.from(e,a)),u.isBuffer(t)||(t=u.from(t,a)),o(d,p),"function"==typeof b&&(y=b,b=void 0),"function"!=typeof y)throw new Error("No callback provided to pbkdf2");var m=f[(b=b||"sha1").toLowerCase()];if(!m||"function"!=typeof n.Promise)return r.nextTick(function(){var r;try{r=s(e,t,d,p,b)}catch(e){return y(e)}y(null,r)});!function(e,t){e.then(function(e){r.nextTick(function(){t(null,e)})},function(e){r.nextTick(function(){t(e)})})}(function(e){if(n.process&&!n.process.browser)return Promise.resolve(!1);if(!c||!c.importKey||!c.deriveBits)return Promise.resolve(!1);if(void 0!==h[e])return h[e];var t=l(i=i||u.alloc(8),i,10,128,e).then(function(){return!0}).catch(function(){return!1});return h[e]=t,t}(m).then(function(r){return r?l(e,t,d,p,m):s(e,t,d,p,b)}),y)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-encoding":249,"./precondition":250,"./sync":251,_process:257,"safe-buffer":290}],249:[function(e,t,r){(function(e){var r;e.browser?r="utf-8":r=parseInt(e.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary";t.exports=r}).call(this,e("_process"))},{_process:257}],250:[function(e,t,r){var n=Math.pow(2,30)-1;t.exports=function(e,t){if("number"!=typeof e)throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if("number"!=typeof t)throw new TypeError("Key length not a number");if(t<0||t>n||t!=t)throw new TypeError("Bad key length")}},{}],251:[function(e,t,r){var n=e("create-hash/md5"),i=e("ripemd160"),o=e("sha.js"),a=e("./precondition"),s=e("./default-encoding"),u=e("safe-buffer").Buffer,c=u.alloc(128),f={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function h(e,t,r){var a=function(e){return"rmd160"===e||"ripemd160"===e?i:"md5"===e?n:function(t){return o(e).update(t).digest()}}(e),s="sha512"===e||"sha384"===e?128:64;t.length>s?t=a(t):t.length1)for(var r=1;rp||new a(t).cmp(d.modulus)>=0)throw new Error("decryption error");l=f?c(new a(t),d):s(t,d);var b=new r(p-l.length);if(b.fill(0),l=r.concat([b,l],p),4===h)return function(e,t){e.modulus;var n=e.modulus.byteLength(),a=(t.length,u("sha1").update(new r("")).digest()),s=a.length;if(0!==t[0])throw new Error("decryption error");var c=t.slice(1,s+1),f=t.slice(s+1),h=o(c,i(f,s)),l=o(f,i(h,n-s-1));if(function(e,t){e=new r(e),t=new r(t);var n=0,i=e.length;e.length!==t.length&&(n++,i=Math.min(e.length,t.length));var o=-1;for(;++o=t.length){o++;break}var a=t.slice(2,i-1);t.slice(i-1,i);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;a.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,l,f);if(3===h)return l;throw new Error("unknown padding")}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245}],262:[function(e,t,r){(function(r){var n=e("parse-asn1"),i=e("randombytes"),o=e("create-hash"),a=e("./mgf"),s=e("./xor"),u=e("bn.js"),c=e("./withPublic"),f=e("browserify-rsa");t.exports=function(e,t,h){var l;l=e.padding?e.padding:h?1:4;var d,p=n(e);if(4===l)d=function(e,t){var n=e.modulus.byteLength(),c=t.length,f=o("sha1").update(new r("")).digest(),h=f.length,l=2*h;if(c>n-l-2)throw new Error("message too long");var d=new r(n-c-l-2);d.fill(0);var p=n-h-1,b=i(h),y=s(r.concat([f,d,new r([1]),t],p),a(b,p)),m=s(b,a(y,h));return new u(r.concat([new r([0]),m,y],n))}(p,t);else if(1===l)d=function(e,t,n){var o,a=t.length,s=e.modulus.byteLength();if(a>s-11)throw new Error("message too long");n?(o=new r(s-a-3)).fill(255):o=function(e,t){var n,o=new r(e),a=0,s=i(2*e),u=0;for(;a=0)throw new Error("data too long for modulus")}return h?f(d,p):c(d,p)}}).call(this,e("buffer").Buffer)},{"./mgf":260,"./withPublic":263,"./xor":264,"bn.js":53,"browserify-rsa":76,buffer:84,"create-hash":91,"parse-asn1":245,randombytes:270}],263:[function(e,t,r){(function(r){var n=e("bn.js");t.exports=function(e,t){return new r(e.toRed(n.mont(t.modulus)).redPow(new n(t.publicExponent)).fromRed().toArray())}}).call(this,e("buffer").Buffer)},{"bn.js":53,buffer:84}],264:[function(e,t,r){t.exports=function(e,t){for(var r=e.length,n=-1;++n= 0x80 (not a basic code point)","invalid-input":"Invalid input"},A=f-h,E=Math.floor,x=String.fromCharCode;function k(e){throw new RangeError(_[e])}function S(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function M(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+S((e=e.replace(w,".")).split("."),t).join(".")}function I(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=x((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=x(e)}).join("")}function U(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function j(e,t,r){var n=0;for(e=r?E(e/p):e>>1,e+=E(e/t);e>A*l>>1;n+=f)e=E(e/A);return E(n+(A+1)*e/(e+d))}function B(e){var t,r,n,i,o,a,s,u,d,p,v,g=[],w=e.length,_=0,A=y,x=b;for((r=e.lastIndexOf(m))<0&&(r=0),n=0;n=128&&k("not-basic"),g.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=w&&k("invalid-input"),((u=(v=e.charCodeAt(i++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:f)>=f||u>E((c-_)/a))&&k("overflow"),_+=u*a,!(u<(d=s<=x?h:s>=x+l?l:s-x));s+=f)a>E(c/(p=f-d))&&k("overflow"),a*=p;x=j(_-o,t=g.length+1,0==o),E(_/t)>c-A&&k("overflow"),A+=E(_/t),_%=t,g.splice(_++,0,A)}return T(g)}function P(e){var t,r,n,i,o,a,s,u,d,p,v,g,w,_,A,S=[];for(g=(e=I(e)).length,t=y,r=0,o=b,a=0;a=t&&vE((c-r)/(w=n+1))&&k("overflow"),r+=(s-t)*w,t=s,a=0;ac&&k("overflow"),v==t){for(u=r,d=f;!(u<(p=d<=o?h:d>=o+l?l:d-o));d+=f)A=u-p,_=f-p,S.push(x(U(p+A%_,0))),u=E(A/_);S.push(x(U(u,0))),o=j(r,w,n==i),r=0,++n}++r,++t}return S.join("")}if(s={version:"1.4.1",ucs2:{decode:I,encode:T},decode:B,encode:P,toASCII:function(e){return M(e,function(e){return g.test(e)?"xn--"+P(e):e})},toUnicode:function(e){return M(e,function(e){return v.test(e)?B(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return s});else if(i&&o)if(t.exports==i)o.exports=s;else for(u in s)s.hasOwnProperty(u)&&(i[u]=s[u]);else n.punycode=s}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],266:[function(e,t,r){"use strict";var n=e("strict-uri-encode"),i=e("object-assign"),o=e("decode-uri-component");function a(e,t){return t.encode?t.strict?n(e):encodeURIComponent(e):e}function s(e){var t=e.indexOf("?");return-1===t?"":e.slice(t+1)}function u(e,t){var r=function(e){var t;switch(e.arrayFormat){case"index":return function(e,r,n){t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return function(e,r,n){t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};default:return function(e,t,r){void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t=i({arrayFormat:"none"},t)),n=Object.create(null);return"string"!=typeof e?n:(e=e.trim().replace(/^[?#&]/,""))?(e.split("&").forEach(function(e){var t=e.replace(/\+/g," ").split("="),i=t.shift(),a=t.length>0?t.join("="):void 0;a=void 0===a?null:o(a),r(o(i),a,n)}),Object.keys(n).sort().reduce(function(e,t){var r=n[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=function e(t){return Array.isArray(t)?t.sort():"object"==typeof t?e(Object.keys(t)).sort(function(e,t){return Number(e)-Number(t)}).map(function(e){return t[e]}):t}(r):e[t]=r,e},Object.create(null))):n}r.extract=s,r.parse=u,r.stringify=function(e,t){!1===(t=i({encode:!0,strict:!0,arrayFormat:"none"},t)).sort&&(t.sort=function(){});var r=function(e){switch(e.arrayFormat){case"index":return function(t,r,n){return null===r?[a(t,e),"[",n,"]"].join(""):[a(t,e),"[",a(n,e),"]=",a(r,e)].join("")};case"bracket":return function(t,r){return null===r?a(t,e):[a(t,e),"[]=",a(r,e)].join("")};default:return function(t,r){return null===r?a(t,e):[a(t,e),"=",a(r,e)].join("")}}}(t);return e?Object.keys(e).sort(t.sort).map(function(n){var i=e[n];if(void 0===i)return"";if(null===i)return a(n,t);if(Array.isArray(i)){var o=[];return i.slice().forEach(function(e){void 0!==e&&o.push(r(n,e,o.length))}),o.join("&")}return a(n,t)+"="+a(i,t)}).filter(function(e){return e.length>0}).join("&"):""},r.parseUrl=function(e,t){return{url:e.split("?")[0]||"",query:u(s(e),t)}}},{"decode-uri-component":98,"object-assign":238,"strict-uri-encode":316}],267:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&",r=r||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(a,d)?i(a[d])?a[d].push(p):a[d]=[a[d],p]:a[d]=p}return a};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],268:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,s){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),function(a){var s=encodeURIComponent(n(a))+r;return i(e[a])?o(e[a],function(e){return s+encodeURIComponent(n(e))}).join(t):s+encodeURIComponent(n(e[a]))}).join(t):s?encodeURIComponent(n(s))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n65536)throw new Error("requested too many random bytes");var a=new n.Uint8Array(e);e>0&&o.getRandomValues(a);var s=i.from(a.buffer);if("function"==typeof t)return r.nextTick(function(){t(null,s)});return s}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,"safe-buffer":290}],271:[function(e,t,r){(function(t,n){"use strict";function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=e("safe-buffer"),a=e("randombytes"),s=o.Buffer,u=o.kMaxLength,c=n.crypto||n.msCrypto,f=Math.pow(2,32)-1;function h(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>f||e<0)throw new TypeError("offset must be a uint32");if(e>u||e>t)throw new RangeError("offset out of range")}function l(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>f||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>u)throw new RangeError("buffer too small")}function d(e,r,n,i){if(t.browser){var o=e.buffer,s=new Uint8Array(o,r,n);return c.getRandomValues(s),i?void t.nextTick(function(){i(null,e)}):e}if(!i)return a(n).copy(e,r),e;a(n,function(t,n){if(t)return i(t);n.copy(e,r),i(null,e)})}c&&c.getRandomValues||!t.browser?(r.randomFill=function(e,t,r,i){if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)i=t,t=0,r=e.length;else if("function"==typeof r)i=r,r=e.length-t;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return h(t,e.length),l(r,t,e.length),d(e,t,r,i)},r.randomFillSync=function(e,t,r){void 0===t&&(t=0);if(!(s.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');h(t,e.length),void 0===r&&(r=e.length-t);return l(r,t,e.length),d(e,t,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,randombytes:270,"safe-buffer":290}],272:[function(e,t,r){t.exports=window.crypto},{}],273:[function(e,t,r){t.exports=e("crypto")},{crypto:272}],274:[function(e,t,r){t.exports=function(t,r){var n=e("./crypto.js"),i="function"==typeof r;if(t>65536){if(!i)throw new Error("Requested too many random bytes.");r(new Error("Requested too many random bytes."))}if(void 0!==n&&n.randomBytes){if(!i)return"0x"+n.randomBytes(t).toString("hex");n.randomBytes(t,function(e,t){e?r(u):r(null,"0x"+t.toString("hex"))})}else{var o;if(void 0!==n?o=n:"undefined"!=typeof msCrypto&&(o=msCrypto),o&&o.getRandomValues){var a=o.getRandomValues(new Uint8Array(t)),s="0x"+Array.from(a).map(function(e){return e.toString(16)}).join("");if(!i)return s;r(null,s)}else{var u=new Error('No "crypto" object available. This Browser doesn\'t support generating secure random bytes.');if(!i)throw u;r(u)}}}},{"./crypto.js":273}],275:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":276}],276:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick,i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=h;var o=e("core-util-is");o.inherits=e("inherits");var a=e("./_stream_readable"),s=e("./_stream_writable");o.inherits(h,a);for(var u=i(s.prototype),c=0;c0?("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),n?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):_(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?_(e,a,t,!1):S(e,a)):_(e,a,t,!1))):n||(a.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=A?e=A:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(d("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i(k,e):k(e))}function k(e){d("emit readable"),e.emit("readable"),U(e)}function S(e,t){t.readingMore||(t.readingMore=!0,i(M,e,t))}function M(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=c.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,a),0===(e-=a)){a===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function B(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i(P,t,e))}function P(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function C(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return d("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?B(this):x(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&B(this),null;var n,i=t.needReadable;return d("need readable",i),(0===t.length||t.length-e0?j(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&B(this)),null!==n&&this.emit("data",n),n},g.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},g.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,d("pipe count=%d opts=%j",o.pipesCount,t);var u=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?f:g;function c(t,r){d("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,d("cleanup"),e.removeListener("close",m),e.removeListener("finish",v),e.removeListener("drain",h),e.removeListener("error",y),e.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",g),n.removeListener("data",b),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||h())}function f(){d("onend"),e.end()}o.endEmitted?i(u):n.once("end",u),e.on("unpipe",c);var h=function(e){return function(){var t=e._readableState;d("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,U(e))}}(n);e.on("drain",h);var l=!1;var p=!1;function b(t){d("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==C(o.pipes,e))&&!l&&(d("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(t){d("onerror",t),g(),e.removeListener("error",y),0===s(e,"error")&&e.emit("error",t)}function m(){e.removeListener("finish",v),g()}function v(){d("onfinish"),e.removeListener("close",m),g()}function g(){d("unpipe"),n.unpipe(e)}return n.on("data",b),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?a(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",y),e.once("close",m),e.once("finish",v),e.emit("pipe",n),o.flowing||(d("pipe resume"),n.resume()),e},g.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:i;m.WritableState=y;var u=e("core-util-is");u.inherits=e("inherits");var c={deprecate:e("util-deprecate")},f=e("./internal/streams/stream"),h=e("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=e("./internal/streams/destroy");function b(){}function y(t,r){a=a||e("./_stream_duplex"),t=t||{};var n=r instanceof a;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var u=t.highWaterMark,c=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=u||0===u?u:n&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===t.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,o=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,o){--t.pendingcb,r?(i(o,n),i(E,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(o(n),e._writableState.errorEmitted=!0,e.emit("error",n),E(e,t))}(e,r,n,t,o);else{var a=_(r);a||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),n?s(g,e,r,a,o):g(e,r,a,o)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function m(t){if(a=a||e("./_stream_duplex"),!(d.call(m,this)||this instanceof a))return new m(t);this._writableState=new y(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),f.call(this)}function v(e,t,r,n,i,o,a){t.writelen=n,t.writecb=a,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function g(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),E(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),a=t.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,v(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,h=r.callback;if(v(e,t,!1,t.objectMode?1:c.length,c,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function A(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),E(e,t)})}function E(e,t){var r=_(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,i(A,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}u.inherits(m,f),y.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(y.prototype,"buffer",{get:c.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===m&&(e&&e._writableState instanceof y)}})):d=function(e){return e instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(e,t,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=e,h.isBuffer(n)||n instanceof l);return s&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof r&&(r=b),o.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),i(t,r)}(this,r):(s||function(e,t,r,n){var o=!0,a=!1;return null===r?a=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),i(n,a),o=!1),o}(this,o,e,r))&&(o.pendingcb++,a=function(e,t,r,n,i,o){if(!r){var a=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,r));return t}(t,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=t.objectMode?1:n.length;t.length+=s;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},m.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,E(e,t),r&&(t.finished?i(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),m.prototype.destroy=p.destroy,m.prototype._undestroy=p.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":276,"./internal/streams/destroy":282,"./internal/streams/stream":283,_process:257,"core-util-is":89,inherits:180,"process-nextick-args":256,"safe-buffer":290,"util-deprecate":330}],281:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,i,o=n.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,r=o,i=s,t.copy(r,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":290,util:55}],282:[function(e,t,r){"use strict";var n=e("process-nextick-args").nextTick;function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var r=this,o=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return o||a?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||n(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n(i,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":256}],283:[function(e,t,r){t.exports=e("events").EventEmitter},{events:157}],284:[function(e,t,r){t.exports=e("./readable").PassThrough},{"./readable":285}],285:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":276,"./lib/_stream_passthrough.js":277,"./lib/_stream_readable.js":278,"./lib/_stream_transform.js":279,"./lib/_stream_writable.js":280}],286:[function(e,t,r){t.exports=e("./readable").Transform},{"./readable":285}],287:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":280}],288:[function(e,t,r){(function(r){"use strict";var n=e("inherits"),i=e("hash-base");function o(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function a(e,t){return e<>>32-t}function s(e,t,r,n,i,o,s,u){return a(e+(t^r^n)+o+s|0,u)+i|0}function u(e,t,r,n,i,o,s,u){return a(e+(t&r|~t&n)+o+s|0,u)+i|0}function c(e,t,r,n,i,o,s,u){return a(e+((t|~r)^n)+o+s|0,u)+i|0}function f(e,t,r,n,i,o,s,u){return a(e+(t&n|r&~n)+o+s|0,u)+i|0}function h(e,t,r,n,i,o,s,u){return a(e+(t^(r|~n))+o+s|0,u)+i|0}n(o,i),o.prototype._update=function(){for(var e=new Array(16),t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,o=this._d,l=this._e;l=s(l,r=s(r,n,i,o,l,e[0],0,11),n,i=a(i,10),o,e[1],0,14),n=s(n=a(n,10),i=s(i,o=s(o,l,r,n,i,e[2],0,15),l,r=a(r,10),n,e[3],0,12),o,l=a(l,10),r,e[4],0,5),o=s(o=a(o,10),l=s(l,r=s(r,n,i,o,l,e[5],0,8),n,i=a(i,10),o,e[6],0,7),r,n=a(n,10),i,e[7],0,9),r=s(r=a(r,10),n=s(n,i=s(i,o,l,r,n,e[8],0,11),o,l=a(l,10),r,e[9],0,13),i,o=a(o,10),l,e[10],0,14),i=s(i=a(i,10),o=s(o,l=s(l,r,n,i,o,e[11],0,15),r,n=a(n,10),i,e[12],0,6),l,r=a(r,10),n,e[13],0,7),l=u(l=a(l,10),r=s(r,n=s(n,i,o,l,r,e[14],0,9),i,o=a(o,10),l,e[15],0,8),n,i=a(i,10),o,e[7],1518500249,7),n=u(n=a(n,10),i=u(i,o=u(o,l,r,n,i,e[4],1518500249,6),l,r=a(r,10),n,e[13],1518500249,8),o,l=a(l,10),r,e[1],1518500249,13),o=u(o=a(o,10),l=u(l,r=u(r,n,i,o,l,e[10],1518500249,11),n,i=a(i,10),o,e[6],1518500249,9),r,n=a(n,10),i,e[15],1518500249,7),r=u(r=a(r,10),n=u(n,i=u(i,o,l,r,n,e[3],1518500249,15),o,l=a(l,10),r,e[12],1518500249,7),i,o=a(o,10),l,e[0],1518500249,12),i=u(i=a(i,10),o=u(o,l=u(l,r,n,i,o,e[9],1518500249,15),r,n=a(n,10),i,e[5],1518500249,9),l,r=a(r,10),n,e[2],1518500249,11),l=u(l=a(l,10),r=u(r,n=u(n,i,o,l,r,e[14],1518500249,7),i,o=a(o,10),l,e[11],1518500249,13),n,i=a(i,10),o,e[8],1518500249,12),n=c(n=a(n,10),i=c(i,o=c(o,l,r,n,i,e[3],1859775393,11),l,r=a(r,10),n,e[10],1859775393,13),o,l=a(l,10),r,e[14],1859775393,6),o=c(o=a(o,10),l=c(l,r=c(r,n,i,o,l,e[4],1859775393,7),n,i=a(i,10),o,e[9],1859775393,14),r,n=a(n,10),i,e[15],1859775393,9),r=c(r=a(r,10),n=c(n,i=c(i,o,l,r,n,e[8],1859775393,13),o,l=a(l,10),r,e[1],1859775393,15),i,o=a(o,10),l,e[2],1859775393,14),i=c(i=a(i,10),o=c(o,l=c(l,r,n,i,o,e[7],1859775393,8),r,n=a(n,10),i,e[0],1859775393,13),l,r=a(r,10),n,e[6],1859775393,6),l=c(l=a(l,10),r=c(r,n=c(n,i,o,l,r,e[13],1859775393,5),i,o=a(o,10),l,e[11],1859775393,12),n,i=a(i,10),o,e[5],1859775393,7),n=f(n=a(n,10),i=f(i,o=c(o,l,r,n,i,e[12],1859775393,5),l,r=a(r,10),n,e[1],2400959708,11),o,l=a(l,10),r,e[9],2400959708,12),o=f(o=a(o,10),l=f(l,r=f(r,n,i,o,l,e[11],2400959708,14),n,i=a(i,10),o,e[10],2400959708,15),r,n=a(n,10),i,e[0],2400959708,14),r=f(r=a(r,10),n=f(n,i=f(i,o,l,r,n,e[8],2400959708,15),o,l=a(l,10),r,e[12],2400959708,9),i,o=a(o,10),l,e[4],2400959708,8),i=f(i=a(i,10),o=f(o,l=f(l,r,n,i,o,e[13],2400959708,9),r,n=a(n,10),i,e[3],2400959708,14),l,r=a(r,10),n,e[7],2400959708,5),l=f(l=a(l,10),r=f(r,n=f(n,i,o,l,r,e[15],2400959708,6),i,o=a(o,10),l,e[14],2400959708,8),n,i=a(i,10),o,e[5],2400959708,6),n=h(n=a(n,10),i=f(i,o=f(o,l,r,n,i,e[6],2400959708,5),l,r=a(r,10),n,e[2],2400959708,12),o,l=a(l,10),r,e[4],2840853838,9),o=h(o=a(o,10),l=h(l,r=h(r,n,i,o,l,e[0],2840853838,15),n,i=a(i,10),o,e[5],2840853838,5),r,n=a(n,10),i,e[9],2840853838,11),r=h(r=a(r,10),n=h(n,i=h(i,o,l,r,n,e[7],2840853838,6),o,l=a(l,10),r,e[12],2840853838,8),i,o=a(o,10),l,e[2],2840853838,13),i=h(i=a(i,10),o=h(o,l=h(l,r,n,i,o,e[10],2840853838,12),r,n=a(n,10),i,e[14],2840853838,5),l,r=a(r,10),n,e[1],2840853838,12),l=h(l=a(l,10),r=h(r,n=h(n,i,o,l,r,e[3],2840853838,13),i,o=a(o,10),l,e[8],2840853838,14),n,i=a(i,10),o,e[11],2840853838,11),n=h(n=a(n,10),i=h(i,o=h(o,l,r,n,i,e[6],2840853838,8),l,r=a(r,10),n,e[15],2840853838,5),o,l=a(l,10),r,e[13],2840853838,6),o=a(o,10);var d=this._a,p=this._b,b=this._c,y=this._d,m=this._e;m=h(m,d=h(d,p,b,y,m,e[5],1352829926,8),p,b=a(b,10),y,e[14],1352829926,9),p=h(p=a(p,10),b=h(b,y=h(y,m,d,p,b,e[7],1352829926,9),m,d=a(d,10),p,e[0],1352829926,11),y,m=a(m,10),d,e[9],1352829926,13),y=h(y=a(y,10),m=h(m,d=h(d,p,b,y,m,e[2],1352829926,15),p,b=a(b,10),y,e[11],1352829926,15),d,p=a(p,10),b,e[4],1352829926,5),d=h(d=a(d,10),p=h(p,b=h(b,y,m,d,p,e[13],1352829926,7),y,m=a(m,10),d,e[6],1352829926,7),b,y=a(y,10),m,e[15],1352829926,8),b=h(b=a(b,10),y=h(y,m=h(m,d,p,b,y,e[8],1352829926,11),d,p=a(p,10),b,e[1],1352829926,14),m,d=a(d,10),p,e[10],1352829926,14),m=f(m=a(m,10),d=h(d,p=h(p,b,y,m,d,e[3],1352829926,12),b,y=a(y,10),m,e[12],1352829926,6),p,b=a(b,10),y,e[6],1548603684,9),p=f(p=a(p,10),b=f(b,y=f(y,m,d,p,b,e[11],1548603684,13),m,d=a(d,10),p,e[3],1548603684,15),y,m=a(m,10),d,e[7],1548603684,7),y=f(y=a(y,10),m=f(m,d=f(d,p,b,y,m,e[0],1548603684,12),p,b=a(b,10),y,e[13],1548603684,8),d,p=a(p,10),b,e[5],1548603684,9),d=f(d=a(d,10),p=f(p,b=f(b,y,m,d,p,e[10],1548603684,11),y,m=a(m,10),d,e[14],1548603684,7),b,y=a(y,10),m,e[15],1548603684,7),b=f(b=a(b,10),y=f(y,m=f(m,d,p,b,y,e[8],1548603684,12),d,p=a(p,10),b,e[12],1548603684,7),m,d=a(d,10),p,e[4],1548603684,6),m=f(m=a(m,10),d=f(d,p=f(p,b,y,m,d,e[9],1548603684,15),b,y=a(y,10),m,e[1],1548603684,13),p,b=a(b,10),y,e[2],1548603684,11),p=c(p=a(p,10),b=c(b,y=c(y,m,d,p,b,e[15],1836072691,9),m,d=a(d,10),p,e[5],1836072691,7),y,m=a(m,10),d,e[1],1836072691,15),y=c(y=a(y,10),m=c(m,d=c(d,p,b,y,m,e[3],1836072691,11),p,b=a(b,10),y,e[7],1836072691,8),d,p=a(p,10),b,e[14],1836072691,6),d=c(d=a(d,10),p=c(p,b=c(b,y,m,d,p,e[6],1836072691,6),y,m=a(m,10),d,e[9],1836072691,14),b,y=a(y,10),m,e[11],1836072691,12),b=c(b=a(b,10),y=c(y,m=c(m,d,p,b,y,e[8],1836072691,13),d,p=a(p,10),b,e[12],1836072691,5),m,d=a(d,10),p,e[2],1836072691,14),m=c(m=a(m,10),d=c(d,p=c(p,b,y,m,d,e[10],1836072691,13),b,y=a(y,10),m,e[0],1836072691,13),p,b=a(b,10),y,e[4],1836072691,7),p=u(p=a(p,10),b=u(b,y=c(y,m,d,p,b,e[13],1836072691,5),m,d=a(d,10),p,e[8],2053994217,15),y,m=a(m,10),d,e[6],2053994217,5),y=u(y=a(y,10),m=u(m,d=u(d,p,b,y,m,e[4],2053994217,8),p,b=a(b,10),y,e[1],2053994217,11),d,p=a(p,10),b,e[3],2053994217,14),d=u(d=a(d,10),p=u(p,b=u(b,y,m,d,p,e[11],2053994217,14),y,m=a(m,10),d,e[15],2053994217,6),b,y=a(y,10),m,e[0],2053994217,14),b=u(b=a(b,10),y=u(y,m=u(m,d,p,b,y,e[5],2053994217,6),d,p=a(p,10),b,e[12],2053994217,9),m,d=a(d,10),p,e[2],2053994217,12),m=u(m=a(m,10),d=u(d,p=u(p,b,y,m,d,e[13],2053994217,9),b,y=a(y,10),m,e[9],2053994217,12),p,b=a(b,10),y,e[7],2053994217,5),p=s(p=a(p,10),b=u(b,y=u(y,m,d,p,b,e[10],2053994217,15),m,d=a(d,10),p,e[14],2053994217,8),y,m=a(m,10),d,e[12],0,8),y=s(y=a(y,10),m=s(m,d=s(d,p,b,y,m,e[15],0,5),p,b=a(b,10),y,e[10],0,12),d,p=a(p,10),b,e[4],0,9),d=s(d=a(d,10),p=s(p,b=s(b,y,m,d,p,e[1],0,12),y,m=a(m,10),d,e[5],0,5),b,y=a(y,10),m,e[8],0,14),b=s(b=a(b,10),y=s(y,m=s(m,d,p,b,y,e[7],0,6),d,p=a(p,10),b,e[6],0,8),m,d=a(d,10),p,e[2],0,13),m=s(m=a(m,10),d=s(d,p=s(p,b,y,m,d,e[13],0,6),b,y=a(y,10),m,e[14],0,5),p,b=a(b,10),y,e[0],0,15),p=s(p=a(p,10),b=s(b,y=s(y,m,d,p,b,e[3],0,13),m,d=a(d,10),p,e[9],0,11),y,m=a(m,10),d,e[11],0,11),y=a(y,10);var v=this._b+i+y|0;this._b=this._c+o+m|0,this._c=this._d+l+d|0,this._d=this._e+r+p|0,this._e=this._a+n+b|0,this._a=v},o.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=new r(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=o}).call(this,e("buffer").Buffer)},{buffer:84,"hash-base":161,inherits:180}],289:[function(e,t,r){const n=e("assert"),i=e("safe-buffer").Buffer;function o(e,t){if("00"===e.slice(0,2))throw new Error("invalid RLP: extra zeros");return parseInt(e,t)}function a(e,t){if(e<56)return i.from([e+t]);var r=u(e),n=u(t+55+r.length/2);return i.from(n+r,"hex")}function s(e){return"0x"===e.slice(0,2)}function u(e){var t=e.toString(16);return t.length%2&&(t="0"+t),t}function c(e){if(!i.isBuffer(e))if("string"==typeof e)e=s(e)?i.from(((r="string"!=typeof(n=e)?n:s(n)?n.slice(2):n).length%2&&(r="0"+r),r),"hex"):i.from(e);else if("number"==typeof e)e?(t=u(e),e=i.from(t,"hex")):e=i.from([]);else if(null==e)e=i.from([]);else{if(!e.toArray)throw new Error("invalid type");e=i.from(e.toArray())}var t,r,n;return e}r.encode=function(e){if(e instanceof Array){for(var t=[],n=0;nt.length)throw new Error("invalid rlp: total length is larger than the data");if(0===(s=t.slice(n,h)).length)throw new Error("invalid rlp, List has a invalid length");for(;s.length;)u=e(s),c.push(u.data),s=u.remainder;return{data:c,remainder:t.slice(h)}}(e=c(e));return t?r:(n.equal(r.remainder.length,0,"invalid remainder"),r.data)},r.getLength=function(e){if(!e||0===e.length)return i.from([]);var t=(e=c(e))[0];if(t<=127)return e.length;if(t<=183)return t-127;if(t<=191)return t-182;if(t<=247)return t-191;var r=t-246;return r+o(e.slice(1,r).toString("hex"),16)}},{assert:19,"safe-buffer":290}],290:[function(e,t,r){var n=e("buffer"),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function a(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,r),r.Buffer=a),o(i,a),a.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:84}],291:[function(e,t,r){const n=e("util"),i=e("events/");var o="object"==typeof Reflect?Reflect:null,a=o&&"function"==typeof o.apply?o.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};function s(){i.call(this)}function u(e,t,r){try{a(e,t,r)}catch(e){setTimeout(()=>{throw e})}}t.exports=s,n.inherits(s,i),s.prototype.emit=function(e){for(var t=[],r=1;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var s=i[e];if(void 0===s)return!1;if("function"==typeof s)u(s,this,t);else{var c=s.length,f=function(e,t){for(var r=new Array(t),n=0;n0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=function(){for(var e=[],t=0;t0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var c=u.length,f=p(u,c);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return l(this,e,!0)},s.prototype.rawListeners=function(e){return l(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},{}],293:[function(e,t,r){t.exports=e("scryptsy")},{scryptsy:294}],294:[function(e,t,r){(function(r){var n=e("pbkdf2").pbkdf2Sync,i=2147483647;function o(e,t,n,i,o){if(r.isBuffer(e)&&r.isBuffer(n))e.copy(n,i,t,t+o);else for(;o--;)n[i++]=e[t++]}t.exports=function(e,t,a,s,u,c,f){if(0===a||0!=(a&a-1))throw Error("N must be > 0 and a power of 2");if(a>i/128/s)throw Error("Parameter N is too large");if(s>i/128/u)throw Error("Parameter r is too large");var h,l=new r(256*s),d=new r(128*s*a),p=new Int32Array(16),b=new Int32Array(16),y=new r(64),m=n(e,t,1,128*u*s,"sha256");if(f){var v=u*a*2,g=0;h=function(){++g%1e3==0&&f({current:g,total:v,percent:g/v*100})}}for(var w=0;w>>32-t}function x(e){var t;for(t=0;t<16;t++)p[t]=(255&e[4*t+0])<<0,p[t]|=(255&e[4*t+1])<<8,p[t]|=(255&e[4*t+2])<<16,p[t]|=(255&e[4*t+3])<<24;for(o(p,0,b,0,16),t=8;t>0;t-=2)b[4]^=E(b[0]+b[12],7),b[8]^=E(b[4]+b[0],9),b[12]^=E(b[8]+b[4],13),b[0]^=E(b[12]+b[8],18),b[9]^=E(b[5]+b[1],7),b[13]^=E(b[9]+b[5],9),b[1]^=E(b[13]+b[9],13),b[5]^=E(b[1]+b[13],18),b[14]^=E(b[10]+b[6],7),b[2]^=E(b[14]+b[10],9),b[6]^=E(b[2]+b[14],13),b[10]^=E(b[6]+b[2],18),b[3]^=E(b[15]+b[11],7),b[7]^=E(b[3]+b[15],9),b[11]^=E(b[7]+b[3],13),b[15]^=E(b[11]+b[7],18),b[1]^=E(b[0]+b[3],7),b[2]^=E(b[1]+b[0],9),b[3]^=E(b[2]+b[1],13),b[0]^=E(b[3]+b[2],18),b[6]^=E(b[5]+b[4],7),b[7]^=E(b[6]+b[5],9),b[4]^=E(b[7]+b[6],13),b[5]^=E(b[4]+b[7],18),b[11]^=E(b[10]+b[9],7),b[8]^=E(b[11]+b[10],9),b[9]^=E(b[8]+b[11],13),b[10]^=E(b[9]+b[8],18),b[12]^=E(b[15]+b[14],7),b[13]^=E(b[12]+b[15],9),b[14]^=E(b[13]+b[12],13),b[15]^=E(b[14]+b[13],18);for(t=0;t<16;++t)p[t]=b[t]+p[t];for(t=0;t<16;t++){var r=4*t;e[r+0]=p[t]>>0&255,e[r+1]=p[t]>>8&255,e[r+2]=p[t]>>16&255,e[r+3]=p[t]>>24&255}}function k(e,t,r,n,i){for(var o=0;o=r)throw RangeError(n)}}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":181}],297:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("bip66"),o=n.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),a=n.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(e,t,r){var i=n.from(r?o:a);return e.copy(i,r?8:9),t.copy(i,r?181:214),i},r.privateKeyImport=function(e){var t=e.length,r=0;if(!(t2||t1?e[r+n-2]<<8:0);if(!(t<(r+=n)+i||t32||t1&&0===t[o]&&!(128&t[o+1]);--r,++o);for(var a=n.concat([n.from([0]),e.s]),s=33,u=0;s>1&&0===a[u]&&!(128&a[u+1]);--s,++u);return i.encode(t.slice(o),a.slice(u))},r.signatureImport=function(e){var t=n.alloc(32,0),r=n.alloc(32,0);try{var o=i.decode(e);if(33===o.r.length&&0===o.r[0]&&(o.r=o.r.slice(1)),o.r.length>32)throw new Error("R length is too long");if(33===o.s.length&&0===o.s[0]&&(o.s=o.s.slice(1)),o.s.length>32)throw new Error("S length is too long")}catch(e){return}return o.r.copy(t,32-o.r.length),o.s.copy(r,32-o.s.length),{r:t,s:r}},r.signatureImportLax=function(e){var t=n.alloc(32,0),r=n.alloc(32,0),i=e.length,o=0;if(48===e[o++]){var a=e[o++];if(!(128&a&&(o+=a-128)>i)&&2===e[o++]){var s=e[o++];if(128&s){if(o+(a=s-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(s=0;a>0;o+=1,a-=1)s=(s<<8)+e[o]}if(!(s>i-o)){var u=o;if(o+=s,2===e[o++]){var c=e[o++];if(128&c){if(o+(a=c-128)>i)return;for(;a>0&&0===e[o];o+=1,a-=1);for(c=0;a>0;o+=1,a-=1)c=(c<<8)+e[o]}if(!(c>i-o)){var f=o;for(o+=c;s>0&&0===e[u];s-=1,u+=1);if(!(s>32)){var h=e.slice(u,u+s);for(h.copy(t,32-h.length);c>0&&0===e[f];c-=1,f+=1);if(!(c>32)){var l=e.slice(f,f+c);return l.copy(r,32-l.length),{r:t,s:r}}}}}}}}}},{bip66:52,"safe-buffer":290}],298:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("create-hash"),o=e("bn.js"),a=e("elliptic").ec,s=e("../messages.json"),u=new a("secp256k1"),c=u.curve;function f(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new o(t);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),u.keyPair({pub:{x:r,y:n}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new o(t),i=new o(r);if(n.cmp(c.p)>=0||i.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),i=i.toRed(c.red),(6===e||7===e)&&i.isOdd()!==(7===e))return null;var a=n.redSqr().redIMul(n);return i.redSqr().redISub(a.redIAdd(c.b)).isZero()?u.keyPair({pub:{x:n,y:i}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}r.privateKeyVerify=function(e){var t=new o(e);return t.cmp(c.n)<0&&!t.isZero()},r.privateKeyExport=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.privateKeyNegate=function(e){var t=new o(e);return t.isZero()?n.alloc(32):c.n.sub(t).umod(c.n).toArrayLike(n,"be",32)},r.privateKeyModInverse=function(e){var t=new o(e);if(t.cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(c.n).toArrayLike(n,"be",32)},r.privateKeyTweakAdd=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new o(e)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(n,"be",32)},r.privateKeyTweakMul=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new o(e)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(n,"be",32)},r.publicKeyCreate=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},r.publicKeyConvert=function(e,t){var r=f(e);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return n.from(r.getPublic(t,!0))},r.publicKeyVerify=function(e){return null!==f(e)},r.publicKeyTweakAdd=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return n.from(c.g.mul(t).add(i.pub).encode(!0,r))},r.publicKeyTweakMul=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return n.from(i.pub.mul(t).encode(!0,r))},r.publicKeyCombine=function(e,t){for(var r=new Array(e.length),i=0;i=0||r.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var i=n.from(e);return 1===r.cmp(u.nh)&&c.n.sub(r).toArrayLike(n,"be",32).copy(i,32),i},r.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new o(t).cmp(c.n)>=0||new o(r).cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},r.signatureImport=function(e){var t=new o(e.r);t.cmp(c.n)>=0&&(t=new o(0));var r=new o(e.s);return r.cmp(c.n)>=0&&(r=new o(0)),n.concat([t.toArrayLike(n,"be",32),r.toArrayLike(n,"be",32)])},r.sign=function(e,t,r,i){if("function"==typeof r){var a=r;r=function(r){var u=a(e,t,null,i,r);if(!n.isBuffer(u)||32!==u.length)throw new Error(s.ECDSA_SIGN_FAIL);return new o(u)}}var f=new o(t);if(f.cmp(c.n)>=0||f.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var h=u.sign(e,t,{canonical:!0,k:r,pers:i});return{signature:n.concat([h.r.toArrayLike(n,"be",32),h.s.toArrayLike(n,"be",32)]),recovery:h.recoveryParam}},r.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},i=new o(n.r),a=new o(n.s);if(i.cmp(c.n)>=0||a.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===a.cmp(u.nh)||i.isZero()||a.isZero())return!1;var h=f(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return u.verify(e,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(e,t,r,i){var a={r:t.slice(0,32),s:t.slice(32,64)},f=new o(a.r),h=new o(a.s);if(f.cmp(c.n)>=0||h.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(f.isZero()||h.isZero())throw new Error;var l=u.recoverPubKey(e,a,r);return n.from(l.encode(!0,i))}catch(e){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(e,t){var n=r.ecdhUnsafe(e,t,!0);return i("sha256").update(n).digest()},r.ecdhUnsafe=function(e,t,r){var i=f(e);if(null===i)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var a=new o(t);if(a.cmp(c.n)>=0||a.isZero())throw new Error(s.ECDH_FAIL);return n.from(i.pub.mul(a).encode(!0,r))}},{"../messages.json":300,"bn.js":53,"create-hash":91,elliptic:109,"safe-buffer":290}],299:[function(e,t,r){"use strict";var n=e("./assert"),i=e("./der"),o=e("./messages.json");function a(e,t){return void 0===e?t:(n.isBoolean(e,o.COMPRESSED_TYPE_INVALID),e)}t.exports=function(e){return{privateKeyVerify:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0);var s=e.privateKeyExport(t,r);return i.privateKeyExport(t,s,r)},privateKeyImport:function(t){if(n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),(t=i.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakAdd(t,r,i)},publicKeyTweakMul:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakMul(t,r,i)},publicKeyCombine:function(t,r){n.isArray(t,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(t,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=2&&("function"==typeof arguments[1]?r.task=arguments[1]:r.n=arguments[1]);var n=r.task;if(r.task=function(){n(t.leave)},t.current+r.n-e>t.capacity)return 1===e&&(t.current--,t.firstHere=!1),t.queue.push(r);t.current+=r.n-e,r.task(t.leave),1===e&&(t.firstHere=!1)},leave:function(e){if(e=e||1,t.current-=e,t.queue.length){var r=t.queue[0];r.n+t.current>t.capacity||(t.queue.shift(),t.current+=r.n,i(r.task))}else if(t.current<0)throw new Error("leave called too many times.")},available:function(e){return e=e||1,t.current+e<=t.capacity}};return t}void 0!==e&&e&&"function"==typeof e.nextTick&&(i=e.nextTick),"object"==typeof r?t.exports=o:"function"==typeof define&&define.amd?define(function(){return o}):n.semaphore=o}(this)}).call(this,e("_process"))},{_process:257}],302:[function(e,t,r){"use strict";t.exports="function"==typeof setImmediate?setImmediate:function(){var e=[].slice.apply(arguments);e.splice(1,0,0),setTimeout.apply(null,e)}},{}],303:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t){this._block=n.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}i.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=n.from(e,t));for(var r=this._block,i=this._blockSize,o=e.length,a=this._len,s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},{"safe-buffer":290}],304:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":305,"./sha1":306,"./sha224":307,"./sha256":308,"./sha384":309,"./sha512":310}],305:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((t=n)<<5|t>>>27)+f(d,i,o,s)+u+r[l]+a[d];u=s,s=o,o=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],306:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function h(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=(t=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=c(n)+h(p,i,o,s)+u+r[d]+a[p]|0;u=s,s=o,o=f(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],307:[function(e,t,r){var n=e("inherits"),i=e("./sha256"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}n(u,i),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=u},{"./hash":303,"./sha256":308,inherits:180,"safe-buffer":290}],308:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function l(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(u,i),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,m=0;m<16;++m)r[m]=e.readInt32BE(4*m);for(;m<64;++m)r[m]=0|(((t=r[m-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[m-7]+d(r[m-15])+r[m-16];for(var v=0;v<64;++v){var g=y+l(u)+c(u,p,b)+a[v]+r[v]|0,w=h(n)+f(n,i,o)|0;y=b,b=p,p=u,u=s+g|0,s=o,o=i,i=n,n=g+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},u.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],309:[function(e,t,r){var n=e("inherits"),i=e("./sha512"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}n(u,i),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=u},{"./hash":303,"./sha512":310,inherits:180,"safe-buffer":290}],310:[function(e,t,r){var n=e("inherits"),i=e("./hash"),o=e("safe-buffer").Buffer,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function l(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function y(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function m(e,t){return e>>>0>>0?1:0}n(u,i),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,s=0|this._eh,u=0|this._fh,v=0|this._gh,g=0|this._hh,w=0|this._al,_=0|this._bl,A=0|this._cl,E=0|this._dl,x=0|this._el,k=0|this._fl,S=0|this._gl,M=0|this._hl,I=0;I<32;I+=2)t[I]=e.readInt32BE(4*I),t[I+1]=e.readInt32BE(4*I+4);for(;I<160;I+=2){var T=t[I-30],U=t[I-30+1],j=d(T,U),B=p(U,T),P=b(T=t[I-4],U=t[I-4+1]),C=y(U,T),N=t[I-14],R=t[I-14+1],L=t[I-32],O=t[I-32+1],D=B+R|0,F=j+N+m(D,B)|0;F=(F=F+P+m(D=D+C|0,C)|0)+L+m(D=D+O|0,O)|0,t[I]=F,t[I+1]=D}for(var q=0;q<160;q+=2){F=t[q],D=t[q+1];var H=f(r,n,i),z=f(w,_,A),K=h(r,w),V=h(w,r),G=l(s,x),W=l(x,s),Y=a[q],X=a[q+1],Z=c(s,u,v),J=c(x,k,S),$=M+W|0,Q=g+G+m($,M)|0;Q=(Q=(Q=Q+Z+m($=$+J|0,J)|0)+Y+m($=$+X|0,X)|0)+F+m($=$+D|0,D)|0;var ee=V+z|0,te=K+H+m(ee,V)|0;g=v,M=S,v=u,S=k,u=s,k=x,s=o+Q+m(x=E+$|0,E)|0,o=i,E=A,i=n,A=_,n=r,_=w,r=Q+te+m(w=$+ee|0,$)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+A|0,this._dl=this._dl+E|0,this._el=this._el+x|0,this._fl=this._fl+k|0,this._gl=this._gl+S|0,this._hl=this._hl+M|0,this._ah=this._ah+r+m(this._al,w)|0,this._bh=this._bh+n+m(this._bl,_)|0,this._ch=this._ch+i+m(this._cl,A)|0,this._dh=this._dh+o+m(this._dl,E)|0,this._eh=this._eh+s+m(this._el,x)|0,this._fh=this._fh+u+m(this._fl,k)|0,this._gh=this._gh+v+m(this._gl,S)|0,this._hh=this._hh+g+m(this._hl,M)|0},u.prototype._hash=function(){var e=o.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=u},{"./hash":303,inherits:180,"safe-buffer":290}],311:[function(e,t,r){t.exports=i;var n=e("events").EventEmitter;function i(){n.call(this)}e("inherits")(i,n),i.Readable=e("readable-stream/readable.js"),i.Writable=e("readable-stream/writable.js"),i.Duplex=e("readable-stream/duplex.js"),i.Transform=e("readable-stream/transform.js"),i.PassThrough=e("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,e.end())}function u(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(f(),0===n.listenerCount(this,"error"))throw e}function f(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),e.removeListener("close",f)}return r.on("error",c),e.on("error",c),r.on("end",f),r.on("close",f),e.on("close",f),e.emit("pipe",r),e}},{events:157,inherits:180,"readable-stream/duplex.js":275,"readable-stream/passthrough.js":284,"readable-stream/readable.js":285,"readable-stream/transform.js":286,"readable-stream/writable.js":287}],312:[function(e,t,r){(function(t){var n=e("./lib/request"),i=e("./lib/response"),o=e("xtend"),a=e("builtin-status-codes"),s=e("url"),u=r;u.request=function(e,r){e="string"==typeof e?s.parse(e):o(e);var i=-1===t.location.protocol.search(/^https?:$/)?"http:":"",a=e.protocol||i,u=e.hostname||e.host,c=e.port,f=e.path||"/";u&&-1!==u.indexOf(":")&&(u="["+u+"]"),e.url=(u?a+"//"+u:"")+(c?":"+c:"")+f,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var h=new n(e);return r&&h.on("response",r),h},u.get=function(e,t){var r=u.request(e,t);return r.end(),r},u.ClientRequest=n,u.IncomingMessage=i,u.Agent=function(){},u.Agent.defaultMaxSockets=4,u.STATUS_CODES=a,u.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/request":314,"./lib/response":315,"builtin-status-codes":85,url:327,xtend:423}],313:[function(e,t,r){(function(e){r.fetch=s(e.fetch)&&s(e.ReadableStream),r.writableStream=s(e.WritableStream),r.abortController=s(e.AbortController),r.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),r.blobConstructor=!0}catch(e){}var t;function n(){if(void 0!==t)return t;if(e.XMLHttpRequest){t=new e.XMLHttpRequest;try{t.open("GET",e.XDomainRequest?"/":"https://example.com")}catch(e){t=null}}else t=null;return t}function i(e){var t=n();if(!t)return!1;try{return t.responseType=e,t.responseType===e}catch(e){}return!1}var o=void 0!==e.ArrayBuffer,a=o&&s(e.ArrayBuffer.prototype.slice);function s(e){return"function"==typeof e}r.arraybuffer=r.fetch||o&&i("arraybuffer"),r.msstream=!r.fetch&&a&&i("ms-stream"),r.mozchunkedarraybuffer=!r.fetch&&o&&i("moz-chunked-arraybuffer"),r.overrideMimeType=r.fetch||!!n()&&s(n().overrideMimeType),r.vbArray=s(e.VBArray),t=null}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],314:[function(e,t,r){(function(r,n,i){var o=e("./capability"),a=e("inherits"),s=e("./response"),u=e("readable-stream"),c=e("to-arraybuffer"),f=s.IncomingMessage,h=s.readyStates;var l=t.exports=function(e){var t,r=this;u.Writable.call(r),r._opts=e,r._body=[],r._headers={},e.auth&&r.setHeader("Authorization","Basic "+new i(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){r.setHeader(t,e.headers[t])});var n=!0;if("disable-fetch"===e.mode||"requestTimeout"in e&&!o.abortController)n=!1,t=!0;else if("prefer-streaming"===e.mode)t=!1;else if("allow-wrong-content-type"===e.mode)t=!o.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");t=!0}r._mode=function(e,t){return o.fetch&&t?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&e?"arraybuffer":o.vbArray&&e?"text:vbarray":"text"}(t,n),r.on("finish",function(){r._onFinish()})};a(l,u.Writable),l.prototype.setHeader=function(e,t){var r=e.toLowerCase();-1===d.indexOf(r)&&(this._headers[r]={name:e,value:t})},l.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},l.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},l.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,a=e._headers,s=null;"GET"!==t.method&&"HEAD"!==t.method&&(s=o.arraybuffer?c(i.concat(e._body)):o.blobConstructor?new n.Blob(e._body.map(function(e){return c(e)}),{type:(a["content-type"]||{}).value||""}):i.concat(e._body).toString());var u=[];if(Object.keys(a).forEach(function(e){var t=a[e].name,r=a[e].value;Array.isArray(r)?r.forEach(function(e){u.push([t,e])}):u.push([t,r])}),"fetch"===e._mode){var f=null;if(o.abortController){var l=new AbortController;f=l.signal,e._fetchAbortController=l,"requestTimeout"in t&&0!==t.requestTimeout&&n.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},t.requestTimeout)}n.fetch(e._opts.url,{method:e._opts.method,headers:u,body:s||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin",signal:f}).then(function(t){e._fetchResponse=t,e._connect()},function(t){e.emit("error",t)})}else{var d=e._xhr=new n.XMLHttpRequest;try{d.open(e._opts.method,e._opts.url,!0)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}"responseType"in d&&(d.responseType=e._mode.split(":")[0]),"withCredentials"in d&&(d.withCredentials=!!t.withCredentials),"text"===e._mode&&"overrideMimeType"in d&&d.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in t&&(d.timeout=t.requestTimeout,d.ontimeout=function(){e.emit("requestTimeout")}),u.forEach(function(e){d.setRequestHeader(e[0],e[1])}),e._response=null,d.onreadystatechange=function(){switch(d.readyState){case h.LOADING:case h.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(d.onprogress=function(){e._onXHRProgress()}),d.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{d.send(s)}catch(t){return void r.nextTick(function(){e.emit("error",t)})}}}},l.prototype._onXHRProgress=function(){(function(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}})(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},l.prototype._connect=function(){var e=this;e._destroyed||(e._response=new f(e._xhr,e._fetchResponse,e._mode),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},l.prototype._write=function(e,t,r){this._body.push(e),r()},l.prototype.abort=l.prototype.destroy=function(){this._destroyed=!0,this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},l.prototype.end=function(e,t,r){"function"==typeof e&&(r=e,e=void 0),u.Writable.prototype.end.call(this,e,t,r)},l.prototype.flushHeaders=function(){},l.prototype.setTimeout=function(){},l.prototype.setNoDelay=function(){},l.prototype.setSocketKeepAlive=function(){};var d=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,"./response":315,_process:257,buffer:84,inherits:180,"readable-stream":285,"to-arraybuffer":323}],315:[function(e,t,r){(function(t,n,i){var o=e("./capability"),a=e("inherits"),s=e("readable-stream"),u=r.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},c=r.IncomingMessage=function(e,r,n){var a=this;if(s.Readable.call(a),a._mode=n,a.headers={},a.rawHeaders=[],a.trailers={},a.rawTrailers=[],a.on("end",function(){t.nextTick(function(){a.emit("close")})}),"fetch"===n){if(a._fetchResponse=r,a.url=r.url,a.statusCode=r.status,a.statusMessage=r.statusText,r.headers.forEach(function(e,t){a.headers[t.toLowerCase()]=e,a.rawHeaders.push(t,e)}),o.writableStream){var u=new WritableStream({write:function(e){return new Promise(function(t,r){a._destroyed||(a.push(new i(e))?t():a._resumeFetch=t)})},close:function(){a._destroyed||a.push(null)},abort:function(e){a._destroyed||a.emit("error",e)}});try{return void r.body.pipeTo(u)}catch(e){}}var c=r.body.getReader();!function e(){c.read().then(function(t){a._destroyed||(t.done?a.push(null):(a.push(new i(t.value)),e()))}).catch(function(e){a._destroyed||a.emit("error",e)})}()}else{if(a._xhr=e,a._pos=0,a.url=e.responseURL,a.statusCode=e.status,a.statusMessage=e.statusText,e.getAllResponseHeaders().split(/\r?\n/).forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var r=t[1].toLowerCase();"set-cookie"===r?(void 0===a.headers[r]&&(a.headers[r]=[]),a.headers[r].push(t[2])):void 0!==a.headers[r]?a.headers[r]+=", "+t[2]:a.headers[r]=t[2],a.rawHeaders.push(t[1],t[2])}}),a._charset="x-user-defined",!o.overrideMimeType){var f=a.rawHeaders["mime-type"];if(f){var h=f.match(/;\s*charset=([^;])(;|$)/);h&&(a._charset=h[1].toLowerCase())}a._charset||(a._charset="utf-8")}}};a(c,s.Readable),c.prototype._read=function(){var e=this._resumeFetch;e&&(this._resumeFetch=null,e())},c.prototype._onXHRProgress=function(){var e=this,t=e._xhr,r=null;switch(e._mode){case"text:vbarray":if(t.readyState!==u.DONE)break;try{r=new n.VBArray(t.responseBody).toArray()}catch(e){}if(null!==r){e.push(new i(r));break}case"text":try{r=t.responseText}catch(t){e._mode="text:vbarray";break}if(r.length>e._pos){var o=r.substr(e._pos);if("x-user-defined"===e._charset){for(var a=new i(o.length),s=0;se._pos&&(e.push(new i(new Uint8Array(c.result.slice(e._pos)))),e._pos=c.result.byteLength)},c.onload=function(){e.push(null)},c.readAsArrayBuffer(r)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":313,_process:257,buffer:84,inherits:180,"readable-stream":285}],316:[function(e,t,r){"use strict";t.exports=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}},{}],317:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=f,this.end=h,t=3;break;default:return this.write=l,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:-1}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�".repeat(r);if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�".repeat(r+1);if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�".repeat(r+2)}}(this,e,t);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function l(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}r.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":290}],318:[function(e,t,r){var n=e("is-hex-prefixed");t.exports=function(e){return"string"!=typeof e?e:n(e)?e.slice(2):e}},{"is-hex-prefixed":185}],319:[function(e,t,r){var n=function(){throw"This swarm.js function isn't available on the browser."},i={readFile:n},o={download:n,safeDownloadArchived:n,directoryTree:n},a={platform:n,arch:n},s={join:n,slice:n},u={spawn:n},c={lookup:n},f=e("xhr-request-promise"),h=e("eth-lib/lib/bytes"),l=e("./swarm-hash.js"),d=e("./pick.js"),p=e("./swarm");t.exports=p({fsp:i,files:o,os:a,path:s,child_process:u,defaultArchives:{},mimetype:c,request:f,downloadUrl:null,bytes:h,hash:l,pick:d})},{"./pick.js":320,"./swarm":322,"./swarm-hash.js":321,"eth-lib/lib/bytes":133,"xhr-request-promise":411}],320:[function(e,t,r){var n=function(e){return function(){return new Promise(function(t,r){var n=function(r){var n={},i=r.target.files.length,o=0;[].map.call(r.target.files,function(r){var a=new FileReader;a.onload=function(a){var s=new Uint8Array(a.target.result);if("directory"===e){var u=r.webkitRelativePath;n[u.slice(u.indexOf("/")+1)]={type:"text/plain",data:s},++o===i&&t(n)}else if("file"===e){var c=r.webkitRelativePath;t({type:mimetype.lookup(c),data:s})}else t(s)},a.readAsArrayBuffer(r)})},i=void 0;"directory"===e?((i=document.createElement("input")).addEventListener("change",n),i.type="file",i.webkitdirectory=!0,i.mozdirectory=!0,i.msdirectory=!0,i.odirectory=!0,i.directory=!0):((i=document.createElement("input")).addEventListener("change",n),i.type="file");var o=document.createEvent("MouseEvents");o.initEvent("click",!0,!1),i.dispatchEvent(o)})}};t.exports={data:n("data"),file:n("file"),directory:n("directory")}},{}],321:[function(e,t,r){var n=e("eth-lib/lib/hash").keccak256,i=e("eth-lib/lib/bytes"),o=function(e,t){var r=i.reverse(i.pad(6,i.fromNumber(e))),o=i.flatten([r,"0x0000",t]);return n(o).slice(2)};t.exports=function e(t){"string"==typeof t&&"0x"!==t.slice(0,2)?t=i.fromString(t):"string"!=typeof t&&void 0!==t.length&&(t=i.fromUint8Array(t));var r=i.length(t);if(r<=4096)return o(r,t);for(var n=4096;128*n0){var a=i.join(r,o);n.push(g(e)(t[o])(a))}return Promise.all(n).then(function(){return r})})}}},_=function(e){return function(t){return u(e+"/bzzr:/",{body:"string"==typeof t?L(t):t,method:"POST"})}},A=function(e){return function(t){return function(r){return function(n){return function i(o){var a="/"===r[0]?r:"/"+r,s=e+"/bzz:/"+t+a,c={method:"PUT",headers:{"Content-Type":n.type},body:n.data};return u(s,c).then(function(e){if(-1!==e.indexOf("error"))throw e;return e}).catch(function(e){return o>0&&i(o-1)})}(3)}}}},E=function(e){return function(t){return k(e)({"":t})}},x=function(e){return function(r){return t.readFile(r).then(function(t){return E(e)({type:a.lookup(r),data:t})})}},k=function(e){return function(t){return _(e)("{}").then(function(r){return Object.keys(t).reduce(function(r,n){return r.then(function(r){return function(n){return A(e)(n)(r)(t[r])}}(n))},Promise.resolve(r))})}},S=function(e){return function(r){return t.readFile(r).then(_(e))}},M=function(e){return function(n){return function(i){return r.directoryTree(i).then(function(e){return Promise.all(e.map(function(e){return t.readFile(e)})).then(function(t){var r=e.map(function(e){return e.slice(i.length)}),n=e.map(function(e){return a.lookup(e)||"text/plain"});return d(r)(t.map(function(e,t){return{type:n[t],data:e}}))})}).then(function(e){return(t=n?{"":e[n]}:{},function(e){var r={};for(var n in t)r[n]=t[n];for(var i in e)r[i]=e[i];return r})(e);var t}).then(k(e))}}},I=function(e){return function(t){if("data"===t.pick)return l.data().then(_(e));if("file"===t.pick)return l.file().then(E(e));if("directory"===t.pick)return l.directory().then(k(e));if(t.path)switch(t.kind){case"data":return S(e)(t.path);case"file":return x(e)(t.path);case"directory":return M(e)(t.defaultFile)(t.path)}else{if(t.length||"string"==typeof t)return _(e)(t);if(t instanceof Object)return k(e)(t)}return Promise.reject(new Error("Bad arguments"))}},T=function(e){return function(t){return function(r){return C(e)(t).then(function(n){return n?r?w(e)(t)(r):v(e)(t):r?g(e)(t)(r):b(e)(t)})}}},U=function(e,t){var i=n.platform().replace("win32","windows")+"-"+("x64"===n.arch()?"amd64":"386"),o=(t||s)[i],a=c+o.archive+".tar.gz",u=o.archiveMD5,f=o.binaryMD5;return r.safeDownloadArchived(a)(u)(f)(e)},j=function(e){return new Promise(function(t,r){var n=o.spawn,i=function(e){return function(t){return-1!==(""+t).indexOf(e)}},a=e.account,s=e.password,u=e.dataDir,c=e.ensApi,f=e.privateKey,h=0,l=n(e.binPath,["--bzzaccount",a||f,"--datadir",u,"--ens-api",c]),d=function(e){0===h&&i("Passphrase")(e)?setTimeout(function(){h=1,l.stdin.write(s+"\n")},500):i("Swarm http proxy started")(e)&&(h=2,clearTimeout(p),t(l))};l.stdout.on("data",d),l.stderr.on("data",d);var p=setTimeout(function(){return r(new Error("Couldn't start swarm process."))},2e4)})},B=function(e){return new Promise(function(t,r){e.stderr.removeAllListeners("data"),e.stdout.removeAllListeners("data"),e.stdin.removeAllListeners("error"),e.removeAllListeners("error"),e.removeAllListeners("exit"),e.kill("SIGINT");var n=setTimeout(function(){return e.kill("SIGKILL")},8e3);e.once("close",function(){clearTimeout(n),t()})})},P=function(e){return _(e)("test").then(function(e){return"c9a99c7d326dcc6316f32fe2625b311f6dc49a175e6877681ded93137d3569e7"===e}).catch(function(){return!1})},C=function(e){return function(t){return b(e)(t).then(function(e){try{return!!JSON.parse(R(e)).entries}catch(e){return!1}})}},N=function(e){return function(t,r,n,i,o){var a;return void 0!==t&&(a=e(t)),void 0!==r&&(a=e(r)),void 0!==n&&(a=e(n)),void 0!==i&&(a=e(i)),void 0!==o&&(a=e(o)),a}},R=function(e){return f.toString(f.fromUint8Array(e))},L=function(e){return f.toUint8Array(f.fromString(e))},O=function(e){return{download:function(t,r){return T(e)(t)(r)},downloadData:N(b(e)),downloadDataToDisk:N(g(e)),downloadDirectory:N(v(e)),downloadDirectoryToDisk:N(w(e)),downloadEntries:N(y(e)),downloadRoutes:N(m(e)),isAvailable:function(){return P(e)},upload:function(t){return I(e)(t)},uploadData:N(_(e)),uploadFile:N(E(e)),uploadFileFromDisk:N(E(e)),uploadDataFromDisk:N(S(e)),uploadDirectory:N(k(e)),uploadDirectoryFromDisk:N(M(e)),uploadToManifest:N(A(e)),pick:l,hash:h,fromString:L,toString:R}};return{at:O,local:function(e){return function(t){return P("http://localhost:8500").then(function(r){return r?t(O("http://localhost:8500")).then(function(){}):U(e.binPath,e.archives).onData(function(t){return(e.onProgress||function(){})(t.length)}).then(function(){return j(e)}).then(function(e){return t(O("http://localhost:8500")).then(function(){return e})}).then(B)})}},download:T,downloadBinary:U,downloadData:b,downloadDataToDisk:g,downloadDirectory:v,downloadDirectoryToDisk:w,downloadEntries:y,downloadRoutes:m,isAvailable:P,startProcess:j,stopProcess:B,upload:I,uploadData:_,uploadDataFromDisk:S,uploadFile:E,uploadFileFromDisk:x,uploadDirectory:k,uploadDirectoryFromDisk:M,uploadToManifest:A,pick:l,hash:h,fromString:L,toString:R}}},{}],323:[function(e,t,r){var n=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(n.isBuffer(e)){for(var t=new Uint8Array(e.length),r=e.length,i=0;i=0&&t<=A};function k(e){return function(t,r,n,i){r=m(r,i,4);var o=!x(t)&&y.keys(t),a=(o||t).length,s=e>0?0:a-1;return arguments.length<3&&(n=t[o?o[s]:s],s+=e),function(t,r,n,i,o,a){for(;o>=0&&o=0},y.invoke=function(e,t){var r=u.call(arguments,2),n=y.isFunction(t);return y.map(e,function(e){var i=n?t:e[t];return null==i?i:i.apply(e,r)})},y.pluck=function(e,t){return y.map(e,y.property(t))},y.where=function(e,t){return y.filter(e,y.matcher(t))},y.findWhere=function(e,t){return y.find(e,y.matcher(t))},y.max=function(e,t,r){var n,i,o=-1/0,a=-1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;so&&(o=n);else t=v(t,r),y.each(e,function(e,r,n){((i=t(e,r,n))>a||i===-1/0&&o===-1/0)&&(o=e,a=i)});return o},y.min=function(e,t,r){var n,i,o=1/0,a=1/0;if(null==t&&null!=e)for(var s=0,u=(e=x(e)?e:y.values(e)).length;sn||void 0===r)return 1;if(r0?0:i-1;o>=0&&o0?a=o>=0?o:Math.max(o+s,a):s=o>=0?Math.min(o+1,s):o+s+1;else if(r&&o&&s)return n[o=r(n,i)]===i?o:-1;if(i!=i)return(o=t(u.call(n,a,s),y.isNaN))>=0?o+a:-1;for(o=e>0?a:s-1;o>=0&&ot?(a&&(clearTimeout(a),a=null),s=c,o=e.apply(n,i),a||(n=i=null)):a||!1===r.trailing||(a=setTimeout(u,f)),o}},y.debounce=function(e,t,r){var n,i,o,a,s,u=function(){var c=y.now()-a;c=0?n=setTimeout(u,t-c):(n=null,r||(s=e.apply(o,i),n||(o=i=null)))};return function(){o=this,i=arguments,a=y.now();var c=r&&!n;return n||(n=setTimeout(u,t)),c&&(s=e.apply(o,i),o=i=null),s}},y.wrap=function(e,t){return y.partial(t,e)},y.negate=function(e){return function(){return!e.apply(this,arguments)}},y.compose=function(){var e=arguments,t=e.length-1;return function(){for(var r=t,n=e[t].apply(this,arguments);r--;)n=e[r].call(this,n);return n}},y.after=function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},y.before=function(e,t){var r;return function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=null),r}},y.once=y.partial(y.before,2);var j=!{toString:null}.propertyIsEnumerable("toString"),B=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];function P(e,t){var r=B.length,n=e.constructor,i=y.isFunction(n)&&n.prototype||o,a="constructor";for(y.has(e,a)&&!y.contains(t,a)&&t.push(a);r--;)(a=B[r])in e&&e[a]!==i[a]&&!y.contains(t,a)&&t.push(a)}y.keys=function(e){if(!y.isObject(e))return[];if(l)return l(e);var t=[];for(var r in e)y.has(e,r)&&t.push(r);return j&&P(e,t),t},y.allKeys=function(e){if(!y.isObject(e))return[];var t=[];for(var r in e)t.push(r);return j&&P(e,t),t},y.values=function(e){for(var t=y.keys(e),r=t.length,n=Array(r),i=0;i":">",'"':""","'":"'","`":"`"},R=y.invert(N),L=function(e){var t=function(t){return e[t]},r="(?:"+y.keys(e).join("|")+")",n=RegExp(r),i=RegExp(r,"g");return function(e){return e=null==e?"":""+e,n.test(e)?e.replace(i,t):e}};y.escape=L(N),y.unescape=L(R),y.result=function(e,t,r){var n=null==e?void 0:e[t];return void 0===n&&(n=r),y.isFunction(n)?n.call(e):n};var O=0;y.uniqueId=function(e){var t=++O+"";return e?e+t:t},y.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var D=/(.)^/,F={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},q=/\\|'|\r|\n|\u2028|\u2029/g,H=function(e){return"\\"+F[e]};y.template=function(e,t,r){!t&&r&&(t=r),t=y.defaults({},t,y.templateSettings);var n=RegExp([(t.escape||D).source,(t.interpolate||D).source,(t.evaluate||D).source].join("|")+"|$","g"),i=0,o="__p+='";e.replace(n,function(t,r,n,a,s){return o+=e.slice(i,s).replace(q,H),i=s+t.length,r?o+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":n?o+="'+\n((__t=("+n+"))==null?'':__t)+\n'":a&&(o+="';\n"+a+"\n__p+='"),t}),o+="';\n",t.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{var a=new Function(t.variable||"obj","_",o)}catch(e){throw e.source=o,e}var s=function(e){return a.call(this,e,y)},u=t.variable||"obj";return s.source="function("+u+"){\n"+o+"}",s},y.chain=function(e){var t=y(e);return t._chain=!0,t};var z=function(e,t){return e._chain?y(t).chain():t};y.mixin=function(e){y.each(y.functions(e),function(t){var r=y[t]=e[t];y.prototype[t]=function(){var e=[this._wrapped];return s.apply(e,arguments),z(this,r.apply(y,e))}})},y.mixin(y),y.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=i[e];y.prototype[e]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==e&&"splice"!==e||0!==r.length||delete r[0],z(this,r)}}),y.each(["concat","join","slice"],function(e){var t=i[e];y.prototype[e]=function(){return z(this,t.apply(this._wrapped,arguments))}}),y.prototype.value=function(){return this._wrapped},y.prototype.valueOf=y.prototype.toJSON=y.prototype.value,y.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return y})}).call(this)},{}],326:[function(e,t,r){t.exports=function(e,t){if(t){t=(t=t.trim().replace(/^(\?|#|&)/,""))?"?"+t:t;var r=e.split(/[\?\#]/),n=r[0];t&&/\:\/\/[^\/]*$/.test(n)&&(n+="/");var i=e.match(/(\#.*)$/);e=n+t,i&&(e+=i[0])}return e}},{}],327:[function(e,t,r){"use strict";var n=e("punycode"),i=e("./util");function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}r.parse=g,r.resolve=function(e,t){return g(e,!1,!0).resolve(t)},r.resolveObject=function(e,t){return e?g(e,!1,!0).resolveObject(t):t},r.format=function(e){i.isString(e)&&(e=g(e));return e instanceof o?e.format():o.prototype.format.call(e)},r.Url=o;var a=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=e("querystring");function g(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o127?P+="x":P+=B[C];if(!P.match(d)){var R=U.slice(0,M),L=U.slice(M+1),O=B.match(p);O&&(R.push(O[1]),L.unshift(O[2])),L.length&&(g="/"+L.join(".")+g),this.hostname=R.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),T||(this.hostname=n.toASCII(this.hostname));var D=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+D,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==g[0]&&(g="/"+g))}if(!b[A])for(M=0,j=f.length;M0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift());return r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!E.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var k=E.slice(-1)[0],S=(r.host||e.host||E.length>1)&&("."===k||".."===k)||""===k,M=0,I=E.length;I>=0;I--)"."===(k=E[I])?E.splice(I,1):".."===k?(E.splice(I,1),M++):M&&(E.splice(I,1),M--);if(!_&&!A)for(;M--;M)E.unshift("..");!_||""===E[0]||E[0]&&"/"===E[0].charAt(0)||E.unshift(""),S&&"/"!==E.join("/").substr(-1)&&E.push("");var T,U=""===E[0]||E[0]&&"/"===E[0].charAt(0);x&&(r.hostname=r.host=U?"":E.length?E.shift():"",(T=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=T.shift(),r.host=r.hostname=T.shift()));return(_=_||r.host&&E.length)&&!U&&E.unshift(""),E.length?r.pathname=E.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":328,punycode:265,querystring:269}],328:[function(e,t,r){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],329:[function(e,t,r){(function(e){!function(n){var i="object"==typeof r&&r,o="object"==typeof t&&t&&t.exports==i&&t,a="object"==typeof e&&e;a.global!==a&&a.window!==a||(n=a);var s,u,c,f=String.fromCharCode;function h(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i=55296&&e<=57343)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value")}function d(e,t){return f(e>>t&63|128)}function p(e){if(0==(4294967168&e))return f(e);var t="";return 0==(4294965248&e)?t=f(e>>6&31|192):0==(4294901760&e)?(l(e),t=f(e>>12&15|224),t+=d(e,6)):0==(4292870144&e)&&(t=f(e>>18&7|240),t+=d(e,12),t+=d(e,6)),t+=f(63&e|128)}function b(){if(c>=u)throw Error("Invalid byte index");var e=255&s[c];if(c++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function y(){var e,t;if(c>u)throw Error("Invalid byte index");if(c==u)return!1;if(e=255&s[c],c++,0==(128&e))return e;if(192==(224&e)){if((t=(31&e)<<6|b())>=128)return t;throw Error("Invalid continuation byte")}if(224==(240&e)){if((t=(15&e)<<12|b()<<6|b())>=2048)return l(t),t;throw Error("Invalid continuation byte")}if(240==(248&e)&&(t=(15&e)<<18|b()<<12|b()<<6|b())>=65536&&t<=1114111)return t;throw Error("Invalid UTF-8 detected")}var m={version:"2.0.0",encode:function(e){for(var t=h(e),r=t.length,n=-1,i="";++n65535&&(i+=f((t-=65536)>>>10&1023|55296),t=56320|1023&t),i+=f(t);return i}(r)}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return m});else if(i&&!i.nodeType)if(o)o.exports=m;else{var v={}.hasOwnProperty;for(var g in m)v.call(m,g)&&(i[g]=m[g])}else n.utf8=m}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],330:[function(e,t,r){(function(e){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],331:[function(e,t,r){arguments[4][180][0].apply(r,arguments)},{dup:180}],332:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],333:[function(e,t,r){(function(t,n){var i=/%[sdj%]/g;r.format=function(e){if(!m(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(t)?n.showHidden=t:t&&r._extend(n,t),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,e,n.depth)}function u(e,t){var r=s.styles[t];return r?"["+s.colors[r][0]+"m"+e+"["+s.colors[r][1]+"m":e}function c(e,t){return e}function f(e,t,n){if(e.customInspect&&t&&E(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return m(i)||(i=f(e,i,n)),i}var o=function(e,t){if(v(t))return e.stylize("undefined","undefined");if(m(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(y(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(b(t))return e.stylize("null","null")}(e,t);if(o)return o;var a=Object.keys(t),s=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),A(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return h(t);if(0===a.length){if(E(t)){var u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","special")}if(g(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(_(t))return e.stylize(Date.prototype.toString.call(t),"date");if(A(t))return h(t)}var c,w="",x=!1,k=["{","}"];(d(t)&&(x=!0,k=["[","]"]),E(t))&&(w=" [Function"+(t.name?": "+t.name:"")+"]");return g(t)&&(w=" "+RegExp.prototype.toString.call(t)),_(t)&&(w=" "+Date.prototype.toUTCString.call(t)),A(t)&&(w=" "+h(t)),0!==a.length||x&&0!=t.length?n<0?g(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=x?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(c,w,k)):k[0]+w+k[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),M(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=b(r)?f(e,u.value,null):f(e,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n")):s=e.stylize("[Circular]","special")),v(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function b(e){return null===e}function y(e){return"number"==typeof e}function m(e){return"string"==typeof e}function v(e){return void 0===e}function g(e){return w(e)&&"[object RegExp]"===x(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===x(e)}function A(e){return w(e)&&("[object Error]"===x(e)||e instanceof Error)}function E(e){return"function"==typeof e}function x(e){return Object.prototype.toString.call(e)}function k(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(v(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=t.pid;a[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else a[e]=function(){};return a[e]},r.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(e){return null==e},r.isNumber=y,r.isString=m,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=v,r.isRegExp=g,r.isObject=w,r.isDate=_,r.isError=A,r.isFunction=E,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[k(e.getHours()),k(e.getMinutes()),k(e.getSeconds())].join(":"),[e.getDate(),S[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":332,_process:257,inherits:331}],334:[function(require,module,exports){var indexOf=require("indexof"),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},c.prototype.getCall=function(e){return n.isFunction(this.call)?this.call(e):this.call},c.prototype.extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},c.prototype.validateArgs=function(e){if(e.length!==this.params)throw i.InvalidNumberOfParams(e.length,this.params,this.name)},c.prototype.formatInput=function(e){var t=this;return this.inputFormatter?this.inputFormatter.map(function(r,n){return r?r.call(t,e[n]):e[n]}):e},c.prototype.formatOutput=function(e){var t=this;return n.isArray(e)?e.map(function(e){return t.outputFormatter&&e?t.outputFormatter(e):e}):this.outputFormatter&&e?this.outputFormatter(e):e},c.prototype.toPayload=function(e){var t=this.getCall(e),r=this.extractCallback(e),n=this.formatInput(e);this.validateArgs(n);var i={method:t,params:n,callback:r};return this.transformPayload&&(i=this.transformPayload(i)),i},c.prototype._confirmTransaction=function(e,t,r){var i=this,f=!1,h=!0,l=0,d=0,p=null,b="",y=n.isObject(r.params[0])&&r.params[0].gas?r.params[0].gas:null,m=n.isObject(r.params[0])&&r.params[0].data&&r.params[0].from&&!r.params[0].to,v=[new c({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:o.outputTransactionReceiptFormatter}),new c({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[o.inputAddressFormatter,o.inputDefaultBlockNumberFormatter]}),new u({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:o.outputBlockFormatter}}})],g={};n.each(v,function(e){e.attachToObject(g),e.requestManager=i.requestManager});var w=function(r,n,o,u,c){if(!o)return c||(c={unsubscribe:function(){clearInterval(p)}}),(r?s.resolve(r):g.getTransactionReceipt(t)).catch(function(t){c.unsubscribe(),f=!0,a._fireError({message:"Failed to check for transaction receipt:",data:t},e.eventEmitter,e.reject)}).then(function(t){if(!t||!t.blockHash)throw new Error("Receipt missing or blockHash null");return i.extraFormatters&&i.extraFormatters.receiptFormatter&&(t=i.extraFormatters.receiptFormatter(t)),e.eventEmitter.listeners("confirmation").length>0&&(void 0!==r&&0===d||e.eventEmitter.emit("confirmation",d,t),h=!1,25===++d&&(c.unsubscribe(),e.eventEmitter.removeAllListeners())),t}).then(function(t){if(m&&!f){if(!t.contractAddress)return h&&(c.unsubscribe(),f=!0),void a._fireError(new Error("The transaction receipt didn't contain a contract address."),e.eventEmitter,e.reject);g.getCode(t.contractAddress,function(r,n){n&&(n.length>2?(e.eventEmitter.emit("receipt",t),i.extraFormatters&&i.extraFormatters.contractDeployFormatter?e.resolve(i.extraFormatters.contractDeployFormatter(t)):e.resolve(t),h&&e.eventEmitter.removeAllListeners()):a._fireError(new Error("The contract code couldn't be stored, please check your gas limit."),e.eventEmitter,e.reject),h&&c.unsubscribe(),f=!0)})}return t}).then(function(t){m||f||(t.outOfGas||y&&y===t.gasUsed||!0!==t.status&&"0x1"!==t.status&&void 0!==t.status?(b=JSON.stringify(t,null,2),!1===t.status||"0x0"===t.status?a._fireError(new Error("Transaction has been reverted by the EVM:\n"+b),e.eventEmitter,e.reject):a._fireError(new Error("Transaction ran out of gas. Please provide more gas:\n"+b),e.eventEmitter,e.reject)):(e.eventEmitter.emit("receipt",t),e.resolve(t),h&&e.eventEmitter.removeAllListeners()),h&&c.unsubscribe(),f=!0)}).catch(function(){l++,n?l-1>=750&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject)):l-1>=50&&(c.unsubscribe(),f=!0,a._fireError(new Error("Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!"),e.eventEmitter,e.reject))});c.unsubscribe(),f=!0,a._fireError({message:"Failed to subscribe to new newBlockHeaders to confirm the transaction receipts.",data:o},e.eventEmitter,e.reject)},_=function(e){n.isFunction(this.requestManager.provider.on)?g.subscribe("newBlockHeaders",w.bind(null,e,!1)):p=setInterval(w.bind(null,e,!0),1e3)}.bind(this);g.getTransactionReceipt(t).then(function(t){t&&t.blockHash?(e.eventEmitter.listeners("confirmation").length>0&&_(t),w(t,!1)):f||_()}).catch(function(){f||_()})};var f=function(e,t){return n.isNumber(e)?t.wallet[e]:n.isObject(e)&&e.address&&e.privateKey?e:t.wallet[e.toLowerCase()]};c.prototype.buildCall=function(){var e=this,t="eth_sendTransaction"===e.call||"eth_sendRawTransaction"===e.call,r=function(){var r=s(!t),i=e.toPayload(Array.prototype.slice.call(arguments)),o=function(n,o){try{o=e.formatOutput(o)}catch(e){n=e}if(o instanceof Error&&(n=o),n)return n.error&&(n=n.error),a._fireError(n,r.eventEmitter,r.reject,i.callback);i.callback&&i.callback(null,o),t?(r.eventEmitter.emit("transactionHash",o),e._confirmTransaction(r,o,i)):n||r.resolve(o)},u=function(t){var r=n.extend({},i,{method:"eth_sendRawTransaction",params:[t.rawTransaction]});e.requestManager.send(r,o)},h=function(e,t){var i;if(t&&t.accounts&&t.accounts.wallet&&t.accounts.wallet.length)if("eth_sendTransaction"===e.method){var a=e.params[0];if((i=f(n.isObject(a)?a.from:null,t.accounts))&&i.privateKey)return t.accounts.signTransaction(n.omit(a,"from"),i.privateKey).then(u)}else if("eth_sign"===e.method){var s=e.params[1];if((i=f(e.params[0],t.accounts))&&i.privateKey){var c=t.accounts.sign(s,i.privateKey);return e.callback&&e.callback(null,c.signature),void r.resolve(c.signature)}}return t.requestManager.send(e,o)};t&&n.isObject(i.params[0])&&void 0===i.params[0].gasPrice?new c({name:"getGasPrice",call:"eth_gasPrice",params:0}).createFunction(e.requestManager)(function(t,r){r&&(i.params[0].gasPrice=r),h(i,e)}):h(i,e);return r.eventEmitter};return r.method=e,r.request=this.request.bind(this),r},c.prototype.request=function(){var e=this.toPayload(Array.prototype.slice.call(arguments));return e.format=this.formatOutput.bind(this),e},t.exports=c},{underscore:325,"web3-core-helpers":338,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-utils":403}],340:[function(e,t,r){"use strict";var n=e("eventemitter3"),i=e("any-promise"),o=function(e){var t,r,o=new i(function(){t=arguments[0],r=arguments[1]});if(e)return{resolve:t,reject:r,eventEmitter:o};var a=new n;return o._events=a._events,o.emit=a.emit,o.on=a.on,o.once=a.once,o.off=a.off,o.listeners=a.listeners,o.addListener=a.addListener,o.removeListener=a.removeListener,o.removeAllListeners=a.removeAllListeners,{resolve:t,reject:r,eventEmitter:o}};o.resolve=function(e){var t=o(!0);return t.resolve(e),t.eventEmitter},t.exports=o},{"any-promise":2,eventemitter3:156}],341:[function(e,t,r){"use strict";var n=e("./jsonrpc"),i=e("web3-core-helpers").errors,o=function(e){this.requestManager=e,this.requests=[]};o.prototype.add=function(e){this.requests.push(e)},o.prototype.execute=function(){var e=this.requests;this.requestManager.sendBatch(e,function(t,r){r=r||[],e.map(function(e,t){return r[t]||{}}).forEach(function(t,r){if(e[r].callback){if(t&&t.error)return e[r].callback(i.ErrorResponse(t));if(!n.isValidResponse(t))return e[r].callback(i.InvalidResponse(t));try{e[r].callback(null,e[r].format?e[r].format(t.result):t.result)}catch(t){e[r].callback(t)}}})})},t.exports=o},{"./jsonrpc":344,"web3-core-helpers":338}],342:[function(e,t,r){"use strict";var n=null,i=window;void 0!==i.ethereumProvider?n=i.ethereumProvider:void 0!==i.web3&&i.web3.currentProvider&&(i.web3.currentProvider.sendAsync&&(i.web3.currentProvider.send=i.web3.currentProvider.sendAsync,delete i.web3.currentProvider.sendAsync),!i.web3.currentProvider.on&&i.web3.currentProvider.connection&&"ipcProviderWrapper"===i.web3.currentProvider.connection.constructor.name&&(i.web3.currentProvider.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.connection.on("data",function(e){var r="";e=e.toString();try{r=JSON.parse(e)}catch(r){return t(new Error("Couldn't parse response data"+e))}r.id||-1===r.method.indexOf("_subscription")||t(null,r)});break;default:this.connection.on(e,t)}}),n=i.web3.currentProvider),t.exports=n},{}],343:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("./jsonrpc.js"),a=e("./batch.js"),s=e("./givenProvider.js"),u=function e(t){this.provider=null,this.providers=e.providers,this.setProvider(t),this.subscriptions={}};u.givenProvider=s,u.providers={WebsocketProvider:e("web3-providers-ws"),HttpProvider:e("web3-providers-http"),IpcProvider:e("web3-providers-ipc")},u.prototype.setProvider=function(e,t){var r=this;if(e&&"string"==typeof e&&this.providers)if(/^http(s)?:\/\//i.test(e))e=new this.providers.HttpProvider(e);else if(/^ws(s)?:\/\//i.test(e))e=new this.providers.WebsocketProvider(e);else if(e&&"object"==typeof t&&"function"==typeof t.connect)e=new this.providers.IpcProvider(e,t);else if(e)throw new Error("Can't autodetect provider for \""+e+'"');this.provider&&this.provider.connected&&this.clearSubscriptions(),this.provider=e||null,this.provider&&this.provider.on&&this.provider.on("data",function(e,t){(e=e||t).method&&r.subscriptions[e.params.subscription]&&r.subscriptions[e.params.subscription].callback&&r.subscriptions[e.params.subscription].callback(null,e.params.result)})},u.prototype.send=function(e,t){if(t=t||function(){},!this.provider)return t(i.InvalidProvider());var r=o.toPayload(e.method,e.params);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,n){return n&&n.id&&r.id!==n.id?t(new Error('Wrong response id "'+n.id+'" (expected: "'+r.id+'") in '+JSON.stringify(r))):e?t(e):n&&n.error?t(i.ErrorResponse(n)):o.isValidResponse(n)?void t(null,n.result):t(i.InvalidResponse(n))})},u.prototype.sendBatch=function(e,t){if(!this.provider)return t(i.InvalidProvider());var r=o.toBatchPayload(e);this.provider[this.provider.sendAsync?"sendAsync":"send"](r,function(e,r){return e?t(e):n.isArray(r)?void t(null,r):t(i.InvalidResponse(r))})},u.prototype.addSubscription=function(e,t,r,n){if(!this.provider.on)throw new Error("The provider doesn't support subscriptions: "+this.provider.constructor.name);this.subscriptions[e]={callback:n,type:r,name:t}},u.prototype.removeSubscription=function(e,t){this.subscriptions[e]&&(this.send({method:this.subscriptions[e].type+"_unsubscribe",params:[e]},t),delete this.subscriptions[e])},u.prototype.clearSubscriptions=function(e){var t=this;Object.keys(this.subscriptions).forEach(function(r){e&&"syncing"===t.subscriptions[r].name||t.removeSubscription(r)}),this.provider.reset&&this.provider.reset()},t.exports={Manager:u,BatchManager:a}},{"./batch.js":341,"./givenProvider.js":342,"./jsonrpc.js":344,underscore:325,"web3-core-helpers":338,"web3-providers-http":398,"web3-providers-ipc":399,"web3-providers-ws":400}],344:[function(e,t,r){"use strict";var n={messageId:0,toPayload:function(e,t){if(!e)throw new Error('JSONRPC method should be specified for params: "'+JSON.stringify(t)+'"!');return n.messageId++,{jsonrpc:"2.0",id:n.messageId,method:e,params:t||[]}},isValidResponse:function(e){return Array.isArray(e)?e.every(t):t(e);function t(e){return!(!e||e.error||"2.0"!==e.jsonrpc||"number"!=typeof e.id&&"string"!=typeof e.id||void 0===e.result)}},toBatchPayload:function(e){return e.map(function(e){return n.toPayload(e.method,e.params)})}};t.exports=n},{}],345:[function(e,t,r){"use strict";var n=e("./subscription.js"),i=function(e){this.name=e.name,this.type=e.type,this.subscriptions=e.subscriptions||{},this.requestManager=null};i.prototype.setRequestManager=function(e){this.requestManager=e},i.prototype.attachToObject=function(e){var t=this.buildCall(),r=this.name.split(".");r.length>1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},i.prototype.buildCall=function(){var e=this;return function(){e.subscriptions[arguments[0]]||console.warn("Subscription "+JSON.stringify(arguments[0])+" doesn't exist. Subscribing anyway.");var t=new n({subscription:e.subscriptions[arguments[0]],requestManager:e.requestManager,type:e.type});return t.subscribe.apply(t,arguments)}},t.exports={subscriptions:i,subscription:n}},{"./subscription.js":346}],346:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("eventemitter3");function a(e){o.call(this),this.id=null,this.callback=n.identity,this.arguments=null,this._reconnectIntervalId=null,this.options={subscription:e.subscription,type:e.type,requestManager:e.requestManager}}a.prototype=Object.create(o.prototype),a.prototype.constructor=a,a.prototype._extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},a.prototype._validateArgs=function(e){var t=this.options.subscription;if(t||(t={}),t.params||(t.params=0),e.length!==t.params)throw i.InvalidNumberOfParams(e.length,t.params+1,e[0])},a.prototype._formatInput=function(e){var t=this.options.subscription;return t&&t.inputFormatter?t.inputFormatter.map(function(t,r){return t?t(e[r]):e[r]}):e},a.prototype._formatOutput=function(e){var t=this.options.subscription;return t&&t.outputFormatter&&e?t.outputFormatter(e):e},a.prototype._toPayload=function(e){var t=[];if(this.callback=this._extractCallback(e)||n.identity,this.subscriptionMethod||(this.subscriptionMethod=e.shift(),this.options.subscription.subscriptionName&&(this.subscriptionMethod=this.options.subscription.subscriptionName)),this.arguments||(this.arguments=this._formatInput(e),this._validateArgs(this.arguments),e=[]),t.push(this.subscriptionMethod),t=t.concat(this.arguments),e.length)throw new Error("Only a callback is allowed as parameter on an already instantiated subscription.");return{method:this.options.type+"_subscribe",params:t}},a.prototype.unsubscribe=function(e){this.options.requestManager.removeSubscription(this.id,e),this.id=null,this.removeAllListeners(),clearInterval(this._reconnectIntervalId)},a.prototype.subscribe=function(){var e=this,t=Array.prototype.slice.call(arguments),r=this._toPayload(t);if(!r)return this;if(!this.options.requestManager.provider){var i=new Error("No provider set.");return this.callback(i,null,this),this.emit("error",i),this}if(!this.options.requestManager.provider.on){var o=new Error("The current provider doesn't support subscriptions: "+this.options.requestManager.provider.constructor.name);return this.callback(o,null,this),this.emit("error",o),this}return this.id&&this.unsubscribe(),this.options.params=r.params[1],"logs"===r.params[0]&&n.isObject(r.params[1])&&r.params[1].hasOwnProperty("fromBlock")&&isFinite(r.params[1].fromBlock)&&this.options.requestManager.send({method:"eth_getLogs",params:[r.params[1]]},function(t,r){t?(e.callback(t,null,e),e.emit("error",t)):r.forEach(function(t){var r=e._formatOutput(t);e.callback(null,r,e),e.emit("data",r)})}),"object"==typeof r.params[1]&&delete r.params[1].fromBlock,this.options.requestManager.send(r,function(t,i){!t&&i?(e.id=i,e.options.requestManager.addSubscription(e.id,r.params[0],e.options.type,function(t,r){t?(e.options.requestManager.removeSubscription(e.id),e.options.requestManager.provider.once&&(e._reconnectIntervalId=setInterval(function(){e.options.requestManager.provider.reconnect&&e.options.requestManager.provider.reconnect()},500),e.options.requestManager.provider.once("connect",function(){clearInterval(e._reconnectIntervalId),e.subscribe(e.callback)})),e.emit("error",t),e.callback(t,null,e)):(n.isArray(r)||(r=[r]),r.forEach(function(t){var r=e._formatOutput(t);if(n.isFunction(e.options.subscription.subscriptionHandler))return e.options.subscription.subscriptionHandler.call(e,r);e.emit("data",r),e.callback(null,r,e)}))})):(e.callback(t,null,e),e.emit("error",t))}),this},t.exports=a},{eventemitter3:156,underscore:325,"web3-core-helpers":338}],347:[function(e,t,r){"use strict";var n=e("web3-core-helpers").formatters,i=e("web3-core-method"),o=e("web3-utils");t.exports=function(e){var t=function(t){var r;return t.property?(e[t.property]||(e[t.property]={}),r=e[t.property]):r=e,t.methods&&t.methods.forEach(function(t){t instanceof i||(t=new i(t)),t.attachToObject(r),t.setRequestManager(e._requestManager)}),e};return t.formatters=n,t.utils=o,t.Method=i,t}},{"web3-core-helpers":338,"web3-core-method":339,"web3-utils":403}],348:[function(e,t,r){"use strict";var n=e("web3-core-requestmanager"),i=e("./extend.js");t.exports={packageInit:function(e,t){if(t=Array.prototype.slice.call(t),!e)throw new Error('You need to instantiate using the "new" keyword.');Object.defineProperty(e,"currentProvider",{get:function(){return e._provider},set:function(t){return e.setProvider(t)},enumerable:!0,configurable:!0}),t[0]&&t[0]._requestManager?e._requestManager=new n.Manager(t[0].currentProvider):(e._requestManager=new n.Manager,e._requestManager.setProvider(t[0],t[1])),e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers,e._provider=e._requestManager.provider,e.setProvider||(e.setProvider=function(t,r){return e._requestManager.setProvider(t,r),e._provider=e._requestManager.provider,!0}),e.BatchRequest=n.BatchManager.bind(null,e._requestManager),e.extend=i(e)},addProviders:function(e){e.givenProvider=n.Manager.givenProvider,e.providers=n.Manager.providers}}},{"./extend.js":347,"web3-core-requestmanager":343}],349:[function(e,t,r){var n=e("underscore"),i=e("web3-utils"),o=new(0,e("ethers/utils/abi-coder").AbiCoder)(function(e,t){return!e.match(/^u?int/)||n.isArray(t)||n.isObject(t)&&"BN"===t.constructor.name?t:t.toString()});function a(){}var s=function(){};s.prototype.encodeFunctionSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e).slice(0,10)},s.prototype.encodeEventSignature=function(e){return n.isObject(e)&&(e=i._jsonInterfaceMethodToString(e)),i.sha3(e)},s.prototype.encodeParameter=function(e,t){return this.encodeParameters([e],[t])},s.prototype.encodeParameters=function(e,t){return o.encode(this.mapTypes(e),t)},s.prototype.mapTypes=function(e){var t=this,r=[];return e.forEach(function(e){if(t.isSimplifiedStructFormat(e)){var n=Object.keys(e)[0];r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}else r.push(e)}),r},s.prototype.isSimplifiedStructFormat=function(e){return"object"==typeof e&&void 0===e.components&&void 0===e.name},s.prototype.mapStructNameAndType=function(e){var t="tuple";return e.indexOf("[]")>-1&&(t="tuple[]",e=e.slice(0,-2)),{type:t,name:e}},s.prototype.mapStructToCoderFormat=function(e){var t=this,r=[];return Object.keys(e).forEach(function(n){"object"!=typeof e[n]?r.push({name:n,type:e[n]}):r.push(Object.assign(t.mapStructNameAndType(n),{components:t.mapStructToCoderFormat(e[n])}))}),r},s.prototype.encodeFunctionCall=function(e,t){return this.encodeFunctionSignature(e)+this.encodeParameters(e.inputs,t).replace("0x","")},s.prototype.decodeParameter=function(e,t){return this.decodeParameters([e],t)[0]},s.prototype.decodeParameters=function(e,t){if(!t||"0x"===t||"0X"===t)throw new Error("Returned values aren't valid, did it run Out of Gas?");var r=o.decode(this.mapTypes(e),"0x"+t.replace(/0x/i,"")),i=new a;return i.__length__=0,e.forEach(function(e,t){var o=r[i.__length__];o="0x"===o?null:o,i[t]=o,n.isObject(e)&&e.name&&(i[e.name]=o),i.__length__++}),i},s.prototype.decodeLog=function(e,t,r){var i=this;r=n.isArray(r)?r:[r],t=t||"";var o=[],s=[],u=0;e.forEach(function(e,t){e.indexed?(s[t]=["bool","int","uint","address","fixed","ufixed"].find(function(t){return-1!==e.type.indexOf(t)})?i.decodeParameter(e.type,r[u]):r[u],u++):o[t]=e});var c=t,f=c?this.decodeParameters(o,c):[],h=new a;return h.__length__=0,e.forEach(function(e,t){h[t]="string"===e.type?"":null,void 0!==f[t]&&(h[t]=f[t]),void 0!==s[t]&&(h[t]=s[t]),e.name&&(h[e.name]=h[t]),h.__length__++}),h};var u=new s;t.exports=u},{"ethers/utils/abi-coder":143,underscore:325,"web3-utils":403}],350:[function(e,t,r){(function(r){var n=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=e("./bytes"),o=e("./nat"),a=e("elliptic"),s=(e("./rlp"),new a.ec("secp256k1")),u=e("./hash"),c=u.keccak256,f=u.keccak256s,h=function(e){for(var t=f(e.slice(2)),r="0x",n=0;n<40;n++)r+=parseInt(t[n+2],16)>7?e[n+2].toUpperCase():e[n+2];return r},l=function(e){var t=new r(e.slice(2),"hex"),n="0x"+s.keyFromPrivate(t).getPublic(!1,"hex").slice(2),i=c(n);return{address:h("0x"+i.slice(-40)),privateKey:e}},d=function(e){var t=n(e,3),r=t[0],o=i.pad(32,t[1]),a=i.pad(32,t[2]);return i.flatten([o,a,r])},p=function(e){return[i.slice(64,i.length(e),e),i.slice(0,32,e),i.slice(32,64,e)]},b=function(e){return function(t,n){var a=s.keyFromPrivate(new r(n.slice(2),"hex")).sign(new r(t.slice(2),"hex"),{canonical:!0});return d([o.fromString(i.fromNumber(e+a.recoveryParam)),i.pad(32,i.fromNat("0x"+a.r.toString(16))),i.pad(32,i.fromNat("0x"+a.s.toString(16)))])}},y=b(27);t.exports={create:function(e){var t=c(i.concat(i.random(32),e||i.random(32))),r=i.concat(i.concat(i.random(32),t),i.random(32)),n=c(r);return l(n)},toChecksum:h,fromPrivate:l,sign:y,makeSigner:b,recover:function(e,t){var n=p(t),o={v:i.toNumber(n[0]),r:n[1].slice(2),s:n[2].slice(2)},a="0x"+s.recoverPubKey(new r(e.slice(2),"hex"),o,o.v<2?o.v:1-o.v%2).encode("hex",!1).slice(2),u=c(a);return h("0x"+u.slice(-40))},encodeSignature:d,decodeSignature:p}}).call(this,e("buffer").Buffer)},{"./bytes":352,"./hash":353,"./nat":354,"./rlp":355,buffer:84,elliptic:109}],351:[function(e,t,r){arguments[4][132][0].apply(r,arguments)},{dup:132}],352:[function(e,t,r){arguments[4][133][0].apply(r,arguments)},{"./array.js":351,dup:133}],353:[function(e,t,r){arguments[4][134][0].apply(r,arguments)},{dup:134}],354:[function(e,t,r){var n=e("bn.js"),i=e("./bytes"),o=function(e){return new n(e.slice(2),16)},a=function(e){var t="0x"+("0x"===e.slice(0,2)?new n(e.slice(2),16):new n(e,10)).toString("hex");return"0x0"===t?"0x":t},s=function(e){return"string"==typeof e?/^0x/.test(e)?e:"0x"+e:"0x"+new n(e).toString("hex")},u=function(e){return o(e).toNumber()},c=function(e){return function(t,r){return"0x"+o(t)[e](o(r)).toString("hex")}},f=c("add"),h=c("mul"),l=c("div"),d=c("sub");t.exports={toString:function(e){return o(e).toString(10)},fromString:a,toNumber:u,fromNumber:s,toEther:function(e){return u(l(e,a("10000000000")))/1e8},fromEther:function(e){return h(s(Math.floor(1e8*e)),a("10000000000"))},toUint256:function(e){return i.pad(32,e)},add:f,mul:h,div:l,sub:d}},{"./bytes":352,"bn.js":53}],355:[function(e,t,r){t.exports={encode:function(e){var t=function(e){return(t=e.toString(16)).length%2==0?t:"0"+t;var t},r=function(e,r){return e<56?t(r+e):t(r+t(e).length/2+55)+t(e)};return"0x"+function e(t){if("string"==typeof t){var n=t.slice(2);return(2!=n.length||n>="80"?r(n.length/2,128):"")+n}var i=t.map(e).join("");return r(i.length/2,192)+i}(e)},decode:function(e){var t=2,r=function(){if(t>=e.length)throw"";var r=e.slice(t,t+2);return r<"80"?(t+=2,"0x"+r):r<"c0"?i():o()},n=function(){var r=parseInt(e.slice(t,t+=2),16)%64;return r<56?r:parseInt(e.slice(t,t+=2*(r-55)),16)},i=function(){var r=n();return"0x"+e.slice(t,t+=2*r)},o=function(){for(var e=2*n()+t,i=[];t>>((3&t)<<3)&255;return i}}t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],357:[function(e,t,r){for(var n=e("./rng"),i=[],o={},a=0;a<256;a++)i[a]=(a+256).toString(16).substr(1),o[i[a]]=a;function s(e,t){var r=t||0,n=i;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var u=n(),c=[1|u[0],u[1],u[2],u[3],u[4],u[5]],f=16383&(u[6]<<8|u[7]),h=0,l=0;function d(e,t,r){var i=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||n)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var a=0;a<16;a++)t[i+a]=o[a];return t||s(o)}var p=d;p.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:f,a=void 0!==e.msecs?e.msecs:(new Date).getTime(),u=void 0!==e.nsecs?e.nsecs:l+1,d=a-h+(u-l)/1e4;if(d<0&&void 0===e.clockseq&&(o=o+1&16383),(d<0||a>h)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");h=a,l=u,f=o;var p=(1e4*(268435455&(a+=122192928e5))+u)%4294967296;i[n++]=p>>>24&255,i[n++]=p>>>16&255,i[n++]=p>>>8&255,i[n++]=255&p;var b=a/4294967296*1e4&268435455;i[n++]=b>>>8&255,i[n++]=255&b,i[n++]=b>>>24&15|16,i[n++]=b>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var y=e.node||c,m=0;m<6;m++)i[n+m]=y[m];return t||s(i)},p.v4=d,p.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=o[e])});i<16;)t[n+i++]=0;return t},p.unparse=s,t.exports=p},{"./rng":356}],358:[function(e,t,r){(function(r,n){"use strict";var i=e("underscore"),o=e("web3-core"),a=e("web3-core-method"),s=e("any-promise"),u=e("eth-lib/lib/account"),c=e("eth-lib/lib/hash"),f=e("eth-lib/lib/rlp"),h=e("eth-lib/lib/nat"),l=e("eth-lib/lib/bytes"),d=e(void 0===r?"crypto-browserify":"crypto"),p=e("scrypt.js"),b=e("uuid"),y=e("web3-utils"),m=e("web3-core-helpers"),v=function(e){return i.isUndefined(e)||i.isNull(e)},g=function(e){for(;e&&e.startsWith("0x0");)e="0x"+e.slice(3);return e},w=function(e){return e.length%2==1&&(e=e.replace("0x","0x0")),e},_=function(){var e=this;o.packageInit(this,arguments),delete this.BatchRequest,delete this.extend;var t=[new a({name:"getId",call:"net_version",params:0,outputFormatter:y.hexToNumber}),new a({name:"getGasPrice",call:"eth_gasPrice",params:0}),new a({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[function(e){if(y.isAddress(e))return e;throw new Error("Address "+e+' is not a valid address to get the "transactionCount".')},function(){return"latest"}]})];this._ethereumCall={},i.each(t,function(t){t.attachToObject(e._ethereumCall),t.setRequestManager(e._requestManager)}),this.wallet=new A(this)};function A(e){this._accounts=e,this.length=0,this.defaultKeyName="web3js_wallet"}_.prototype._addAccountFunctions=function(e){var t=this;return e.signTransaction=function(r,n){return t.signTransaction(r,e.privateKey,n)},e.sign=function(r){return t.sign(r,e.privateKey)},e.encrypt=function(r,n){return t.encrypt(e.privateKey,r,n)},e},_.prototype.create=function(e){return this._addAccountFunctions(u.create(e||y.randomHex(32)))},_.prototype.privateKeyToAccount=function(e){return this._addAccountFunctions(u.fromPrivate(e))},_.prototype.signTransaction=function(e,t,r){var n,o=!1;if(r=r||function(){},!e)return o=new Error("No transaction object given!"),r(o),s.reject(o);function a(e){if(e.gas||e.gasLimit||(o=new Error('"gas" is missing')),(e.nonce<0||e.gas<0||e.gasPrice<0||e.chainId<0)&&(o=new Error("Gas, gasPrice, nonce or chainId is lower than 0")),o)return r(o),s.reject(o);try{var i=e=m.formatters.inputCallFormatter(e);i.to=e.to||"0x",i.data=e.data||"0x",i.value=e.value||"0x",i.chainId=y.numberToHex(e.chainId);var a=f.encode([l.fromNat(i.nonce),l.fromNat(i.gasPrice),l.fromNat(i.gas),i.to.toLowerCase(),l.fromNat(i.value),i.data,l.fromNat(i.chainId||"0x1"),"0x","0x"]),d=c.keccak256(a),p=u.makeSigner(2*h.toNumber(i.chainId||"0x1")+35)(c.keccak256(a),t),b=f.decode(a).slice(0,6).concat(u.decodeSignature(p));b[6]=w(g(b[6])),b[7]=w(g(b[7])),b[8]=w(g(b[8]));var v=f.encode(b),_=f.decode(v);n={messageHash:d,v:g(_[6]),r:g(_[7]),s:g(_[8]),rawTransaction:v}}catch(e){return r(e),s.reject(e)}return r(null,n),n}return void 0!==e.nonce&&void 0!==e.chainId&&void 0!==e.gasPrice?s.resolve(a(e)):s.all([v(e.chainId)?this._ethereumCall.getId():e.chainId,v(e.gasPrice)?this._ethereumCall.getGasPrice():e.gasPrice,v(e.nonce)?this._ethereumCall.getTransactionCount(this.privateKeyToAccount(t).address):e.nonce]).then(function(t){if(v(t[0])||v(t[1])||v(t[2]))throw new Error('One of the values "chainId", "gasPrice", or "nonce" couldn\'t be fetched: '+JSON.stringify(t));return a(i.extend(e,{chainId:t[0],gasPrice:t[1],nonce:t[2]}))})},_.prototype.recoverTransaction=function(e){var t=f.decode(e),r=u.encodeSignature(t.slice(6,9)),n=l.toNumber(t[6]),i=n<35?[]:[l.fromNumber(n-35>>1),"0x","0x"],o=t.slice(0,6).concat(i),a=f.encode(o);return u.recover(c.keccak256(a),r)},_.prototype.hashMessage=function(e){var t=y.isHexStrict(e)?y.hexToBytes(e):e,r=n.from(t),i="Ethereum Signed Message:\n"+t.length,o=n.from(i),a=n.concat([o,r]);return c.keccak256s(a)},_.prototype.sign=function(e,t){var r=this.hashMessage(e),n=u.sign(r,t),i=u.decodeSignature(n);return{message:e,messageHash:r,v:i[0],r:i[1],s:i[2],signature:n}},_.prototype.recover=function(e,t,r){var n=[].slice.apply(arguments);return i.isObject(e)?this.recover(e.messageHash,u.encodeSignature([e.v,e.r,e.s]),!0):(r||(e=this.hashMessage(e)),n.length>=4?(r=n.slice(-1)[0],r=!!i.isBoolean(r)&&!!r,this.recover(e,u.encodeSignature(n.slice(1,4)),r)):u.recover(e,t))},_.prototype.decrypt=function(e,t,r){if(!i.isString(t))throw new Error("No password given.");var o,a,s=i.isObject(e)?e:JSON.parse(r?e.toLowerCase():e);if(3!==s.version)throw new Error("Not a valid V3 wallet");if("scrypt"===s.crypto.kdf)a=s.crypto.kdfparams,o=p(new n(t),new n(a.salt,"hex"),a.n,a.r,a.p,a.dklen);else{if("pbkdf2"!==s.crypto.kdf)throw new Error("Unsupported key derivation scheme");if("hmac-sha256"!==(a=s.crypto.kdfparams).prf)throw new Error("Unsupported parameters to PBKDF2");o=d.pbkdf2Sync(new n(t),new n(a.salt,"hex"),a.c,a.dklen,"sha256")}var u=new n(s.crypto.ciphertext,"hex");if(y.sha3(n.concat([o.slice(16,32),u])).replace("0x","")!==s.crypto.mac)throw new Error("Key derivation failed - possibly wrong password");var c=d.createDecipheriv(s.crypto.cipher,o.slice(0,16),new n(s.crypto.cipherparams.iv,"hex")),f="0x"+n.concat([c.update(u),c.final()]).toString("hex");return this.privateKeyToAccount(f)},_.prototype.encrypt=function(e,t,r){var i,o=this.privateKeyToAccount(e),a=(r=r||{}).salt||d.randomBytes(32),s=r.iv||d.randomBytes(16),u=r.kdf||"scrypt",c={dklen:r.dklen||32,salt:a.toString("hex")};if("pbkdf2"===u)c.c=r.c||262144,c.prf="hmac-sha256",i=d.pbkdf2Sync(new n(t),a,c.c,c.dklen,"sha256");else{if("scrypt"!==u)throw new Error("Unsupported kdf");c.n=r.n||8192,c.r=r.r||8,c.p=r.p||1,i=p(new n(t),a,c.n,c.r,c.p,c.dklen)}var f=d.createCipheriv(r.cipher||"aes-128-ctr",i.slice(0,16),s);if(!f)throw new Error("Unsupported cipher");var h=n.concat([f.update(new n(o.privateKey.replace("0x",""),"hex")),f.final()]),l=y.sha3(n.concat([i.slice(16,32),new n(h,"hex")])).replace("0x","");return{version:3,id:b.v4({random:r.uuid||d.randomBytes(16)}),address:o.address.toLowerCase().replace("0x",""),crypto:{ciphertext:h.toString("hex"),cipherparams:{iv:s.toString("hex")},cipher:r.cipher||"aes-128-ctr",kdf:u,kdfparams:c,mac:l.toString("hex")}}},A.prototype._findSafeIndex=function(e){return e=e||0,i.has(this,e)?this._findSafeIndex(e+1):e},A.prototype._currentIndexes=function(){return Object.keys(this).map(function(e){return parseInt(e)}).filter(function(e){return e<9e20})},A.prototype.create=function(e,t){for(var r=0;r=2?t.slice(2):t;var r=h.decodeParameters(e,t);return 1===r.__length__?r[0]:(delete r.__length__,r)},l.prototype.deploy=function(e,t){if((e=e||{}).arguments=e.arguments||[],!(e=this._getOrSetDefaultOptions(e)).data)return a._fireError(new Error('No "data" specified in neither the given options, nor the default options.'),null,null,t);var r=n.find(this.options.jsonInterface,function(e){return"constructor"===e.type})||{};return r.signature="constructor",this._createTxObject.apply({method:r,parent:this,deployData:e.data,_ethAccounts:this.constructor._ethAccounts},e.arguments)},l.prototype._generateEventOptions=function(){var e=Array.prototype.slice.call(arguments),t=this._getCallback(e),r=n.isObject(e[e.length-1])?e.pop():{},i=n.isString(e[0])?e[0]:"allevents";if(!(i="allevents"===i.toLowerCase()?{name:"ALLEVENTS",jsonInterface:this.options.jsonInterface}:this.options.jsonInterface.find(function(e){return"event"===e.type&&(e.name===i||e.signature==="0x"+i.replace("0x",""))})))throw new Error('Event "'+i.name+"\" doesn't exist in this contract.");if(!a.isAddress(this.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return{params:this._encodeEventABI(i,r),event:i,callback:t}},l.prototype.clone=function(){return new this.constructor(this.options.jsonInterface,this.options.address,this.options)},l.prototype.once=function(e,t,r){var i=Array.prototype.slice.call(arguments);if(!(r=this._getCallback(i)))throw new Error("Once requires a callback as the second parameter.");t&&delete t.fromBlock,this._on(e,t,function(e,t,i){i.unsubscribe(),n.isFunction(r)&&r(e,t,i)})},l.prototype._on=function(){var e=this._generateEventOptions.apply(this,arguments);this._checkListener("newListener",e.event.name,e.callback),this._checkListener("removeListener",e.event.name,e.callback);var t=new s({subscription:{params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event),subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},type:"eth",requestManager:this._requestManager});return t.subscribe("logs",e.params,e.callback||function(){}),t},l.prototype.getPastEvents=function(){var e=this._generateEventOptions.apply(this,arguments),t=new o({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(e.event)});t.setRequestManager(this._requestManager);var r=t.buildCall();return t=null,r(e.params,e.callback)},l.prototype._createTxObject=function(){var e=Array.prototype.slice.call(arguments),t={};if("function"===this.method.type&&(t.call=this.parent._executeMethod.bind(t,"call"),t.call.request=this.parent._executeMethod.bind(t,"call",!0)),t.send=this.parent._executeMethod.bind(t,"send"),t.send.request=this.parent._executeMethod.bind(t,"send",!0),t.encodeABI=this.parent._encodeMethodABI.bind(t),t.estimateGas=this.parent._executeMethod.bind(t,"estimate"),e&&this.method.inputs&&e.length!==this.method.inputs.length){if(this.nextMethod)return this.nextMethod.apply(null,e);throw c.InvalidNumberOfParams(e.length,this.method.inputs.length,this.method.name)}return t.arguments=e||[],t._method=this.method,t._parent=this.parent,t._ethAccounts=this.parent.constructor._ethAccounts||this._ethAccounts,this.deployData&&(t._deployData=this.deployData),t},l.prototype._processExecuteArguments=function(e,t){var r={};if(r.type=e.shift(),r.callback=this._parent._getCallback(e),"call"===r.type&&!0!==e[e.length-1]&&(n.isString(e[e.length-1])||isFinite(e[e.length-1]))&&(r.defaultBlock=e.pop()),r.options=n.isObject(e[e.length-1])?e.pop():{},r.generateRequest=!0===e[e.length-1]&&e.pop(),r.options=this._parent._getOrSetDefaultOptions(r.options),r.options.data=this.encodeABI(),!this._deployData&&!a.isAddress(this._parent.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return this._deployData||(r.options.to=this._parent.options.address),r.options.data?r:a._fireError(new Error("Couldn't find a matching contract method, or the number of parameters is wrong."),t.eventEmitter,t.reject,r.callback)},l.prototype._executeMethod=function(){var e=this,t=this._parent._processExecuteArguments.call(this,Array.prototype.slice.call(arguments),r),r=f("send"!==t.type),i=e.constructor._ethAccounts||e._ethAccounts;if(t.generateRequest){var s={params:[u.inputCallFormatter.call(this._parent,t.options)],callback:t.callback};return"call"===t.type?(s.params.push(u.inputDefaultBlockNumberFormatter.call(this._parent,t.defaultBlock)),s.method="eth_call",s.format=this._parent._decodeMethodReturn.bind(null,this._method.outputs)):s.method="eth_sendTransaction",s}switch(t.type){case"estimate":return new o({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[u.inputCallFormatter],outputFormatter:a.hexToNumber,requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.callback);case"call":return new o({name:"call",call:"eth_call",params:2,inputFormatter:[u.inputCallFormatter,u.inputDefaultBlockNumberFormatter],outputFormatter:function(t){return e._parent._decodeMethodReturn(e._method.outputs,t)},requestManager:e._parent._requestManager,accounts:i,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock}).createFunction()(t.options,t.defaultBlock,t.callback);case"send":if(!a.isAddress(t.options.from))return a._fireError(new Error('No "from" address specified in neither the given options, nor the default options.'),r.eventEmitter,r.reject,t.callback);if(n.isBoolean(this._method.payable)&&!this._method.payable&&t.options.value&&t.options.value>0)return a._fireError(new Error("Can not send value to non-payable contract method or constructor"),r.eventEmitter,r.reject,t.callback);var c={receiptFormatter:function(t){if(n.isArray(t.logs)){var r=n.map(t.logs,function(t){return e._parent._decodeEventABI.call({name:"ALLEVENTS",jsonInterface:e._parent.options.jsonInterface},t)});t.events={};var i=0;r.forEach(function(e){e.event?t.events[e.event]?Array.isArray(t.events[e.event])?t.events[e.event].push(e):t.events[e.event]=[t.events[e.event],e]:t.events[e.event]=e:(t.events[i]=e,i++)}),delete t.logs}return t},contractDeployFormatter:function(t){var r=e._parent.clone();return r.options.address=t.contractAddress,r}};return new o({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[u.inputTransactionFormatter],requestManager:e._parent._requestManager,accounts:e.constructor._ethAccounts||e._ethAccounts,defaultAccount:e._parent.defaultAccount,defaultBlock:e._parent.defaultBlock,extraFormatters:c}).createFunction()(t.options,t.callback)}},t.exports=l},{underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-promievent":340,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-utils":403}],360:[function(e,t,r){"use strict";var n=e("./config"),i=e("./contracts/Registry"),o=e("./lib/ResolverMethodHandler");function a(e){this.eth=e}Object.defineProperty(a.prototype,"registry",{get:function(){return new i(this)},enumerable:!0}),Object.defineProperty(a.prototype,"resolverMethodHandler",{get:function(){return new o(this.registry)},enumerable:!0}),a.prototype.resolver=function(e){return this.registry.resolver(e)},a.prototype.getAddress=function(e,t){return this.resolverMethodHandler.method(e,"addr",[]).call(t)},a.prototype.setAddress=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setAddr",[t]).send(r,n)},a.prototype.getPubkey=function(e,t){return this.resolverMethodHandler.method(e,"pubkey",[],t).call(t)},a.prototype.setPubkey=function(e,t,r,n,i){return this.resolverMethodHandler.method(e,"setPubkey",[t,r]).send(n,i)},a.prototype.getContent=function(e,t){return this.resolverMethodHandler.method(e,"content",[]).call(t)},a.prototype.setContent=function(e,t,r,n){return this.resolverMethodHandler.method(e,"setContent",[t]).send(r,n)},a.prototype.getMultihash=function(e,t){return this.resolverMethodHandler.method(e,"multihash",[]).call(t)},a.prototype.setMultihash=function(e,t,r,n){return this.resolverMethodHandler.method(e,"multihash",[t]).send(r,n)},a.prototype.checkNetwork=function(){var e=this;return e.eth.getBlock("latest").then(function(t){var r=new Date/1e3-t.timestamp;if(r>3600)throw new Error("Network not synced; last block was "+r+" seconds ago");return e.eth.net.getNetworkType()}).then(function(e){var t=n.addresses[e];if(void 0===t)throw new Error("ENS is not supported on network "+e);return t})},t.exports=a},{"./config":361,"./contracts/Registry":362,"./lib/ResolverMethodHandler":364}],361:[function(e,t,r){"use strict";t.exports={addresses:{main:"0x314159265dD8dbb310642f98f50C066173C1259b",ropsten:"0x112234455c3a32fd11230c42e7bccd4a84e02010",rinkeby:"0xe7410170f87102df0055eb195163a03b7f2bff4a"}}},{}],362:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-eth-contract"),o=e("eth-ens-namehash"),a=e("web3-core-promievent"),s=e("../ressources/ABI/Registry"),u=e("../ressources/ABI/Resolver");function c(e){var t=this;this.ens=e,this.contract=e.checkNetwork().then(function(e){var r=new i(s,e);return r.setProvider(t.ens.eth.currentProvider),r})}c.prototype.owner=function(e,t){var r=new a(!0);return this.contract.then(function(i){i.methods.owner(o.hash(e)).call().then(function(e){r.resolve(e),n.isFunction(t)&&t(e)}).catch(function(e){r.reject(e),n.isFunction(t)&&t(e)})}),r.eventEmitter},c.prototype.resolver=function(e){var t=this;return this.contract.then(function(t){return t.methods.resolver(o.hash(e)).call()}).then(function(e){var r=new i(u,e);return r.setProvider(t.ens.eth.currentProvider),r})},t.exports=c},{"../ressources/ABI/Registry":365,"../ressources/ABI/Resolver":366,"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340,"web3-eth-contract":359}],363:[function(e,t,r){"use strict";var n=e("./ENS");t.exports=n},{"./ENS":360}],364:[function(e,t,r){"use strict";var n=e("web3-core-promievent"),i=e("eth-ens-namehash"),o=e("underscore");function a(e){this.registry=e}a.prototype.method=function(e,t,r,n){return{call:this.call.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this}),send:this.send.bind({ensName:e,methodName:t,methodArguments:r,callback:n,parent:this})}},a.prototype.call=function(e){var t=this,r=new n,i=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){t.parent.handleCall(r,n.methods[t.methodName],i,e)}).catch(function(e){r.reject(e)}),r.eventEmitter},a.prototype.send=function(e,t){var r=this,i=new n,o=this.parent.prepareArguments(this.ensName,this.methodArguments);return this.parent.registry.resolver(this.ensName).then(function(n){r.parent.handleSend(i,n.methods[r.methodName],o,e,t)}).catch(function(e){i.reject(e)}),i.eventEmitter},a.prototype.handleCall=function(e,t,r,n){return t.apply(this,r).call().then(function(t){e.resolve(t),o.isFunction(n)&&n(t)}).catch(function(t){e.reject(t),o.isFunction(n)&&n(t)}),e},a.prototype.handleSend=function(e,t,r,n,i){return t.apply(this,r).send(n).on("transactionHash",function(t){e.eventEmitter.emit("transactionHash",t)}).on("confirmation",function(t,r){e.eventEmitter.emit("confirmation",t,r)}).on("receipt",function(t){e.eventEmitter.emit("receipt",t),e.resolve(t),o.isFunction(i)&&i(t)}).on("error",function(t){e.eventEmitter.emit("error",t),e.reject(t),o.isFunction(i)&&i(t)}),e},a.prototype.prepareArguments=function(e,t){var r=i.hash(e);return t.length>0?(t.unshift(r),t):[r]},t.exports=a},{"eth-ens-namehash":127,underscore:325,"web3-core-promievent":340}],365:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"resolver",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"owner",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"label",type:"bytes32"},{name:"owner",type:"address"}],name:"setSubnodeOwner",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"ttl",type:"uint64"}],name:"setTTL",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"ttl",outputs:[{name:"",type:"uint64"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"resolver",type:"address"}],name:"setResolver",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"owner",type:"address"}],name:"setOwner",outputs:[],payable:!1,type:"function"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"label",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"NewOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"resolver",type:"address"}],name:"NewResolver",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"ttl",type:"uint64"}],name:"NewTTL",type:"event"}]},{}],366:[function(e,t,r){"use strict";t.exports=[{constant:!0,inputs:[{name:"interfaceID",type:"bytes4"}],name:"supportsInterface",outputs:[{name:"",type:"bool"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"},{name:"contentTypes",type:"uint256"}],name:"ABI",outputs:[{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes"}],name:"setMultihash",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"multihash",outputs:[{name:"",type:"bytes"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"setPubkey",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"content",outputs:[{name:"ret",type:"bytes32"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"addr",outputs:[{name:"ret",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],name:"setABI",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"name",outputs:[{name:"ret",type:"string"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"name",type:"string"}],name:"setName",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes32"}],name:"setContent",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"pubkey",outputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"addr",type:"address"}],name:"setAddr",outputs:[],payable:!1,type:"function"},{inputs:[{name:"ensAddr",type:"address"}],payable:!1,type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"a",type:"address"}],name:"AddrChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"hash",type:"bytes32"}],name:"ContentChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"name",type:"string"}],name:"NameChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"contentType",type:"uint256"}],name:"ABIChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"x",type:"bytes32"},{indexed:!1,name:"y",type:"bytes32"}],name:"PubkeyChanged",type:"event"}]},{}],367:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],368:[function(e,t,r){"use strict";var n=e("web3-utils"),i=e("bn.js"),o=function(e){var t="A".charCodeAt(0),r="Z".charCodeAt(0);return(e=(e=e.toUpperCase()).substr(4)+e.substr(0,4)).split("").map(function(e){var n=e.charCodeAt(0);return n>=t&&n<=r?n-t+10:e}).join("")},a=function(e){for(var t,r=e;r.length>2;)t=r.slice(0,9),r=parseInt(t,10)%97+r.slice(t.length);return parseInt(r,10)%97},s=function(e){this._iban=e};s.toAddress=function(e){if(!(e=new s(e)).isDirect())throw new Error("IBAN is indirect and can't be converted");return e.toAddress()},s.toIban=function(e){return s.fromAddress(e).toString()},s.fromAddress=function(e){if(!n.isAddress(e))throw new Error("Provided address is not a valid address: "+e);e=e.replace("0x","").replace("0X","");var t=function(e,t){for(var r=e;r.length<2*t;)r="0"+r;return r}(new i(e,16).toString(36),15);return s.fromBban(t.toUpperCase())},s.fromBban=function(e){var t=("0"+(98-a(o("XE00"+e)))).slice(-2);return new s("XE"+t+e)},s.createIndirect=function(e){return s.fromBban("ETH"+e.institution+e.identifier)},s.isValid=function(e){return new s(e).isValid()},s.prototype.isValid=function(){return/^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban)&&1===a(o(this._iban))},s.prototype.isDirect=function(){return 34===this._iban.length||35===this._iban.length},s.prototype.isIndirect=function(){return 20===this._iban.length},s.prototype.checksum=function(){return this._iban.substr(2,2)},s.prototype.institution=function(){return this.isIndirect()?this._iban.substr(7,4):""},s.prototype.client=function(){return this.isIndirect()?this._iban.substr(11):""},s.prototype.toAddress=function(){if(this.isDirect()){var e=this._iban.substr(4),t=new i(e,36);return n.toChecksumAddress(t.toString(16,20))}return""},s.prototype.toString=function(){return this._iban},t.exports=s},{"bn.js":367,"web3-utils":403}],369:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=e("web3-net"),s=e("web3-core-helpers").formatters,u=function(){var e=this;n.packageInit(this,arguments),this.net=new a(this.currentProvider);var t=null,r="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return t},set:function(e){return e&&(t=o.toChecksumAddress(s.inputAddressFormatter(e))),u.forEach(function(e){e.defaultAccount=t}),e},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return r},set:function(e){return r=e,u.forEach(function(e){e.defaultBlock=r}),e},enumerable:!0});var u=[new i({name:"getAccounts",call:"personal_listAccounts",params:0,outputFormatter:o.toChecksumAddress}),new i({name:"newAccount",call:"personal_newAccount",params:1,inputFormatter:[null],outputFormatter:o.toChecksumAddress}),new i({name:"unlockAccount",call:"personal_unlockAccount",params:3,inputFormatter:[s.inputAddressFormatter,null,null]}),new i({name:"lockAccount",call:"personal_lockAccount",params:1,inputFormatter:[s.inputAddressFormatter]}),new i({name:"importRawKey",call:"personal_importRawKey",params:2}),new i({name:"sendTransaction",call:"personal_sendTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"signTransaction",call:"personal_signTransaction",params:2,inputFormatter:[s.inputTransactionFormatter,null]}),new i({name:"sign",call:"personal_sign",params:3,inputFormatter:[s.inputSignFormatter,s.inputAddressFormatter,null]}),new i({name:"ecRecover",call:"personal_ecRecover",params:2,inputFormatter:[s.inputSignFormatter,null]})];u.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};n.addProviders(u),t.exports=u},{"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-net":372,"web3-utils":403}],370:[function(e,t,r){"use strict";var n=e("underscore");t.exports=function(e){var t,r=this;return this.net.getId().then(function(e){return t=e,r.getBlock(0)}).then(function(r){var i="private";return"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"===r.hash&&1===t&&(i="main"),"0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303"===r.hash&&2===t&&(i="morden"),"0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"===r.hash&&3===t&&(i="ropsten"),"0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177"===r.hash&&4===t&&(i="rinkeby"),"0xa3c565fc15c7478862d50ccd6561e3c06b24cc509bf388941c25ea985ce32cb9"===r.hash&&42===t&&(i="kovan"),n.isFunction(e)&&e(null,i),i}).catch(function(t){if(!n.isFunction(e))throw t;e(t)})}},{underscore:325}],371:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core"),o=e("web3-core-helpers"),a=e("web3-core-subscriptions").subscriptions,s=e("web3-core-method"),u=e("web3-utils"),c=e("web3-net"),f=e("web3-eth-ens"),h=e("web3-eth-personal"),l=e("web3-eth-contract"),d=e("web3-eth-iban"),p=e("web3-eth-accounts"),b=e("web3-eth-abi"),y=e("./getNetworkType.js"),m=o.formatters,v=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},g=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},w=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},_=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},A=function(e){return n.isString(e[0])&&0===e[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"},E=function(){var e=this;i.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments),e.personal.setProvider.apply(e,arguments),e.accounts.setProvider.apply(e,arguments),e.Contract.setProvider(e.currentProvider,e.accounts)};var r=null,o="latest";Object.defineProperty(this,"defaultAccount",{get:function(){return r},set:function(t){return t&&(r=u.toChecksumAddress(m.inputAddressFormatter(t))),e.Contract.defaultAccount=r,e.personal.defaultAccount=r,k.forEach(function(e){e.defaultAccount=r}),t},enumerable:!0}),Object.defineProperty(this,"defaultBlock",{get:function(){return o},set:function(t){return o=t,e.Contract.defaultBlock=o,e.personal.defaultBlock=o,k.forEach(function(e){e.defaultBlock=o}),t},enumerable:!0}),this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new c(this.currentProvider),this.net.getNetworkType=y.bind(this),this.accounts=new p(this.currentProvider),this.personal=new h(this.currentProvider),this.personal.defaultAccount=this.defaultAccount;var E=this,x=function(){l.apply(this,arguments);var e=this,t=E.setProvider;E.setProvider=function(){t.apply(E,arguments),i.packageInit(e,[E.currentProvider])}};x.setProvider=function(){l.setProvider.apply(this,arguments)},(x.prototype=Object.create(l.prototype)).constructor=x,this.Contract=x,this.Contract.defaultAccount=this.defaultAccount,this.Contract.defaultBlock=this.defaultBlock,this.Contract.setProvider(this.currentProvider,this.accounts),this.Iban=d,this.abi=b,this.ens=new f(this);var k=[new s({name:"getNodeInfo",call:"web3_clientVersion"}),new s({name:"getProtocolVersion",call:"eth_protocolVersion",params:0}),new s({name:"getCoinbase",call:"eth_coinbase",params:0}),new s({name:"isMining",call:"eth_mining",params:0}),new s({name:"getHashrate",call:"eth_hashrate",params:0,outputFormatter:u.hexToNumber}),new s({name:"isSyncing",call:"eth_syncing",params:0,outputFormatter:m.outputSyncingFormatter}),new s({name:"getGasPrice",call:"eth_gasPrice",params:0,outputFormatter:m.outputBigNumberFormatter}),new s({name:"getAccounts",call:"eth_accounts",params:0,outputFormatter:u.toChecksumAddress}),new s({name:"getBlockNumber",call:"eth_blockNumber",params:0,outputFormatter:u.hexToNumber}),new s({name:"getBalance",call:"eth_getBalance",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:m.outputBigNumberFormatter}),new s({name:"getStorageAt",call:"eth_getStorageAt",params:3,inputFormatter:[m.inputAddressFormatter,u.numberToHex,m.inputDefaultBlockNumberFormatter]}),new s({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"getBlock",call:v,params:2,inputFormatter:[m.inputBlockNumberFormatter,function(e){return!!e}],outputFormatter:m.outputBlockFormatter}),new s({name:"getUncle",call:w,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputBlockFormatter}),new s({name:"getBlockTransactionCount",call:_,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getBlockUncleCount",call:A,params:1,inputFormatter:[m.inputBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"getTransaction",call:"eth_getTransactionByHash",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionFromBlock",call:g,params:2,inputFormatter:[m.inputBlockNumberFormatter,u.numberToHex],outputFormatter:m.outputTransactionFormatter}),new s({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,inputFormatter:[null],outputFormatter:m.outputTransactionReceiptFormatter}),new s({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[m.inputAddressFormatter,m.inputDefaultBlockNumberFormatter],outputFormatter:u.hexToNumber}),new s({name:"sendSignedTransaction",call:"eth_sendRawTransaction",params:1,inputFormatter:[null]}),new s({name:"signTransaction",call:"eth_signTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[m.inputTransactionFormatter]}),new s({name:"sign",call:"eth_sign",params:2,inputFormatter:[m.inputSignFormatter,m.inputAddressFormatter],transformPayload:function(e){return e.params.reverse(),e}}),new s({name:"call",call:"eth_call",params:2,inputFormatter:[m.inputCallFormatter,m.inputDefaultBlockNumberFormatter]}),new s({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[m.inputCallFormatter],outputFormatter:u.hexToNumber}),new s({name:"submitWork",call:"eth_submitWork",params:3}),new s({name:"getWork",call:"eth_getWork",params:0}),new s({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter}),new a({name:"subscribe",type:"eth",subscriptions:{newBlockHeaders:{subscriptionName:"newHeads",params:0,outputFormatter:m.outputBlockFormatter},pendingTransactions:{subscriptionName:"newPendingTransactions",params:0},logs:{params:1,inputFormatter:[m.inputLogFormatter],outputFormatter:m.outputLogFormatter,subscriptionHandler:function(e){e.removed?this.emit("changed",e):this.emit("data",e),n.isFunction(this.callback)&&this.callback(null,e,this)}},syncing:{params:0,outputFormatter:m.outputSyncingFormatter,subscriptionHandler:function(e){var t=this;!0!==this._isSyncing?(this._isSyncing=!0,this.emit("changed",t._isSyncing),n.isFunction(this.callback)&&this.callback(null,t._isSyncing,this),setTimeout(function(){t.emit("data",e),n.isFunction(t.callback)&&t.callback(null,e,t)},0)):(this.emit("data",e),n.isFunction(t.callback)&&this.callback(null,e,this),clearTimeout(this._isSyncingTimeout),this._isSyncingTimeout=setTimeout(function(){e.currentBlock>e.highestBlock-200&&(t._isSyncing=!1,t.emit("changed",t._isSyncing),n.isFunction(t.callback)&&t.callback(null,t._isSyncing,t))},500))}}}})];k.forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager,e.accounts),t.defaultBlock=e.defaultBlock,t.defaultAccount=e.defaultAccount})};i.addProviders(E),t.exports=E},{"./getNetworkType.js":370,underscore:325,"web3-core":348,"web3-core-helpers":338,"web3-core-method":339,"web3-core-subscriptions":345,"web3-eth-abi":349,"web3-eth-accounts":358,"web3-eth-contract":359,"web3-eth-ens":363,"web3-eth-iban":368,"web3-eth-personal":369,"web3-net":372,"web3-utils":403}],372:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-method"),o=e("web3-utils"),a=function(){var e=this;n.packageInit(this,arguments),[new i({name:"getId",call:"net_version",params:0,outputFormatter:o.hexToNumber}),new i({name:"isListening",call:"net_listening",params:0}),new i({name:"getPeerCount",call:"net_peerCount",params:0,outputFormatter:o.hexToNumber})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(a),t.exports=a},{"web3-core":348,"web3-core-method":339,"web3-utils":403}],373:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits,o=e("ethereumjs-util"),a=e("eth-block-tracker"),s=e("async/map"),u=e("async/eachSeries"),c=e("./util/stoplight.js");e("./util/rpc-cache-utils.js"),e("./util/create-payload.js");function f(e){const t=this;n.call(t),t.setMaxListeners(30),e=e||{};const r={sendAsync:t._handleAsync.bind(t)},i=e.blockTrackerProvider||r;t._blockTracker=e.blockTracker||new a({provider:i,pollingInterval:e.pollingInterval||4e3}),t._blockTracker.on("block",e=>{const r=function(e){return{number:o.toBuffer(e.number),hash:o.toBuffer(e.hash),parentHash:o.toBuffer(e.parentHash),nonce:o.toBuffer(e.nonce),mixHash:o.toBuffer(e.mixHash),sha3Uncles:o.toBuffer(e.sha3Uncles),logsBloom:o.toBuffer(e.logsBloom),transactionsRoot:o.toBuffer(e.transactionsRoot),stateRoot:o.toBuffer(e.stateRoot),receiptsRoot:o.toBuffer(e.receiptRoot||e.receiptsRoot),miner:o.toBuffer(e.miner),difficulty:o.toBuffer(e.difficulty),totalDifficulty:o.toBuffer(e.totalDifficulty),size:o.toBuffer(e.size),extraData:o.toBuffer(e.extraData),gasLimit:o.toBuffer(e.gasLimit),gasUsed:o.toBuffer(e.gasUsed),timestamp:o.toBuffer(e.timestamp),transactions:e.transactions}}(e);t._setCurrentBlock(r)}),t._blockTracker.on("block",t.emit.bind(t,"rawBlock")),t._blockTracker.on("sync",t.emit.bind(t,"sync")),t._blockTracker.on("latest",t.emit.bind(t,"latest")),t._ready=new c,t._blockTracker.once("block",()=>{t._ready.go()}),t.currentBlock=null,t._providers=[]}t.exports=f,i(f,n),f.prototype.start=function(e=function(){}){this._blockTracker.start().then(e).catch(e)},f.prototype.stop=function(){this._blockTracker.stop()},f.prototype.addProvider=function(e){this._providers.push(e),e.setEngine(this)},f.prototype.send=function(e){throw new Error("Web3ProviderEngine does not support synchronous requests.")},f.prototype.sendAsync=function(e,t){const r=this;r._ready.await(function(){Array.isArray(e)?s(e,r._handleAsync.bind(r),t):r._handleAsync(e,t)})},f.prototype._handleAsync=function(e,t){var r=this,n=-1,i=null,o=null,a=[];function s(r,n){o=r,i=n,u(a,function(e,t){e?e(o,i,t):t()},function(){var r={id:e.id,jsonrpc:e.jsonrpc,result:i};null!=o?(r.error={message:o.stack||o.message||o,code:-32e3},t(o,r)):t(null,r)})}!function t(i){n+=1;a.unshift(i);if(n>=r._providers.length)s(new Error('Request for method "'+e.method+'" not handled by any subprovider. Please check your subprovider configuration to ensure this method is handled.'));else try{var o=r._providers[n];o.handleRequest(e,t,s)}catch(e){s(e)}}()},f.prototype._setCurrentBlock=function(e){this.currentBlock=e,this.emit("block",e)}},{"./util/create-payload.js":391,"./util/rpc-cache-utils.js":394,"./util/stoplight.js":396,"async/eachSeries":25,"async/map":41,"eth-block-tracker":126,"ethereumjs-util":141,events:157,util:333}],374:[function(e,t,r){var n="undefined"!=typeof JSON?JSON:e("jsonify");t.exports=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var r=t.space||"";"number"==typeof r&&(r=Array(r+1).join(" "));var a,s="boolean"==typeof t.cycles&&t.cycles,u=t.replacer||function(e,t){return t},c=t.cmp&&(a=t.cmp,function(e){return function(t,r){var n={key:t,value:e[t]},i={key:r,value:e[r]};return a(n,i)}}),f=[];return function e(t,a,h,l){var d=r?"\n"+new Array(l+1).join(r):"",p=r?": ":":";if(h&&h.toJSON&&"function"==typeof h.toJSON&&(h=h.toJSON()),void 0!==(h=u.call(t,a,h))){if("object"!=typeof h||null===h)return n.stringify(h);if(i(h)){for(var b=[],y=0;y dist/ProviderEngine.js","bundle-zero":"browserify -s ZeroClientProvider -e zero.js -t [ babelify --presets [ es2015 ] ] > dist/ZeroClientProvider.js",prepublish:"npm run build && npm run bundle",test:"node test/index.js"},version:"14.1.0"}},{}],376:[function(e,t,r){const n=e("util").inherits,i=e("ethereumjs-util"),o=i.BN,a=e("clone"),s=e("../util/rpc-cache-utils.js"),u=e("../util/stoplight.js"),c=e("./subprovider.js");function f(e){e=e||{},this._ready=new u,this.strategies={perma:new l({eth_getTransactionByHash:p,eth_getTransactionReceipt:p}),block:new d(this),fork:new d(this)}}function h(){var e=this;e.cache={};var t=setInterval(function(){e.cache={}},6e5);t.unref&&t.unref()}function l(e){this.strategy=new h,this.conditionals=e}function d(){this.cache={}}function p(e){if(!e)return!1;if(!e.blockHash)return!1;var t;return(t=e.blockHash,new o(i.toBuffer(t))).gt(new o(0))}t.exports=f,n(f,c),f.prototype.setEngine=function(e){const t=this;function r(e){var r=t.currentBlock;t.currentBlock=e,r&&(t.strategies.block.cacheRollOff(r),t.strategies.fork.cacheRollOff(r))}t.engine=e,e.once("block",function(n){t.currentBlock=n,t._ready.go(),e.on("block",r)})},f.prototype.handleRequest=function(e,t,r){const n=this;return e.skipCache?t():"eth_getBlockByNumber"===e.method&&"latest"===e.params[0]?t():void n._ready.await(function(){n._handleRequest(e,t,r)})},f.prototype._handleRequest=function(e,t,r){const n=this;var o=s.cacheTypeForPayload(e),a=this.strategies[o];if(!a)return t();if(!a.canCache(e))return t();var u,c=s.blockTagForPayload(e);c||(c="latest"),u="earliest"===c?"0x00":"latest"===c?i.bufferToHex(n.currentBlock.number):c,a.hitCheck(e,u,r,function(){t(function(t,r,n){if(t)return n();a.cacheResult(e,r,u,n)})})},h.prototype.hitCheck=function(e,t,r,n){var i,o,u,c,f=s.cacheIdentifierForPayload(e),h=this.cache[f];return h&&(i=t,o=h.blockNumber,u=parseInt(i,16),c=parseInt(o,16),(u===c?0:u>c?1:-1)>=0)?r(null,a(h.result)):n()},h.prototype.cacheResult=function(e,t,r,n){var i=s.cacheIdentifierForPayload(e);if(t){var o=a(t);this.cache[i]={blockNumber:r,result:o}}n()},h.prototype.canCache=function(e){return s.canCache(e)},l.prototype.hitCheck=function(e,t,r,n){return this.strategy.hitCheck(e,t,r,n)},l.prototype.cacheResult=function(e,t,r,n){var i=this.conditionals[e.method];i?i(t)?this.strategy.cacheResult(e,t,r,n):n():this.strategy.cacheResult(e,t,r,n)},l.prototype.canCache=function(e){return this.strategy.canCache(e)},d.prototype.getBlockCacheForPayload=function(e,t){const r=Number.parseInt(t,16);let n=this.cache[r];if(!n){const e={};this.cache[r]=e,n=e}return n},d.prototype.hitCheck=function(e,t,r,n){var i=this.getBlockCacheForPayload(e,t);if(!i)return n();var o=i[s.cacheIdentifierForPayload(e)];return o?r(null,o):n()},d.prototype.cacheResult=function(e,t,r,n){t&&(this.getBlockCacheForPayload(e,r)[s.cacheIdentifierForPayload(e)]=t);n()},d.prototype.canCache=function(e){return!!s.canCache(e)&&"pending"!==s.blockTagForPayload(e)},d.prototype.cacheRollOff=function(e){const t=this,r=i.bufferToHex(e.number),n=Number.parseInt(r,16);Object.keys(t.cache).map(Number).filter(e=>e<=n).forEach(e=>delete t.cache[e])}},{"../util/rpc-cache-utils.js":394,"../util/stoplight.js":396,"./subprovider.js":387,clone:87,"ethereumjs-util":141,util:333}],377:[function(e,t,r){const n=e("util").inherits,i=e("xtend"),o=e("./fixture.js"),a=e("../package.json").version;function s(e){var t=i({web3_clientVersion:"ProviderEngine/v"+a+"/javascript",net_listening:!0,eth_hashrate:"0x00",eth_mining:!1},e=e||{});o.call(this,t)}t.exports=s,n(s,o)},{"../package.json":375,"./fixture.js":380,util:333,xtend:423}],378:[function(e,t,r){const n=e("cross-fetch"),i=e("util").inherits,o=e("async/retry"),a=e("async/waterfall"),s=e("async/asyncify"),u=e("json-rpc-error"),c=e("promise-to-callback"),f=e("../util/create-payload.js"),h=e("./subprovider.js"),l=["Gateway timeout","ETIMEDOUT","SyntaxError"];function d(e){this.rpcUrl=e.rpcUrl,this.originHttpHeaderKey=e.originHttpHeaderKey}function p(e){const t=e.toString();return l.some(e=>t.includes(e))}t.exports=d,i(d,h),d.prototype.handleRequest=function(e,t,r){const n=this,i=e.origin,a=f(e);delete a.origin;const s={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(a)};n.originHttpHeaderKey&&i&&(s.headers[n.originHttpHeaderKey]=i),o({times:5,interval:1e3,errorFilter:p},e=>n._submitRequest(s,e),(e,t)=>{if(e&&p(e)){const t=`FetchSubprovider - cannot complete request. All retries exhausted.\nOriginal Error:\n${e.toString()}\n\n`,n=new Error(t);return r(n)}return r(e,t)})},d.prototype._submitRequest=function(e,t){const r=this.rpcUrl;c(n(r,e))((e,r)=>{if(e)return t(e);a([function(e){switch(r.status){case 405:return e(new u.MethodNotFound);case 418:return e(function(){const e=new Error("Request is being rate limited.");return new u.InternalError(e)}());case 503:case 504:return e(function(){let e="Gateway timeout. The request took too long to process. ";const t=new Error(e+="This can happen when querying logs over too wide a block range.");return new u.InternalError(t)}());default:return e()}},e=>c(r.text())(e),s(e=>JSON.parse(e)),function(e,t){if(200!==r.status)return t(new u.InternalError(e));if(e.error)return t(new u.InternalError(e.error));t(null,e.result)}],t)})}},{"../util/create-payload.js":391,"./subprovider.js":387,"async/asyncify":20,"async/retry":43,"async/waterfall":44,"cross-fetch":96,"json-rpc-error":189,"promise-to-callback":258,util:333}],379:[function(e,t,r){const n=e("async"),i=e("util").inherits,o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/stoplight.js"),u=e("events").EventEmitter;function c(e){e=e||{};const t=this;t.filterIndex=0,t.filters={},t.filterDestroyHandlers={},t.asyncBlockHandlers={},t.asyncPendingBlockHandlers={},t._ready=new s,t._ready.setMaxListeners(e.maxFilters||25),t._ready.go(),t.pendingBlockTimeout=e.pendingBlockTimeout||4e3,t.checkForPendingBlocksActive=!1,setTimeout(function(){t.engine.on("block",function(e){t._ready.stop();var r=v(t.asyncBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,function(e){e&&console.error(e),t._ready.go()})})})}function f(e){u.apply(this),this.type="block",this.engine=e.engine,this.blockNumber=e.blockNumber,this.updates=[]}function h(e){u.apply(this),this.type="log",this.fromBlock=void 0!==e.fromBlock?e.fromBlock:"latest",this.toBlock=void 0!==e.toBlock?e.toBlock:"latest";var t=e.address&&(Array.isArray(e.address)?e.address:[e.address]);this.address=t&&t.map(d),this.topics=e.topics||[],this.updates=[],this.allResults=[]}function l(){u.apply(this),this.type="pendingTx",this.updates=[],this.allResults=[]}function d(e){return"0x"===e.slice(0,2)?e:"0x"+e}function p(e){return o.intToHex(e)}function b(e){return Number(e)}function y(e){return function(e){let t=o.stripHexPrefix(e);for(;"0"===t[0];)t=t.substr(1);return`0x${t}`}(e.toString("hex"))}function m(e){return e&&-1===["earliest","latest","pending"].indexOf(e)}function v(e){return Object.keys(e).map(function(t){return e[t]})}t.exports=c,i(c,a),c.prototype.handleRequest=function(e,t,r){const n=this;switch(e.method){case"eth_newBlockFilter":return void n.newBlockFilter(r);case"eth_newPendingTransactionFilter":return n.newPendingTransactionFilter(r),void n.checkForPendingBlocks();case"eth_newFilter":return void n.newLogFilter(e.params[0],r);case"eth_getFilterChanges":return void n._ready.await(function(){n.getFilterChanges(e.params[0],r)});case"eth_getFilterLogs":return void n._ready.await(function(){n.getFilterLogs(e.params[0],r)});case"eth_uninstallFilter":return void n._ready.await(function(){n.uninstallFilter(e.params[0],r)});default:return void t()}},c.prototype.newBlockFilter=function(e){const t=this;t._getBlockNumber(function(r,n){if(r)return e(r);var i=new f({blockNumber:n}),o=i.update.bind(i);t.engine.on("block",o);t.filterIndex++,t.filters[t.filterIndex]=i,t.filterDestroyHandlers[t.filterIndex]=function(){t.engine.removeListener("block",o)};var a=p(t.filterIndex);e(null,a)})},c.prototype.newLogFilter=function(e,t){const r=this;r._getBlockNumber(function(n,i){if(n)return t(n);var o=new h(e),a=o.update.bind(o);r.filterIndex++,r.asyncBlockHandlers[r.filterIndex]=function(e,t){r._logsForBlock(e,function(e,r){if(e)return t(e);a(r),t()})},r.filters[r.filterIndex]=o;var s=p(r.filterIndex);t(null,s)})},c.prototype.newPendingTransactionFilter=function(e){const t=this;var r=new l,n=r.update.bind(r);t.filterIndex++,t.asyncPendingBlockHandlers[t.filterIndex]=function(e,r){t._txHashesForBlock(e,function(e,t){if(e)return r(e);n(t),r()})},t.filters[t.filterIndex]=r,e(null,p(t.filterIndex))},c.prototype.getFilterChanges=function(e,t){var r=Number.parseInt(e,16),n=this.filters[r];if(n||console.warn("FilterSubprovider - no filter with that id:",e),!n)return t(null,[]);var i=n.getChanges();n.clearChanges(),t(null,i)},c.prototype.getFilterLogs=function(e,t){const r=this;var n=Number.parseInt(e,16),i=r.filters[n];if(i||console.warn("FilterSubprovider - no filter with that id:",e),!i)return t(null,[]);if("log"===i.type)r.emitPayload({method:"eth_getLogs",params:[{fromBlock:i.fromBlock,toBlock:i.toBlock,address:i.address,topics:i.topics}]},function(e,r){if(e)return t(e);t(null,r.result)});else{t(null,[])}},c.prototype.uninstallFilter=function(e,t){var r=Number.parseInt(e,16);if(this.filters[r]){this.filters[r].removeAllListeners();var n=this.filterDestroyHandlers[r];delete this.filters[r],delete this.asyncBlockHandlers[r],delete this.asyncPendingBlockHandlers[r],delete this.filterDestroyHandlers[r],n&&n(),t(null,!0)}else t(null,!1)},c.prototype.checkForPendingBlocks=function(){const e=this;e.checkForPendingBlocksActive||!!Object.keys(e.asyncPendingBlockHandlers).length&&(e.checkForPendingBlocksActive=!0,e.emitPayload({method:"eth_getBlockByNumber",params:["pending",!0]},function(t,r){if(t)return e.checkForPendingBlocksActive=!1,void console.error(t);e.onNewPendingBlock(r.result,function(t){t&&console.error(t),e.checkForPendingBlocksActive=!1,setTimeout(e.checkForPendingBlocks.bind(e),e.pendingBlockTimeout)})}))},c.prototype.onNewPendingBlock=function(e,t){var r=v(this.asyncPendingBlockHandlers).map(function(t){return t.bind(null,e)});n.parallel(r,t)},c.prototype._getBlockNumber=function(e){e(null,y(this.engine.currentBlock.number))},c.prototype._logsForBlock=function(e,t){var r=y(e.number);this.emitPayload({method:"eth_getLogs",params:[{fromBlock:r,toBlock:r}]},function(e,r){return e?t(e):r.error?t(r.error):void t(null,r.result)})},c.prototype._txHashesForBlock=function(e,t){var r=e.transactions;if(0===r.length)return t(null,[]);"string"==typeof r[0]?t(null,r):t(null,r.map(e=>e.hash))},i(f,u),f.prototype.update=function(e){var t="0x"+e.hash.toString("hex");this.updates.push(t),this.emit("data",e)},f.prototype.getChanges=function(){return this.updates},f.prototype.clearChanges=function(){this.updates=[]},i(h,u),h.prototype.validateLog=function(e){return!(m(this.fromBlock)&&b(this.fromBlock)>=b(e.blockNumber))&&(!(m(this.toBlock)&&b(this.toBlock)<=b(e.blockNumber))&&(!(this.address&&!this.address.map(e=>e.toLowerCase()).includes(e.address.toLowerCase()))&&this.topics.reduce(function(t,r,n){if(!t)return!1;if(!r)return!0;var i=e.topics[n];return!!i&&(Array.isArray(r)?r:[r]).filter(function(e){return i.toLowerCase()===e.toLowerCase()}).length>0},!0)))},h.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateLog(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},h.prototype.getChanges=function(){return this.updates},h.prototype.getAllResults=function(){return this.allResults},h.prototype.clearChanges=function(){this.updates=[]},i(l,u),l.prototype.validateUnique=function(e){return-1===this.allResults.indexOf(e)},l.prototype.update=function(e){const t=this;var r=[];e.forEach(function(e){t.validateUnique(e)&&(r.push(e),t.updates.push(e),t.allResults.push(e))}),r.length>0&&t.emit("data",r)},l.prototype.getChanges=function(){return this.updates},l.prototype.getAllResults=function(){return this.allResults},l.prototype.clearChanges=function(){this.updates=[]}},{"../util/stoplight.js":396,"./subprovider.js":387,async:21,"ethereumjs-util":141,events:157,util:333}],380:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){e=e||{},this.staticResponses=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){var n=this.staticResponses[e.method];"function"==typeof n?n(e,t,r):void 0!==n?setTimeout(()=>r(null,n)):t()}},{"./subprovider.js":387,util:333}],381:[function(e,t,r){const n=e("async/waterfall"),i=e("async/parallel"),o=e("util").inherits,a=e("ethereumjs-util"),s=e("eth-sig-util"),u=e("xtend"),c=e("semaphore"),f=e("./subprovider.js"),h=e("../util/estimate-gas.js"),l=/^[0-9A-Fa-f]+$/g;function d(e){this.nonceLock=c(1),e.getAccounts&&(this.getAccounts=e.getAccounts),e.processTransaction&&(this.processTransaction=e.processTransaction),e.processMessage&&(this.processMessage=e.processMessage),e.processPersonalMessage&&(this.processPersonalMessage=e.processPersonalMessage),e.processTypedMessage&&(this.processTypedMessage=e.processTypedMessage),this.approveTransaction=e.approveTransaction||this.autoApprove,this.approveMessage=e.approveMessage||this.autoApprove,this.approvePersonalMessage=e.approvePersonalMessage||this.autoApprove,this.approveTypedMessage=e.approveTypedMessage||this.autoApprove,e.signTransaction&&(this.signTransaction=e.signTransaction||y("signTransaction")),e.signMessage&&(this.signMessage=e.signMessage||y("signMessage")),e.signPersonalMessage&&(this.signPersonalMessage=e.signPersonalMessage||y("signPersonalMessage")),e.signTypedMessage&&(this.signTypedMessage=e.signTypedMessage||y("signTypedMessage")),e.recoverPersonalSignature&&(this.recoverPersonalSignature=e.recoverPersonalSignature),e.publishTransaction&&(this.publishTransaction=e.publishTransaction)}function p(e){return e.toLowerCase()}function b(e){return"string"==typeof e&&("0x"===e.slice(0,2)&&e.slice(2).match(l))}function y(e){return function(t,r){r(new Error('ProviderEngine - HookedWalletSubprovider - Must provide "'+e+'" fn in constructor options'))}}t.exports=d,o(d,f),d.prototype.handleRequest=function(e,t,r){const i=this;let o,s,c,f,h;switch(i._parityRequests={},i._parityRequestCount=0,e.method){case"eth_coinbase":return void i.getAccounts(function(e,t){if(e)return r(e);let n=t[0]||null;r(null,n)});case"eth_accounts":return void i.getAccounts(function(e,t){if(e)return r(e);r(null,t)});case"eth_sendTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processTransaction(o,e)],r);case"eth_signTransaction":return o=e.params[0],void n([e=>i.validateTransaction(o,e),e=>i.processSignTransaction(o,e)],r);case"eth_sign":return h=e.params[0],f=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateMessage(s,e),e=>i.processMessage(s,e)],r);case"personal_sign":const l=e.params[0];if(function(e){const t=a.addHexPrefix(e);return!a.isValidAddress(t)&&b(e)}(e.params[1])&&function(e){const t=a.addHexPrefix(e);return a.isValidAddress(t)}(l)){let t="The eth_personalSign method requires params ordered ";t+="[message, address]. This was previously handled incorrectly, ",t+="and has been corrected automatically. ",t+="Please switch this param order for smooth behavior in the future.",console.warn(t),h=e.params[0],f=e.params[1]}else f=e.params[0],h=e.params[1];return c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validatePersonalMessage(s,e),e=>i.processPersonalMessage(s,e)],r);case"personal_ecRecover":f=e.params[0];let d=e.params[1];return c=e.params[2]||{},s=u(c,{sig:d,data:f}),void i.recoverPersonalSignature(s,r);case"eth_signTypedData":return f=e.params[0],h=e.params[1],c=e.params[2]||{},s=u(c,{from:h,data:f}),void n([e=>i.validateTypedMessage(s,e),e=>i.processTypedMessage(s,e)],r);case"parity_postTransaction":return o=e.params[0],void i.parityPostTransaction(o,r);case"parity_postSign":return h=e.params[0],f=e.params[1],void i.parityPostSign(h,f,r);case"parity_checkRequest":const p=e.params[0];return void i.parityCheckRequest(p,r);case"parity_defaultAccount":return void i.getAccounts(function(e,t){if(e)return r(e);const n=t[0]||null;r(null,n)});default:return void t()}},d.prototype.getAccounts=function(e){e(null,[])},d.prototype.processTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeAndSubmitTx(e,t)],t)},d.prototype.processSignTransaction=function(e,t){const r=this;n([t=>r.approveTransaction(e,t),(e,t)=>r.checkApproval("transaction",e,t),t=>r.finalizeTx(e,t)],t)},d.prototype.processMessage=function(e,t){const r=this;n([t=>r.approveMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signMessage(e,t)],t)},d.prototype.processPersonalMessage=function(e,t){const r=this;n([t=>r.approvePersonalMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signPersonalMessage(e,t)],t)},d.prototype.processTypedMessage=function(e,t){const r=this;n([t=>r.approveTypedMessage(e,t),(e,t)=>r.checkApproval("message",e,t),t=>r.signTypedMessage(e,t)],t)},d.prototype.autoApprove=function(e,t){t(null,!0)},d.prototype.checkApproval=function(e,t,r){r(t?null:new Error("User denied "+e+" signature."))},d.prototype.parityPostTransaction=function(e,t){const r=this,n=`0x${r._parityRequestCount.toString(16)}`;r._parityRequestCount++,r.emitPayload({method:"eth_sendTransaction",params:[e]},function(e,t){if(e)return void(r._parityRequests[n]={error:e});const i=t.result;r._parityRequests[n]=i}),t(null,n)},d.prototype.parityPostSign=function(e,t,r){const n=this,i=`0x${n._parityRequestCount.toString(16)}`;n._parityRequestCount++,n.emitPayload({method:"eth_sign",params:[e,t]},function(e,t){if(e)return void(n._parityRequests[i]={error:e});const r=t.result;n._parityRequests[i]=r}),r(null,i)},d.prototype.parityCheckRequest=function(e,t){const r=this._parityRequests[e]||null;return r?r.error?t(r.error):void t(null,r):t(null,null)},d.prototype.recoverPersonalSignature=function(e,t){let r;try{r=s.recoverPersonalSignature(e)}catch(e){return t(e)}t(null,r)},d.prototype.validateTransaction=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign transaction."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign transaction for this address: "${e.from}"`))})},d.prototype.validateMessage=function(e,t){if(void 0===e.from)return t(new Error("Undefined address - from address required to sign message."));this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validatePersonalMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign personal message.")):void 0===e.data?t(new Error("Undefined message - message required to sign personal message.")):b(e.data)?void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))}):t(new Error("HookedWalletSubprovider - validateMessage - message was not encoded as hex."))},d.prototype.validateTypedMessage=function(e,t){return void 0===e.from?t(new Error("Undefined address - from address required to sign typed data.")):void 0===e.data?t(new Error("Undefined data - message required to sign typed data.")):void this.validateSender(e.from,function(r,n){return r?t(r):n?void t():t(new Error(`Unknown address - unable to sign message for this address: "${e.from}"`))})},d.prototype.validateSender=function(e,t){if(!e)return t(null,!1);this.getAccounts(function(r,n){if(r)return t(r);const i=-1!==n.map(p).indexOf(e.toLowerCase());t(null,i)})},d.prototype.finalizeAndSubmitTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r),r.publishTransaction.bind(r)],function(e,n){if(r.nonceLock.leave(),e)return t(e);t(null,n)})})},d.prototype.finalizeTx=function(e,t){const r=this;r.nonceLock.take(function(){n([r.fillInTxExtras.bind(r,e),r.signTransaction.bind(r)],function(n,i){if(r.nonceLock.leave(),n)return t(n);t(null,{raw:i,tx:e})})})},d.prototype.publishTransaction=function(e,t){this.emitPayload({method:"eth_sendRawTransaction",params:[e]},function(e,r){if(e)return t(e);t(null,r.result)})},d.prototype.fillInTxExtras=function(e,t){const r=this,n=e.from,o={};void 0===e.gasPrice&&(o.gasPrice=r.emitPayload.bind(r,{method:"eth_gasPrice",params:[]})),void 0===e.nonce&&(o.nonce=r.emitPayload.bind(r,{method:"eth_getTransactionCount",params:[n,"pending"]})),void 0===e.gas&&(o.gas=h.bind(null,r.engine,function(e){return{from:e.from,to:e.to,value:e.value,data:e.data,gas:e.gas,gasPrice:e.gasPrice,nonce:e.nonce}}(e))),i(o,function(r,n){if(r)return t(r);const i={};n.gasPrice&&(i.gasPrice=n.gasPrice.result),n.nonce&&(i.nonce=n.nonce.result),n.gas&&(i.gas=n.gas),t(null,u(e,i))})}},{"../util/estimate-gas.js":392,"./subprovider.js":387,"async/parallel":42,"async/waterfall":44,"eth-sig-util":136,"ethereumjs-util":141,semaphore:301,util:333,xtend:423}],382:[function(e,t,r){const n=e("../util/rpc-cache-utils.js").cacheIdentifierForPayload,i=e("./subprovider.js");t.exports=class extends i{constructor(e){super(),this.inflightRequests={}}addEngine(e){this.engine=e}handleRequest(e,t,r){const i=n(e,{includeBlockRef:!0});if(!i)return t();let o=this.inflightRequests[i];o?o.push(r):(o=[],this.inflightRequests[i]=o,t((e,t,r)=>{delete this.inflightRequests[i],o.forEach(r=>r(e,t)),r(e,t)}))}}},{"../util/rpc-cache-utils.js":394,"./subprovider.js":387}],383:[function(e,t,r){const n=e("eth-json-rpc-infura/src/createProvider"),i=e("./provider.js");t.exports=class extends i{constructor(e={}){super(n(e))}}},{"./provider.js":385,"eth-json-rpc-infura/src/createProvider":129}],384:[function(e,t,r){(function(r){const n=e("util").inherits,i=e("ethereumjs-tx"),o=e("ethereumjs-util"),a=e("./subprovider.js"),s=e("../util/rpc-cache-utils").blockTagForPayload;function u(e){this.nonceCache={}}t.exports=u,n(u,a),u.prototype.handleRequest=function(e,t,n){const a=this;switch(e.method){case"eth_getTransactionCount":var u=s(e),c=e.params[0].toLowerCase(),f=a.nonceCache[c];return void("pending"===u?f?n(null,f):t(function(e,t,r){if(e)return r();void 0===a.nonceCache[c]&&(a.nonceCache[c]=t),r()}):t());case"eth_sendRawTransaction":return void t(function(t,n,s){if(t)return s();var u=e.params[0],c=(o.stripHexPrefix(u),new r(o.stripHexPrefix(u),"hex"),new i(new r(o.stripHexPrefix(u),"hex"))),f="0x"+c.getSenderAddress().toString("hex").toLowerCase(),h=o.bufferToInt(c.nonce),l=(++h).toString(16);l.length%2&&(l="0"+l),l="0x"+l,a.nonceCache[f]=l,s()});default:return void t()}}}).call(this,e("buffer").Buffer)},{"../util/rpc-cache-utils":394,"./subprovider.js":387,buffer:84,"ethereumjs-tx":140,"ethereumjs-util":141,util:333}],385:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js");function o(e){if(!e)throw new Error("ProviderSubprovider - no provider specified");if(!e.sendAsync)throw new Error("ProviderSubprovider - specified provider does not have a sendAsync method");this.provider=e}t.exports=o,n(o,i),o.prototype.handleRequest=function(e,t,r){this.provider.sendAsync(e,function(e,t){return e?r(e):t.error?r(new Error(t.error.message)):void r(null,t.result)})}},{"./subprovider.js":387,util:333}],386:[function(e,t,r){const n=e("util").inherits,i=e("./subprovider.js"),o=(e("xtend"),e("ethereumjs-util"));function a(e){}t.exports=a,n(a,i),a.prototype.handleRequest=function(e,t,r){var n=e.params[0];if("object"==typeof n&&!Array.isArray(n)){var i=function(e){return s.reduce(function(t,r){return r in e&&(Array.isArray(e[r])?t[r]=e[r].map(function(e){return u(e)}):t[r]=u(e[r])),t},{})}(n);e.params[0]=i}t()};var s=["from","to","value","data","gas","gasPrice","nonce","fromBlock","toBlock","address","topics"];function u(e){switch(e){case"latest":case"pending":case"earliest":return e;default:return"string"==typeof e?o.addHexPrefix(e.toLowerCase()):e}}},{"./subprovider.js":387,"ethereumjs-util":141,util:333,xtend:423}],387:[function(e,t,r){const n=e("../util/create-payload.js");function i(){}t.exports=i,i.prototype.setEngine=function(e){const t=this;t.engine=e,e.on("block",function(e){t.currentBlock=e})},i.prototype.handleRequest=function(e,t,r){throw new Error("Subproviders should override `handleRequest`.")},i.prototype.emitPayload=function(e,t){this.engine.sendAsync(n(e),t)}},{"../util/create-payload.js":391}],388:[function(e,t,r){const n=e("events").EventEmitter,i=e("./filters.js"),o=e("../util/rpc-hex-encoding.js"),a=e("util").inherits,s=e("ethereumjs-util");function u(e){e=e||{},n.apply(this,Array.prototype.slice.call(arguments)),i.apply(this,[e]),this.subscriptions={}}a(u,i),Object.assign(u.prototype,n.prototype),u.prototype.constructor=u,u.prototype.eth_subscribe=function(e,t){const r=this;let n=()=>{},i=e.params[0];switch(i){case"logs":let o=e.params[1];n=r.newLogFilter.bind(r,o);break;case"newPendingTransactions":n=r.newPendingTransactionFilter.bind(r);break;case"newHeads":n=r.newBlockFilter.bind(r);break;case"syncing":default:return void t(new Error("unsupported subscription type"))}n(function(e,n){if(e)return t(e);const o=Number.parseInt(n,16);r.subscriptions[o]=i,r.filters[o].on("data",function(e){Array.isArray(e)||(e=[e]);var t=r._notificationHandler.bind(r,n,i);e.forEach(t),r.filters[o].clearChanges()}),"newPendingTransactions"===i&&r.checkForPendingBlocks(),t(null,n)})},u.prototype.eth_unsubscribe=function(e,t){const r=this;let n=e.params[0];const i=Number.parseInt(n,16);if(r.subscriptions[i]){r.subscriptions[i];r.uninstallFilter(n,function(e,n){delete r.subscriptions[i],t(e,n)})}else t(new Error(`Subscription ID ${n} not found.`))},u.prototype._notificationHandler=function(e,t,r){const n=this;"newHeads"===t&&(r=n._notificationResultFromBlock(r)),n.emit("data",null,{jsonrpc:"2.0",method:"eth_subscription",params:{subscription:e,result:r}})},u.prototype._notificationResultFromBlock=function(e){return{hash:s.bufferToHex(e.hash),parentHash:s.bufferToHex(e.parentHash),sha3Uncles:s.bufferToHex(e.sha3Uncles),miner:s.bufferToHex(e.miner),stateRoot:s.bufferToHex(e.stateRoot),transactionsRoot:s.bufferToHex(e.transactionsRoot),receiptsRoot:s.bufferToHex(e.receiptsRoot),logsBloom:s.bufferToHex(e.logsBloom),difficulty:o.intToQuantityHex(s.bufferToInt(e.difficulty)),number:o.intToQuantityHex(s.bufferToInt(e.number)),gasLimit:o.intToQuantityHex(s.bufferToInt(e.gasLimit)),gasUsed:o.intToQuantityHex(s.bufferToInt(e.gasUsed)),nonce:e.nonce?s.bufferToHex(e.nonce):null,mixHash:s.bufferToHex(e.mixHash),timestamp:o.intToQuantityHex(s.bufferToInt(e.timestamp)),extraData:s.bufferToHex(e.extraData)}},u.prototype.handleRequest=function(e,t,r){switch(e.method){case"eth_subscribe":this.eth_subscribe(e,r);break;case"eth_unsubscribe":this.eth_unsubscribe(e,r);break;default:i.prototype.handleRequest.apply(this,Array.prototype.slice.call(arguments))}},t.exports=u},{"../util/rpc-hex-encoding.js":395,"./filters.js":379,"ethereumjs-util":141,events:157,util:333}],389:[function(e,t,r){(function(r){const n=e("backoff"),i=e("events"),o=(e("util").inherits,r.WebSocket||e("ws")),a=e("./subprovider"),s=e("../util/create-payload");class u extends a{constructor({rpcUrl:e,debug:t,origin:r}){super(),i.call(this),Object.defineProperties(this,{_backoff:{value:n.exponential({randomisationFactor:.2,maxDelay:5e3})},_connectTime:{value:null,writable:!0},_log:{value:t?(...e)=>console.info.apply(console,["[WSProvider]",...e]):()=>{}},_origin:{value:r},_pendingRequests:{value:new Map},_socket:{value:null,writable:!0},_unhandledRequests:{value:[]},_url:{value:e}}),this._handleSocketClose=this._handleSocketClose.bind(this),this._handleSocketMessage=this._handleSocketMessage.bind(this),this._handleSocketOpen=this._handleSocketOpen.bind(this),this._backoff.on("ready",()=>{this._openSocket()}),this._openSocket()}handleRequest(e,t,r){if(!this._socket||this._socket.readyState!==o.OPEN)return this._unhandledRequests.push(Array.from(arguments)),void this._log("Socket not open. Request queued.");this._pendingRequests.set(e.id,[e,r]);const n=s(e);delete n.origin,this._socket.send(JSON.stringify(n)),this._log(`Sent: ${n.method} #${n.id}`)}_handleSocketClose({reason:e,code:t}){this._log(`Socket closed, code ${t} (${e||"no reason"})`),this._connectTime&&Date.now()-this._connectTime>5e3&&this._backoff.reset(),this._socket.removeEventListener("close",this._handleSocketClose),this._socket.removeEventListener("message",this._handleSocketMessage),this._socket.removeEventListener("open",this._handleSocketOpen),this._socket=null,this._backoff.backoff()}_handleSocketMessage(e){let t;try{t=JSON.parse(e.data)}catch(e){return void this._log("Received a message that is not valid JSON:",t)}if(void 0===t.id)return this.emit("data",null,t);if(!this._pendingRequests.has(t.id))return;const[r,n]=this._pendingRequests.get(t.id);if(this._pendingRequests.delete(t.id),this._log(`Received: ${r.method} #${t.id}`),t.error)return n(new Error(t.error.message));n(null,t.result)}_handleSocketOpen(){this._log("Socket open."),this._connectTime=Date.now(),this._pendingRequests.forEach(([e,t])=>{this._unhandledRequests.push([e,null,t])}),this._pendingRequests.clear(),this._unhandledRequests.splice(0,this._unhandledRequests.length).forEach(e=>{this.handleRequest.apply(this,e)})}_openSocket(){this._log("Opening socket..."),this._socket=new o(this._url,null,{origin:this._origin}),this._socket.addEventListener("close",this._handleSocketClose),this._socket.addEventListener("message",this._handleSocketMessage),this._socket.addEventListener("open",this._handleSocketOpen)}}Object.assign(u.prototype,i.prototype),t.exports=u}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util/create-payload":391,"./subprovider":387,backoff:45,events:157,util:333,ws:55}],390:[function(e,t,r){t.exports=function(e,t){if(!e)throw t||"Assertion failed"}},{}],391:[function(e,t,r){const n=e("./random-id.js"),i=e("xtend");t.exports=function(e){return i({id:n(),jsonrpc:"2.0",params:[]},e)}},{"./random-id.js":393,xtend:423}],392:[function(e,t,r){const n=e("./create-payload.js");t.exports=function(e,t,r){e.sendAsync(n({method:"eth_estimateGas",params:[t]}),function(e,t){if(e)return"no contract code at given address"===e.message?r(null,"0xcf08"):r(e);r(null,t.result)})}},{"./create-payload.js":391}],393:[function(e,t,r){const n=3;t.exports=function(){var e=(new Date).getTime()*Math.pow(10,n),t=Math.floor(Math.random()*Math.pow(10,n));return e+t}},{}],394:[function(e,t,r){const n=e("json-stable-stringify");function i(e){return"never"!==s(e)}function o(e){var t=a(e);return t>=e.params.length?e.params:"eth_getBlockByNumber"===e.method?e.params.slice(1):e.params.slice(0,t)}function a(e){switch(e.method){case"eth_getStorageAt":return 2;case"eth_getBalance":case"eth_getCode":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":return 1;case"eth_getBlockByNumber":return 0;default:return}}function s(e){switch(e.method){case"web3_clientVersion":case"web3_sha3":case"eth_protocolVersion":case"eth_getBlockTransactionCountByHash":case"eth_getUncleCountByBlockHash":case"eth_getCode":case"eth_getBlockByHash":case"eth_getTransactionByHash":case"eth_getTransactionByBlockHashAndIndex":case"eth_getTransactionReceipt":case"eth_getUncleByBlockHashAndIndex":case"eth_getCompilers":case"eth_compileLLL":case"eth_compileSolidity":case"eth_compileSerpent":case"shh_version":return"perma";case"eth_getBlockByNumber":case"eth_getBlockTransactionCountByNumber":case"eth_getUncleCountByBlockNumber":case"eth_getTransactionByBlockNumberAndIndex":case"eth_getUncleByBlockNumberAndIndex":return"fork";case"eth_gasPrice":case"eth_blockNumber":case"eth_getBalance":case"eth_getStorageAt":case"eth_getTransactionCount":case"eth_call":case"eth_estimateGas":case"eth_getFilterLogs":case"eth_getLogs":case"net_peerCount":return"block";case"net_version":case"net_peerCount":case"net_listening":case"eth_syncing":case"eth_sign":case"eth_coinbase":case"eth_mining":case"eth_hashrate":case"eth_accounts":case"eth_sendTransaction":case"eth_sendRawTransaction":case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_getFilterChanges":case"eth_getWork":case"eth_submitWork":case"eth_submitHashrate":case"db_putString":case"db_getString":case"db_putHex":case"db_getHex":case"shh_post":case"shh_newIdentity":case"shh_hasIdentity":case"shh_newGroup":case"shh_addToGroup":case"shh_newFilter":case"shh_uninstallFilter":case"shh_getFilterChanges":case"shh_getMessages":return"never"}}t.exports={cacheIdentifierForPayload:function(e,t={}){if(!i(e))return null;const{includeBlockRef:r}=t,a=r?e.params:o(e);return e.method+":"+n(a)},canCache:i,blockTagForPayload:function(e){var t=a(e);if(t>=e.params.length)return null;return e.params[t]},paramsWithoutBlockTag:o,blockTagParamIndex:a,cacheTypeForPayload:s}},{"json-stable-stringify":374}],395:[function(e,t,r){(function(r){const n=e("ethereumjs-util"),i=e("./assert.js");t.exports={intToQuantityHex:function(e){i("number"==typeof e&&e===Math.floor(e),"intToQuantityHex arg must be an integer");var t=n.toBuffer(e).toString("hex");"0"===t[0]&&(t=t.substring(1));return n.addHexPrefix(t)},quantityHexToInt:function(e){i("string"==typeof e,"arg to quantityHexToInt must be a string");var t=n.stripHexPrefix(e);t.length%2!=0&&(t="0"+t);var o=new r(t,"hex");return n.bufferToInt(o)}}}).call(this,e("buffer").Buffer)},{"./assert.js":390,buffer:84,"ethereumjs-util":141}],396:[function(e,t,r){const n=e("events").EventEmitter,i=e("util").inherits;function o(){n.call(this),this.isLocked=!0}t.exports=o,i(o,n),o.prototype.go=function(){this.isLocked=!1,this.emit("unlock")},o.prototype.stop=function(){this.isLocked=!0,this.emit("lock")},o.prototype.await=function(e){const t=this;t.isLocked?t.once("unlock",e):setTimeout(e)}},{events:157,util:333}],397:[function(e,t,r){const n=e("./index.js"),i=e("./subproviders/default-fixture.js"),o=e("./subproviders/nonce-tracker.js"),a=e("./subproviders/cache.js"),s=e("./subproviders/filters.js"),u=e("./subproviders/subscriptions"),c=e("./subproviders/inflight-cache"),f=e("./subproviders/hooked-wallet.js"),h=e("./subproviders/sanitizer.js"),l=e("./subproviders/infura.js"),d=e("./subproviders/fetch.js"),p=e("./subproviders/websocket.js");t.exports=function(e={}){const t=function({rpcUrl:e}){if(!e)return;switch(e.split(":")[0].toLowerCase()){case"http":case"https":return"http";case"ws":case"wss":return"ws";default:throw new Error(`ProviderEngine - unrecognized protocol in "${e}"`)}}(e),r=new n(e.engineParams),b=new i(e.static);r.addProvider(b),r.addProvider(new o);const y=new h;r.addProvider(y);const m=new a;if(r.addProvider(m),"ws"===t){const e=new s;r.addProvider(e)}else{const e=new u;e.on("data",(e,t)=>{r.emit("data",e,t)}),r.addProvider(e)}const v=new c;r.addProvider(v);const g=new f({getAccounts:e.getAccounts,processTransaction:e.processTransaction,approveTransaction:e.approveTransaction,signTransaction:e.signTransaction,publishTransaction:e.publishTransaction,processMessage:e.processMessage,approveMessage:e.approveMessage,signMessage:e.signMessage,processPersonalMessage:e.processPersonalMessage,processTypedMessage:e.processTypedMessage,approvePersonalMessage:e.approvePersonalMessage,approveTypedMessage:e.approveTypedMessage,signPersonalMessage:e.signPersonalMessage,signTypedMessage:e.signTypedMessage,personalRecoverSigner:e.personalRecoverSigner});r.addProvider(g);const w=e.dataSubprovider||function(e,t){const{rpcUrl:r,debug:n}=t;if(!e)return new l;if("http"===e)return new d({rpcUrl:r,debug:n});if("ws"===e)return new p({rpcUrl:r,debug:n});throw new Error(`ProviderEngine - unrecognized connectionType "${e}"`)}(t,e);"ws"===t&&w.on("data",(e,t)=>{r.emit("data",e,t)});r.addProvider(w),e.stopped||r.start();return r}},{"./index.js":373,"./subproviders/cache.js":376,"./subproviders/default-fixture.js":377,"./subproviders/fetch.js":378,"./subproviders/filters.js":379,"./subproviders/hooked-wallet.js":381,"./subproviders/inflight-cache":382,"./subproviders/infura.js":383,"./subproviders/nonce-tracker.js":384,"./subproviders/sanitizer.js":386,"./subproviders/subscriptions":388,"./subproviders/websocket.js":389}],398:[function(e,t,r){var n=e("web3-core-helpers").errors,i=e("xhr2-cookies").XMLHttpRequest,o=e("http"),a=e("https"),s=function(e,t){t=t||{},this.host=e||"http://localhost:8545","https"===this.host.substring(0,5)?this.httpsAgent=new a.Agent({keepAlive:!0}):this.httpAgent=new o.Agent({keepAlive:!0}),this.timeout=t.timeout||0,this.headers=t.headers,this.connected=!1};s.prototype._prepareRequest=function(){var e=new i;return e.nodejsSet({httpsAgent:this.httpsAgent,httpAgent:this.httpAgent}),e.open("POST",this.host,!0),e.setRequestHeader("Content-Type","application/json"),e.timeout=this.timeout&&1!==this.timeout?this.timeout:0,e.withCredentials=!0,this.headers&&this.headers.forEach(function(t){e.setRequestHeader(t.name,t.value)}),e},s.prototype.send=function(e,t){var r=this,i=this._prepareRequest();i.onreadystatechange=function(){if(4===i.readyState&&1!==i.timeout){var e=i.responseText,o=null;try{e=JSON.parse(e)}catch(e){o=n.InvalidResponse(i.responseText)}r.connected=!0,t(o,e)}},i.ontimeout=function(){r.connected=!1,t(n.ConnectionTimeout(this.timeout))};try{i.send(JSON.stringify(e))}catch(e){this.connected=!1,t(n.InvalidConnection(this.host))}},s.prototype.disconnect=function(){},t.exports=s},{http:312,https:175,"web3-core-helpers":338,"xhr2-cookies":418}],399:[function(e,t,r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=e("oboe"),a=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],this.path=e,this.connected=!1,this.connection=t.connect({path:this.path}),this.addDefaultEvents();var i=function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,t||-1===e.method.indexOf("_subscription")?r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t]):r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)})};"Socket"===t.constructor.name?o(this.connection).done(i):this.connection.on("data",function(e){r._parseResponse(e.toString()).forEach(i)})};a.prototype.addDefaultEvents=function(){var e=this;this.connection.on("connect",function(){e.connected=!0}),this.connection.on("close",function(){e.connected=!1}),this.connection.on("error",function(){e._timeout()}),this.connection.on("end",function(){e._timeout()}),this.connection.on("timeout",function(){e._timeout()})},a.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},a.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n},a.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on IPC")),delete this.responseCallbacks[e])},a.prototype.reconnect=function(){this.connection.connect({path:this.path})},a.prototype.send=function(e,t){this.connection.writable||this.connection.connect({path:this.path}),this.connection.write(JSON.stringify(e)),this._addResponseCallback(e,t)},a.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;default:this.connection.on(e,t)}},a.prototype.once=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");this.connection.once(e,t)},a.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)});break;default:this.connection.removeListener(e,t)}},a.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;default:this.connection.removeAllListeners(e)}},a.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.connection.removeAllListeners("error"),this.connection.removeAllListeners("end"),this.connection.removeAllListeners("timeout"),this.addDefaultEvents()},t.exports=a},{oboe:239,underscore:325,"web3-core-helpers":338}],400:[function(e,t,r){(function(r){"use strict";var n=e("underscore"),i=e("web3-core-helpers").errors,o=null,a=null,s=null;if("undefined"!=typeof window&&void 0!==window.WebSocket)o=function(e,t){return new window.WebSocket(e,t)},a=btoa,s=function(e){return new URL(e)};else{o=e("websocket").w3cwebsocket,a=function(e){return r(e).toString("base64")};var u=e("url");if(u.URL){var c=u.URL;s=function(e){return new c(e)}}else s=e("url").parse}var f=function(e,t){var r=this;this.responseCallbacks={},this.notificationCallbacks=[],t=t||{},this._customTimeout=t.timeout;var i=s(e),u=t.headers||{},c=t.protocol||void 0;i.username&&i.password&&(u.authorization="Basic "+a(i.username+":"+i.password));var f=t.clientConfig||void 0;i.auth&&(u.authorization="Basic "+a(i.auth)),this.connection=new o(e,c,void 0,u,void 0,f),this.addDefaultEvents(),this.connection.onmessage=function(e){var t="string"==typeof e.data?e.data:"";r._parseResponse(t).forEach(function(e){var t=null;n.isArray(e)?e.forEach(function(e){r.responseCallbacks[e.id]&&(t=e.id)}):t=e.id,!t&&e&&e.method&&-1!==e.method.indexOf("_subscription")?r.notificationCallbacks.forEach(function(t){n.isFunction(t)&&t(e)}):r.responseCallbacks[t]&&(r.responseCallbacks[t](null,e),delete r.responseCallbacks[t])})},Object.defineProperty(this,"connected",{get:function(){return this.connection&&this.connection.readyState===this.connection.OPEN},enumerable:!0})};f.prototype.addDefaultEvents=function(){var e=this;this.connection.onerror=function(){e._timeout()},this.connection.onclose=function(){e._timeout(),e.reset()}},f.prototype._parseResponse=function(e){var t=this,r=[];return e.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|").forEach(function(e){t.lastChunk&&(e=t.lastChunk+e);var n=null;try{n=JSON.parse(e)}catch(r){return t.lastChunk=e,clearTimeout(t.lastChunkTimeout),void(t.lastChunkTimeout=setTimeout(function(){throw t._timeout(),i.InvalidResponse(e)},15e3))}clearTimeout(t.lastChunkTimeout),t.lastChunk=null,n&&r.push(n)}),r},f.prototype._addResponseCallback=function(e,t){var r=e.id||e[0].id,n=e.method||e[0].method;this.responseCallbacks[r]=t,this.responseCallbacks[r].method=n;var o=this;this._customTimeout&&setTimeout(function(){o.responseCallbacks[r]&&(o.responseCallbacks[r](i.ConnectionTimeout(o._customTimeout)),delete o.responseCallbacks[r])},this._customTimeout)},f.prototype._timeout=function(){for(var e in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(e)&&(this.responseCallbacks[e](i.InvalidConnection("on WS")),delete this.responseCallbacks[e])},f.prototype.send=function(e,t){var r=this;if(this.connection.readyState!==this.connection.CONNECTING){if(this.connection.readyState!==this.connection.OPEN)return console.error("connection not open on send()"),"function"==typeof this.connection.onerror?this.connection.onerror(new Error("connection not open")):console.error("no error callback"),void t(new Error("connection not open"));this.connection.send(JSON.stringify(e)),this._addResponseCallback(e,t)}else setTimeout(function(){r.send(e,t)},10)},f.prototype.on=function(e,t){if("function"!=typeof t)throw new Error("The second parameter callback must be a function.");switch(e){case"data":this.notificationCallbacks.push(t);break;case"connect":this.connection.onopen=t;break;case"end":this.connection.onclose=t;break;case"error":this.connection.onerror=t}},f.prototype.removeListener=function(e,t){var r=this;switch(e){case"data":this.notificationCallbacks.forEach(function(e,n){e===t&&r.notificationCallbacks.splice(n,1)})}},f.prototype.removeAllListeners=function(e){switch(e){case"data":this.notificationCallbacks=[];break;case"connect":this.connection.onopen=null;break;case"end":this.connection.onclose=null;break;case"error":this.connection.onerror=null}},f.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.addDefaultEvents()},f.prototype.disconnect=function(){this.connection&&this.connection.close()},t.exports=f}).call(this,e("buffer").Buffer)},{buffer:84,underscore:325,url:327,"web3-core-helpers":338,websocket:408}],401:[function(e,t,r){"use strict";var n=e("web3-core"),i=e("web3-core-subscriptions").subscriptions,o=e("web3-core-method"),a=e("web3-net"),s=function(){var e=this;n.packageInit(this,arguments);var t=this.setProvider;this.setProvider=function(){t.apply(e,arguments),e.net.setProvider.apply(e,arguments)},this.clearSubscriptions=e._requestManager.clearSubscriptions,this.net=new a(this.currentProvider),[new i({name:"subscribe",type:"shh",subscriptions:{messages:{params:1}}}),new o({name:"getVersion",call:"shh_version",params:0}),new o({name:"getInfo",call:"shh_info",params:0}),new o({name:"setMaxMessageSize",call:"shh_setMaxMessageSize",params:1}),new o({name:"setMinPoW",call:"shh_setMinPoW",params:1}),new o({name:"markTrustedPeer",call:"shh_markTrustedPeer",params:1}),new o({name:"newKeyPair",call:"shh_newKeyPair",params:0}),new o({name:"addPrivateKey",call:"shh_addPrivateKey",params:1}),new o({name:"deleteKeyPair",call:"shh_deleteKeyPair",params:1}),new o({name:"hasKeyPair",call:"shh_hasKeyPair",params:1}),new o({name:"getPublicKey",call:"shh_getPublicKey",params:1}),new o({name:"getPrivateKey",call:"shh_getPrivateKey",params:1}),new o({name:"newSymKey",call:"shh_newSymKey",params:0}),new o({name:"addSymKey",call:"shh_addSymKey",params:1}),new o({name:"generateSymKeyFromPassword",call:"shh_generateSymKeyFromPassword",params:1}),new o({name:"hasSymKey",call:"shh_hasSymKey",params:1}),new o({name:"getSymKey",call:"shh_getSymKey",params:1}),new o({name:"deleteSymKey",call:"shh_deleteSymKey",params:1}),new o({name:"newMessageFilter",call:"shh_newMessageFilter",params:1}),new o({name:"getFilterMessages",call:"shh_getFilterMessages",params:1}),new o({name:"deleteMessageFilter",call:"shh_deleteMessageFilter",params:1}),new o({name:"post",call:"shh_post",params:1,inputFormatter:[null]}),new o({name:"unsubscribe",call:"shh_unsubscribe",params:1})].forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};n.addProviders(s),t.exports=s},{"web3-core":348,"web3-core-method":339,"web3-core-subscriptions":345,"web3-net":372}],402:[function(e,t,r){arguments[4][154][0].apply(r,arguments)},{dup:154}],403:[function(e,t,r){var n=e("underscore"),i=e("ethjs-unit"),o=e("./utils.js"),a=e("./soliditySha3.js"),s=e("randomhex"),u=function(e,t){var r=[];return t.forEach(function(t){if("object"==typeof t.components){if("tuple"!==t.type.substring(0,5))throw new Error("components found but type is not tuple; report on GitHub");var i="",o=t.type.indexOf("[");o>=0&&(i=t.type.substring(o));var a=u(e,t.components);n.isArray(a)&&e?r.push("tuple("+a.join(",")+")"+i):e?r.push("("+a+")"):r.push("("+a.join(",")+")"+i)}else r.push(t.type)}),r},c=function(e){if(!o.isHexStrict(e))throw new Error("The parameter must be a valid HEX string.");var t="",r=0,n=e.length;for("0x"===e.substring(0,2)&&(r=2);r7?r+=e[n].toUpperCase():r+=e[n];return r},toHex:o.toHex,toBN:o.toBN,bytesToHex:o.bytesToHex,hexToBytes:o.hexToBytes,hexToNumberString:o.hexToNumberString,hexToNumber:o.hexToNumber,toDecimal:o.hexToNumber,numberToHex:o.numberToHex,fromDecimal:o.numberToHex,hexToUtf8:o.hexToUtf8,hexToString:o.hexToUtf8,toUtf8:o.hexToUtf8,utf8ToHex:o.utf8ToHex,stringToHex:o.utf8ToHex,fromUtf8:o.utf8ToHex,hexToAscii:c,toAscii:c,asciiToHex:f,fromAscii:f,unitMap:i.unitMap,toWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.toWei(e,t):i.toWei(e,t).toString(10)},fromWei:function(e,t){if(t=h(t),!o.isBN(e)&&!n.isString(e))throw new Error("Please pass numbers as strings or BigNumber objects to avoid precision errors.");return o.isBN(e)?i.fromWei(e,t):i.fromWei(e,t).toString(10)},padLeft:o.leftPad,leftPad:o.leftPad,padRight:o.rightPad,rightPad:o.rightPad,toTwosComplement:o.toTwosComplement}},{"./soliditySha3.js":404,"./utils.js":405,"ethjs-unit":153,randomhex:274,underscore:325}],404:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("./utils.js"),a=function(e){var t=typeof e;if("string"===t)return o.isHexStrict(e)?new i(e.replace(/0x/i,""),16):new i(e,10);if("number"===t)return new i(e);if(o.isBigNumber(e))return new i(e.toString(10));if(o.isBN(e))return e;throw new Error(e+" is not a number")},s=function(e,t,r){var n,s,u;if("bytes"===(e=(u=e).startsWith("int[")?"int256"+u.slice(3):"int"===u?"int256":u.startsWith("uint[")?"uint256"+u.slice(4):"uint"===u?"uint256":u.startsWith("fixed[")?"fixed128x128"+u.slice(5):"fixed"===u?"fixed128x128":u.startsWith("ufixed[")?"ufixed128x128"+u.slice(6):"ufixed"===u?"ufixed128x128":u)){if(t.replace(/^0x/i,"").length%2!=0)throw new Error("Invalid bytes characters "+t.length);return t}if("string"===e)return o.utf8ToHex(t);if("bool"===e)return t?"01":"00";if(e.startsWith("address")){if(n=r?64:40,!o.isAddress(t))throw new Error(t+" is not a valid address, or the checksum is invalid.");return o.leftPad(t.toLowerCase(),n)}if(n=function(e){var t=/^\D+(\d+).*$/.exec(e);return t?parseInt(t[1],10):null}(e),e.startsWith("bytes")){if(!n)throw new Error("bytes[] not yet supported in solidity");if(r&&(n=32),n<1||n>32||n256)throw new Error("Invalid uint"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied uint exceeds width: "+n+" vs "+s.bitLength());if(s.lt(new i(0)))throw new Error("Supplied uint "+s.toString()+" is negative");return n?o.leftPad(s.toString("hex"),n/8*2):s}if(e.startsWith("int")){if(n%8||n<8||n>256)throw new Error("Invalid int"+n+" size");if((s=a(t)).bitLength()>n)throw new Error("Supplied int exceeds width: "+n+" vs "+s.bitLength());return s.lt(new i(0))?s.toTwos(n).toString("hex"):n?o.leftPad(s.toString("hex"),n/8*2):s}throw new Error("Unsupported or invalid type: "+e)},u=function(e){if(n.isArray(e))throw new Error("Autodetection of array types is not supported.");var t,r,a="";if(n.isObject(e)&&(e.hasOwnProperty("v")||e.hasOwnProperty("t")||e.hasOwnProperty("value")||e.hasOwnProperty("type"))?(t=e.hasOwnProperty("t")?e.t:e.type,a=e.hasOwnProperty("v")?e.v:e.value):(t=o.toHex(e,!0),a=o.toHex(e),t.startsWith("int")||t.startsWith("uint")||(t="bytes")),!t.startsWith("int")&&!t.startsWith("uint")||"string"!=typeof a||/^(-)?0x/i.test(a)||(a=new i(a)),n.isArray(a)){if((r=function(e){var t=/^\D+\d*\[(\d+)\]$/.exec(e);return t?parseInt(t[1],10):null}(t))&&a.length!==r)throw new Error(t+" is not matching the given array "+JSON.stringify(a));r=a.length}return n.isArray(a)?a.map(function(e){return s(t,e,r).toString("hex").replace("0x","")}).join(""):s(t,a,r).toString("hex").replace("0x","")};t.exports=function(){var e=Array.prototype.slice.call(arguments),t=n.map(e,u);return o.sha3("0x"+t.join(""))}},{"./utils.js":405,"bn.js":402,underscore:325}],405:[function(e,t,r){var n=e("underscore"),i=e("bn.js"),o=e("number-to-bn"),a=e("utf8"),s=e("eth-lib/lib/hash"),u=function(e){return e instanceof i||e&&e.constructor&&"BN"===e.constructor.name},c=function(e){return e&&e.constructor&&"BigNumber"===e.constructor.name},f=function(e){try{return o.apply(null,arguments)}catch(t){throw new Error(t+' Given value: "'+e+'"')}},h=function(e){return!!/^(0x)?[0-9a-f]{40}$/i.test(e)&&(!(!/^(0x|0X)?[0-9a-f]{40}$/.test(e)&&!/^(0x|0X)?[0-9A-F]{40}$/.test(e))||l(e))},l=function(e){e=e.replace(/^0x/i,"");for(var t=m(e.toLowerCase()).replace(/^0x/i,""),r=0;r<40;r++)if(parseInt(t[r],16)>7&&e[r].toUpperCase()!==e[r]||parseInt(t[r],16)<=7&&e[r].toLowerCase()!==e[r])return!1;return!0},d=function(e){var t="";e=(e=(e=(e=(e=a.encode(e)).replace(/^(?:\u0000)*/,"")).split("").reverse().join("")).replace(/^(?:\u0000)*/,"")).split("").reverse().join("");for(var r=0;r>>4).toString(16)),t.push((15&e[r]).toString(16));return"0x"+t.join("")},isHex:function(e){return(n.isString(e)||n.isNumber(e))&&/^(-0x|0x)?[0-9a-f]*$/i.test(e)},isHexStrict:y,leftPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+new Array(i).join(r||"0")+e},rightPad:function(e,t,r){var n=/^0x/i.test(e)||"number"==typeof e,i=t-(e=e.toString(16).replace(/^0x/i,"")).length+1>=0?t-e.length+1:0;return(n?"0x":"")+e+new Array(i).join(r||"0")},toTwosComplement:function(e){return"0x"+f(e).toTwos(256).toString(16,64)},sha3:m}},{"bn.js":402,"eth-lib/lib/hash":134,"number-to-bn":237,underscore:325,utf8:329}],406:[function(e,t,r){t.exports={_from:"web3@1.0.0-beta.36",_id:"web3@1.0.0-beta.36",_inBundle:!1,_integrity:"sha512-fZDunw1V0AQS27r5pUN3eOVP7u8YAvyo6vOapdgVRolAu5LgaweP7jncYyLINqIX9ZgWdS5A090bt+ymgaYHsw==",_location:"/web3",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"web3@1.0.0-beta.36",name:"web3",escapedName:"web3",rawSpec:"1.0.0-beta.36",saveSpec:null,fetchSpec:"1.0.0-beta.36"},_requiredBy:["#USER","/"],_resolved:"https://registry.npmjs.org/web3/-/web3-1.0.0-beta.36.tgz",_shasum:"2954da9e431124c88396025510d840ba731c8373",_spec:"web3@1.0.0-beta.36",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy",author:{name:"ethereum.org"},authors:[{name:"Fabian Vogelsteller",email:"fabian@ethereum.org",homepage:"http://frozeman.de"},{name:"Marek Kotewicz",email:"marek@parity.io",url:"https://github.com/debris"},{name:"Marian Oancea",url:"https://github.com/cubedro"},{name:"Gav Wood",email:"g@parity.io",homepage:"http://gavwood.com"},{name:"Jeffery Wilcke",email:"jeffrey.wilcke@ethereum.org",url:"https://github.com/obscuren"}],bugs:{url:"https://github.com/ethereum/web3.js/issues"},bundleDependencies:!1,dependencies:{"web3-bzz":"1.0.0-beta.36","web3-core":"1.0.0-beta.36","web3-eth":"1.0.0-beta.36","web3-eth-personal":"1.0.0-beta.36","web3-net":"1.0.0-beta.36","web3-shh":"1.0.0-beta.36","web3-utils":"1.0.0-beta.36"},deprecated:!1,description:"Ethereum JavaScript API",keywords:["Ethereum","JavaScript","API"],license:"LGPL-3.0",main:"src/index.js",name:"web3",namespace:"ethereum",repository:{type:"git",url:"https://github.com/ethereum/web3.js/tree/master/packages/web3"},version:"1.0.0-beta.36"}},{}],407:[function(e,t,r){"use strict";var n=e("../package.json").version,i=e("web3-core"),o=e("web3-eth"),a=e("web3-net"),s=e("web3-eth-personal"),u=e("web3-shh"),c=e("web3-bzz"),f=e("web3-utils"),h=function(){var e=this;i.packageInit(this,arguments),this.version=n,this.utils=f,this.eth=new o(this),this.shh=new u(this),this.bzz=new c(this);var t=this.setProvider;this.setProvider=function(r,n){return t.apply(e,arguments),this.eth.setProvider(r,n),this.shh.setProvider(r,n),this.bzz.setProvider(r),!0}};h.version=n,h.utils=f,h.modules={Eth:o,Net:a,Personal:s,Shh:u,Bzz:c},i.addProviders(h),t.exports=h},{"../package.json":406,"web3-bzz":335,"web3-core":348,"web3-eth":371,"web3-eth-personal":369,"web3-net":372,"web3-shh":401,"web3-utils":403}],408:[function(e,t,r){var n=function(){return this||{}}(),i=n.WebSocket||n.MozWebSocket,o=e("./version");function a(e,t){return t?new i(e,t):new i(e)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(e){Object.defineProperty(a,e,{get:function(){return i[e]}})}),t.exports={w3cwebsocket:i?a:null,version:o}},{"./version":409}],409:[function(e,t,r){t.exports=e("../package.json").version},{"../package.json":410}],410:[function(e,t,r){t.exports={_from:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_id:"websocket@1.0.26",_inBundle:!1,_integrity:"",_location:"/websocket",_phantomChildren:{},_requested:{type:"git",raw:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",name:"websocket",escapedName:"websocket",rawSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",saveSpec:"git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",fetchSpec:"git://github.com/frozeman/WebSocket-Node.git",gitCommittish:"browserifyCompatible"},_requiredBy:["/web3-providers-ws"],_resolved:"git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",_spec:"websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",_where:"/Users/alexvlasov/Blockchain/web3swift/web3swiftJSProxy/node_modules/web3-providers-ws",author:{name:"Brian McKelvey",email:"brian@worlize.com",url:"https://www.worlize.com/"},browser:"lib/browser.js",bugs:{url:"https://github.com/theturtle32/WebSocket-Node/issues"},bundleDependencies:!1,config:{verbose:!1},contributors:[{name:"Iñaki Baz Castillo",email:"ibc@aliax.net",url:"http://dev.sipdoc.net"}],dependencies:{debug:"^2.2.0",nan:"^2.3.3","typedarray-to-buffer":"^3.1.2",yaeti:"^0.0.6"},deprecated:!1,description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",devDependencies:{"buffer-equal":"^1.0.0",faucet:"^0.0.1",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-jshint":"^2.0.4",jshint:"^2.0.0","jshint-stylish":"^2.2.1",tape:"^4.0.1"},directories:{lib:"./lib"},engines:{node:">=0.10.0"},homepage:"https://github.com/theturtle32/WebSocket-Node",keywords:["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],license:"Apache-2.0",main:"index",name:"websocket",repository:{type:"git",url:"git+https://github.com/theturtle32/WebSocket-Node.git"},scripts:{gulp:"gulp",install:"(node-gyp rebuild 2> builderror.log) || (exit 0)",test:"faucet test/unit"},version:"1.0.26"}},{}],411:[function(e,t,r){var n=e("xhr-request");t.exports=function(e,t){return new Promise(function(r,i){n(e,t,function(e,t){e?i(e):r(t)})})}},{"xhr-request":412}],412:[function(e,t,r){var n=e("query-string"),i=e("url-set-query"),o=e("object-assign"),a=e("./lib/ensure-header.js"),s=e("./lib/request.js"),u="application/json",c=function(){};t.exports=function(e,t,r){if(!e||"string"!=typeof e)throw new TypeError("must specify a URL");"function"==typeof t&&(r=t,t={});if(r&&"function"!=typeof r)throw new TypeError("expected cb to be undefined or a function");r=r||c;var f=(t=t||{}).json?"json":"text",h=(t=o({responseType:f},t)).headers||{},l=(t.method||"GET").toUpperCase(),d=t.query;d&&("string"!=typeof d&&(d=n.stringify(d)),e=i(e,d));"json"===t.responseType&&a(h,"Accept",u);t.json&&"GET"!==l&&"HEAD"!==l&&(a(h,"Content-Type",u),t.body=JSON.stringify(t.body));return t.method=l,t.url=e,t.headers=h,delete t.query,delete t.json,s(t,r)}},{"./lib/ensure-header.js":413,"./lib/request.js":415,"object-assign":238,"query-string":266,"url-set-query":326}],413:[function(e,t,r){t.exports=function(e,t,r){var n=t.toLowerCase();e[t]||e[n]||(e[t]=r)}},{}],414:[function(e,t,r){t.exports=function(e,t){return t?{statusCode:t.statusCode,headers:t.headers,method:e.method,url:e.url,rawRequest:t.rawRequest?t.rawRequest:t}:null}},{}],415:[function(e,t,r){var n=e("xhr"),i=e("./normalize-response"),o=function(){};t.exports=function(e,t){delete e.uri;var r=!1;"json"===e.responseType&&(e.responseType="text",r=!0);var a=n(e,function(n,a,s){if(r&&!n)try{var u=a.rawRequest.responseText;s=JSON.parse(u)}catch(e){n=e}a=i(e,a),t(n,n?null:s,a),t=o}),s=a.onabort;return a.onabort=function(){var e=s.apply(a,Array.prototype.slice.call(arguments));return t(new Error("XHR Aborted")),t=o,e},a}},{"./normalize-response":414,xhr:416}],416:[function(e,t,r){"use strict";var n=e("global/window"),i=e("is-function"),o=e("parse-headers"),a=e("xtend");function s(e,t,r){var n=e;return i(t)?(r=t,"string"==typeof e&&(n={uri:e})):n=a(t,{uri:e}),n.callback=r,n}function u(e,t,r){return c(t=s(e,t,r))}function c(e){if(void 0===e.callback)throw new Error("callback argument missing");var t=!1,r=function(r,n,i){t||(t=!0,e.callback(r,n,i))};function n(e){return clearTimeout(f),e instanceof Error||(e=new Error(""+(e||"Unknown XMLHttpRequest Error"))),e.statusCode=0,r(e,m)}function i(){if(!s){var t;clearTimeout(f),t=e.useXDR&&void 0===c.status?200:1223===c.status?204:c.status;var n=m,i=null;return 0!==t?(n={body:function(){var e=void 0;if(e=c.response?c.response:c.responseText||function(e){try{if("document"===e.responseType)return e.responseXML;var t=e.responseXML&&"parsererror"===e.responseXML.documentElement.nodeName;if(""===e.responseType&&!t)return e.responseXML}catch(e){}return null}(c),y)try{e=JSON.parse(e)}catch(e){}return e}(),statusCode:t,method:l,headers:{},url:h,rawRequest:c},c.getAllResponseHeaders&&(n.headers=o(c.getAllResponseHeaders()))):i=new Error("Internal XMLHttpRequest Error"),r(i,n,n.body)}}var a,s,c=e.xhr||null;c||(c=e.cors||e.useXDR?new u.XDomainRequest:new u.XMLHttpRequest);var f,h=c.url=e.uri||e.url,l=c.method=e.method||"GET",d=e.body||e.data,p=c.headers=e.headers||{},b=!!e.sync,y=!1,m={body:void 0,headers:{},statusCode:0,method:l,url:h,rawRequest:c};if("json"in e&&!1!==e.json&&(y=!0,p.accept||p.Accept||(p.Accept="application/json"),"GET"!==l&&"HEAD"!==l&&(p["content-type"]||p["Content-Type"]||(p["Content-Type"]="application/json"),d=JSON.stringify(!0===e.json?d:e.json))),c.onreadystatechange=function(){4===c.readyState&&setTimeout(i,0)},c.onload=i,c.onerror=n,c.onprogress=function(){},c.onabort=function(){s=!0},c.ontimeout=n,c.open(l,h,!b,e.username,e.password),b||(c.withCredentials=!!e.withCredentials),!b&&e.timeout>0&&(f=setTimeout(function(){if(!s){s=!0,c.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT",n(e)}},e.timeout)),c.setRequestHeader)for(a in p)p.hasOwnProperty(a)&&c.setRequestHeader(a,p[a]);else if(e.headers&&!function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}(e.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in e&&(c.responseType=e.responseType),"beforeSend"in e&&"function"==typeof e.beforeSend&&e.beforeSend(c),c.send(d||null),c}t.exports=u,t.exports.default=u,u.XMLHttpRequest=n.XMLHttpRequest||function(){},u.XDomainRequest="withCredentials"in new u.XMLHttpRequest?u.XMLHttpRequest:n.XDomainRequest,function(e,t){for(var r=0;r=0)return this._url=this._parseUrl(t.headers.location),this._method="GET",this._loweredHeaders["content-type"]&&(delete this._headers[this._loweredHeaders["content-type"]],delete this._loweredHeaders["content-type"]),null!=this._headers["Content-Type"]&&delete this._headers["Content-Type"],delete this._headers["Content-Length"],this.upload._reset(),this._finalizeHeaders(),void this._sendHxxpRequest();this._response=t,this._response.on("data",function(e){return n._onHttpResponseData(t,e)}),this._response.on("end",function(){return n._onHttpResponseEnd(t)}),this._response.on("close",function(){return n._onHttpResponseClose(t)}),this.responseUrl=this._url.href.split("#")[0],this.status=t.statusCode,this.statusText=s.STATUS_CODES[this.status],this._parseResponseHeaders(t);var i=this._responseHeaders["content-length"]||"";this._totalBytes=+i,this._lengthComputable=!!i,this._setReadyState(r.HEADERS_RECEIVED)}},r.prototype._onHttpResponseData=function(e,t){this._response===e&&(this._responseParts.push(new n(t)),this._loadedBytes+=t.length,this.readyState!==r.LOADING&&this._setReadyState(r.LOADING),this._dispatchProgress("progress"))},r.prototype._onHttpResponseEnd=function(e){this._response===e&&(this._parseResponse(),this._request=null,this._response=null,this._setReadyState(r.DONE),this._dispatchProgress("load"),this._dispatchProgress("loadend"))},r.prototype._onHttpResponseClose=function(e){if(this._response===e){var t=this._request;this._setError(),t.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend")}},r.prototype._onHttpTimeout=function(e){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("timeout"),this._dispatchProgress("loadend"))},r.prototype._onHttpRequestError=function(e,t){this._request===e&&(this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend"))},r.prototype._dispatchProgress=function(e){var t=new r.ProgressEvent(e);t.lengthComputable=this._lengthComputable,t.loaded=this._loadedBytes,t.total=this._totalBytes,this.dispatchEvent(t)},r.prototype._setError=function(){this._request=null,this._response=null,this._responseHeaders=null,this._responseParts=null},r.prototype._parseUrl=function(e,t,r){var n=null==this.nodejsBaseUrl?e:f.resolve(this.nodejsBaseUrl,e),i=f.parse(n,!1,!0);i.hash=null;var o=(i.auth||"").split(":"),a=o[0],s=o[1];return(a||s||t||r)&&(i.auth=(t||a||"")+":"+(r||s||"")),i},r.prototype._parseResponseHeaders=function(e){for(var t in this._responseHeaders={},e.headers){var r=t.toLowerCase();this._privateHeaders[r]||(this._responseHeaders[r]=e.headers[t])}null!=this._mimeOverride&&(this._responseHeaders["content-type"]=this._mimeOverride)},r.prototype._parseResponse=function(){var e=n.concat(this._responseParts);switch(this._responseParts=null,this.responseType){case"json":this.responseText=null;try{this.response=JSON.parse(e.toString("utf-8"))}catch(e){this.response=null}return;case"buffer":return this.responseText=null,void(this.response=e);case"arraybuffer":this.responseText=null;for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),i=0;i Date: Thu, 9 Mar 2023 09:51:30 +0200 Subject: [PATCH 155/210] chore: fixed spacing; KeystoreParamsV3 init - removed local names of arguments; --- .../KeystoreManager/KeystoreParams.swift | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/KeystoreParams.swift b/Sources/Web3Core/KeystoreManager/KeystoreParams.swift index 07dfb9d2a..a4729d112 100644 --- a/Sources/Web3Core/KeystoreManager/KeystoreParams.swift +++ b/Sources/Web3Core/KeystoreManager/KeystoreParams.swift @@ -12,6 +12,7 @@ public struct KdfParamsV3: Decodable, Encodable { var r: Int? var c: Int? var prf: String? + public init(salt: String, dklen: Int, n: Int? = nil, p: Int? = nil, r: Int? = nil, c: Int? = nil, prf: String? = nil) { self.salt = salt self.dklen = dklen @@ -25,6 +26,7 @@ public struct KdfParamsV3: Decodable, Encodable { public struct CipherParamsV3: Decodable, Encodable { var iv: String + public init(iv: String) { self.iv = iv } @@ -38,6 +40,7 @@ public struct CryptoParamsV3: Decodable, Encodable { var kdfparams: KdfParamsV3 var mac: String var version: String? + public init(ciphertext: String, cipher: String, cipherparams: CipherParamsV3, kdf: String, kdfparams: KdfParamsV3, mac: String, version: String? = nil) { self.ciphertext = ciphertext self.cipher = cipher @@ -54,12 +57,12 @@ public protocol AbstractKeystoreParams: Codable { var id: String? { get } var version: Int { get } var isHDWallet: Bool { get } - } public struct PathAddressPair: Codable { public let path: String public let address: String + public init(path: String, address: String) { self.path = path self.address = address @@ -97,23 +100,20 @@ public struct KeystoreParamsBIP32: AbstractKeystoreParams { self.rootPath = rootPath self.isHDWallet = true } - } public struct KeystoreParamsV3: AbstractKeystoreParams { + public var address: String? public var crypto: CryptoParamsV3 public var id: String? public var version: Int public var isHDWallet: Bool - public var address: String? - - public init(address ad: String?, crypto cr: CryptoParamsV3, id i: String, version ver: Int) { - address = ad - self.crypto = cr - self.id = i - self.version = ver + public init(address: String?, crypto: CryptoParamsV3, id: String, version: Int) { + self.address = address + self.crypto = crypto + self.id = id + self.version = version self.isHDWallet = false } - } From 95214d9c517c1845c71ac6f8a544f41fa88f4d19 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Thu, 9 Mar 2023 10:14:39 +0200 Subject: [PATCH 156/210] chore: removed pathToAddress; replaced En/Decodable with Codable --- .../KeystoreManager/KeystoreParams.swift | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/KeystoreParams.swift b/Sources/Web3Core/KeystoreManager/KeystoreParams.swift index a4729d112..4d6667720 100644 --- a/Sources/Web3Core/KeystoreManager/KeystoreParams.swift +++ b/Sources/Web3Core/KeystoreManager/KeystoreParams.swift @@ -4,7 +4,7 @@ import Foundation -public struct KdfParamsV3: Decodable, Encodable { +public struct KdfParamsV3: Codable { var salt: String var dklen: Int var n: Int? @@ -24,7 +24,7 @@ public struct KdfParamsV3: Decodable, Encodable { } } -public struct CipherParamsV3: Decodable, Encodable { +public struct CipherParamsV3: Codable { var iv: String public init(iv: String) { @@ -32,7 +32,7 @@ public struct CipherParamsV3: Decodable, Encodable { } } -public struct CryptoParamsV3: Decodable, Encodable { +public struct CryptoParamsV3: Codable { var ciphertext: String var cipher: String var cipherparams: CipherParamsV3 @@ -75,20 +75,6 @@ public struct KeystoreParamsBIP32: AbstractKeystoreParams { public var version: Int public var isHDWallet: Bool - @available(*, deprecated, message: "Please use pathAddressPairs instead") - var pathToAddress: [String: String] { - get { - return self.pathAddressPairs.reduce(into: [String: String]()) { - $0[$1.path] = $1.address - } - } - set { - for pair in newValue { - self.pathAddressPairs.append(PathAddressPair(path: pair.0, address: pair.1)) - } - } - } - public var pathAddressPairs: [PathAddressPair] var rootPath: String? From 368c80aeb7eb4bdb019b9aa5012ec3ec095afaa5 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Thu, 9 Mar 2023 10:22:17 +0200 Subject: [PATCH 157/210] chore: fixed typo in a comment in ENSBaseRegistrar.swift --- Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift b/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift index a7082d731..5b7c2d5f4 100644 --- a/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift +++ b/Sources/web3swift/Utils/ENS/ENSBaseRegistrar.swift @@ -64,7 +64,7 @@ public extension ENS { return expirity } - @available(*, message: "This function should not be used to check if a name can be registered by a user. To check if a name can be registered by a user, check name availablility via the controller") + @available(*, message: "This function should not be used to check if a name can be registered by a user. To check if a name can be registered by a user, check name availability via the controller") public func isNameAvailable(name: BigUInt) async throws -> Bool { guard let transaction = self.contract.createReadOperation("available", parameters: [name]) else { throw Web3Error.transactionSerializationError } From 4ff3f356eb69c193716755ee9fc55e847d84866f Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Thu, 9 Mar 2023 10:25:52 +0200 Subject: [PATCH 158/210] chore: fixed trailing whitespaces --- Sources/Web3Core/KeystoreManager/KeystoreParams.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/KeystoreParams.swift b/Sources/Web3Core/KeystoreManager/KeystoreParams.swift index 4d6667720..c6de1ae24 100644 --- a/Sources/Web3Core/KeystoreManager/KeystoreParams.swift +++ b/Sources/Web3Core/KeystoreManager/KeystoreParams.swift @@ -74,10 +74,10 @@ public struct KeystoreParamsBIP32: AbstractKeystoreParams { public var id: String? public var version: Int public var isHDWallet: Bool - + public var pathAddressPairs: [PathAddressPair] var rootPath: String? - + public init(crypto cr: CryptoParamsV3, id i: String, version ver: Int = 32, rootPath: String? = nil) { self.crypto = cr self.id = i @@ -94,7 +94,7 @@ public struct KeystoreParamsV3: AbstractKeystoreParams { public var id: String? public var version: Int public var isHDWallet: Bool - + public init(address: String?, crypto: CryptoParamsV3, id: String, version: Int) { self.address = address self.crypto = crypto From c8827b6f41d395a12a69d806589610b2c0a6df89 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Thu, 9 Mar 2023 10:43:27 +0200 Subject: [PATCH 159/210] chore: ran swiftlint --fix --- .../Web3Core/KeystoreManager/KeystoreParams.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/KeystoreParams.swift b/Sources/Web3Core/KeystoreManager/KeystoreParams.swift index c6de1ae24..2b1747a03 100644 --- a/Sources/Web3Core/KeystoreManager/KeystoreParams.swift +++ b/Sources/Web3Core/KeystoreManager/KeystoreParams.swift @@ -12,7 +12,7 @@ public struct KdfParamsV3: Codable { var r: Int? var c: Int? var prf: String? - + public init(salt: String, dklen: Int, n: Int? = nil, p: Int? = nil, r: Int? = nil, c: Int? = nil, prf: String? = nil) { self.salt = salt self.dklen = dklen @@ -26,7 +26,7 @@ public struct KdfParamsV3: Codable { public struct CipherParamsV3: Codable { var iv: String - + public init(iv: String) { self.iv = iv } @@ -40,7 +40,7 @@ public struct CryptoParamsV3: Codable { var kdfparams: KdfParamsV3 var mac: String var version: String? - + public init(ciphertext: String, cipher: String, cipherparams: CipherParamsV3, kdf: String, kdfparams: KdfParamsV3, mac: String, version: String? = nil) { self.ciphertext = ciphertext self.cipher = cipher @@ -62,7 +62,7 @@ public protocol AbstractKeystoreParams: Codable { public struct PathAddressPair: Codable { public let path: String public let address: String - + public init(path: String, address: String) { self.path = path self.address = address @@ -74,10 +74,10 @@ public struct KeystoreParamsBIP32: AbstractKeystoreParams { public var id: String? public var version: Int public var isHDWallet: Bool - + public var pathAddressPairs: [PathAddressPair] var rootPath: String? - + public init(crypto cr: CryptoParamsV3, id i: String, version ver: Int = 32, rootPath: String? = nil) { self.crypto = cr self.id = i @@ -94,7 +94,7 @@ public struct KeystoreParamsV3: AbstractKeystoreParams { public var id: String? public var version: Int public var isHDWallet: Bool - + public init(address: String?, crypto: CryptoParamsV3, id: String, version: Int) { self.address = address self.crypto = crypto From c103517b811ba8938b45f1d75be642b128483b65 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Thu, 9 Mar 2023 11:29:57 +0200 Subject: [PATCH 160/210] chore: static constants marked as `let` --- Sources/Web3Core/KeystoreManager/BIP32HDNode.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift index 12e2afcb9..bac00db02 100644 --- a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift @@ -117,12 +117,12 @@ public class HDNode { childNumber = UInt32(0) } - private static var curveOrder = BigUInt("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", radix: 16)! - public static var defaultPath: String = "m/44'/60'/0'/0" - public static var defaultPathPrefix: String = "m/44'/60'/0'" - public static var defaultPathMetamask: String = "m/44'/60'/0'/0/0" - public static var defaultPathMetamaskPrefix: String = "m/44'/60'/0'/0" - public static var hardenedIndexPrefix: UInt32 { Self.maxIterationIndex } + private static let curveOrder = BigUInt("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", radix: 16)! + public static let defaultPath = "m/44'/60'/0'/0" + public static let defaultPathPrefix = "m/44'/60'/0'" + public static let defaultPathMetamask = "m/44'/60'/0'/0/0" + public static let defaultPathMetamaskPrefix = "m/44'/60'/0'/0" + public static let hardenedIndexPrefix: UInt32 { Self.maxIterationIndex } } extension HDNode { From 4450b0ffe815579354ebeb3f1615bcc58bcd0145 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Thu, 9 Mar 2023 15:20:13 +0200 Subject: [PATCH 161/210] fix: computed variables cannot bet declared as let --- Sources/Web3Core/KeystoreManager/BIP32HDNode.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift index bac00db02..9fe9df709 100644 --- a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift @@ -122,7 +122,7 @@ public class HDNode { public static let defaultPathPrefix = "m/44'/60'/0'" public static let defaultPathMetamask = "m/44'/60'/0'/0/0" public static let defaultPathMetamaskPrefix = "m/44'/60'/0'/0" - public static let hardenedIndexPrefix: UInt32 { Self.maxIterationIndex } + public static var hardenedIndexPrefix: UInt32 { Self.maxIterationIndex } } extension HDNode { From 59375372e425550e117c4b79ae17e66928351aad Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Thu, 9 Mar 2023 15:26:16 +0200 Subject: [PATCH 162/210] chore: removed extra space --- Sources/Web3Core/KeystoreManager/BIP32Keystore.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index 238f89c29..35e6f3d1a 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -107,7 +107,7 @@ public class BIP32Keystore: AbstractKeystore { try self.init(seed: seed, password: password, prefixPath: prefixPath, aesMode: aesMode) } - public init? (seed: Data, password: String, prefixPath: String = HDNode.defaultPathMetamaskPrefix, aesMode: String = "aes-128-cbc") throws { + public init?(seed: Data, password: String, prefixPath: String = HDNode.defaultPathMetamaskPrefix, aesMode: String = "aes-128-cbc") throws { addressStorage = PathAddressStorage() guard let rootNode = HDNode(seed: seed)?.derive(path: prefixPath, derivePrivateKey: true) else { return nil } self.rootPrefix = prefixPath From b5fb56a01df96a92c6c3d8c15cade45f9ad8ded7 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Thu, 9 Mar 2023 15:31:52 +0200 Subject: [PATCH 163/210] chore: dropped extra line; avoiding convertion from error to optional Instead of calling `try? getPrefixNodeData(password)` in a function that is able to throw we must call `try getPrefixNodeData(password)`. --- Sources/Web3Core/KeystoreManager/BIP32Keystore.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index 35e6f3d1a..4277cca61 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -137,7 +137,6 @@ public class BIP32Keystore: AbstractKeystore { } func createNewAccount(parentNode: HDNode, password: String = "web3swift") throws { - let maxIndex = addressStorage.paths .compactMap { $0.components(separatedBy: "/").last } .compactMap { UInt32($0) } @@ -167,7 +166,7 @@ public class BIP32Keystore: AbstractKeystore { } public func createNewCustomChildAccount(password: String, path: String) throws { - guard let decryptedRootNode = try? getPrefixNodeData(password) else { + guard let decryptedRootNode = try getPrefixNodeData(password) else { throw AbstractKeystoreError.encryptionError("Failed to decrypt a keystore") } guard let rootNode = HDNode(decryptedRootNode) else { From cedbad9c0ea9849428223fc168b58a36ac3ae065 Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:33:08 +0000 Subject: [PATCH 164/210] address review --- Sources/Web3Core/Structure/SECP256k1.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index d47c0577b..4c32a5b3b 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -189,7 +189,7 @@ extension SECP256K1 { } else if v >= 35 && v <= 38 { v -= 35 } - let result = serializedSignature.withUnsafeBytes { (setRawBufferPtr: UnsafeRawBufferPointer) -> Int32? in + let result = serializedSignature.withUnsafeBytes { (rawBufferPtr: UnsafeRawBufferPointer) -> Int32? in if let setRawPtr = setRawBufferPtr.baseAddress, setRawBufferPtr.count > 0 { let setPtr = setRawPtr.assumingMemoryBound(to: UInt8.self) return withUnsafeMutablePointer(to: &recoverableSignature) { (signaturePointer: UnsafeMutablePointer) -> Int32 in From 605ce5b7f7e59a1259ec588207712800405583d8 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Thu, 9 Mar 2023 10:39:31 -0800 Subject: [PATCH 165/210] cleanup per PR comments --- .../Web3Core/KeystoreManager/BIP32HDNode.swift | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift index 9fe9df709..748b54a15 100644 --- a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift @@ -22,18 +22,18 @@ extension UInt32 { } public class HDNode { - static var maxIterationIndex = UInt32(1) << 31 + private static var maxIterationIndex = UInt32(1) << 31 public struct HDversion { // swiftlint:disable force_unwrapping - public var privatePrefix: Data = Data.fromHex("0x0488ADE4") ?? Data() - public var publicPrefix: Data = Data.fromHex("0x0488B21E") ?? Data() + public var privatePrefix: Data = Data.fromHex("0x0488ADE4")! + public var publicPrefix: Data = Data.fromHex("0x0488B21E")! // swiftlint:enable force_unwrapping public init() {} - public static var privatePrefix: Data { + public static var privatePrefix: Data? { HDversion().privatePrefix } - public static var publicPrefix: Data { + public static var publicPrefix: Data? { HDversion().publicPrefix } @@ -49,11 +49,7 @@ public class HDNode { childNumber >= Self.maxIterationIndex } public var index: UInt32 { - if self.isHardened { - return childNumber - Self.maxIterationIndex - } else { - return childNumber - } + childNumber - (isHardened ? Self.maxIterationIndex : 0) } public var hasPrivate: Bool { privateKey != nil @@ -101,7 +97,7 @@ public class HDNode { guard seed.count >= 16 else { return nil } guard let hmacKey = "Bitcoin seed".data(using: .ascii) else { return nil } - let hmac: Authenticator = HMAC(key: hmacKey.bytes, variant: HMAC.Variant.sha2(.sha512)) + let hmac = HMAC(key: hmacKey.bytes, variant: .sha2(.sha512)) guard let entropy = try? hmac.authenticate(seed.bytes), entropy.count == 64 else { return nil } let I_L = entropy[0..<32] From d1623b8ebf3ff8cc5db5428f4594e9f5036b8fac Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:33:18 +0000 Subject: [PATCH 166/210] address review Signed-off-by: Sara Tavares --- Sources/Web3Core/Structure/SECP256k1.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index 4c32a5b3b..20cfc40fc 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -190,7 +190,7 @@ extension SECP256K1 { v -= 35 } let result = serializedSignature.withUnsafeBytes { (rawBufferPtr: UnsafeRawBufferPointer) -> Int32? in - if let setRawPtr = setRawBufferPtr.baseAddress, setRawBufferPtr.count > 0 { + if let setRawPtr = rawBufferPtr.baseAddress, rawBufferPtr.count > 0 { let setPtr = setRawPtr.assumingMemoryBound(to: UInt8.self) return withUnsafeMutablePointer(to: &recoverableSignature) { (signaturePointer: UnsafeMutablePointer) -> Int32 in let res = secp256k1_ecdsa_recoverable_signature_parse_compact(context, signaturePointer, setPtr, v) From 27b76f7b278e2268b81f9974245f1b7a49c047b3 Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:34:32 +0000 Subject: [PATCH 167/210] address review Signed-off-by: Sara Tavares --- Sources/Web3Core/Structure/SECP256k1.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index 20cfc40fc..1ab6e5bde 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -190,7 +190,7 @@ extension SECP256K1 { v -= 35 } let result = serializedSignature.withUnsafeBytes { (rawBufferPtr: UnsafeRawBufferPointer) -> Int32? in - if let setRawPtr = rawBufferPtr.baseAddress, rawBufferPtr.count > 0 { + if let rawPtr = rawBufferPtr.baseAddress, rawBufferPtr.count > 0 { let setPtr = setRawPtr.assumingMemoryBound(to: UInt8.self) return withUnsafeMutablePointer(to: &recoverableSignature) { (signaturePointer: UnsafeMutablePointer) -> Int32 in let res = secp256k1_ecdsa_recoverable_signature_parse_compact(context, signaturePointer, setPtr, v) From ef0a0080aed3efeb14a3c509a1d7540127693e81 Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:34:40 +0000 Subject: [PATCH 168/210] address review Signed-off-by: Sara Tavares --- Sources/Web3Core/Structure/SECP256k1.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index 1ab6e5bde..dae3d7e9a 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -191,7 +191,7 @@ extension SECP256K1 { } let result = serializedSignature.withUnsafeBytes { (rawBufferPtr: UnsafeRawBufferPointer) -> Int32? in if let rawPtr = rawBufferPtr.baseAddress, rawBufferPtr.count > 0 { - let setPtr = setRawPtr.assumingMemoryBound(to: UInt8.self) + let setPtr = rawPtr.assumingMemoryBound(to: UInt8.self) return withUnsafeMutablePointer(to: &recoverableSignature) { (signaturePointer: UnsafeMutablePointer) -> Int32 in let res = secp256k1_ecdsa_recoverable_signature_parse_compact(context, signaturePointer, setPtr, v) return res From 5b0dba3dd116462d256b72ea0b94e434c5504c73 Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:36:11 +0000 Subject: [PATCH 169/210] address review Signed-off-by: Sara Tavares --- Sources/Web3Core/Structure/SECP256k1.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index dae3d7e9a..c802f48ac 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -215,7 +215,7 @@ extension SECP256K1 { let setSignaturePointer = setSignatureRawPointer.assumingMemoryBound(to: UInt8.self) return withUnsafePointer(to: &recoverableSignature) { (signaturePointer: UnsafePointer) -> Int32 in withUnsafeMutablePointer(to: &v) { (vPtr: UnsafeMutablePointer) -> Int32 in - let res = secp256k1_ecdsa_recoverable_signature_serialize_compact(context, setSignaturePointer, vPtr, signaturePointer) + let res = secp256k1_ecdsa_recoverable_signature_serialize_compact(context, signaturePointer, vPtr, signaturePointer) return res } } From faba3e195a927049cce0596ef06f02438522bab3 Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:36:19 +0000 Subject: [PATCH 170/210] address review Signed-off-by: Sara Tavares --- Sources/Web3Core/Structure/SECP256k1.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index c802f48ac..9447f422b 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -212,7 +212,7 @@ extension SECP256K1 { var v: Int32 = 0 let result = serializedSignature.withUnsafeMutableBytes { (setSignatureRawBufferPointer: UnsafeMutableRawBufferPointer) -> Int32? in if let setSignatureRawPointer = setSignatureRawBufferPointer.baseAddress, setSignatureRawBufferPointer.count > 0 { - let setSignaturePointer = setSignatureRawPointer.assumingMemoryBound(to: UInt8.self) + let signaturePointer = signatureRawPointer.assumingMemoryBound(to: UInt8.self) return withUnsafePointer(to: &recoverableSignature) { (signaturePointer: UnsafePointer) -> Int32 in withUnsafeMutablePointer(to: &v) { (vPtr: UnsafeMutablePointer) -> Int32 in let res = secp256k1_ecdsa_recoverable_signature_serialize_compact(context, signaturePointer, vPtr, signaturePointer) From 8954763a986deae165951bd8fc200d9db44dc75f Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:36:30 +0000 Subject: [PATCH 171/210] address review Signed-off-by: Sara Tavares --- Sources/Web3Core/Structure/SECP256k1.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index 9447f422b..2fe4ecc97 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -210,7 +210,7 @@ extension SECP256K1 { guard let context = context else { return nil } var serializedSignature = Data(repeating: 0x00, count: 64) var v: Int32 = 0 - let result = serializedSignature.withUnsafeMutableBytes { (setSignatureRawBufferPointer: UnsafeMutableRawBufferPointer) -> Int32? in + let result = serializedSignature.withUnsafeMutableBytes { (signatureRawBufferPointer: UnsafeMutableRawBufferPointer) -> Int32? in if let setSignatureRawPointer = setSignatureRawBufferPointer.baseAddress, setSignatureRawBufferPointer.count > 0 { let signaturePointer = signatureRawPointer.assumingMemoryBound(to: UInt8.self) return withUnsafePointer(to: &recoverableSignature) { (signaturePointer: UnsafePointer) -> Int32 in From 81357c53014777f600b96f9544e90221efbf10f4 Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:36:39 +0000 Subject: [PATCH 172/210] address review Signed-off-by: Sara Tavares --- Sources/Web3Core/Structure/SECP256k1.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index 2fe4ecc97..f9c688710 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -211,7 +211,7 @@ extension SECP256K1 { var serializedSignature = Data(repeating: 0x00, count: 64) var v: Int32 = 0 let result = serializedSignature.withUnsafeMutableBytes { (signatureRawBufferPointer: UnsafeMutableRawBufferPointer) -> Int32? in - if let setSignatureRawPointer = setSignatureRawBufferPointer.baseAddress, setSignatureRawBufferPointer.count > 0 { + if let signatureRawPointer = signatureRawBufferPointer.baseAddress, signatureRawBufferPointer.count > 0 { let signaturePointer = signatureRawPointer.assumingMemoryBound(to: UInt8.self) return withUnsafePointer(to: &recoverableSignature) { (signaturePointer: UnsafePointer) -> Int32 in withUnsafeMutablePointer(to: &v) { (vPtr: UnsafeMutablePointer) -> Int32 in From 224c2eac7f0afd5c45aa5214f5fd02384275ed7e Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:38:12 +0000 Subject: [PATCH 173/210] address review Signed-off-by: Sara Tavares <29093946+stavares843@users.noreply.github.com> Signed-off-by: Sara Tavares --- Sources/Web3Core/Structure/SECP256k1.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index f9c688710..d126489d9 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -193,7 +193,7 @@ extension SECP256K1 { if let rawPtr = rawBufferPtr.baseAddress, rawBufferPtr.count > 0 { let setPtr = rawPtr.assumingMemoryBound(to: UInt8.self) return withUnsafeMutablePointer(to: &recoverableSignature) { (signaturePointer: UnsafeMutablePointer) -> Int32 in - let res = secp256k1_ecdsa_recoverable_signature_parse_compact(context, signaturePointer, setPtr, v) + let res = secp256k1_ecdsa_recoverable_signature_parse_compact(context, signaturePointer, ptr, v) return res } } else { From 58fcb1377834c1121592634e38d5786d2da59efc Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:38:24 +0000 Subject: [PATCH 174/210] address review Signed-off-by: Sara Tavares <29093946+stavares843@users.noreply.github.com> Signed-off-by: Sara Tavares --- Sources/Web3Core/Structure/SECP256k1.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index d126489d9..330a85ecb 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -191,7 +191,7 @@ extension SECP256K1 { } let result = serializedSignature.withUnsafeBytes { (rawBufferPtr: UnsafeRawBufferPointer) -> Int32? in if let rawPtr = rawBufferPtr.baseAddress, rawBufferPtr.count > 0 { - let setPtr = rawPtr.assumingMemoryBound(to: UInt8.self) + let ptr = rawPtr.assumingMemoryBound(to: UInt8.self) return withUnsafeMutablePointer(to: &recoverableSignature) { (signaturePointer: UnsafeMutablePointer) -> Int32 in let res = secp256k1_ecdsa_recoverable_signature_parse_compact(context, signaturePointer, ptr, v) return res From 7ce0ab62eea593849c6ab6632ea069e2a92e90e7 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 10 Mar 2023 14:50:47 +0200 Subject: [PATCH 175/210] fix: conflicting variable names --- Sources/Web3Core/Structure/SECP256k1.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Web3Core/Structure/SECP256k1.swift b/Sources/Web3Core/Structure/SECP256k1.swift index 330a85ecb..82f7fb375 100755 --- a/Sources/Web3Core/Structure/SECP256k1.swift +++ b/Sources/Web3Core/Structure/SECP256k1.swift @@ -212,10 +212,10 @@ extension SECP256K1 { var v: Int32 = 0 let result = serializedSignature.withUnsafeMutableBytes { (signatureRawBufferPointer: UnsafeMutableRawBufferPointer) -> Int32? in if let signatureRawPointer = signatureRawBufferPointer.baseAddress, signatureRawBufferPointer.count > 0 { - let signaturePointer = signatureRawPointer.assumingMemoryBound(to: UInt8.self) + let typedSignaturePointer = signatureRawPointer.assumingMemoryBound(to: UInt8.self) return withUnsafePointer(to: &recoverableSignature) { (signaturePointer: UnsafePointer) -> Int32 in withUnsafeMutablePointer(to: &v) { (vPtr: UnsafeMutablePointer) -> Int32 in - let res = secp256k1_ecdsa_recoverable_signature_serialize_compact(context, signaturePointer, vPtr, signaturePointer) + let res = secp256k1_ecdsa_recoverable_signature_serialize_compact(context, typedSignaturePointer, vPtr, signaturePointer) return res } } From 28b1334f1229f3bd77288f478fe74f7ae918b828 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 10 Mar 2023 17:36:27 +0200 Subject: [PATCH 176/210] feat: transaction polling task --- .../Transaction/TransactionPollingTask.swift | 66 +++++++++++++++++++ .../TransactionPollingTaskTest.swift | 33 ++++++++++ 2 files changed, 99 insertions(+) create mode 100644 Sources/web3swift/Transaction/TransactionPollingTask.swift create mode 100644 Tests/web3swiftTests/localTests/TransactionPollingTaskTest.swift diff --git a/Sources/web3swift/Transaction/TransactionPollingTask.swift b/Sources/web3swift/Transaction/TransactionPollingTask.swift new file mode 100644 index 000000000..08593e42c --- /dev/null +++ b/Sources/web3swift/Transaction/TransactionPollingTask.swift @@ -0,0 +1,66 @@ +// +// TransactionPollingTask.swift +// +// Created by JeneaVranceanu on 10.03.2023. +// + +import Foundation +import Web3Core + +/// Monitors a transaction's state on blockchain until transaction is completed successfully or not. +final public class TransactionPollingTask { + + private enum DelayUnit: UInt64 { + case shortest = 1 + case medium = 5 + case longest = 60 + + func shouldIncreaseDelay(_ startTime: Date) -> Bool { + let timePassed = Date().timeIntervalSince1970 - startTime.timeIntervalSince1970 + switch self { + case .shortest: + return timePassed > 10 + case .medium: + return timePassed > 120 + case .longest: + return false + } + } + + var nextDelayUnit: DelayUnit { + switch self { + case .shortest: + return .medium + case .medium, .longest: + return .longest + } + } + } + + public let transactionHash: Data + + private let web3Instance: Web3 + private var delayUnit: DelayUnit = .shortest + + public init(transactionHash: Data, web3Instance: Web3) { + self.transactionHash = transactionHash + self.web3Instance = web3Instance + } + + public func wait() async throws -> TransactionReceipt { + let startTime = Date() + while true { + let transactionReceipt = try await web3Instance.eth.transactionReceipt(transactionHash) + + if transactionReceipt.status != .notYetProcessed { + return transactionReceipt + } + + if delayUnit.shouldIncreaseDelay(startTime) { + delayUnit = delayUnit.nextDelayUnit + } + + try await Task.sleep(nanoseconds: delayUnit.rawValue) + } + } +} diff --git a/Tests/web3swiftTests/localTests/TransactionPollingTaskTest.swift b/Tests/web3swiftTests/localTests/TransactionPollingTaskTest.swift new file mode 100644 index 000000000..1ded4ce8a --- /dev/null +++ b/Tests/web3swiftTests/localTests/TransactionPollingTaskTest.swift @@ -0,0 +1,33 @@ +// +// TransactionPollingTaskTest.swift +// +// Created by JeneaVranceanu on 10.03.2023. +// + +import XCTest +import Foundation +@testable import web3swift +@testable import Web3Core + +class TransactionPollingTaskTest: LocalTestCase { + + func testTransactionPolling() async throws { + let web3 = try await Web3.new(LocalTestCase.url) + let sendToAddress = EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")! + let allAddresses = try await web3.eth.ownedAccounts() + let contract = web3.contract(Web3.Utils.coldWalletABI, at: sendToAddress) + let writeTX = contract!.createWriteOperation("fallback")! + writeTX.transaction.from = allAddresses[0] + writeTX.transaction.value = 1 + + let policies = Policies(gasLimitPolicy: .automatic) + let result = try await writeTX.writeToChain(password: "", policies: policies, sendRaw: false) + + let txHash = Data.fromHex(result.hash.stripHexPrefix())! + + let transactionReceipt = try await TransactionPollingTask(transactionHash: txHash, web3Instance: web3).wait() + + XCTAssertEqual(transactionReceipt.status, .ok) + } + +} From b855b91e100f9981bd5ed469a5407f84c3e83d33 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 12 Mar 2023 20:03:33 +0200 Subject: [PATCH 177/210] chore: changed order of access control keyword --- Sources/Web3Core/KeystoreManager/BIP39.swift | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP39.swift b/Sources/Web3Core/KeystoreManager/BIP39.swift index 0036ed390..690425d64 100755 --- a/Sources/Web3Core/KeystoreManager/BIP39.swift +++ b/Sources/Web3Core/KeystoreManager/BIP39.swift @@ -74,12 +74,12 @@ public class BIP39 { /// - bitsOfEntropy: 128 - 12 words, 192 - 18 words, 256 - 24 words in output. /// - language: words language, default english /// - Returns: random 12-24 words, that represent new Mnemonic phrase. - static public func generateMnemonics(bitsOfEntropy: Int, language: BIP39Language = .english) throws -> String? { + public static func generateMnemonics(bitsOfEntropy: Int, language: BIP39Language = .english) throws -> String? { guard let entropy = entropyOf(size: bitsOfEntropy) else { throw AbstractKeystoreError.noEntropyError } return generateMnemonicsFromEntropy(entropy: entropy, language: language) } - static public func generateMnemonics(entropy: Int, language: BIP39Language = .english) -> [String]? { + public static func generateMnemonics(entropy: Int, language: BIP39Language = .english) -> [String]? { guard let entropy = entropyOf(size: entropy) else { return nil } return generateMnemonicsFrom(entropy: entropy, language: language) } @@ -108,14 +108,14 @@ public class BIP39 { return checksum } - static public func generateMnemonicsFromEntropy(entropy: Data, language: BIP39Language = .english) -> String? { + public static func generateMnemonicsFromEntropy(entropy: Data, language: BIP39Language = .english) -> String? { guard entropy.count >= 16, entropy.count & 4 == 0 else {return nil} let separator = language.separator let wordList = generateMnemonicsFrom(entropy: entropy) return wordList.joined(separator: separator) } - static public func generateMnemonicsFrom(entropy: Data, language: BIP39Language = .english) -> [String] { + public static func generateMnemonicsFrom(entropy: Data, language: BIP39Language = .english) -> [String] { let entropyBitSize = entropy.count * 8 let checksum_length = entropyBitSize / 32 @@ -135,12 +135,12 @@ public class BIP39 { } } - static public func mnemonicsToEntropy(_ mnemonics: String, language: BIP39Language = .english) -> Data? { + public static func mnemonicsToEntropy(_ mnemonics: String, language: BIP39Language = .english) -> Data? { let wordList = mnemonics.components(separatedBy: language.separator) return mnemonicsToEntropy(wordList, language: language) } - static public func mnemonicsToEntropy(_ mnemonics: [String], language: BIP39Language = .english) -> Data? { + public static func mnemonicsToEntropy(_ mnemonics: [String], language: BIP39Language = .english) -> Data? { guard mnemonics.count >= 12 && mnemonics.count.isMultiple(of: 3) && mnemonics.count <= 24 else {return nil} var bitString = "" for word in mnemonics { @@ -166,12 +166,12 @@ public class BIP39 { return entropy } - static public func seedFromMmemonics(_ mnemonics: [String], password: String = "", language: BIP39Language = .english) -> Data? { + public static func seedFromMmemonics(_ mnemonics: [String], password: String = "", language: BIP39Language = .english) -> Data? { let wordList = mnemonics.joined(separator: language.separator) return seedFromMmemonics(wordList, password: password, language: language) } - static public func seedFromMmemonics(_ mnemonics: String, password: String = "", language: BIP39Language = .english) -> Data? { + public static func seedFromMmemonics(_ mnemonics: String, password: String = "", language: BIP39Language = .english) -> Data? { if mnemonicsToEntropy(mnemonics, language: language) == nil { return nil } @@ -186,7 +186,7 @@ public class BIP39 { return Data(seedArray) } - static public func seedFromEntropy(_ entropy: Data, password: String = "", language: BIP39Language = .english) -> Data? { + public static func seedFromEntropy(_ entropy: Data, password: String = "", language: BIP39Language = .english) -> Data? { guard let mnemonics = generateMnemonicsFromEntropy(entropy: entropy, language: language) else { return nil } From 1861aa6656ac55d967b41f99c0e2b57961df563d Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 12 Mar 2023 20:05:42 +0200 Subject: [PATCH 178/210] chore: spacing update --- Sources/Web3Core/KeystoreManager/BIP39.swift | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP39.swift b/Sources/Web3Core/KeystoreManager/BIP39.swift index 690425d64..cefb6fff5 100755 --- a/Sources/Web3Core/KeystoreManager/BIP39.swift +++ b/Sources/Web3Core/KeystoreManager/BIP39.swift @@ -15,6 +15,7 @@ public enum BIP39Language { case french case italian case spanish + public var words: [String] { switch self { case .english: @@ -109,7 +110,7 @@ public class BIP39 { } public static func generateMnemonicsFromEntropy(entropy: Data, language: BIP39Language = .english) -> String? { - guard entropy.count >= 16, entropy.count & 4 == 0 else {return nil} + guard entropy.count >= 16, entropy.count & 4 == 0 else { return nil } let separator = language.separator let wordList = generateMnemonicsFrom(entropy: entropy) return wordList.joined(separator: separator) @@ -141,7 +142,7 @@ public class BIP39 { } public static func mnemonicsToEntropy(_ mnemonics: [String], language: BIP39Language = .english) -> Data? { - guard mnemonics.count >= 12 && mnemonics.count.isMultiple(of: 3) && mnemonics.count <= 24 else {return nil} + guard mnemonics.count >= 12 && mnemonics.count.isMultiple(of: 3) && mnemonics.count <= 24 else { return nil } var bitString = "" for word in mnemonics { guard let idx = language.words.firstIndex(of: word) else { @@ -179,10 +180,10 @@ public class BIP39 { } static private func dataFrom(mnemonics: String, password: String) -> Data? { - guard let mnemData = mnemonics.decomposedStringWithCompatibilityMapping.data(using: .utf8) else {return nil} + guard let mnemData = mnemonics.decomposedStringWithCompatibilityMapping.data(using: .utf8) else { return nil } let salt = "mnemonic" + password - guard let saltData = salt.decomposedStringWithCompatibilityMapping.data(using: .utf8) else {return nil} - guard let seedArray = try? PKCS5.PBKDF2(password: mnemData.bytes, salt: saltData.bytes, iterations: 2048, keyLength: 64, variant: HMAC.Variant.sha2(.sha512)).calculate() else {return nil} + guard let saltData = salt.decomposedStringWithCompatibilityMapping.data(using: .utf8) else { return nil } + guard let seedArray = try? PKCS5.PBKDF2(password: mnemData.bytes, salt: saltData.bytes, iterations: 2048, keyLength: 64, variant: HMAC.Variant.sha2(.sha512)).calculate() else { return nil } return Data(seedArray) } From d146895c0bb49c7a6a9330c7eb118e6c8d6b4987 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 12 Mar 2023 20:06:32 +0200 Subject: [PATCH 179/210] chore: removed redundant variable --- Sources/Web3Core/KeystoreManager/BIP39.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP39.swift b/Sources/Web3Core/KeystoreManager/BIP39.swift index cefb6fff5..d18ade8fc 100755 --- a/Sources/Web3Core/KeystoreManager/BIP39.swift +++ b/Sources/Web3Core/KeystoreManager/BIP39.swift @@ -105,8 +105,7 @@ public class BIP39 { guard let checksumData = inputData.sha256().bitsInRange(0, checksumLength) else { return nil } - let checksum = String(checksumData, radix: 2).leftPadding(toLength: checksumLength, withPad: "0") - return checksum + return String(checksumData, radix: 2).leftPadding(toLength: checksumLength, withPad: "0") } public static func generateMnemonicsFromEntropy(entropy: Data, language: BIP39Language = .english) -> String? { From 5014bc4c32de649d42af482dcfac030c5be5fe75 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 12 Mar 2023 20:32:37 +0200 Subject: [PATCH 180/210] chore: HDversion refactoring + documentation --- .../KeystoreManager/BIP32HDNode.swift | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift index 748b54a15..ab1d67295 100644 --- a/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32HDNode.swift @@ -24,20 +24,29 @@ extension UInt32 { public class HDNode { private static var maxIterationIndex = UInt32(1) << 31 + /// Contains private and public prefixes for serialization. + /// See [BIP-32's serialization format](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format) for more info. public struct HDversion { - // swiftlint:disable force_unwrapping - public var privatePrefix: Data = Data.fromHex("0x0488ADE4")! - public var publicPrefix: Data = Data.fromHex("0x0488B21E")! - // swiftlint:enable force_unwrapping - public init() {} - public static var privatePrefix: Data? { - HDversion().privatePrefix + /// Mainnet public key prefix. + /// Value `0x0488B21E` is a string `xpub` encoded as Base-58 and later as hexadecimal. + public static let publicPrefix: Data! = Data.fromHex("0x0488B21E") + + /// Mainnet private key prefix. + /// Value `0x0488ADE4` is a string `xprv` encoded as Base-58 and later as hexadecimal. + public static let privatePrefix: Data! = Data.fromHex("0x0488ADE4") + + public let publicPrefix: Data + public let privatePrefix: Data + + /// Default values for `publicPrefix` and `privatePrefix` are + /// `HDversion.publicPrefix` and `HDversion.privatePrefix` respectively. + public init(public publicPrefix: Data = HDversion.publicPrefix, + private privatePrefix: Data = HDversion.privatePrefix) { + self.publicPrefix = publicPrefix + self.privatePrefix = privatePrefix } - public static var publicPrefix: Data? { - HDversion().publicPrefix - } - } + public var path: String? = "m" public var privateKey: Data? public var publicKey: Data From 02c8992e4f3553ec61188fa0cb21cf642bb4a2e6 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 12 Mar 2023 20:35:49 +0200 Subject: [PATCH 181/210] chore: HDNode.HDversion test for prefixes --- .../localTests/HDversionTest.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Tests/web3swiftTests/localTests/HDversionTest.swift diff --git a/Tests/web3swiftTests/localTests/HDversionTest.swift b/Tests/web3swiftTests/localTests/HDversionTest.swift new file mode 100644 index 000000000..f3cef2070 --- /dev/null +++ b/Tests/web3swiftTests/localTests/HDversionTest.swift @@ -0,0 +1,18 @@ +// +// HDversionTest.swift +// +// Created by JeneaVranceanu on 12.03.2023. +// + +import Foundation +import XCTest +import Web3Core + +class HDversionTest: XCTestCase { + + func testPrefixesNotNil() { + XCTAssertNotNil(HDNode.HDversion.publicPrefix) + XCTAssertNotNil(HDNode.HDversion.privatePrefix) + } + +} From 3d2d91292c0e189ec8ab305de23de04ee1487fb4 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 12 Mar 2023 20:55:28 +0200 Subject: [PATCH 182/210] chore: docs update + func entropyOf now throws if entropy failed to be generated --- Sources/Web3Core/KeystoreManager/BIP39.swift | 35 +++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP39.swift b/Sources/Web3Core/KeystoreManager/BIP39.swift index d18ade8fc..3d8802fe4 100755 --- a/Sources/Web3Core/KeystoreManager/BIP39.swift +++ b/Sources/Web3Core/KeystoreManager/BIP39.swift @@ -70,27 +70,38 @@ public enum BIP39Language { } public class BIP39 { - /// Initializes a new mnemonics set with the provided bitsOfEntropy. + + /// Generates a mnemonic phrase length of which depends on the provided `bitsOfEntropy`. + /// Returned value is a single string where words are joined by ``BIP39Language/separator``. + /// Keep in mind that different languages may have different separators. /// - Parameters: /// - bitsOfEntropy: 128 - 12 words, 192 - 18 words, 256 - 24 words in output. - /// - language: words language, default english - /// - Returns: random 12-24 words, that represent new Mnemonic phrase. + /// - language: words language, default is set to english. + /// - Returns: mnemonic phrase as a single string containing 12, 15, 18, 21 or 24 words. public static func generateMnemonics(bitsOfEntropy: Int, language: BIP39Language = .english) throws -> String? { - guard let entropy = entropyOf(size: bitsOfEntropy) else { throw AbstractKeystoreError.noEntropyError } + let entropy = try entropyOf(size: bitsOfEntropy) return generateMnemonicsFromEntropy(entropy: entropy, language: language) } - public static func generateMnemonics(entropy: Int, language: BIP39Language = .english) -> [String]? { - guard let entropy = entropyOf(size: entropy) else { return nil } + /// Generates a mnemonic phrase length of which depends on the provided `entropy`. + /// - Parameters: + /// - entropy: 128 - 12 words, 192 - 18 words, 256 - 24 words in output. + /// - language: words language, default is set to english. + /// - Returns: mnemonic phrase as an array containing 12, 15, 18, 21 or 24 words. + /// `nil` is returned in cases like wrong `entropy` value (e.g. `entropy` is not a multiple of 32). + public static func generateMnemonics(entropy: Int, language: BIP39Language = .english) throws -> [String] { + let entropy = try entropyOf(size: entropy) return generateMnemonicsFrom(entropy: entropy, language: language) } - static private func entropyOf(size: Int) -> Data? { - guard size >= 128 && size <= 256 && size.isMultiple(of: 32) else { - return nil + private static func entropyOf(size: Int) throws -> Data { + guard + size >= 128 && size <= 256 && size.isMultiple(of: 32), + let entropy = Data.randomBytes(length: size/8) + else { + throw AbstractKeystoreError.noEntropyError } - - return Data.randomBytes(length: size/8) + return entropy } static func bitarray(from data: Data) -> String { @@ -178,7 +189,7 @@ public class BIP39 { return dataFrom(mnemonics: mnemonics, password: password) } - static private func dataFrom(mnemonics: String, password: String) -> Data? { + private static func dataFrom(mnemonics: String, password: String) -> Data? { guard let mnemData = mnemonics.decomposedStringWithCompatibilityMapping.data(using: .utf8) else { return nil } let salt = "mnemonic" + password guard let saltData = salt.decomposedStringWithCompatibilityMapping.data(using: .utf8) else { return nil } From 62cd2410992e2c6284c50c3c192ee3509ce2869e Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 12 Mar 2023 20:55:45 +0200 Subject: [PATCH 183/210] chore: a couple of new tests for BIP39.generateMnemonics --- .../localTests/BIP39Tests.swift | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Tests/web3swiftTests/localTests/BIP39Tests.swift b/Tests/web3swiftTests/localTests/BIP39Tests.swift index 0c19353d4..f9006622b 100644 --- a/Tests/web3swiftTests/localTests/BIP39Tests.swift +++ b/Tests/web3swiftTests/localTests/BIP39Tests.swift @@ -11,7 +11,7 @@ import XCTest final class BIP39Tests: XCTestCase { - func testBIP39 () throws { + func testBIP39() throws { var entropy = Data.fromHex("00000000000000000000000000000000")! var phrase = BIP39.generateMnemonicsFromEntropy(entropy: entropy) XCTAssert( phrase == "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about") @@ -139,16 +139,31 @@ final class BIP39Tests: XCTestCase { } func testNewBIP32keystoreArray() throws { - let mnemonic = BIP39.generateMnemonics(entropy: 256)! + let mnemonic = try BIP39.generateMnemonics(entropy: 256) let keystore = try BIP32Keystore(mnemonicsPhrase: mnemonic, password: "", mnemonicsPassword: "") XCTAssert(keystore != nil) } func testSameAddressesFromTheSameMnemonicsArray() throws { - let mnemonic = BIP39.generateMnemonics(entropy: 256)! + let mnemonic = try BIP39.generateMnemonics(entropy: 256) let keystore1 = try BIP32Keystore(mnemonicsPhrase: mnemonic, password: "", mnemonicsPassword: "") let keystore2 = try BIP32Keystore(mnemonicsPhrase: mnemonic, password: "", mnemonicsPassword: "") XCTAssert(keystore1?.addresses?.first == keystore2?.addresses?.first) } + func testWrongBitsOfEntropyMustThrow() throws { + XCTAssertThrowsError(try BIP39.generateMnemonics(entropy: 127)) + XCTAssertThrowsError(try BIP39.generateMnemonics(entropy: 255)) + XCTAssertThrowsError(try BIP39.generateMnemonics(entropy: 32)) + XCTAssertThrowsError(try BIP39.generateMnemonics(entropy: 288)) + } + + func testCorrectBitsOfEntropy() throws { + XCTAssertFalse(try BIP39.generateMnemonics(entropy: 128).isEmpty) + XCTAssertFalse(try BIP39.generateMnemonics(entropy: 160).isEmpty) + XCTAssertFalse(try BIP39.generateMnemonics(entropy: 192).isEmpty) + XCTAssertFalse(try BIP39.generateMnemonics(entropy: 224).isEmpty) + XCTAssertFalse(try BIP39.generateMnemonics(entropy: 256).isEmpty) + } + } From 7c0b51c81d76b193cfab890ab595090671decf0e Mon Sep 17 00:00:00 2001 From: JD Date: Mon, 13 Mar 2023 11:17:46 +0100 Subject: [PATCH 184/210] Add remote test --- .../TransactionPollingTaskRemoteTest.swift | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Tests/web3swiftTests/remoteTests/TransactionPollingTaskRemoteTest.swift diff --git a/Tests/web3swiftTests/remoteTests/TransactionPollingTaskRemoteTest.swift b/Tests/web3swiftTests/remoteTests/TransactionPollingTaskRemoteTest.swift new file mode 100644 index 000000000..5c4cb44ce --- /dev/null +++ b/Tests/web3swiftTests/remoteTests/TransactionPollingTaskRemoteTest.swift @@ -0,0 +1,25 @@ +// +// TransactionPollingTaskRemoteTest.swift +// +// +// Created by Jann Driessen on 13.03.23. +// + +import XCTest + +@testable import web3swift +@testable import Web3Core + +final class TransactionPollingTaskRemoteTest: XCTestCase { + + func testTransactionPolling() async throws { + let web3 = try await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken) + let txHash = Data.fromHex("0xb37cab767de85e734821f4b7b46f5093126658322a3f1b10bfef82b8009c8b82")! + let transactionReceipt = try await TransactionPollingTask(transactionHash: txHash, web3Instance: web3).wait() + XCTAssertEqual(transactionReceipt.status, .ok) + XCTAssertEqual(transactionReceipt.blockHash, Data.fromHex("0xdac48e6612d3c5b21c0e4b8edd9d25687a97137c636ff57a8df9f1f01bdfd25d")) + XCTAssertEqual(transactionReceipt.blockNumber, 16818367) + XCTAssertEqual(transactionReceipt.gasUsed, "21000") + } + +} From e33de2e78aa8d2316dc11a27b039a51732908c53 Mon Sep 17 00:00:00 2001 From: 6od9i <6od911@gmail.com> Date: Wed, 15 Mar 2023 10:43:59 +0400 Subject: [PATCH 185/210] - ABIDecoding getting data slice in followTheData changed to using start data index --- Sources/Web3Core/EthereumABI/ABIDecoding.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Web3Core/EthereumABI/ABIDecoding.swift b/Sources/Web3Core/EthereumABI/ABIDecoding.swift index cb220fec6..aface0d84 100755 --- a/Sources/Web3Core/EthereumABI/ABIDecoding.swift +++ b/Sources/Web3Core/EthereumABI/ABIDecoding.swift @@ -188,12 +188,12 @@ extension ABIDecoder { fileprivate static func followTheData(type: ABI.Element.ParameterType, data: Data, pointer: UInt64 = 0) -> (elementEncoding: Data?, nextElementPointer: UInt64?) { if type.isStatic { guard data.count >= pointer + type.memoryUsage else {return (nil, nil)} - let elementItself = data[pointer ..< pointer + type.memoryUsage] + let elementItself = data[data.indices.startIndex + Int(pointer) ..< data.indices.startIndex + Int(pointer + type.memoryUsage)] let nextElement = pointer + type.memoryUsage return (Data(elementItself), nextElement) } else { guard data.count >= pointer + type.memoryUsage else {return (nil, nil)} - let dataSlice = data[pointer ..< pointer + type.memoryUsage] + let dataSlice = data[data.indices.startIndex + Int(pointer) ..< data.indices.startIndex + Int(pointer + type.memoryUsage)] let bn = BigUInt(dataSlice) if bn > UInt64.max || bn >= data.count { // there are ERC20 contracts that use bytes32 instead of string. Let's be optimistic and return some data From e37bdca685013d61bfcd0d16a0b4c0d0073ba9f1 Mon Sep 17 00:00:00 2001 From: 6od9i <6od911@gmail.com> Date: Wed, 15 Mar 2023 18:19:56 +0400 Subject: [PATCH 186/210] - Safe getting bounds from data slices in decoding added --- Sources/Web3Core/Contract/ContractProtocol.swift | 10 +++++----- Sources/Web3Core/EthereumABI/ABIElements.swift | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Sources/Web3Core/Contract/ContractProtocol.swift b/Sources/Web3Core/Contract/ContractProtocol.swift index 06e3c01a7..b64d8c3da 100755 --- a/Sources/Web3Core/Contract/ContractProtocol.swift +++ b/Sources/Web3Core/Contract/ContractProtocol.swift @@ -210,8 +210,8 @@ extension ContractProtocol { func decodeInputData(_ data: Data) -> [String: Any]? { guard data.count >= 4 else { return nil } - let methodId = data[0..<4].toHexString() - let data = data[4...] + let methodId = data[data.indices.startIndex.. [String: Any]? { guard data.count % 32 == 4 else { return nil } - let methodSignature = data[0..<4].toHexString().addHexPrefix().lowercased() + let methodSignature = data[data.indices.startIndex .. ABI.Element.Function? { guard data.count >= 4 else { return nil } - return methods[data[0..<4].toHexString().addHexPrefix()]?.first + return methods[data[data.indices.startIndex..= 100, - Data(data[0..<4]) == Data.fromHex("08C379A0"), - BigInt(data[4..<36]) == 32, - let messageLength = Int(Data(data[36..<68]).toHexString(), radix: 16), + Data(data[data.indices.startIndex..= 4, let errors = errors, - let customError = errors[data[0..<4].toHexString().stripHexPrefix()] { + let customError = errors[data[data.indices.startIndex + 0.. 32 && !customError.inputs.isEmpty), - let decodedInputs = ABIDecoder.decode(types: customError.inputs, data: Data(data[4.. Date: Wed, 15 Mar 2023 18:24:47 +0400 Subject: [PATCH 187/210] - boundses in data fixed --- Sources/Web3Core/EthereumABI/ABIElements.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/Web3Core/EthereumABI/ABIElements.swift b/Sources/Web3Core/EthereumABI/ABIElements.swift index 0f09a6fa7..0ceec904f 100755 --- a/Sources/Web3Core/EthereumABI/ABIElements.swift +++ b/Sources/Web3Core/EthereumABI/ABIElements.swift @@ -397,9 +397,9 @@ extension ABI.Element.Function { /// 4) `messageLength` is used to determine where message bytes end to decode string correctly. /// 5) The rest of the `data` must be 0 bytes or empty. if data.bytes.count >= 100, - Data(data[data.indices.startIndex..= 4, let errors = errors, - let customError = errors[data[data.indices.startIndex + 0.. 32 && !customError.inputs.isEmpty), - let decodedInputs = ABIDecoder.decode(types: customError.inputs, data: Data(data[data.indices.startIndex + 4.. Date: Wed, 15 Mar 2023 18:26:57 +0400 Subject: [PATCH 188/210] - boundses in contract protocol fixed --- Sources/Web3Core/Contract/ContractProtocol.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Web3Core/Contract/ContractProtocol.swift b/Sources/Web3Core/Contract/ContractProtocol.swift index b64d8c3da..42f54504b 100755 --- a/Sources/Web3Core/Contract/ContractProtocol.swift +++ b/Sources/Web3Core/Contract/ContractProtocol.swift @@ -210,8 +210,8 @@ extension ContractProtocol { func decodeInputData(_ data: Data) -> [String: Any]? { guard data.count >= 4 else { return nil } - let methodId = data[data.indices.startIndex.. [String: Any]? { guard data.count % 32 == 4 else { return nil } - let methodSignature = data[data.indices.startIndex .. ABI.Element.Function? { guard data.count >= 4 else { return nil } - return methods[data[data.indices.startIndex.. Date: Thu, 16 Mar 2023 18:44:05 +0800 Subject: [PATCH 189/210] return a new instance of Data in decodeSingleType --- Sources/Web3Core/EthereumABI/ABIDecoding.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Web3Core/EthereumABI/ABIDecoding.swift b/Sources/Web3Core/EthereumABI/ABIDecoding.swift index cb220fec6..e5984c81a 100755 --- a/Sources/Web3Core/EthereumABI/ABIDecoding.swift +++ b/Sources/Web3Core/EthereumABI/ABIDecoding.swift @@ -70,7 +70,7 @@ extension ABIDecoder { case .bytes(let length): guard elementItself.count >= 32 else {break} let dataSlice = elementItself[0 ..< length] - return (dataSlice, type.memoryUsage) + return (Data(dataSlice), type.memoryUsage) case .string: guard elementItself.count >= 32 else {break} var dataSlice = elementItself[0 ..< 32] @@ -85,7 +85,7 @@ extension ABIDecoder { let length = UInt64(BigUInt(dataSlice)) guard elementItself.count >= 32+length else {break} dataSlice = elementItself[32 ..< 32 + length] - return (dataSlice, nextElementPointer) + return (Data(dataSlice), nextElementPointer) case .array(type: let subType, length: let length): switch type.arraySize { case .dynamicSize: From 93af1e8fb90ededecc798fca8c1f46116d9e3720 Mon Sep 17 00:00:00 2001 From: august Date: Thu, 16 Mar 2023 19:40:00 +0800 Subject: [PATCH 190/210] add decode multicall test --- .../localTests/ABIDecoderTests.swift | 370 ++++++++++++++++++ 1 file changed, 370 insertions(+) create mode 100644 Tests/web3swiftTests/localTests/ABIDecoderTests.swift diff --git a/Tests/web3swiftTests/localTests/ABIDecoderTests.swift b/Tests/web3swiftTests/localTests/ABIDecoderTests.swift new file mode 100644 index 000000000..9c563f018 --- /dev/null +++ b/Tests/web3swiftTests/localTests/ABIDecoderTests.swift @@ -0,0 +1,370 @@ +// +// ABIDecoderTests.swift +// +// +// Created by liugang zhang on 2023/3/16. +// + +import Foundation +import Web3Core +import XCTest +import BigInt +@testable import web3swift + +final class ABIDecoderTests: XCTestCase { + + func testDecodeMulticall() throws { + // get result from http + // + // let requests = tokenAddress.map { address -> AnyObject in + // let callData = erc20_balanceof.encodeParameters([account as NSString]) + // return [address, callData as Any] as AnyObject + // } as AnyObject + // + // let read = contract.createReadOperation( + // "tryAggregate", + // parameters: [false, requests] as [AnyObject] + // ) + // let results = try await read?.callContractMethod() + + let data = Data(hex: "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000004fe6dab4abca350650") + let contract = try EthereumContract(Self.multiCall2, at: nil) + let erc20_balanceof = try EthereumContract(Web3.Utils.erc20ABI).methods["balanceOf"]!.first! + guard let decodedData = contract.decodeReturnData("tryAggregate", data: data) else { + throw Web3Error.processingError(desc: "Can not decode returned parameters") + } + + guard let returnData = decodedData["returnData"] as? Array> else { + throw Web3Error.dataError + } + var resultArray = [BigUInt]() + for i in 0..<2 { + guard let data = returnData[i][1] as? Data, + let balance = erc20_balanceof.decodeReturnData(data)["0"] as? BigUInt else { + resultArray.append(0) + continue + } + resultArray.append(balance) + } + print(resultArray) + XCTAssert(resultArray.count == 2) + } + + public static let multiCall2 = """ + [ + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall2.Call[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "aggregate", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "bytes[]", + "name": "returnData", + "type": "bytes[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall2.Call[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "blockAndAggregate", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall2.Result[]", + "name": "returnData", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getBlockHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumber", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockCoinbase", + "outputs": [ + { + "internalType": "address", + "name": "coinbase", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockDifficulty", + "outputs": [ + { + "internalType": "uint256", + "name": "difficulty", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockGasLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "gaslimit", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "getEthBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLastBlockHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "requireSuccess", + "type": "bool" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall2.Call[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "tryAggregate", + "outputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall2.Result[]", + "name": "returnData", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "requireSuccess", + "type": "bool" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall2.Call[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "tryBlockAndAggregate", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall2.Result[]", + "name": "returnData", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ] + """ +} From 15ea9690d25ae862888454e4aa62a68ac73c184f Mon Sep 17 00:00:00 2001 From: august Date: Thu, 16 Mar 2023 20:07:05 +0800 Subject: [PATCH 191/210] fix lint --- Tests/web3swiftTests/localTests/ABIDecoderTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/web3swiftTests/localTests/ABIDecoderTests.swift b/Tests/web3swiftTests/localTests/ABIDecoderTests.swift index 9c563f018..cd565c9a9 100644 --- a/Tests/web3swiftTests/localTests/ABIDecoderTests.swift +++ b/Tests/web3swiftTests/localTests/ABIDecoderTests.swift @@ -34,7 +34,7 @@ final class ABIDecoderTests: XCTestCase { throw Web3Error.processingError(desc: "Can not decode returned parameters") } - guard let returnData = decodedData["returnData"] as? Array> else { + guard let returnData = decodedData["returnData"] as? [[Any]] else { throw Web3Error.dataError } var resultArray = [BigUInt]() From a6eb0c32f50618251ab04972711681db17bb7de5 Mon Sep 17 00:00:00 2001 From: august Date: Thu, 16 Mar 2023 20:37:37 +0800 Subject: [PATCH 192/210] minify multicall contract string --- .../localTests/ABIDecoderTests.swift | 320 +----------------- 1 file changed, 2 insertions(+), 318 deletions(-) diff --git a/Tests/web3swiftTests/localTests/ABIDecoderTests.swift b/Tests/web3swiftTests/localTests/ABIDecoderTests.swift index cd565c9a9..278e976d8 100644 --- a/Tests/web3swiftTests/localTests/ABIDecoderTests.swift +++ b/Tests/web3swiftTests/localTests/ABIDecoderTests.swift @@ -1,6 +1,6 @@ // // ABIDecoderTests.swift -// +// // // Created by liugang zhang on 2023/3/16. // @@ -50,321 +50,5 @@ final class ABIDecoderTests: XCTestCase { XCTAssert(resultArray.count == 2) } - public static let multiCall2 = """ - [ - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "bytes", - "name": "callData", - "type": "bytes" - } - ], - "internalType": "struct Multicall2.Call[]", - "name": "calls", - "type": "tuple[]" - } - ], - "name": "aggregate", - "outputs": [ - { - "internalType": "uint256", - "name": "blockNumber", - "type": "uint256" - }, - { - "internalType": "bytes[]", - "name": "returnData", - "type": "bytes[]" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "bytes", - "name": "callData", - "type": "bytes" - } - ], - "internalType": "struct Multicall2.Call[]", - "name": "calls", - "type": "tuple[]" - } - ], - "name": "blockAndAggregate", - "outputs": [ - { - "internalType": "uint256", - "name": "blockNumber", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - }, - { - "components": [ - { - "internalType": "bool", - "name": "success", - "type": "bool" - }, - { - "internalType": "bytes", - "name": "returnData", - "type": "bytes" - } - ], - "internalType": "struct Multicall2.Result[]", - "name": "returnData", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "blockNumber", - "type": "uint256" - } - ], - "name": "getBlockHash", - "outputs": [ - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getBlockNumber", - "outputs": [ - { - "internalType": "uint256", - "name": "blockNumber", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockCoinbase", - "outputs": [ - { - "internalType": "address", - "name": "coinbase", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockDifficulty", - "outputs": [ - { - "internalType": "uint256", - "name": "difficulty", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockGasLimit", - "outputs": [ - { - "internalType": "uint256", - "name": "gaslimit", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockTimestamp", - "outputs": [ - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "getEthBalance", - "outputs": [ - { - "internalType": "uint256", - "name": "balance", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getLastBlockHash", - "outputs": [ - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "requireSuccess", - "type": "bool" - }, - { - "components": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "bytes", - "name": "callData", - "type": "bytes" - } - ], - "internalType": "struct Multicall2.Call[]", - "name": "calls", - "type": "tuple[]" - } - ], - "name": "tryAggregate", - "outputs": [ - { - "components": [ - { - "internalType": "bool", - "name": "success", - "type": "bool" - }, - { - "internalType": "bytes", - "name": "returnData", - "type": "bytes" - } - ], - "internalType": "struct Multicall2.Result[]", - "name": "returnData", - "type": "tuple[]" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "requireSuccess", - "type": "bool" - }, - { - "components": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "bytes", - "name": "callData", - "type": "bytes" - } - ], - "internalType": "struct Multicall2.Call[]", - "name": "calls", - "type": "tuple[]" - } - ], - "name": "tryBlockAndAggregate", - "outputs": [ - { - "internalType": "uint256", - "name": "blockNumber", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - }, - { - "components": [ - { - "internalType": "bool", - "name": "success", - "type": "bool" - }, - { - "internalType": "bytes", - "name": "returnData", - "type": "bytes" - } - ], - "internalType": "struct Multicall2.Result[]", - "name": "returnData", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } - ] - """ + public static let multiCall2 = "[{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"aggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes[]\",\"name\":\"returnData\",\"type\":\"bytes[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"blockAndAggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBlockNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockCoinbase\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"coinbase\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"difficulty\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockGasLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"gaslimit\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getEthBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLastBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"requireSuccess\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"tryAggregate\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"requireSuccess\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"tryBlockAndAggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" } From f909a0085279c83e02577172f4da09931e758238 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Fri, 24 Mar 2023 11:43:30 +0200 Subject: [PATCH 193/210] chore: docs instead of a comment --- Tests/web3swiftTests/localTests/BIP39Tests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/web3swiftTests/localTests/BIP39Tests.swift b/Tests/web3swiftTests/localTests/BIP39Tests.swift index f9006622b..15e89968d 100644 --- a/Tests/web3swiftTests/localTests/BIP39Tests.swift +++ b/Tests/web3swiftTests/localTests/BIP39Tests.swift @@ -31,7 +31,7 @@ final class BIP39Tests: XCTestCase { XCTAssert(seed == recoveredSeed) } -// https://github.com/trezor/python-mnemonic/blob/master/vectors.json + /// Test cases were borrowed from https://github.com/trezor/python-mnemonic/blob/master/vectors.json func testBIP39MnemonicIsMultipleOfThree() { // https://github.com/trezor/python-mnemonic/blob/master/vectors.json#L95 let mnemonic_12 = "scheme spot photo card baby mountain device kick cradle pact join borrow" @@ -80,7 +80,7 @@ final class BIP39Tests: XCTestCase { let keystore2 = try BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "") XCTAssert(keystore1?.addresses?.first == keystore2?.addresses?.first) } - //==================================================================== + func testBIP39Array () throws { var entropy = Data.fromHex("00000000000000000000000000000000")! var phrase = BIP39.generateMnemonicsFrom(entropy: entropy) From b773e164aba4de71c676b1ed061299f033c3557f Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Fri, 24 Mar 2023 11:44:34 +0200 Subject: [PATCH 194/210] chore: docs instead of a comment --- Tests/web3swiftTests/localTests/BIP39Tests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/web3swiftTests/localTests/BIP39Tests.swift b/Tests/web3swiftTests/localTests/BIP39Tests.swift index 15e89968d..e97c3f71c 100644 --- a/Tests/web3swiftTests/localTests/BIP39Tests.swift +++ b/Tests/web3swiftTests/localTests/BIP39Tests.swift @@ -101,7 +101,7 @@ final class BIP39Tests: XCTestCase { XCTAssert(seed == recoveredSeed) } -// https://github.com/trezor/python-mnemonic/blob/master/vectors.json + /// Test cases were borrowed from https://github.com/trezor/python-mnemonic/blob/master/vectors.json func testBIP39MnemonicIsMultipleOfThreeArray() { // https://github.com/trezor/python-mnemonic/blob/master/vectors.json#L95 let mnemonic_12 = ["scheme", "spot", "photo", "card", "baby", "mountain", "device", "kick", "cradle", "pact", "join", "borrow"] From 81e1c5116f933e72c04adc8dd6aedc128b0b73a9 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Fri, 24 Mar 2023 11:46:38 +0200 Subject: [PATCH 195/210] chore: spacing fix --- Tests/web3swiftTests/localTests/BIP39Tests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/web3swiftTests/localTests/BIP39Tests.swift b/Tests/web3swiftTests/localTests/BIP39Tests.swift index e97c3f71c..e9ccf6410 100644 --- a/Tests/web3swiftTests/localTests/BIP39Tests.swift +++ b/Tests/web3swiftTests/localTests/BIP39Tests.swift @@ -81,7 +81,7 @@ final class BIP39Tests: XCTestCase { XCTAssert(keystore1?.addresses?.first == keystore2?.addresses?.first) } - func testBIP39Array () throws { + func testBIP39Array() throws { var entropy = Data.fromHex("00000000000000000000000000000000")! var phrase = BIP39.generateMnemonicsFrom(entropy: entropy) XCTAssert( phrase == ["abandon", "abandon", "abandon", "abandon", "abandon", "abandon", "abandon", "abandon", "abandon", "abandon", "abandon", "about"]) From 83b4f64ffddbb4d14251b74cd09568e0e8049770 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Fri, 24 Mar 2023 11:50:46 +0200 Subject: [PATCH 196/210] chore: added docs to test suite --- Tests/web3swiftTests/localTests/BIP39StringTests.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/web3swiftTests/localTests/BIP39StringTests.swift b/Tests/web3swiftTests/localTests/BIP39StringTests.swift index d67fca812..ab94f6e5a 100644 --- a/Tests/web3swiftTests/localTests/BIP39StringTests.swift +++ b/Tests/web3swiftTests/localTests/BIP39StringTests.swift @@ -9,7 +9,8 @@ import XCTest @testable import Web3Core @testable import web3swift - +/// This test suite is focused on testing the ability of `BIP32Keystore` +/// to be able to parse and work with mnemonic phrase that is of type `String`. final class BIP39StringTests: XCTestCase { let mnemonic = "fruit wave dwarf banana earth journey tattoo true farm silk olive fence" From 02846e29c5e49d6f37561aa7a0c0c98587a89534 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Fri, 24 Mar 2023 11:55:41 +0200 Subject: [PATCH 197/210] chore: docs for BIP39ArrayTests + renamed file --- ...ests.swift => BIP32MnemonicPhraseStringArrayTests.swift} | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) rename Tests/web3swiftTests/localTests/{BIP39ArrayTests.swift => BIP32MnemonicPhraseStringArrayTests.swift} (94%) diff --git a/Tests/web3swiftTests/localTests/BIP39ArrayTests.swift b/Tests/web3swiftTests/localTests/BIP32MnemonicPhraseStringArrayTests.swift similarity index 94% rename from Tests/web3swiftTests/localTests/BIP39ArrayTests.swift rename to Tests/web3swiftTests/localTests/BIP32MnemonicPhraseStringArrayTests.swift index c8b4b66be..39bf6ff7f 100644 --- a/Tests/web3swiftTests/localTests/BIP39ArrayTests.swift +++ b/Tests/web3swiftTests/localTests/BIP32MnemonicPhraseStringArrayTests.swift @@ -1,5 +1,5 @@ // -// BIP39ArrayTests.swift +// BIP32MnemonicPhraseStringArrayTests.swift // // // Created by Daniel Bell on 11/26/22. @@ -9,7 +9,9 @@ import XCTest @testable import Web3Core @testable import web3swift -final class BIP39ArrayTests: XCTestCase { +/// This test suite is focused on testing the ability of `BIP32Keystore` +/// to be able to parse and work with mnemonic phrase that is of type `[String]`. +final class BIP32MnemonicPhraseStringArrayTests: XCTestCase { let mnemonic = ["fruit", "wave", "dwarf", "banana", "earth", "journey", "tattoo", "true", "farm", "silk", "olive", "fence"] From 3788524810b991a078fb2cf3c1530ac1c2a7617d Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Fri, 24 Mar 2023 11:56:58 +0200 Subject: [PATCH 198/210] chore: renamed BIP39StringTests -> BIP32MnemonicPhraseStringTests --- ...StringTests.swift => BIP32MnemonicPhraseStringTests.swift} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename Tests/web3swiftTests/localTests/{BIP39StringTests.swift => BIP32MnemonicPhraseStringTests.swift} (97%) diff --git a/Tests/web3swiftTests/localTests/BIP39StringTests.swift b/Tests/web3swiftTests/localTests/BIP32MnemonicPhraseStringTests.swift similarity index 97% rename from Tests/web3swiftTests/localTests/BIP39StringTests.swift rename to Tests/web3swiftTests/localTests/BIP32MnemonicPhraseStringTests.swift index ab94f6e5a..d08accd03 100644 --- a/Tests/web3swiftTests/localTests/BIP39StringTests.swift +++ b/Tests/web3swiftTests/localTests/BIP32MnemonicPhraseStringTests.swift @@ -1,5 +1,5 @@ // -// BIP39StringTests.swift +// BIP32MnemonicPhraseStringTests.swift // // // Created by Daniel Bell on 11/26/22. @@ -11,7 +11,7 @@ import XCTest /// This test suite is focused on testing the ability of `BIP32Keystore` /// to be able to parse and work with mnemonic phrase that is of type `String`. -final class BIP39StringTests: XCTestCase { +final class BIP32MnemonicPhraseStringTests: XCTestCase { let mnemonic = "fruit wave dwarf banana earth journey tattoo true farm silk olive fence" From b5156903182914169f5f2d45937bf59abab8457e Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Fri, 24 Mar 2023 11:59:26 +0200 Subject: [PATCH 199/210] chore: checking mnemonics.count with range ~= --- Sources/Web3Core/KeystoreManager/BIP39.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP39.swift b/Sources/Web3Core/KeystoreManager/BIP39.swift index 3d8802fe4..fc1eeccd6 100755 --- a/Sources/Web3Core/KeystoreManager/BIP39.swift +++ b/Sources/Web3Core/KeystoreManager/BIP39.swift @@ -152,7 +152,7 @@ public class BIP39 { } public static func mnemonicsToEntropy(_ mnemonics: [String], language: BIP39Language = .english) -> Data? { - guard mnemonics.count >= 12 && mnemonics.count.isMultiple(of: 3) && mnemonics.count <= 24 else { return nil } + guard 12...24 ~= mnemonics.count && mnemonics.count.isMultiple(of: 3) else { return nil } var bitString = "" for word in mnemonics { guard let idx = language.words.firstIndex(of: word) else { From e23a33efc6953bbccf4cdf0efc4527a723e28b9a Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Fri, 24 Mar 2023 12:01:25 +0200 Subject: [PATCH 200/210] chore: replaced if with guard --- Sources/Web3Core/KeystoreManager/BIP39.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP39.swift b/Sources/Web3Core/KeystoreManager/BIP39.swift index fc1eeccd6..1113b4bb2 100755 --- a/Sources/Web3Core/KeystoreManager/BIP39.swift +++ b/Sources/Web3Core/KeystoreManager/BIP39.swift @@ -183,7 +183,7 @@ public class BIP39 { } public static func seedFromMmemonics(_ mnemonics: String, password: String = "", language: BIP39Language = .english) -> Data? { - if mnemonicsToEntropy(mnemonics, language: language) == nil { + guard mnemonicsToEntropy(mnemonics, language: language) != nil else { return nil } return dataFrom(mnemonics: mnemonics, password: password) From 9683e3e7f2860a56304f5aa77366a74b6ca9a4cb Mon Sep 17 00:00:00 2001 From: august Date: Fri, 24 Mar 2023 18:49:11 +0800 Subject: [PATCH 201/210] remove comments --- .../localTests/ABIDecoderTests.swift | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/Tests/web3swiftTests/localTests/ABIDecoderTests.swift b/Tests/web3swiftTests/localTests/ABIDecoderTests.swift index 278e976d8..1d4ae0524 100644 --- a/Tests/web3swiftTests/localTests/ABIDecoderTests.swift +++ b/Tests/web3swiftTests/localTests/ABIDecoderTests.swift @@ -14,19 +14,6 @@ import BigInt final class ABIDecoderTests: XCTestCase { func testDecodeMulticall() throws { - // get result from http - // - // let requests = tokenAddress.map { address -> AnyObject in - // let callData = erc20_balanceof.encodeParameters([account as NSString]) - // return [address, callData as Any] as AnyObject - // } as AnyObject - // - // let read = contract.createReadOperation( - // "tryAggregate", - // parameters: [false, requests] as [AnyObject] - // ) - // let results = try await read?.callContractMethod() - let data = Data(hex: "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000004fe6dab4abca350650") let contract = try EthereumContract(Self.multiCall2, at: nil) let erc20_balanceof = try EthereumContract(Web3.Utils.erc20ABI).methods["balanceOf"]!.first! @@ -46,9 +33,10 @@ final class ABIDecoderTests: XCTestCase { } resultArray.append(balance) } - print(resultArray) XCTAssert(resultArray.count == 2) } +} +extension ABIDecoderTests { public static let multiCall2 = "[{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"aggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes[]\",\"name\":\"returnData\",\"type\":\"bytes[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"blockAndAggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBlockNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockCoinbase\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"coinbase\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"difficulty\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockGasLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"gaslimit\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getEthBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLastBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"requireSuccess\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"tryAggregate\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"requireSuccess\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"tryBlockAndAggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" } From 3b28de62b5486086d298c1cb60c2da1b7350f36c Mon Sep 17 00:00:00 2001 From: 6od9i <6od911@gmail.com> Date: Fri, 24 Mar 2023 16:32:01 +0400 Subject: [PATCH 202/210] - Test slices decoding added - PR fixed --- .../Web3Core/EthereumABI/ABIElements.swift | 2 +- .../localTests/ABIDecoderSliceTests.swift | 103 ++++++++++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 Tests/web3swiftTests/localTests/ABIDecoderSliceTests.swift diff --git a/Sources/Web3Core/EthereumABI/ABIElements.swift b/Sources/Web3Core/EthereumABI/ABIElements.swift index 0ceec904f..d2c7ab9b6 100755 --- a/Sources/Web3Core/EthereumABI/ABIElements.swift +++ b/Sources/Web3Core/EthereumABI/ABIElements.swift @@ -410,7 +410,7 @@ extension ABI.Element.Function { if data.count >= 4, let errors = errors, - let customError = errors[data[data.indices.startIndex + 0 ..< data.indices.startIndex + 4].toHexString().stripHexPrefix()] { + let customError = errors[data[data.indices.startIndex ..< data.indices.startIndex + 4].toHexString().stripHexPrefix()] { var errorResponse: [String: Any] = ["_success": false, "_abortedByRevertOrRequire": true, "_error": customError.errorDeclaration] if (data.count > 32 && !customError.inputs.isEmpty), diff --git a/Tests/web3swiftTests/localTests/ABIDecoderSliceTests.swift b/Tests/web3swiftTests/localTests/ABIDecoderSliceTests.swift new file mode 100644 index 000000000..a3fbeb43c --- /dev/null +++ b/Tests/web3swiftTests/localTests/ABIDecoderSliceTests.swift @@ -0,0 +1,103 @@ +// +// ABIDecoderSliceTests.swift +// localTests +// +// Created by 6od9i on 24.03.2023. +// + +import Foundation +import Web3Core +import XCTest +import BigInt +@testable import web3swift + +final class ABIDecoderSliceTests: XCTestCase { + func testBallancesDataSlice() throws { + /// Arrange + let balanceofMethod = try EthereumContract(Web3.Utils.erc20ABI).methods["balanceOf"]!.first! + let correctValues = ["13667129429770787859", "3298264", "47475", "19959", "607690442193821", "999170411478050086"] + let hex6Responses = + "000000000000000000000000000000000000000000000000bdab65ce08c65c1300000000000000000000000000000000000000000000000000000000003253d8000000000000000000000000000000000000000000000000000000000000b9730000000000000000000000000000000000000000000000000000000000004df7000000000000000000000000000000000000000000000000000228b0f4f0bb9d0000000000000000000000000000000000000000000000000dddc432063ae526" + let data = Data(hex: hex6Responses) + let answerSize = 32 + var startIndex = 0 + var results = [String]() + + /// Act + while startIndex < data.count { + let slice = data[startIndex ..< startIndex + answerSize] + startIndex += answerSize + guard let bigInt = balanceofMethod.decodeReturnData(slice)["0"] as? BigUInt else { + throw Web3Error.processingError(desc: "Can not decode returned parameters") + } + let value = Utilities.formatToPrecision(bigInt, units: .wei) + results.append(value) + } + + /// Assert + XCTAssertEqual(correctValues, results) + } + + func testDecodeMulticallDifferentValues() async throws { + /// Arrange + let multiCall2Contract = try EthereumContract(Self.multiCall2, at: nil) + let differentRequestsContract = try EthereumContract(Self.differentRequestsContract, at: nil) + + let data = Data(hex: "0000000000000000000000000000000000000000000000000000000001980dd40000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000001af3f329e8be154074d8769d1ffa4ee058b1dbc3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000000000006358d8a5000000000000000000000000000000000000000000000000000000007628d02500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000212295b818158b400000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000") + + let methods = [differentRequestsContract.methods["arrayValue"]?.first, + differentRequestsContract.methods["firstValue"]?.first, + differentRequestsContract.methods["secondValue"]?.first].compactMap({$0}) + + XCTAssertEqual(methods.count, 3) + + /// Act + guard let decodedData = multiCall2Contract.decodeReturnData("aggregate", data: data) else { + throw Web3Error.processingError(desc: "Can not decode returned parameters") + } + + guard let returnData = decodedData["returnData"] as? [Data] else { + throw Web3Error.dataError + } + + XCTAssertEqual(returnData.count, 3) + + for item in methods.enumerated() { + XCTAssertNotNil(item.element.decodeReturnData(returnData[item.offset])["0"]) + } + } + + func testDecodeMulticallCopy() throws { + /// Arrange + let data = Data(hex: "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000004fe6dab4abca350650") + let contract = try EthereumContract(Self.multiCall2, at: nil) + let erc20_balanceof = try EthereumContract(Web3.Utils.erc20ABI).methods["balanceOf"]!.first! + + /// Act + guard let decodedData = contract.decodeReturnData("tryAggregate", data: data) else { + throw Web3Error.processingError(desc: "Can not decode returned parameters") + } + + guard let returnData = decodedData["returnData"] as? [[Any]] else { + throw Web3Error.dataError + } + var resultArray = [BigUInt]() + for i in 0..<2 { + guard let data = returnData[i][1] as? Data, + let balance = erc20_balanceof.decodeReturnData(data)["0"] as? BigUInt else { + resultArray.append(0) + continue + } + resultArray.append(balance) + } + + /// Assert + XCTAssert(resultArray.count == 2) + } +} + +extension ABIDecoderSliceTests { + public static let differentRequestsContract = "[{\"inputs\":[],\"name\":\"firstValue\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"arrayValue\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"enum IInstanceV1.Period\",\"name\":\"period\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"startTime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"endTime\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"secondValue\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]" + + public static let multiCall2 = "[{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"aggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes[]\",\"name\":\"returnData\",\"type\":\"bytes[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"blockAndAggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBlockNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockCoinbase\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"coinbase\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"difficulty\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockGasLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"gaslimit\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getEthBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLastBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"requireSuccess\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"tryAggregate\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"requireSuccess\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"tryBlockAndAggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" +} From bfcf02829a10f087fe2c9c739155cb49d511f139 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 1 Apr 2023 01:38:39 +0300 Subject: [PATCH 203/210] fix: moved test to a different file --- .../localTests/ABIDecoderTests.swift | 42 ------------------- 1 file changed, 42 deletions(-) delete mode 100644 Tests/web3swiftTests/localTests/ABIDecoderTests.swift diff --git a/Tests/web3swiftTests/localTests/ABIDecoderTests.swift b/Tests/web3swiftTests/localTests/ABIDecoderTests.swift deleted file mode 100644 index 1d4ae0524..000000000 --- a/Tests/web3swiftTests/localTests/ABIDecoderTests.swift +++ /dev/null @@ -1,42 +0,0 @@ -// -// ABIDecoderTests.swift -// -// -// Created by liugang zhang on 2023/3/16. -// - -import Foundation -import Web3Core -import XCTest -import BigInt -@testable import web3swift - -final class ABIDecoderTests: XCTestCase { - - func testDecodeMulticall() throws { - let data = Data(hex: "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000004fe6dab4abca350650") - let contract = try EthereumContract(Self.multiCall2, at: nil) - let erc20_balanceof = try EthereumContract(Web3.Utils.erc20ABI).methods["balanceOf"]!.first! - guard let decodedData = contract.decodeReturnData("tryAggregate", data: data) else { - throw Web3Error.processingError(desc: "Can not decode returned parameters") - } - - guard let returnData = decodedData["returnData"] as? [[Any]] else { - throw Web3Error.dataError - } - var resultArray = [BigUInt]() - for i in 0..<2 { - guard let data = returnData[i][1] as? Data, - let balance = erc20_balanceof.decodeReturnData(data)["0"] as? BigUInt else { - resultArray.append(0) - continue - } - resultArray.append(balance) - } - XCTAssert(resultArray.count == 2) - } -} - -extension ABIDecoderTests { - public static let multiCall2 = "[{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"aggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes[]\",\"name\":\"returnData\",\"type\":\"bytes[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"blockAndAggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBlockNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockCoinbase\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"coinbase\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"difficulty\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockGasLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"gaslimit\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentBlockTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getEthBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLastBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"requireSuccess\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"tryAggregate\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"requireSuccess\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"tryBlockAndAggregate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"internalType\":\"struct Multicall2.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" -} From 8cd4c44a30dda2d422cbc0235c39702372750d6d Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sat, 1 Apr 2023 01:39:17 +0300 Subject: [PATCH 204/210] fix: using Data.startIndex to safely handle decoding of Data and Data slices --- .../Web3Core/EthereumABI/ABIDecoding.swift | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/Sources/Web3Core/EthereumABI/ABIDecoding.swift b/Sources/Web3Core/EthereumABI/ABIDecoding.swift index f9ecae472..0ae82695b 100755 --- a/Sources/Web3Core/EthereumABI/ABIDecoding.swift +++ b/Sources/Web3Core/EthereumABI/ABIDecoding.swift @@ -34,27 +34,28 @@ extension ABIDecoder { guard let elementItself = elData, let nextElementPointer = nextPtr else { return (nil, nil) } + let startIndex = UInt64(elementItself.startIndex) switch type { case .uint(let bits): guard elementItself.count >= 32 else {break} let mod = BigUInt(1) << bits - let dataSlice = elementItself[0 ..< 32] + let dataSlice = elementItself[startIndex ..< startIndex + 32] let v = BigUInt(dataSlice) % mod return (v, type.memoryUsage) case .int(let bits): guard elementItself.count >= 32 else {break} let mod = BigInt(1) << bits - let dataSlice = elementItself[0 ..< 32] + let dataSlice = elementItself[startIndex ..< startIndex + 32] let v = BigInt.fromTwosComplement(data: dataSlice) % mod return (v, type.memoryUsage) case .address: guard elementItself.count >= 32 else {break} - let dataSlice = elementItself[12 ..< 32] + let dataSlice = elementItself[startIndex + 12 ..< startIndex + 32] let address = EthereumAddress(dataSlice) return (address, type.memoryUsage) case .bool: guard elementItself.count >= 32 else {break} - let dataSlice = elementItself[0 ..< 32] + let dataSlice = elementItself[startIndex ..< startIndex + 32] let v = BigUInt(dataSlice) if v == BigUInt(36) || v == BigUInt(32) || @@ -69,22 +70,22 @@ extension ABIDecoder { } case .bytes(let length): guard elementItself.count >= 32 else {break} - let dataSlice = elementItself[0 ..< length] + let dataSlice = elementItself[startIndex ..< startIndex + length] return (Data(dataSlice), type.memoryUsage) case .string: guard elementItself.count >= 32 else {break} - var dataSlice = elementItself[0 ..< 32] + var dataSlice = elementItself[startIndex ..< startIndex + 32] let length = UInt64(BigUInt(dataSlice)) - guard elementItself.count >= 32+length else {break} + guard elementItself.count >= 32 + length else {break} dataSlice = elementItself[32 ..< 32 + length] guard let string = String(data: dataSlice, encoding: .utf8) else {break} return (string, type.memoryUsage) case .dynamicBytes: guard elementItself.count >= 32 else {break} - var dataSlice = elementItself[0 ..< 32] + var dataSlice = elementItself[startIndex ..< startIndex + 32] let length = UInt64(BigUInt(dataSlice)) - guard elementItself.count >= 32+length else {break} - dataSlice = elementItself[32 ..< 32 + length] + guard elementItself.count >= 32 + length else {break} + dataSlice = elementItself[startIndex + 32 ..< startIndex + 32 + length] return (Data(dataSlice), nextElementPointer) case .array(type: let subType, length: let length): switch type.arraySize { @@ -92,10 +93,10 @@ extension ABIDecoder { if subType.isStatic { // uint[] like, expect length and elements guard elementItself.count >= 32 else {break} - var dataSlice = elementItself[0 ..< 32] + var dataSlice = elementItself[startIndex ..< startIndex + 32] let length = UInt64(BigUInt(dataSlice)) guard elementItself.count >= 32 + subType.memoryUsage*length else {break} - dataSlice = elementItself[32 ..< 32 + subType.memoryUsage*length] + dataSlice = elementItself[startIndex + 32 ..< startIndex + 32 + subType.memoryUsage*length] var subpointer: UInt64 = 32 var toReturn = [Any]() for _ in 0 ..< length { @@ -108,10 +109,10 @@ extension ABIDecoder { } else { // in principle is true for tuple[], so will work for string[] too guard elementItself.count >= 32 else {break} - var dataSlice = elementItself[0 ..< 32] + var dataSlice = elementItself[startIndex ..< startIndex + 32] let length = UInt64(BigUInt(dataSlice)) guard elementItself.count >= 32 else {break} - dataSlice = Data(elementItself[32 ..< elementItself.count]) + dataSlice = Data(elementItself[startIndex + 32 ..< UInt64(elementItself.count)]) var subpointer: UInt64 = 0 var toReturn = [Any]() for _ in 0 ..< length { @@ -179,7 +180,7 @@ extension ABIDecoder { } case .function: guard elementItself.count >= 32 else {break} - let dataSlice = elementItself[8 ..< 32] + let dataSlice = elementItself[startIndex + 8 ..< startIndex + 32] return (dataSlice, type.memoryUsage) } return (nil, nil) @@ -209,7 +210,8 @@ extension ABIDecoder { return (nil, nil) } let elementPointer = UInt64(bn) - let elementItself = data[elementPointer ..< UInt64(data.count)] + let startIndex = UInt64(data.startIndex) + let elementItself = data[startIndex + elementPointer ..< startIndex + UInt64(data.count)] let nextElement = pointer + type.memoryUsage return (Data(elementItself), nextElement) } From f18cfba19a2d53d4c44f7bdd82dd047606618857 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Fri, 31 Mar 2023 18:58:28 -0700 Subject: [PATCH 205/210] updates per comments --- Sources/Web3Core/KeystoreManager/BIP39.swift | 2 +- .../localTests/BIP32MnemonicPhraseStringArrayTests.swift | 2 +- .../localTests/BIP32MnemonicPhraseStringTests.swift | 2 +- Tests/web3swiftTests/localTests/KeystoresTests.swift | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP39.swift b/Sources/Web3Core/KeystoreManager/BIP39.swift index 1113b4bb2..e9965ef5d 100755 --- a/Sources/Web3Core/KeystoreManager/BIP39.swift +++ b/Sources/Web3Core/KeystoreManager/BIP39.swift @@ -75,7 +75,7 @@ public class BIP39 { /// Returned value is a single string where words are joined by ``BIP39Language/separator``. /// Keep in mind that different languages may have different separators. /// - Parameters: - /// - bitsOfEntropy: 128 - 12 words, 192 - 18 words, 256 - 24 words in output. + /// - bitsOfEntropy: 128 - 12 words, 160 - 15 words, and up to 256 - 24 words as output. The value must be a multiple of 32. /// - language: words language, default is set to english. /// - Returns: mnemonic phrase as a single string containing 12, 15, 18, 21 or 24 words. public static func generateMnemonics(bitsOfEntropy: Int, language: BIP39Language = .english) throws -> String? { diff --git a/Tests/web3swiftTests/localTests/BIP32MnemonicPhraseStringArrayTests.swift b/Tests/web3swiftTests/localTests/BIP32MnemonicPhraseStringArrayTests.swift index 39bf6ff7f..350318c6b 100644 --- a/Tests/web3swiftTests/localTests/BIP32MnemonicPhraseStringArrayTests.swift +++ b/Tests/web3swiftTests/localTests/BIP32MnemonicPhraseStringArrayTests.swift @@ -71,7 +71,7 @@ final class BIP32MnemonicPhraseStringArrayTests: XCTestCase { print(keystore!.addressStorage.paths) } - func testByBIP32keystoreSaveAndDeriva() throws { + func testByBIP32keystoreSaveAndDerive() throws { let keystore = try BIP32Keystore(mnemonicsPhrase: mnemonic, password: "", mnemonicsPassword: "", prefixPath: "m/44'/60'/0'") XCTAssertNotNil(keystore) XCTAssertEqual(keystore!.addresses?.count, 1) diff --git a/Tests/web3swiftTests/localTests/BIP32MnemonicPhraseStringTests.swift b/Tests/web3swiftTests/localTests/BIP32MnemonicPhraseStringTests.swift index d08accd03..fcdbd37a0 100644 --- a/Tests/web3swiftTests/localTests/BIP32MnemonicPhraseStringTests.swift +++ b/Tests/web3swiftTests/localTests/BIP32MnemonicPhraseStringTests.swift @@ -71,7 +71,7 @@ final class BIP32MnemonicPhraseStringTests: XCTestCase { print(keystore!.addressStorage.paths) } - func testByBIP32keystoreSaveAndDeriva() throws { + func testByBIP32keystoreSaveAndDerive() throws { let keystore = try BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "", prefixPath: "m/44'/60'/0'") XCTAssertNotNil(keystore) XCTAssertEqual(keystore!.addresses?.count, 1) diff --git a/Tests/web3swiftTests/localTests/KeystoresTests.swift b/Tests/web3swiftTests/localTests/KeystoresTests.swift index cab2dae5f..46da9aa9b 100755 --- a/Tests/web3swiftTests/localTests/KeystoresTests.swift +++ b/Tests/web3swiftTests/localTests/KeystoresTests.swift @@ -175,7 +175,7 @@ class KeystoresTests: LocalTestCase { } - func testByBIP32keystoreSaveAndDeriva() throws { + func testByBIP32keystoreSaveAndDerive() throws { let mnemonic = "normal dune pole key case cradle unfold require tornado mercy hospital buyer" let keystore = try! BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "", prefixPath: "m/44'/60'/0'") XCTAssertNotNil(keystore) From ffbf4e7a55bf1b6bc11c94e2ce8944dfcf49ed9b Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 2 Apr 2023 10:57:33 +0300 Subject: [PATCH 206/210] chore: replaced data.indices.startIndex with data.startIndex --- Sources/Web3Core/Contract/ContractProtocol.swift | 12 ++++++------ Sources/Web3Core/EthereumABI/ABIDecoding.swift | 4 ++-- Sources/Web3Core/EthereumABI/ABIElements.swift | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Sources/Web3Core/Contract/ContractProtocol.swift b/Sources/Web3Core/Contract/ContractProtocol.swift index 42f54504b..3dd0b5c1d 100755 --- a/Sources/Web3Core/Contract/ContractProtocol.swift +++ b/Sources/Web3Core/Contract/ContractProtocol.swift @@ -210,8 +210,8 @@ extension ContractProtocol { func decodeInputData(_ data: Data) -> [String: Any]? { guard data.count >= 4 else { return nil } - let methodId = data[data.indices.startIndex ..< data.indices.startIndex + 4].toHexString() - let data = data[(data.indices.startIndex + 4)...] + let methodId = data[data.startIndex ..< data.startIndex + 4].toHexString() + let data = data[(data.startIndex + 4)...] return decodeInputData(methodId, data: data) } } @@ -326,21 +326,21 @@ extension DefaultContractProtocol { if method == "fallback" { return nil } - return methods[method]?.compactMap({ function in + return methods[method]?.compactMap({ functio n in return function.decodeInputData(data) }).first } public func decodeInputData(_ data: Data) -> [String: Any]? { guard data.count % 32 == 4 else { return nil } - let methodSignature = data[data.indices.startIndex ..< data.indices.startIndex + 4].toHexString().addHexPrefix().lowercased() + let methodSignature = data[data.startIndex ..< data.startIndex + 4].toHexString().addHexPrefix().lowercased() guard let function = methods[methodSignature]?.first else { return nil } - return function.decodeInputData(Data(data[data.indices.startIndex + 4 ..< data.indices.startIndex + data.count])) + return function.decodeInputData(Data(data[data.startIndex + 4 ..< data.startIndex + data.count])) } public func getFunctionCalled(_ data: Data) -> ABI.Element.Function? { guard data.count >= 4 else { return nil } - return methods[data[data.indices.startIndex ..< data.indices.startIndex + 4].toHexString().addHexPrefix()]?.first + return methods[data[data.startIndex ..< data.startIndex + 4].toHexString().addHexPrefix()]?.first } } diff --git a/Sources/Web3Core/EthereumABI/ABIDecoding.swift b/Sources/Web3Core/EthereumABI/ABIDecoding.swift index 0ae82695b..d7cc65605 100755 --- a/Sources/Web3Core/EthereumABI/ABIDecoding.swift +++ b/Sources/Web3Core/EthereumABI/ABIDecoding.swift @@ -189,12 +189,12 @@ extension ABIDecoder { fileprivate static func followTheData(type: ABI.Element.ParameterType, data: Data, pointer: UInt64 = 0) -> (elementEncoding: Data?, nextElementPointer: UInt64?) { if type.isStatic { guard data.count >= pointer + type.memoryUsage else {return (nil, nil)} - let elementItself = data[data.indices.startIndex + Int(pointer) ..< data.indices.startIndex + Int(pointer + type.memoryUsage)] + let elementItself = data[data.startIndex + Int(pointer) ..< data.startIndex + Int(pointer + type.memoryUsage)] let nextElement = pointer + type.memoryUsage return (Data(elementItself), nextElement) } else { guard data.count >= pointer + type.memoryUsage else {return (nil, nil)} - let dataSlice = data[data.indices.startIndex + Int(pointer) ..< data.indices.startIndex + Int(pointer + type.memoryUsage)] + let dataSlice = data[data.startIndex + Int(pointer) ..< data.startIndex + Int(pointer + type.memoryUsage)] let bn = BigUInt(dataSlice) if bn > UInt64.max || bn >= data.count { // there are ERC20 contracts that use bytes32 instead of string. Let's be optimistic and return some data diff --git a/Sources/Web3Core/EthereumABI/ABIElements.swift b/Sources/Web3Core/EthereumABI/ABIElements.swift index d2c7ab9b6..5dca0b331 100755 --- a/Sources/Web3Core/EthereumABI/ABIElements.swift +++ b/Sources/Web3Core/EthereumABI/ABIElements.swift @@ -397,9 +397,9 @@ extension ABI.Element.Function { /// 4) `messageLength` is used to determine where message bytes end to decode string correctly. /// 5) The rest of the `data` must be 0 bytes or empty. if data.bytes.count >= 100, - Data(data[data.indices.startIndex ..< data.indices.startIndex + 4]) == Data.fromHex("08C379A0"), - BigInt(data[data.indices.startIndex + 4 ..< data.indices.startIndex + 36]) == 32, - let messageLength = Int(Data(data[data.indices.startIndex + 36 ..< data.indices.startIndex + 68]).toHexString(), radix: 16), + Data(data[data.startIndex ..< data.startIndex + 4]) == Data.fromHex("08C379A0"), + BigInt(data[data.startIndex + 4 ..< data.startIndex + 36]) == 32, + let messageLength = Int(Data(data[data.startIndex + 36 ..< data.startIndex + 68]).toHexString(), radix: 16), let message = String(bytes: data.bytes[68..<(68+messageLength)], encoding: .utf8), (68+messageLength == data.count || data.bytes[68+messageLength..= 4, let errors = errors, - let customError = errors[data[data.indices.startIndex ..< data.indices.startIndex + 4].toHexString().stripHexPrefix()] { + let customError = errors[data[data.startIndex ..< data.startIndex + 4].toHexString().stripHexPrefix()] { var errorResponse: [String: Any] = ["_success": false, "_abortedByRevertOrRequire": true, "_error": customError.errorDeclaration] if (data.count > 32 && !customError.inputs.isEmpty), - let decodedInputs = ABIDecoder.decode(types: customError.inputs, data: Data(data[data.indices.startIndex + 4 ..< data.indices.startIndex + data.count])) { + let decodedInputs = ABIDecoder.decode(types: customError.inputs, data: Data(data[data.startIndex + 4 ..< data.startIndex + data.count])) { for idx in decodedInputs.indices { errorResponse["\(idx)"] = decodedInputs[idx] if !customError.inputs[idx].name.isEmpty { From 9c28cae35c2eb6d7c064d5254121cd1af53b237c Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 2 Apr 2023 11:02:39 +0300 Subject: [PATCH 207/210] fix: argument name fix --- Sources/Web3Core/Contract/ContractProtocol.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Contract/ContractProtocol.swift b/Sources/Web3Core/Contract/ContractProtocol.swift index 3dd0b5c1d..43a4c1543 100755 --- a/Sources/Web3Core/Contract/ContractProtocol.swift +++ b/Sources/Web3Core/Contract/ContractProtocol.swift @@ -326,7 +326,7 @@ extension DefaultContractProtocol { if method == "fallback" { return nil } - return methods[method]?.compactMap({ functio n in + return methods[method]?.compactMap({ function in return function.decodeInputData(data) }).first } From d39762613de43aae2ca366bbee8ac532bafa5b24 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 2 Apr 2023 11:08:22 +0300 Subject: [PATCH 208/210] chore: wrapped data slice into Data --- Sources/Web3Core/EthereumABI/ABIDecoding.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/EthereumABI/ABIDecoding.swift b/Sources/Web3Core/EthereumABI/ABIDecoding.swift index d7cc65605..5fb9df99b 100755 --- a/Sources/Web3Core/EthereumABI/ABIDecoding.swift +++ b/Sources/Web3Core/EthereumABI/ABIDecoding.swift @@ -181,7 +181,7 @@ extension ABIDecoder { case .function: guard elementItself.count >= 32 else {break} let dataSlice = elementItself[startIndex + 8 ..< startIndex + 32] - return (dataSlice, type.memoryUsage) + return (Data(dataSlice), type.memoryUsage) } return (nil, nil) } From 62b74376a2fcf8e30a8326a69f1368a13dfbc18a Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Sun, 2 Apr 2023 14:03:54 +0300 Subject: [PATCH 209/210] fix: marked pathAddressPairs as public internal(set) var --- Sources/Web3Core/KeystoreManager/KeystoreParams.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/KeystoreManager/KeystoreParams.swift b/Sources/Web3Core/KeystoreManager/KeystoreParams.swift index 2b1747a03..9eaa047c7 100644 --- a/Sources/Web3Core/KeystoreManager/KeystoreParams.swift +++ b/Sources/Web3Core/KeystoreManager/KeystoreParams.swift @@ -75,7 +75,7 @@ public struct KeystoreParamsBIP32: AbstractKeystoreParams { public var version: Int public var isHDWallet: Bool - public var pathAddressPairs: [PathAddressPair] + public internal(set) var pathAddressPairs: [PathAddressPair] var rootPath: String? public init(crypto cr: CryptoParamsV3, id i: String, version ver: Int = 32, rootPath: String? = nil) { From 5ebb1d91d94c7828cb683b7f52652f316a010ad7 Mon Sep 17 00:00:00 2001 From: YS Date: Fri, 28 Apr 2023 15:51:40 -0500 Subject: [PATCH 210/210] Make -createNewAccount- an internal function and remove -password- argument --- Sources/Web3Core/KeystoreManager/BIP32Keystore.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index 4277cca61..b4a3c764d 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -111,7 +111,7 @@ public class BIP32Keystore: AbstractKeystore { addressStorage = PathAddressStorage() guard let rootNode = HDNode(seed: seed)?.derive(path: prefixPath, derivePrivateKey: true) else { return nil } self.rootPrefix = prefixPath - try createNewAccount(parentNode: rootNode, password: password) + try createNewAccount(parentNode: rootNode) guard let serializedRootNode = rootNode.serialize(serializePublic: false) else { throw AbstractKeystoreError.keyDerivationError } @@ -129,14 +129,14 @@ public class BIP32Keystore: AbstractKeystore { guard rootNode.depth == prefixPath.components(separatedBy: "/").count - 1 else { throw AbstractKeystoreError.encryptionError("Derivation depth mismatch") } - try createNewAccount(parentNode: rootNode, password: password) + try createNewAccount(parentNode: rootNode) guard let serializedRootNode = rootNode.serialize(serializePublic: false) else { throw AbstractKeystoreError.keyDerivationError } try encryptDataToStorage(password, data: serializedRootNode, aesMode: self.keystoreParams!.crypto.cipher) } - func createNewAccount(parentNode: HDNode, password: String = "web3swift") throws { + internal func createNewAccount(parentNode: HDNode) throws { let maxIndex = addressStorage.paths .compactMap { $0.components(separatedBy: "/").last } .compactMap { UInt32($0) }